fix: scope instance-served state to the connected instance
Linear and GitHub logins, quotas, MCP status, skills and agent memory are served by whichever instance is connected, but each was cached globally or by directory alone — which two instances can share. Switching instances left the previous instance's answers on screen and its Linear login usable against a runtime that has no Linear. Reset them all through runtimeEndpointReset, each store guarding its in-flight requests with a generation so a response for the previous instance cannot land in the new one. The Linear team filter is now persisted per instance: a team belongs to one workspace, so carrying it across filtered the new instance's issue list down to nothing. Usage also waits for the instance to report itself initialised before loading. Providers report themselves as configured only once the instance can read their credentials, so a fetch fired at mount answered "nothing configured" for every provider and cached it — which is why Usage stayed missing from the work-status panel until Settings -> Usage forced a fresh fetch.
This commit is contained in:
@@ -11,6 +11,13 @@ import { useFileSearchStore } from '@/stores/useFileSearchStore';
|
||||
import { useGitStore } from '@/stores/useGitStore';
|
||||
import { useGitHubPrStatusStore } from '@/stores/useGitHubPrStatusStore';
|
||||
import { useSessionFoldersStore } from '@/stores/useSessionFoldersStore';
|
||||
import { useLinearAuthStore } from '@/stores/useLinearAuthStore';
|
||||
import { useGitHubAuthStore } from '@/stores/useGitHubAuthStore';
|
||||
import { useQuotaStore } from '@/stores/useQuotaStore';
|
||||
import { useMcpStore } from '@/stores/useMcpStore';
|
||||
import { useSkillsStore } from '@/stores/useSkillsStore';
|
||||
import { useAgentMemoryStore } from '@/stores/useAgentMemoryStore';
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { useFilesViewTabsStore } from '@/stores/useFilesViewTabsStore';
|
||||
import { useTerminalStore } from '@/stores/useTerminalStore';
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
@@ -68,6 +75,22 @@ export const resetAppForRuntimeEndpointChange = (detail: RuntimeEndpointChangedD
|
||||
useGitHubPrStatusStore.getState().resetForRuntimeSwitch();
|
||||
useSessionFoldersStore.getState().resetForRuntimeSwitch(detail.runtimeKey);
|
||||
useFilesViewTabsStore.getState().resetForRuntimeSwitch(detail.runtimeKey);
|
||||
// Linear and GitHub are authenticated on the instance, not in the browser.
|
||||
// Left in place, the previous instance's login stayed visible and usable —
|
||||
// its rail tab, its issue pickers, its work-status rows — against a runtime
|
||||
// that has no such integration. `App` re-asks once the new instance answers.
|
||||
useLinearAuthStore.getState().resetForRuntimeSwitch();
|
||||
useGitHubAuthStore.getState().resetForRuntimeSwitch();
|
||||
// Work-status readouts served from the instance: quotas, MCP servers, skills
|
||||
// and agent memory. All were cached globally or by directory alone, so they
|
||||
// reported the previous instance until something happened to refetch.
|
||||
useQuotaStore.getState().resetForRuntimeSwitch();
|
||||
useMcpStore.getState().resetForRuntimeSwitch();
|
||||
useSkillsStore.getState().resetForRuntimeSwitch();
|
||||
useAgentMemoryStore.getState().reset();
|
||||
// The Linear team filter names a team in one workspace. Carried across, it
|
||||
// filters the new instance's issue list down to nothing.
|
||||
useUIStore.getState().applyLinearIssueListFiltersForRuntime();
|
||||
useSessionUIStore.getState().restoreForRuntimeSwitch(detail.runtimeKey);
|
||||
resetStreamingState();
|
||||
queueMicrotask(() => void syncDesktopSettings());
|
||||
|
||||
Reference in New Issue
Block a user