refactor(ext): load org entries in the shared switcher (works in popup + vault tab)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W3b8DA2mXmLWkd4zDbHXHg
This commit is contained in:
adlee-was-taken
2026-06-27 12:01:06 -04:00
parent c327c21fdc
commit dd0b415cdf
6 changed files with 86 additions and 65 deletions

View File

@@ -7,6 +7,7 @@
import { getState } from './state';
import type { Request } from './messages';
import type { ItemId, ManifestEntry, OrgManifestEntry } from './types';
export function currentContext(): 'personal' | string {
return getState().orgContext ?? 'personal';
@@ -19,3 +20,11 @@ export function messageForList(): Request {
export function messageForGet(id: string): Request {
return currentContext() === 'personal' ? { type: 'get_item', id } : { type: 'org_get_item', id };
}
// Normalize OrgManifestEntry[] (leaner org shape; no attachment_summaries /
// favorite / icon_hint / group) into the Array<[ItemId, ManifestEntry]> that
// both list renderers (popup renderItemList + vault renderListPane) expect.
// Org rows show no attachment indicator (PM-accepted).
export function normalizeOrgEntries(entries: OrgManifestEntry[]): Array<[ItemId, ManifestEntry]> {
return entries.map(e => [e.id, { ...e, favorite: false, attachment_summaries: [] }]);
}

View File

@@ -57,11 +57,6 @@ export interface PopupState {
orgOffline?: boolean;
orgConfigs?: OrgConfigSummary[];
orgCollections?: Collection[];
// Tracks which context's items were last loaded into `entries`. Used by
// renderItemList to fire a context-aware load exactly ONCE per context
// switch (loop-safe guard: setState({loadedContext}) re-renders, but the
// guard then matches so no second load fires).
loadedContext?: string;
// Vault-tab-only fields. The popup surface leaves these at their defaults
// (unlocked=false implicit via separate lock-screen view, drawer/panel false).
// Kept on the shared shape so VaultState satisfies StateHost.getState()