From 46df7949a76e60cd8997757257b56525a1e30989 Mon Sep 17 00:00:00 2001 From: Hibryda Date: Wed, 11 Mar 2026 22:56:52 +0100 Subject: [PATCH] refactor(components): apply branded types at Svelte component call sites GroupAgentsPanel, TaskBoardTab, SettingsTab now use GroupId/AgentId branded constructors at their IPC call sites. --- v2/src/lib/components/Workspace/GroupAgentsPanel.svelte | 5 +++-- v2/src/lib/components/Workspace/SettingsTab.svelte | 5 +++-- v2/src/lib/components/Workspace/TaskBoardTab.svelte | 8 +++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/v2/src/lib/components/Workspace/GroupAgentsPanel.svelte b/v2/src/lib/components/Workspace/GroupAgentsPanel.svelte index c1f2b84..b75a8f0 100644 --- a/v2/src/lib/components/Workspace/GroupAgentsPanel.svelte +++ b/v2/src/lib/components/Workspace/GroupAgentsPanel.svelte @@ -3,6 +3,7 @@ import { getActiveGroup, getEnabledProjects, setActiveProject } from '../../stores/workspace.svelte'; import type { GroupAgentConfig, GroupAgentStatus, ProjectConfig } from '../../types/groups'; import { getGroupAgents, setAgentStatus, type BtmsgAgent } from '../../adapters/btmsg-bridge'; + import type { AgentId } from '../../types/ids'; /** Runtime agent status from btmsg database */ let btmsgAgents = $state([]); @@ -46,12 +47,12 @@ if (pollTimer) clearInterval(pollTimer); }); - function getStatus(agentId: string): GroupAgentStatus { + function getStatus(agentId: AgentId): GroupAgentStatus { const btAgent = btmsgAgents.find(a => a.id === agentId); return (btAgent?.status as GroupAgentStatus) ?? 'stopped'; } - function getUnread(agentId: string): number { + function getUnread(agentId: AgentId): number { const btAgent = btmsgAgents.find(a => a.id === agentId); return btAgent?.unreadCount ?? 0; } diff --git a/v2/src/lib/components/Workspace/SettingsTab.svelte b/v2/src/lib/components/Workspace/SettingsTab.svelte index 4fc67a5..dba7400 100644 --- a/v2/src/lib/components/Workspace/SettingsTab.svelte +++ b/v2/src/lib/components/Workspace/SettingsTab.svelte @@ -14,6 +14,7 @@ switchGroup, } from '../../stores/workspace.svelte'; import { deriveIdentifier, type GroupAgentRole, AGENT_ROLE_ICONS } from '../../types/groups'; + import { ProjectId, GroupId } from '../../types/ids'; import { generateAgentPrompt } from '../../utils/agent-prompts'; import { getSetting, setSetting } from '../../adapters/settings-bridge'; import { getCurrentTheme, setTheme } from '../../stores/theme.svelte'; @@ -284,7 +285,7 @@ function handleAddProject() { if (!newName.trim() || !newCwd.trim() || !activeGroupId) return; - const id = crypto.randomUUID(); + const id = ProjectId(crypto.randomUUID()); addProject(activeGroupId, { id, name: newName.trim(), @@ -304,7 +305,7 @@ function handleAddGroup() { if (!newGroupName.trim()) return; - const id = crypto.randomUUID(); + const id = GroupId(crypto.randomUUID()); addGroup({ id, name: newGroupName.trim(), projects: [] }); newGroupName = ''; } diff --git a/v2/src/lib/components/Workspace/TaskBoardTab.svelte b/v2/src/lib/components/Workspace/TaskBoardTab.svelte index 9ca1299..e16e617 100644 --- a/v2/src/lib/components/Workspace/TaskBoardTab.svelte +++ b/v2/src/lib/components/Workspace/TaskBoardTab.svelte @@ -1,9 +1,11 @@