Skip to content

Commit c713145

Browse files
committed
fix: keep empty workbench overlay hidden
1 parent 1e77847 commit c713145

3 files changed

Lines changed: 86 additions & 4 deletions

File tree

apps/web/src/shared/utils/workspace.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export const buildWorkbenchStateFromBootstrap = (
394394
layout: workbenchLayoutFromBackend(bootstrap.ui_state.layout),
395395
overlay: {
396396
...current.overlay,
397-
visible: tabs.length === 0,
397+
visible: false,
398398
input: tabs.length === 0 ? current.overlay.input : "",
399399
},
400400
};
@@ -515,7 +515,7 @@ export const applyWorkbenchUiState = (
515515
layout: workbenchLayoutFromBackend(uiState.layout),
516516
overlay: {
517517
...current.overlay,
518-
visible: tabs.length === 0,
518+
visible: false,
519519
},
520520
};
521521
};

apps/web/src/state/workbench-core.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,27 @@ const sanitizeTabSessions = (tab: Tab, locale: Locale): Tab => {
430430

431431
export const normalizeWorkbenchState = (input: Partial<WorkbenchState> | null | undefined): WorkbenchState => {
432432
const fallback = createDefaultWorkbenchState();
433-
if (!input?.tabs?.length) return fallback;
433+
if (!input?.tabs?.length) {
434+
return {
435+
...fallback,
436+
overlay: {
437+
...fallback.overlay,
438+
visible: false,
439+
},
440+
};
441+
}
434442

435443
const locale = getPreferredLocale();
436444
const tabs = input.tabs.filter(Boolean).map((tab) => sanitizeTabSessions(tab, locale));
437-
if (!tabs.length) return fallback;
445+
if (!tabs.length) {
446+
return {
447+
...fallback,
448+
overlay: {
449+
...fallback.overlay,
450+
visible: false,
451+
},
452+
};
453+
}
438454

439455
const activeTabId = tabs.some((tab) => tab.id === input.activeTabId) ? input.activeTabId ?? tabs[0].id : tabs[0].id;
440456
const hasHistory = tabs.some((tab) =>
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import test from "node:test";
2+
import assert from "node:assert/strict";
3+
import {
4+
normalizeWorkbenchState,
5+
} from "../apps/web/src/state/workbench-core.ts";
6+
import {
7+
buildWorkbenchStateFromBootstrap,
8+
} from "../apps/web/src/shared/utils/workspace.ts";
9+
import {
10+
defaultAppSettings,
11+
} from "../apps/web/src/shared/app/settings.ts";
12+
13+
test("empty workbench state does not auto-open the launch overlay", () => {
14+
const normalized = normalizeWorkbenchState({
15+
tabs: [],
16+
overlay: {
17+
visible: true,
18+
mode: "local",
19+
input: "",
20+
target: { type: "native" },
21+
},
22+
});
23+
24+
assert.equal(normalized.overlay.visible, false);
25+
});
26+
27+
test("bootstrap with zero open workspaces keeps the launch overlay hidden", () => {
28+
const next = buildWorkbenchStateFromBootstrap(
29+
{
30+
tabs: [],
31+
activeTabId: "",
32+
layout: {
33+
leftWidth: 320,
34+
rightWidth: 320,
35+
rightSplit: 64,
36+
showCodePanel: true,
37+
showTerminalPanel: true,
38+
},
39+
overlay: {
40+
visible: false,
41+
mode: "local",
42+
input: "",
43+
target: { type: "native" },
44+
},
45+
},
46+
{
47+
workspaces: [],
48+
ui_state: {
49+
open_workspace_ids: [],
50+
active_workspace_id: null,
51+
layout: {
52+
left_width: 320,
53+
right_width: 320,
54+
right_split: 64,
55+
show_code_panel: true,
56+
show_terminal_panel: true,
57+
},
58+
},
59+
},
60+
"en",
61+
defaultAppSettings(),
62+
);
63+
64+
assert.equal(next.tabs.length, 0);
65+
assert.equal(next.overlay.visible, false);
66+
});

0 commit comments

Comments
 (0)