Problem
ui-store.ts maintains 8 separate Record<string, T> maps all indexed by gatewayId, each with its own setter action:
gatewayStatusMap: Record<string, GatewayConnectionStatus>;
setGatewayStatusByGateway: (gatewayId, status) => void;
gatewayVersionMap: Record<string, string>;
setGatewayVersion: (gatewayId, version) => void;
gatewayReconnectInfo: Record<string, { attempt; max; gaveUp }>;
setGatewayReconnectInfo: (gatewayId, info) => void;
gatewayInfoMap: Record<string, GatewayInfo>;
setGatewayInfoMap: (map) => void;
modelCatalogByGateway: Record<string, ModelCatalogEntry[]>;
setModelCatalogForGateway: (gatewayId, models) => void;
agentCatalogByGateway: Record<string, { agents; defaultId }>;
setAgentCatalogForGateway: (gatewayId, agents, defaultId) => void;
toolsCatalogByGateway: Record<string, ToolsCatalog>;
setToolsCatalogForGateway: (gatewayId, catalog) => void;
skillsStatusByGateway: Record<string, SkillStatusReport>;
setSkillsStatusForGateway: (gatewayId, report) => void;
This is 16 interface members (8 state + 8 setters) for what is logically one concept: per-gateway state.
Location
File: packages/core/src/stores/ui-store.ts:38-73
Fix Approach
Unify into a single gateway registry:
interface GatewayState {
status: GatewayConnectionStatus;
version?: string;
reconnectInfo?: { attempt: number; max: number; gaveUp: boolean };
info: GatewayInfo;
models: ModelCatalogEntry[];
agents: { agents: AgentInfo[]; defaultId: string };
tools: ToolsCatalog | null;
skills: SkillStatusReport | null;
}
// In store:
gatewayRegistry: Record<string, GatewayState>;
updateGateway: (gatewayId: string, patch: Partial<GatewayState>) => void;
16 members → 2 members. Selectors become:
const status = useUiStore((s) => s.gatewayRegistry[gatewayId]?.status);
Note: This is a larger refactor — ~30 files reference the individual maps. Should be done incrementally:
- Add
gatewayRegistry + updateGateway alongside existing maps
- Migrate consumers file by file
- Remove old maps
Verification
- Run
pnpm check — must pass
- Connect/disconnect gateways, verify all status/catalog/version info displays correctly
Context
- WG: Task & Session Core + UI & Design System
- Priority: Medium
- Estimated effort: ~2 hours (incremental)
Problem
ui-store.tsmaintains 8 separateRecord<string, T>maps all indexed bygatewayId, each with its own setter action:This is 16 interface members (8 state + 8 setters) for what is logically one concept: per-gateway state.
Location
File:
packages/core/src/stores/ui-store.ts:38-73Fix Approach
Unify into a single gateway registry:
16 members → 2 members. Selectors become:
Note: This is a larger refactor — ~30 files reference the individual maps. Should be done incrementally:
gatewayRegistry+updateGatewayalongside existing mapsVerification
pnpm check— must passContext