fix(v3): terminal tabs close + naming — replace $state<Map> with Record for Svelte 5 reactivity

This commit is contained in:
Hibryda 2026-03-08 03:13:02 +01:00
parent 0e5fcd766b
commit 308664a4c9

View file

@ -20,7 +20,7 @@ let activeTab = $state<WorkspaceTab>('sessions');
let activeProjectId = $state<string | null>(null); let activeProjectId = $state<string | null>(null);
/** Terminal tabs per project (keyed by project ID) */ /** Terminal tabs per project (keyed by project ID) */
let projectTerminals = $state<Map<string, TerminalTab[]>>(new Map()); let projectTerminals = $state<Record<string, TerminalTab[]>>({});
// --- Getters --- // --- Getters ---
@ -68,7 +68,7 @@ export async function switchGroup(groupId: string): Promise<void> {
if (groupId === activeGroupId) return; if (groupId === activeGroupId) return;
// Teardown: clear terminal tabs and agent sessions for the old group // Teardown: clear terminal tabs and agent sessions for the old group
projectTerminals = new Map(); projectTerminals = {};
clearAllAgentSessions(); clearAllAgentSessions();
activeGroupId = groupId; activeGroupId = groupId;
@ -90,19 +90,17 @@ export async function switchGroup(groupId: string): Promise<void> {
// --- Terminal tab management per project --- // --- Terminal tab management per project ---
export function getTerminalTabs(projectId: string): TerminalTab[] { export function getTerminalTabs(projectId: string): TerminalTab[] {
return projectTerminals.get(projectId) ?? []; return projectTerminals[projectId] ?? [];
} }
export function addTerminalTab(projectId: string, tab: TerminalTab): void { export function addTerminalTab(projectId: string, tab: TerminalTab): void {
const tabs = projectTerminals.get(projectId) ?? []; const tabs = projectTerminals[projectId] ?? [];
tabs.push(tab); projectTerminals[projectId] = [...tabs, tab];
projectTerminals.set(projectId, [...tabs]);
} }
export function removeTerminalTab(projectId: string, tabId: string): void { export function removeTerminalTab(projectId: string, tabId: string): void {
const tabs = projectTerminals.get(projectId) ?? []; const tabs = projectTerminals[projectId] ?? [];
const filtered = tabs.filter(t => t.id !== tabId); projectTerminals[projectId] = tabs.filter(t => t.id !== tabId);
projectTerminals.set(projectId, filtered);
} }
// --- Persistence --- // --- Persistence ---
@ -111,7 +109,7 @@ export async function loadWorkspace(initialGroupId?: string): Promise<void> {
try { try {
const config = await loadGroups(); const config = await loadGroups();
groupsConfig = config; groupsConfig = config;
projectTerminals = new Map(); projectTerminals = {};
// CLI --group flag takes priority, then explicit param, then persisted // CLI --group flag takes priority, then explicit param, then persisted
let cliGroup: string | null = null; let cliGroup: string | null = null;