Skip to content

Commit 3a2dca6

Browse files
committed
fix: preserve zero-tab overlay state
1 parent c96a6c5 commit 3a2dca6

3 files changed

Lines changed: 94 additions & 3 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: false,
397+
visible: tabs.length === 0 ? current.overlay.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: false,
518+
visible: tabs.length === 0 ? current.overlay.visible : false,
519519
},
520520
};
521521
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ export const createDefaultWorkbenchState = (): WorkbenchState => {
300300
showTerminalPanel: false
301301
},
302302
overlay: {
303-
visible: true,
303+
visible: false,
304304
mode: "local",
305305
input: "",
306306
target: { type: "native" }

tests/workspace-welcome-screen.test.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import test from "node:test";
22
import assert from "node:assert/strict";
33
import {
4+
createDefaultWorkbenchState,
45
normalizeWorkbenchState,
56
} from "../apps/web/src/state/workbench-core.ts";
67
import {
@@ -28,6 +29,13 @@ test("empty workbench state does not auto-open the launch overlay", () => {
2829
assert.deepEqual(normalized.overlay.target, { type: "wsl", distro: "Ubuntu" });
2930
});
3031

32+
test("default workbench state keeps the launch overlay hidden on startup", () => {
33+
const initial = createDefaultWorkbenchState();
34+
35+
assert.equal(initial.tabs.length, 0);
36+
assert.equal(initial.overlay.visible, false);
37+
});
38+
3139
test("bootstrap with zero open workspaces keeps the launch overlay hidden", () => {
3240
const next = buildWorkbenchStateFromBootstrap(
3341
{
@@ -69,6 +77,50 @@ test("bootstrap with zero open workspaces keeps the launch overlay hidden", () =
6977
assert.equal(next.overlay.visible, false);
7078
});
7179

80+
test("bootstrap with zero open workspaces preserves a user-opened launch overlay", () => {
81+
const next = buildWorkbenchStateFromBootstrap(
82+
{
83+
tabs: [],
84+
activeTabId: "",
85+
layout: {
86+
leftWidth: 320,
87+
rightWidth: 320,
88+
rightSplit: 64,
89+
showCodePanel: true,
90+
showTerminalPanel: true,
91+
},
92+
overlay: {
93+
visible: true,
94+
mode: "remote",
95+
input: "ssh://demo",
96+
target: { type: "wsl", distro: "Ubuntu" },
97+
},
98+
},
99+
{
100+
workspaces: [],
101+
ui_state: {
102+
open_workspace_ids: [],
103+
active_workspace_id: null,
104+
layout: {
105+
left_width: 320,
106+
right_width: 320,
107+
right_split: 64,
108+
show_code_panel: true,
109+
show_terminal_panel: true,
110+
},
111+
},
112+
},
113+
"en",
114+
defaultAppSettings(),
115+
);
116+
117+
assert.equal(next.tabs.length, 0);
118+
assert.equal(next.overlay.visible, true);
119+
assert.equal(next.overlay.mode, "remote");
120+
assert.equal(next.overlay.input, "ssh://demo");
121+
assert.deepEqual(next.overlay.target, { type: "wsl", distro: "Ubuntu" });
122+
});
123+
72124
test("ui state with zero open workspaces keeps the launch overlay hidden", () => {
73125
const next = applyWorkbenchUiState(
74126
{
@@ -107,3 +159,42 @@ test("ui state with zero open workspaces keeps the launch overlay hidden", () =>
107159
assert.equal(next.overlay.input, "ssh://demo");
108160
assert.deepEqual(next.overlay.target, { type: "wsl", distro: "Ubuntu" });
109161
});
162+
163+
test("ui state with zero open workspaces preserves a user-opened launch overlay", () => {
164+
const next = applyWorkbenchUiState(
165+
{
166+
tabs: [],
167+
activeTabId: "",
168+
layout: {
169+
leftWidth: 320,
170+
rightWidth: 320,
171+
rightSplit: 64,
172+
showCodePanel: true,
173+
showTerminalPanel: true,
174+
},
175+
overlay: {
176+
visible: true,
177+
mode: "remote",
178+
input: "ssh://demo",
179+
target: { type: "wsl", distro: "Ubuntu" },
180+
},
181+
},
182+
{
183+
open_workspace_ids: [],
184+
active_workspace_id: null,
185+
layout: {
186+
left_width: 320,
187+
right_width: 320,
188+
right_split: 64,
189+
show_code_panel: true,
190+
show_terminal_panel: true,
191+
},
192+
},
193+
);
194+
195+
assert.equal(next.tabs.length, 0);
196+
assert.equal(next.overlay.visible, true);
197+
assert.equal(next.overlay.mode, "remote");
198+
assert.equal(next.overlay.input, "ssh://demo");
199+
assert.deepEqual(next.overlay.target, { type: "wsl", distro: "Ubuntu" });
200+
});

0 commit comments

Comments
 (0)