fix: resolve workspace teardown race with persistence fence
This commit is contained in:
parent
a69022756a
commit
dba6a88a28
5 changed files with 39 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { loadGroups, saveGroups, getCliGroup } from '../adapters/groups-bridge';
|
||||
import type { GroupsFile, GroupConfig, ProjectConfig } from '../types/groups';
|
||||
import { clearAllAgentSessions } from '../stores/agents.svelte';
|
||||
import { waitForPendingPersistence } from '../agent-dispatcher';
|
||||
|
||||
export type WorkspaceTab = 'sessions' | 'docs' | 'context' | 'settings';
|
||||
|
||||
|
|
@ -69,6 +70,9 @@ export function setActiveProject(projectId: string | null): void {
|
|||
export async function switchGroup(groupId: string): Promise<void> {
|
||||
if (groupId === activeGroupId) return;
|
||||
|
||||
// Wait for any in-flight persistence before clearing state
|
||||
await waitForPendingPersistence();
|
||||
|
||||
// Teardown: clear terminal tabs and agent sessions for the old group
|
||||
projectTerminals = {};
|
||||
clearAllAgentSessions();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue