fix(app,server): discover server-cached setup snapshots across sessions
807cce6a hides the "Show setup" action when there is no workspace setup
snapshot. That broke the case where setup genuinely ran on a different
WebSocket session than the one the browser reconnected with: the snapshot
was cached per-Session, so discovery returned null and the action stayed
hidden.
Share the setup snapshot cache at the websocket-server level and inject
it into every Session. On focus, the workspace screen now requests
fetchWorkspaceSetupStatus when it has no local snapshot; workspaces with
no setup history still return null, preserving 807cce6a's intent.
This commit is contained in:
@@ -976,6 +976,7 @@ function WorkspaceScreenContent({
|
||||
const workspaceSetupSnapshot = useWorkspaceSetupStore((state) =>
|
||||
persistenceKey ? (state.snapshots[persistenceKey] ?? null) : null,
|
||||
);
|
||||
const upsertWorkspaceSetupProgress = useWorkspaceSetupStore((state) => state.upsertProgress);
|
||||
const showWorkspaceSetup = shouldShowWorkspaceSetup(workspaceSetupSnapshot);
|
||||
const uiTabs = useMemo(
|
||||
() => (workspaceLayout ? collectAllTabs(workspaceLayout.root) : EMPTY_UI_TABS),
|
||||
@@ -1191,6 +1192,55 @@ function WorkspaceScreenContent({
|
||||
|
||||
const emptyWorkspaceSeedRef = useRef<string | null>(null);
|
||||
const autoOpenedSetupTabWorkspaceRef = useRef<string | null>(null);
|
||||
const requestedWorkspaceSetupStatusKeyRef = useRef<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isRouteFocused) {
|
||||
return;
|
||||
}
|
||||
if (!client || !normalizedServerId || !normalizedWorkspaceId || !persistenceKey) {
|
||||
return;
|
||||
}
|
||||
if (workspaceSetupSnapshot) {
|
||||
return;
|
||||
}
|
||||
if (requestedWorkspaceSetupStatusKeyRef.current === persistenceKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
requestedWorkspaceSetupStatusKeyRef.current = persistenceKey;
|
||||
let isCancelled = false;
|
||||
|
||||
client
|
||||
.fetchWorkspaceSetupStatus(normalizedWorkspaceId)
|
||||
.then((response) => {
|
||||
if (isCancelled || response.workspaceId !== normalizedWorkspaceId || !response.snapshot) {
|
||||
return;
|
||||
}
|
||||
upsertWorkspaceSetupProgress({
|
||||
serverId: normalizedServerId,
|
||||
payload: { workspaceId: response.workspaceId, ...response.snapshot },
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
if (requestedWorkspaceSetupStatusKeyRef.current === persistenceKey) {
|
||||
requestedWorkspaceSetupStatusKeyRef.current = null;
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
isCancelled = true;
|
||||
};
|
||||
}, [
|
||||
client,
|
||||
isRouteFocused,
|
||||
normalizedServerId,
|
||||
normalizedWorkspaceId,
|
||||
persistenceKey,
|
||||
upsertWorkspaceSetupProgress,
|
||||
workspaceSetupSnapshot,
|
||||
]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isRouteFocused) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user