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:
@@ -91,6 +91,12 @@ interface McpStore {
|
||||
completeAuth: (name: string, code: string, directory?: string | null) => Promise<void>;
|
||||
clearAuth: (name: string, directory?: string | null) => Promise<void>;
|
||||
testConnection: (name: string, directory?: string | null) => Promise<TestConnectionResult>;
|
||||
/**
|
||||
* MCP status is keyed by directory alone, and two instances can hold the same
|
||||
* project path — so on a switch the previous instance's servers would be
|
||||
* reported for the new one. Drop everything and let consumers re-ask.
|
||||
*/
|
||||
resetForRuntimeSwitch: () => void;
|
||||
}
|
||||
|
||||
export const useMcpStore = create<McpStore>()(
|
||||
@@ -101,6 +107,17 @@ export const useMcpStore = create<McpStore>()(
|
||||
lastErrorKeys: {},
|
||||
refreshedAtKeys: {},
|
||||
|
||||
resetForRuntimeSwitch: () => {
|
||||
ensureFreshInFlight.clear();
|
||||
set({
|
||||
byDirectory: {},
|
||||
diagnosticsByDirectory: {},
|
||||
loadingKeys: {},
|
||||
lastErrorKeys: {},
|
||||
refreshedAtKeys: {},
|
||||
});
|
||||
},
|
||||
|
||||
getStatusForDirectory: (directory) => {
|
||||
const key = toKey(directory ?? useDirectoryStore.getState().currentDirectory);
|
||||
return get().byDirectory[key] ?? EMPTY_STATUS;
|
||||
|
||||
Reference in New Issue
Block a user