@cueloop/client 0.1.0-alpha.8 → 0.1.0-alpha.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/native/build-pty.sh +51 -0
  2. package/native/build.sh +82 -0
  3. package/native/darwin-arm64/libcuelooppty.dylib +0 -0
  4. package/native/darwin-arm64/libcueloopvt.dylib +0 -0
  5. package/native/src/pty.zig +193 -0
  6. package/native/src/shim.zig +114 -0
  7. package/package.json +40 -32
  8. package/src/App.appearance.test.tsx +53 -0
  9. package/src/App.autoclose.test.tsx +77 -51
  10. package/src/App.diff.test.tsx +176 -45
  11. package/src/App.export.test.tsx +58 -41
  12. package/src/App.focus.test.ts +89 -0
  13. package/src/App.identity.test.tsx +78 -0
  14. package/src/App.plan-render.test.tsx +209 -0
  15. package/src/App.plan-review.test.tsx +428 -0
  16. package/src/App.prototype-markdown.test.tsx +92 -0
  17. package/src/App.prototype.test.tsx +176 -0
  18. package/src/App.readonly.test.tsx +129 -67
  19. package/src/App.regression.test.tsx +94 -0
  20. package/src/App.rendering.test.tsx +61 -35
  21. package/src/App.share-dialog.test.tsx +172 -0
  22. package/src/App.submit-confirm.test.tsx +222 -0
  23. package/src/App.test.tsx +333 -131
  24. package/src/App.toast.test.tsx +98 -0
  25. package/src/App.tsx +1338 -608
  26. package/src/App.visual.test.tsx +57 -0
  27. package/src/App.walk.test.tsx +299 -0
  28. package/src/App.workbench.test.tsx +701 -0
  29. package/src/__snapshots__/view-plan.regression.test.ts.snap +100 -0
  30. package/src/annotation-palette.ts +62 -0
  31. package/src/ansi-screen.test.ts +28 -0
  32. package/src/ansi-screen.ts +72 -0
  33. package/src/app-key-state.ts +61 -0
  34. package/src/app-screens.tsx +574 -0
  35. package/src/app-view-model.ts +162 -0
  36. package/src/attribution.test.ts +31 -0
  37. package/src/attribution.ts +42 -0
  38. package/src/clipboard.test.ts +23 -0
  39. package/src/clipboard.ts +33 -0
  40. package/src/components/AnnotatableFileView.stories.tsx +42 -0
  41. package/src/components/AnnotatableFileView.test.tsx +102 -0
  42. package/src/components/AnnotatableFileView.tsx +134 -0
  43. package/src/components/AnnotationCards.stories.tsx +86 -0
  44. package/src/components/AnnotationCards.tsx +341 -0
  45. package/src/components/AnsiScreen.stories.tsx +12 -0
  46. package/src/components/AnsiScreen.tsx +28 -0
  47. package/src/components/AppHeader.stories.tsx +50 -0
  48. package/src/components/AppHeader.tsx +83 -0
  49. package/src/components/AppShell.brand.test.tsx +58 -0
  50. package/src/components/AppShell.stories.tsx +89 -0
  51. package/src/components/AppShell.tsx +329 -0
  52. package/src/components/AppShell.zoom.test.tsx +135 -0
  53. package/src/components/BareWorkbenchFileView.stories.tsx +27 -0
  54. package/src/components/BareWorkbenchFileView.tsx +64 -0
  55. package/src/components/Breadcrumb.stories.tsx +19 -0
  56. package/src/components/Breadcrumb.tsx +45 -0
  57. package/src/components/ChangesColumn.stories.tsx +44 -0
  58. package/src/components/ChangesColumn.tsx +199 -0
  59. package/src/components/ChangesFileTree.test.tsx +61 -0
  60. package/src/components/CodeBlock.stories.tsx +42 -0
  61. package/src/components/CodeBlock.tsx +84 -0
  62. package/src/components/CompletionOverlay.stories.tsx +37 -0
  63. package/src/components/CompletionOverlay.tsx +77 -0
  64. package/src/components/ConfirmCard.stories.tsx +37 -0
  65. package/src/components/ConfirmCard.tsx +153 -0
  66. package/src/components/ConfirmDialog.stories.tsx +21 -0
  67. package/src/components/ConfirmDialog.tsx +72 -0
  68. package/src/components/DiffContentView.scroll.test.tsx +121 -0
  69. package/src/components/DiffContentView.split.test.tsx +140 -0
  70. package/src/components/DiffContentView.stories.tsx +80 -0
  71. package/src/components/DiffContentView.syntax.test.tsx +82 -0
  72. package/src/components/DiffContentView.tsx +876 -0
  73. package/src/components/DiscussionMarkerRail.stories.tsx +54 -0
  74. package/src/components/DiscussionMarkerRail.tsx +186 -0
  75. package/src/components/EditorGrid.stories.tsx +59 -0
  76. package/src/components/EditorGrid.tabs.test.tsx +118 -0
  77. package/src/components/EditorGrid.tsx +426 -0
  78. package/src/components/EditorGrid.zoom.test.tsx +68 -0
  79. package/src/components/FileContentsView.stories.tsx +16 -0
  80. package/src/components/FileContentsView.test.tsx +29 -0
  81. package/src/components/FileContentsView.tsx +98 -0
  82. package/src/components/GridTabContent.stories.tsx +59 -0
  83. package/src/components/GridTabContent.tsx +182 -0
  84. package/src/components/HandleChipsInput.stories.tsx +24 -0
  85. package/src/components/HandleChipsInput.test.tsx +35 -0
  86. package/src/components/HandleChipsInput.tsx +145 -0
  87. package/src/components/KeybindsDialog.stories.tsx +31 -0
  88. package/src/components/KeybindsDialog.tsx +103 -0
  89. package/src/components/MarkdownGridBlock.stories.tsx +33 -0
  90. package/src/components/MarkdownGridBlock.tsx +72 -0
  91. package/src/components/MarkdownThreadEditor.stories.tsx +15 -0
  92. package/src/components/MarkdownThreadEditor.test.tsx +98 -0
  93. package/src/components/MarkdownThreadEditor.tsx +162 -0
  94. package/src/components/MenuBar.stories.tsx +28 -0
  95. package/src/components/MenuBar.tsx +44 -0
  96. package/src/components/NavModeHint.stories.tsx +40 -0
  97. package/src/components/NavModeHint.tsx +31 -0
  98. package/src/components/OverlayScrollbar.stories.tsx +33 -0
  99. package/src/components/OverlayScrollbar.test.tsx +139 -0
  100. package/src/components/OverlayScrollbar.tsx +129 -0
  101. package/src/components/PaneGrid.stories.tsx +84 -0
  102. package/src/components/PaneGrid.tsx +128 -0
  103. package/src/components/PanelColumn.stories.tsx +25 -0
  104. package/src/components/PanelColumn.tsx +98 -0
  105. package/src/components/ProjectTreeView.stories.tsx +25 -0
  106. package/src/components/ProjectTreeView.test.tsx +59 -0
  107. package/src/components/ProjectTreeView.tsx +111 -0
  108. package/src/components/PromptDialog.stories.tsx +36 -0
  109. package/src/components/PromptDialog.test.tsx +61 -0
  110. package/src/components/PromptDialog.tsx +99 -0
  111. package/src/components/PrototypeContentView.stories.tsx +19 -0
  112. package/src/components/PrototypeContentView.tsx +446 -0
  113. package/src/components/RootOverlay.stories.tsx +45 -0
  114. package/src/components/RootOverlay.tsx +48 -0
  115. package/src/components/ScrollArea.stories.tsx +20 -0
  116. package/src/components/ScrollArea.tsx +44 -0
  117. package/src/components/SettingsDialog.stories.tsx +117 -0
  118. package/src/components/SettingsDialog.tsx +186 -0
  119. package/src/components/SettingsRows.stories.tsx +18 -0
  120. package/src/components/SettingsRows.tsx +112 -0
  121. package/src/components/ShareDialog.stories.tsx +121 -0
  122. package/src/components/ShareDialog.tsx +552 -0
  123. package/src/components/ShellHeader.stories.tsx +50 -0
  124. package/src/components/ShellHeader.tsx +137 -0
  125. package/src/components/SlashComposer.stories.tsx +37 -0
  126. package/src/components/SlashComposer.tsx +87 -0
  127. package/src/components/ThreadFooter.stories.tsx +30 -0
  128. package/src/components/ThreadFooter.test.tsx +47 -0
  129. package/src/components/ThreadFooter.tsx +76 -0
  130. package/src/components/ThreadTree.stories.tsx +46 -0
  131. package/src/components/ThreadTree.tsx +255 -0
  132. package/src/components/ThreadView.selection.test.tsx +899 -0
  133. package/src/components/ThreadView.slash.test.tsx +146 -0
  134. package/src/components/ThreadView.stories.tsx +26 -0
  135. package/src/components/ThreadView.tsx +472 -0
  136. package/src/components/Toast.stories.tsx +19 -0
  137. package/src/components/Toast.tsx +52 -0
  138. package/src/components/Tooltip.stories.tsx +26 -0
  139. package/src/components/Tooltip.tsx +72 -0
  140. package/src/components/TreePane.stories.tsx +106 -0
  141. package/src/components/TreePane.tsx +157 -0
  142. package/src/components/WalkWizard.stories.tsx +100 -0
  143. package/src/components/WalkWizard.tsx +150 -0
  144. package/src/components/WelcomePlayground.stories.tsx +12 -0
  145. package/src/components/WelcomePlayground.test.tsx +47 -0
  146. package/src/components/WelcomePlayground.tsx +142 -0
  147. package/src/components/__snapshots__/stories.test.tsx.snap +2238 -0
  148. package/src/components/diff-content-view-layout.test.ts +198 -0
  149. package/src/components/diff-content-view-layout.ts +84 -0
  150. package/src/components/editor-grid.test.ts +86 -0
  151. package/src/components/editor-grid.ts +138 -0
  152. package/src/components/file-tree.test.ts +60 -0
  153. package/src/components/file-tree.ts +112 -0
  154. package/src/components/menu-control.stories.tsx +35 -0
  155. package/src/components/menu-control.tsx +43 -0
  156. package/src/components/pages/Workspace.stories.tsx +181 -0
  157. package/src/components/primitives/Button.stories.tsx +32 -0
  158. package/src/components/primitives/Button.tsx +56 -0
  159. package/src/components/primitives/Card.stories.tsx +25 -0
  160. package/src/components/primitives/Card.tsx +63 -0
  161. package/src/components/primitives/Dialog.stories.tsx +24 -0
  162. package/src/components/primitives/Dialog.test.tsx +37 -0
  163. package/src/components/primitives/Dialog.tsx +71 -0
  164. package/src/components/primitives/DialogActions.stories.tsx +20 -0
  165. package/src/components/primitives/DialogActions.tsx +39 -0
  166. package/src/components/primitives/IconButton.stories.tsx +36 -0
  167. package/src/components/primitives/IconButton.tsx +62 -0
  168. package/src/components/primitives/StatusBar.stories.tsx +11 -0
  169. package/src/components/primitives/StatusBar.tsx +23 -0
  170. package/src/components/primitives/Switch.stories.tsx +17 -0
  171. package/src/components/primitives/Switch.tsx +32 -0
  172. package/src/components/primitives/Tabs.stories.tsx +29 -0
  173. package/src/components/primitives/Tabs.tsx +102 -0
  174. package/src/components/primitives/Toolbar.stories.tsx +17 -0
  175. package/src/components/primitives/Toolbar.tsx +14 -0
  176. package/src/components/primitives/Tree.stories.tsx +124 -0
  177. package/src/components/primitives/Tree.tsx +100 -0
  178. package/src/components/primitives/frame.test.ts +12 -0
  179. package/src/components/primitives/frame.ts +17 -0
  180. package/src/components/primitives/icons.ts +61 -0
  181. package/src/components/primitives/tree-model.test.ts +99 -0
  182. package/src/components/primitives/tree-model.ts +137 -0
  183. package/src/components/quick-actions-editor.stories.tsx +58 -0
  184. package/src/components/quick-actions-editor.test.tsx +117 -0
  185. package/src/components/quick-actions-editor.tsx +226 -0
  186. package/src/components/share-dialog-store.ts +58 -0
  187. package/src/components/stories-app.tsx +193 -0
  188. package/src/components/stories.test.tsx +74 -0
  189. package/src/components/story-fixtures.ts +102 -0
  190. package/src/components/story-tree.test.ts +108 -0
  191. package/src/components/story.ts +159 -0
  192. package/src/components/syntax-highlight.ts +133 -0
  193. package/src/components/terminal-pane.test.tsx +40 -0
  194. package/src/components/terminal-pane.ts +199 -0
  195. package/src/components/theme-context.stories.tsx +46 -0
  196. package/src/components/theme-context.tsx +37 -0
  197. package/src/components/thread-tree.test.ts +134 -0
  198. package/src/components/thread-tree.ts +109 -0
  199. package/src/components/truncate-text.ts +7 -0
  200. package/src/components/truncate-title.test.ts +31 -0
  201. package/src/components/truncate-title.ts +15 -0
  202. package/src/config-identity.test.ts +78 -0
  203. package/src/config.test.ts +517 -33
  204. package/src/config.ts +467 -57
  205. package/src/diff-fold.test.ts +78 -0
  206. package/src/diff-fold.ts +126 -0
  207. package/src/diff-hunk-curate.test.ts +315 -0
  208. package/src/diff-hunk-curate.ts +153 -0
  209. package/src/diff-intraline.test.ts +238 -0
  210. package/src/diff-intraline.ts +236 -0
  211. package/src/diff-syntax.test.ts +112 -0
  212. package/src/diff-syntax.ts +179 -0
  213. package/src/discussions.ts +79 -0
  214. package/src/editor.test.ts +149 -0
  215. package/src/editor.ts +139 -9
  216. package/src/ghostty-terminal.test.ts +85 -0
  217. package/src/ghostty-terminal.ts +199 -0
  218. package/src/github-identity.test.ts +58 -0
  219. package/src/github-identity.ts +41 -0
  220. package/src/herdr.test.ts +9 -34
  221. package/src/herdr.ts +25 -21
  222. package/src/index.ts +13 -0
  223. package/src/integrations.test.ts +41 -0
  224. package/src/integrations.ts +32 -0
  225. package/src/intent-dispatch.test.ts +723 -0
  226. package/src/intent-dispatch.ts +692 -0
  227. package/src/key-bindings.test.ts +156 -0
  228. package/src/key-bindings.ts +459 -0
  229. package/src/keymap.test.ts +461 -113
  230. package/src/keymap.ts +321 -79
  231. package/src/kitty-image.test.ts +66 -0
  232. package/src/kitty-image.ts +138 -0
  233. package/src/launch-layout.test.ts +52 -0
  234. package/src/launch-layout.ts +42 -0
  235. package/src/mark-runs.ts +121 -0
  236. package/src/markdown-editor-syntax-style.ts +50 -0
  237. package/src/markdown-grid.test.ts +101 -0
  238. package/src/markdown-grid.ts +203 -0
  239. package/src/markdown-highlight.test.ts +61 -0
  240. package/src/markdown-highlight.ts +122 -0
  241. package/src/pasted-image.test.ts +67 -0
  242. package/src/pasted-image.ts +60 -0
  243. package/src/perf/otlp-trace.test.ts +116 -0
  244. package/src/perf/otlp-trace.ts +130 -0
  245. package/src/perf/perf-report.ts +17 -0
  246. package/src/perf/perf-timings.test.ts +18 -0
  247. package/src/perf/perf-timings.ts +38 -0
  248. package/src/prototype-browser.test.ts +64 -0
  249. package/src/prototype-browser.ts +329 -0
  250. package/src/prototype-pixels.tsx +35 -0
  251. package/src/pty.test.ts +81 -0
  252. package/src/pty.ts +245 -0
  253. package/src/ready-signal.test.ts +85 -0
  254. package/src/ready-signal.ts +52 -0
  255. package/src/run.ts +78 -13
  256. package/src/serve.test.ts +24 -12
  257. package/src/serve.ts +52 -10
  258. package/src/share.ts +237 -0
  259. package/src/skills.test.ts +74 -0
  260. package/src/skills.ts +75 -0
  261. package/src/slash-palette.test.ts +103 -0
  262. package/src/slash-palette.ts +129 -0
  263. package/src/split-diff.test.ts +110 -0
  264. package/src/split-diff.ts +149 -0
  265. package/src/test-support.test.ts +264 -0
  266. package/src/test-support.ts +369 -0
  267. package/src/theme-presets.test.ts +51 -0
  268. package/src/theme-presets.ts +214 -0
  269. package/src/theme.ts +84 -19
  270. package/src/thread-chords.test.ts +79 -0
  271. package/src/thread-chords.ts +163 -0
  272. package/src/thread-controller.curate.test.ts +450 -0
  273. package/src/thread-controller.derivation.test.ts +62 -0
  274. package/src/thread-controller.live-diff.test.ts +322 -0
  275. package/src/thread-controller.optimistic.test.ts +69 -0
  276. package/src/thread-controller.share.test.ts +561 -0
  277. package/src/thread-controller.switch-cache.test.ts +176 -0
  278. package/src/thread-controller.tree.test.ts +261 -0
  279. package/src/thread-controller.ts +1893 -0
  280. package/src/thread-selection.test.ts +210 -0
  281. package/src/thread-selection.ts +243 -0
  282. package/src/tree-view.test.ts +128 -0
  283. package/src/tree-view.ts +148 -0
  284. package/src/use-annotation-surface.tsx +915 -0
  285. package/src/use-changes-workbench.ts +190 -0
  286. package/src/use-frame-measure.ts +41 -0
  287. package/src/use-remember-layout.ts +31 -0
  288. package/src/use-settings-dialog.tsx +320 -0
  289. package/src/use-terminal-virtualizer.ts +233 -0
  290. package/src/use-thread-body-editing.tsx +58 -0
  291. package/src/version.ts +5 -0
  292. package/src/view-diff.test.ts +137 -9
  293. package/src/view-diff.ts +269 -23
  294. package/src/view-plan.regression.test.ts +60 -0
  295. package/src/view-plan.test.ts +456 -0
  296. package/src/view-plan.ts +719 -0
  297. package/src/visual/contrast.test.ts +35 -0
  298. package/src/visual/contrast.ts +33 -0
  299. package/src/walk.test.ts +121 -0
  300. package/src/walk.ts +74 -0
  301. package/src/workbench-snapshot.test.ts +81 -0
  302. package/src/workbench-snapshot.ts +29 -0
  303. package/src/session-controller.ts +0 -345
  304. package/src/syntax.test.ts +0 -41
  305. package/src/syntax.ts +0 -88
  306. package/src/view.test.ts +0 -157
  307. package/src/view.ts +0 -312
@@ -0,0 +1,701 @@
1
+ /** The four-pane workbench in the virtual terminal, mirroring the browser prototype's interactions:
2
+ * a diff session lays out Threads | Thread | Changes editor | Project sidebar; the diff (±) and tree
3
+ * toggles are mutually exclusive and switching to tree keeps the Changes editor open; a project-tree
4
+ * file opens as a read-only contents tab; the split control offers four directions and the arrow keys
5
+ * split; dismissing the Changes tab collapses the Changes pane but keeps the Project sidebar;
6
+ * the right-sidebar toggle collapses the region to a thin rail and reopens it; zoom hides the Thread pane
7
+ * while the sidebars stay. */
8
+
9
+ import { afterEach, beforeEach, describe, expect, test } from "bun:test";
10
+ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { join } from "node:path";
13
+ import React from "react";
14
+ import { testRender } from "@opentui/react/test-utils";
15
+ import { DaemonServer } from "@cueloop/daemon";
16
+ import type { Thread } from "@cueloop/schema";
17
+ import { App } from "./App";
18
+ import { loadConfig } from "./config";
19
+ import { planLayout, reviewLayout } from "./launch-layout";
20
+ import {
21
+ dragText,
22
+ isolateUserConfig,
23
+ locateText,
24
+ press,
25
+ pressKey,
26
+ typeText,
27
+ waitForState,
28
+ waitForText,
29
+ waitForTextGone,
30
+ renderReadyApp,
31
+ } from "./test-support";
32
+ import { NERD } from "./components/primitives/icons";
33
+
34
+ const PATCH = `diff --git a/src/store.ts b/src/store.ts
35
+ index 111..222 100644
36
+ --- a/src/store.ts
37
+ +++ b/src/store.ts
38
+ @@ -1,3 +1,3 @@
39
+ export class Store {
40
+ - private items = [];
41
+ + private items = new Map();
42
+ }
43
+ `;
44
+
45
+ let home: string;
46
+ let repo: string;
47
+ let restoreUserConfig: () => void;
48
+ let server: DaemonServer;
49
+ let session: Thread;
50
+
51
+ /** A throwaway git repo so the Project tree (git ls-files) and file contents resolve without a real checkout. */
52
+ function makeRepo(): string {
53
+ const root = mkdtempSync(join(tmpdir(), "cueloop-workbench-repo-"));
54
+
55
+ mkdirSync(join(root, "src"), { recursive: true });
56
+ writeFileSync(join(root, "README.md"), "# Workbench Fixture\n\nA tiny tracked repo.\n");
57
+ writeFileSync(join(root, "src", "store.ts"), "export class Store {}\n");
58
+ writeFileSync(join(root, "src", "util.ts"), "export const noop = () => {};\n");
59
+ const git = (args: string[]) => Bun.spawnSync(["git", "-C", root, ...args]);
60
+
61
+ git(["init", "-q"]);
62
+ git(["config", "user.email", "fixture@example.com"]);
63
+ git(["config", "user.name", "Fixture"]);
64
+ git(["add", "-A"]);
65
+ git(["commit", "-q", "-m", "seed"]);
66
+
67
+ return root;
68
+ }
69
+
70
+ beforeEach(() => {
71
+ home = mkdtempSync(join(tmpdir(), "cueloop-workbench-"));
72
+ repo = makeRepo();
73
+ restoreUserConfig = isolateUserConfig(home);
74
+ server = new DaemonServer({ home, idleExitMs: 0 });
75
+ server.start();
76
+ session = server.core.sessionCreate({
77
+ workspace: { repoRoot: repo, branch: "main" },
78
+ artifact: { type: "diff", content: PATCH, meta: { title: "working tree" } },
79
+ });
80
+ });
81
+ afterEach(() => {
82
+ restoreUserConfig();
83
+ server.stop();
84
+ rmSync(home, { recursive: true, force: true });
85
+ rmSync(repo, { recursive: true, force: true });
86
+ });
87
+
88
+ async function renderApp() {
89
+ const setup = await renderReadyApp(<App home={home} sessionId={session.id} />, {
90
+ width: 160,
91
+ height: 20,
92
+ });
93
+
94
+ await waitForText(setup, "store.ts");
95
+
96
+ return setup;
97
+ }
98
+
99
+ type Setup = Awaited<ReturnType<typeof renderApp>>;
100
+
101
+ /** The header controls sit on the top content row of the compact header. */
102
+ const HEADER_ROW = 0;
103
+ const BARE_NAV_HINT = "c comment · z fold · type to leave";
104
+
105
+ /** Column of a Project-header toggle, located by its own glyph so spacing changes never break the click. */
106
+ function toggleColumn(setup: Setup, glyph: string): number {
107
+ return setup.captureCharFrame().split("\n")[HEADER_ROW]!.lastIndexOf(glyph);
108
+ }
109
+ const diffToggleColumn = (setup: Setup): number => toggleColumn(setup, "changes");
110
+ const treeToggleColumn = (setup: Setup): number => toggleColumn(setup, "project");
111
+ const rightToggleColumn = (setup: Setup): number => toggleColumn(setup, NERD.sidebarRight);
112
+ // the collapsed rail shows the outline (off) variant, mirroring the left toggle's filled/outline states
113
+ const railToggleColumn = (setup: Setup): number => toggleColumn(setup, NERD.sidebarRightOff);
114
+
115
+ describe("the four-pane workbench", () => {
116
+ test("a diff session lays out the four panes with the diff toggle active", async () => {
117
+ const setup = await renderApp();
118
+
119
+ const frame = setup.captureCharFrame();
120
+ expect(frame).toContain("cueloop");
121
+ expect(frame).toContain("Changes");
122
+ expect(frame).toContain("store.ts");
123
+ // the diff (±) toggle exists in the Project header
124
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
125
+ });
126
+
127
+ test("switching to the project tree keeps the Changes editor open", async () => {
128
+ const setup = await renderApp();
129
+
130
+ // the diff and tree toggles are mutually exclusive; switch to the full project tree
131
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
132
+ await waitForText(setup, "README.md");
133
+
134
+ const frame = setup.captureCharFrame();
135
+ // the full tree is showing...
136
+ expect(frame).toContain("README.md");
137
+ expect(frame).toContain("src");
138
+ // ...and the Changes editor stayed open through the mode switch
139
+ expect(frame).toContain("Changes");
140
+ });
141
+
142
+ test("opening a project-tree file adds a read-only contents tab", async () => {
143
+ const setup = await renderApp();
144
+
145
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
146
+ await waitForText(setup, "README.md");
147
+
148
+ const readme = locateText(setup, "README.md");
149
+ await setup.mockMouse.click(readme.column, readme.row);
150
+ await waitForText(setup, "Workbench Fixture");
151
+
152
+ const frame = setup.captureCharFrame();
153
+ // the contents tab carries the file's text with no diff markers
154
+ expect(frame).toContain("A tiny tracked repo.");
155
+ expect(frame.split("\n")[HEADER_ROW]!).toContain("README.md");
156
+ });
157
+
158
+ test("the split control offers four directions and arrow-right makes two groups", async () => {
159
+ const setup = await renderApp();
160
+
161
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
162
+ await waitForText(setup, "README.md");
163
+ const readme = locateText(setup, "README.md");
164
+ await setup.mockMouse.click(readme.column, readme.row);
165
+ await waitForText(setup, "Workbench Fixture");
166
+
167
+ // the split control appears only on a file tab
168
+ const split = locateText(setup, "split");
169
+ await setup.mockMouse.click(split.column, split.row);
170
+ await waitForText(setup, "right");
171
+
172
+ const menu = setup.captureCharFrame();
173
+ expect(menu).toContain("left");
174
+ expect(menu).toContain("right");
175
+ expect(menu).toContain("up");
176
+ expect(menu).toContain("down");
177
+
178
+ // the arrow keys drive the popover: right splits the group into two
179
+ await pressKey(setup, "ARROW_RIGHT");
180
+ await waitForState(setup, () => setup.captureCharFrame().split("split").length - 1 >= 2);
181
+ expect((setup.captureCharFrame().match(/README\.md/g) ?? []).length).toBeGreaterThanOrEqual(2);
182
+ });
183
+
184
+ test("dismissing the Changes tab collapses the Changes pane but keeps the Project sidebar", async () => {
185
+ const setup = await renderApp();
186
+
187
+ const changes = locateText(setup, "Changes");
188
+ // the tab's close box sits just past the label; the ✕ is a hover affordance, the box always clicks
189
+ await setup.mockMouse.click(changes.column + 8, changes.row);
190
+ await waitForState(setup, () => !setup.captureCharFrame().includes("store.ts"));
191
+
192
+ const frame = setup.captureCharFrame();
193
+ // the Changes editor is gone...
194
+ expect(frame).not.toContain("store.ts");
195
+ // ...but the Project sidebar and its toggles remain
196
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
197
+ });
198
+
199
+ test("the right-sidebar toggle closes the region and its header toggle reopens it", async () => {
200
+ const setup = await renderApp();
201
+
202
+ await setup.mockMouse.click(rightToggleColumn(setup), HEADER_ROW);
203
+ await waitForState(setup, () => !setup.captureCharFrame().includes("store.ts"));
204
+
205
+ // the right region is closed: no Changes editor, no Project tree toggles, no gutter
206
+ expect(setup.captureCharFrame()).not.toContain("store.ts");
207
+ expect(diffToggleColumn(setup)).toBe(-1);
208
+
209
+ // the reopen toggle (outline/off variant) rides the thread header; clicking it reopens the region
210
+ await setup.mockMouse.click(railToggleColumn(setup), HEADER_ROW);
211
+ await waitForText(setup, "store.ts");
212
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
213
+ });
214
+
215
+ test("the Threads toggle opens and closes the sidebar, relocating the brand", async () => {
216
+ const setup = await renderApp();
217
+
218
+ // deep-linked into a session, the Threads sidebar starts collapsed: the brand rides in the
219
+ // Thread header and the inbox groups are hidden
220
+ const collapsed = setup.captureCharFrame();
221
+ expect(collapsed).toContain("cueloop");
222
+ expect(collapsed).not.toContain("Threads");
223
+
224
+ // the sidebar toggle sits just left of the brand (one glyph plus its margin)
225
+ const brand = locateText(setup, "cueloop");
226
+ await setup.mockMouse.click(brand.column - 3, brand.row);
227
+ await waitForText(setup, "Threads");
228
+
229
+ // the Threads pane is open with its inbox groups, and the brand moved into its header
230
+ expect(setup.captureCharFrame()).toContain("Threads");
231
+
232
+ // toggling again collapses it back
233
+ const reopened = locateText(setup, "cueloop");
234
+ await setup.mockMouse.click(reopened.column - 3, reopened.row);
235
+ await waitForState(setup, () => !setup.captureCharFrame().includes("Threads"));
236
+ expect(setup.captureCharFrame()).not.toContain("Threads");
237
+ });
238
+
239
+ test("zoom hides the Thread pane while the sidebars stay", async () => {
240
+ const setup = await renderApp();
241
+
242
+ const zoom = locateText(setup, NERD.zoom);
243
+ await setup.mockMouse.click(zoom.column, zoom.row);
244
+ await waitForState(setup, () => !setup.captureCharFrame().includes("Select a thread"));
245
+
246
+ const frame = setup.captureCharFrame();
247
+ // the Thread pane's prompt is gone...
248
+ expect(frame).not.toContain("Select a thread");
249
+ // ...while the Changes editor and Project sidebar stay
250
+ expect(frame).toContain("store.ts");
251
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
252
+ });
253
+
254
+ test("a create-command session remembers its zoom toggle for the next bare launch", async () => {
255
+ // a create-command opens the review zoomed; toggling zoom off must persist to the remembered layout
256
+ const setup = await renderReadyApp(
257
+ <App home={home} sessionId={session.id} layout={reviewLayout()} />,
258
+ {
259
+ width: 160,
260
+ height: 20,
261
+ },
262
+ );
263
+ await waitForText(setup, "store.ts");
264
+
265
+ const zoom = locateText(setup, NERD.zoom);
266
+ await setup.mockMouse.click(zoom.column, zoom.row);
267
+ await waitForState(
268
+ setup,
269
+ () =>
270
+ loadConfig({ userConfigPath: process.env.CUELOOP_CONFIG }).ui.layout?.zoomChanges === false,
271
+ );
272
+ expect(loadConfig({ userConfigPath: process.env.CUELOOP_CONFIG }).ui.layout?.zoomChanges).toBe(
273
+ false,
274
+ );
275
+ });
276
+
277
+ test("selecting a non-diff thread while zoomed exits zoom and restores the Thread pane", async () => {
278
+ // a second, non-diff thread to navigate to; its sync has no Changes editor to fill a zoom
279
+ server.core.sessionCreate({
280
+ workspace: { repoRoot: repo, branch: "main" },
281
+ artifact: {
282
+ type: "plan",
283
+ content: "# Zoomed Plan\n\nReview this plan.\n",
284
+ meta: { title: "Zoomed Plan" },
285
+ },
286
+ });
287
+ const setup = await renderApp();
288
+
289
+ // open the collapsed Threads sidebar first (its toggle sits three cells left of the brand); the
290
+ // brand rides the Thread header, which zoom then hides, so it must be reached before zooming
291
+ const brand = locateText(setup, "cueloop");
292
+ await setup.mockMouse.click(brand.column - 3, brand.row);
293
+ await waitForText(setup, "Zoomed Plan");
294
+
295
+ // zoom the diff - the Thread pane hides and the footer rides the Changes pane
296
+ const zoom = locateText(setup, NERD.zoom);
297
+ await setup.mockMouse.click(zoom.column, zoom.row);
298
+ await waitForState(setup, () => !setup.captureCharFrame().includes("Select a thread"));
299
+
300
+ // switch to the plan thread: it has no Changes editor, so a stranded zoom would blank the middle
301
+ const planRow = locateText(setup, "Zoomed Plan");
302
+ await setup.mockMouse.click(planRow.column, planRow.row);
303
+ await waitForText(setup, "Review this plan.");
304
+
305
+ const frame = setup.captureCharFrame();
306
+ // the Thread pane is back with the plan, and the diff's Changes editor is gone - never a blank middle
307
+ expect(frame).toContain("Review this plan.");
308
+ expect(frame).not.toContain("store.ts");
309
+ });
310
+
311
+ test("toggling the right sidebar while zoomed exits zoom and restores the Thread pane", async () => {
312
+ const setup = await renderApp();
313
+
314
+ // zoom the Changes editor - the Thread pane hides
315
+ const zoom = locateText(setup, NERD.zoom);
316
+ await setup.mockMouse.click(zoom.column, zoom.row);
317
+ await waitForState(setup, () => !setup.captureCharFrame().includes("Select a thread"));
318
+
319
+ // toggling the right sidebar off must not strand a blank screen: zoom exits, the Thread pane returns
320
+ await setup.mockMouse.click(rightToggleColumn(setup), HEADER_ROW);
321
+ await waitForText(setup, "Select a thread");
322
+ const frame = setup.captureCharFrame();
323
+ expect(frame).toContain("Select a thread");
324
+ // the right region is collapsed and the Changes editor is gone
325
+ expect(frame).not.toContain("store.ts");
326
+ expect(diffToggleColumn(setup)).toBe(-1);
327
+ });
328
+
329
+ test("hovering the right-sidebar icon surfaces its tooltip label at the screen root", async () => {
330
+ const setup = await renderApp();
331
+
332
+ // the tip is not painted until the pointer is over the control
333
+ expect(setup.captureCharFrame()).not.toContain("Toggle Sidebar");
334
+
335
+ await setup.mockMouse.moveTo(rightToggleColumn(setup), HEADER_ROW);
336
+ // the label surfaces at the root, escaping the header cell that would otherwise clip it
337
+ await waitForText(setup, "Toggle Sidebar");
338
+ });
339
+ });
340
+
341
+ /** The bare-launch (no thread) shell is the same four panes as a thread: the Thread pane waits in its
342
+ * empty state and a disposable Welcome tab rides in the Changes editor. The right-region toggles behave
343
+ * like the thread shell, dismissing Welcome collapses the editor without stranding an empty screen, and
344
+ * a closed right region moves its reopen toggle into the header rather than leaving a gutter. */
345
+ describe("the bare-launch welcome shell", () => {
346
+ let welcomeHome: string;
347
+ let welcomeRepo: string;
348
+ let restoreWelcome: () => void;
349
+ let welcomeServer: DaemonServer;
350
+
351
+ beforeEach(() => {
352
+ welcomeHome = mkdtempSync(join(tmpdir(), "cueloop-welcome-"));
353
+ // a small, controlled launch repo so the welcome tree/changes resolve fast and deterministically
354
+ welcomeRepo = makeRepo();
355
+ writeFileSync(join(welcomeRepo, "README.md"), "# Fixture\n\nedited in the working tree\n");
356
+ restoreWelcome = isolateUserConfig(welcomeHome);
357
+ welcomeServer = new DaemonServer({ home: welcomeHome, idleExitMs: 0 });
358
+ welcomeServer.start();
359
+ });
360
+ afterEach(() => {
361
+ restoreWelcome();
362
+ welcomeServer.stop();
363
+ rmSync(welcomeHome, { recursive: true, force: true });
364
+ rmSync(welcomeRepo, { recursive: true, force: true });
365
+ });
366
+
367
+ async function renderWelcome() {
368
+ const setup = await testRender(
369
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
370
+ { width: 180, height: 14 },
371
+ );
372
+ await waitForText(setup, "cueloop");
373
+
374
+ return setup;
375
+ }
376
+
377
+ test("the project tree shows the launch repo's files even with no thread open", async () => {
378
+ const setup = await renderWelcome();
379
+
380
+ // the tree toggle loads the git repo the client launched in
381
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
382
+ await waitForText(setup, "README.md");
383
+ expect(setup.captureCharFrame()).toContain("README.md");
384
+ });
385
+
386
+ test("the first comment in the bare shell creates and persists a per-repo workbench thread", async () => {
387
+ const setup = await renderWelcome();
388
+
389
+ // open a project file in the bare shell (no thread yet - nothing on disk)
390
+ expect(welcomeServer.core.sessionList().length).toBe(0);
391
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
392
+ await waitForText(setup, "README.md");
393
+ const readme = locateText(setup, "README.md");
394
+ await setup.mockMouse.click(readme.column, readme.row);
395
+ await waitForText(setup, "edited in the working tree");
396
+
397
+ // comment on a line - the first note find-or-creates the workbench thread
398
+ const line = "edited in the working tree";
399
+ await dragText(setup, line, line, line.length);
400
+ await typeText(setup, "workbench note");
401
+ await pressKey(setup, "RETURN", { meta: true });
402
+
403
+ // the daemon persisted one per-repo workbench thread carrying the note
404
+ await waitForState(setup, () =>
405
+ welcomeServer.core.sessionList().some((thread) => thread.artifact.meta.workbench === true),
406
+ );
407
+ const workbench = welcomeServer.core
408
+ .sessionList()
409
+ .find((thread) => thread.artifact.meta.workbench === true)!;
410
+ expect(workbench.workspace.rootCommit).toBeTruthy();
411
+ await waitForState(setup, () =>
412
+ welcomeServer.core
413
+ .sessionGet(workbench.id)
414
+ .annotations.some((note) => note.body.includes("workbench note")),
415
+ );
416
+ });
417
+
418
+ test("the changes tree lists the launch repo's working-tree changes", async () => {
419
+ const setup = await renderWelcome();
420
+
421
+ // changes mode is the default; the edited README shows with its status
422
+ await waitForText(setup, "README.md");
423
+ expect(setup.captureCharFrame()).toContain("README.md");
424
+ });
425
+
426
+ test("a review layout opens the Changes panel, listing the working-tree changes", async () => {
427
+ const setup = await testRender(
428
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} layout={reviewLayout()} />,
429
+ { width: 180, height: 14 },
430
+ );
431
+ await waitForText(setup, "README.md");
432
+ expect(setup.captureCharFrame()).toContain("README.md");
433
+ });
434
+
435
+ test("a plan layout opens with the right region closed, so no Changes panel shows", async () => {
436
+ const setup = await testRender(
437
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} layout={planLayout()} />,
438
+ { width: 180, height: 14 },
439
+ );
440
+ await waitForText(setup, "cueloop");
441
+ // rightSidebar "off": neither the Changes list nor the launch repo's files paint
442
+ expect(setup.captureCharFrame()).not.toContain("README.md");
443
+ });
444
+
445
+ test("a hand-edited off+zoom layout drops the zoom so the center is not stranded blank", async () => {
446
+ // zoom fills the middle with the Changes editor; with the region off there is none, so honoring zoom
447
+ // would hide the Thread pane over a blank center. The Thread placeholder must still render.
448
+ const setup = await testRender(
449
+ <App
450
+ home={welcomeHome}
451
+ sessionId={undefined}
452
+ cwd={welcomeRepo}
453
+ layout={{ threads: true, rightSidebar: "off", zoomChanges: true }}
454
+ />,
455
+ { width: 180, height: 14 },
456
+ );
457
+ await waitForText(setup, "Select a thread");
458
+ expect(setup.captureCharFrame()).toContain("Select a thread");
459
+ });
460
+
461
+ test("closing the right region on the vanilla shell remembers it for the next launch", async () => {
462
+ const setup = await testRender(
463
+ <App
464
+ home={welcomeHome}
465
+ sessionId={undefined}
466
+ cwd={welcomeRepo}
467
+ layout={{ threads: true, rightSidebar: "changes", zoomChanges: false }}
468
+ />,
469
+ { width: 180, height: 14 },
470
+ );
471
+ await waitForText(setup, "README.md");
472
+
473
+ // close the Changes/Project region; the remembered layout follows it to "off"
474
+ await setup.mockMouse.click(rightToggleColumn(setup), HEADER_ROW);
475
+ await waitForState(
476
+ setup,
477
+ () =>
478
+ loadConfig({ userConfigPath: process.env.CUELOOP_CONFIG }).ui.layout?.rightSidebar ===
479
+ "off",
480
+ );
481
+ expect(loadConfig({ userConfigPath: process.env.CUELOOP_CONFIG }).ui.layout).toEqual({
482
+ threads: true,
483
+ rightSidebar: "off",
484
+ zoomChanges: false,
485
+ });
486
+ });
487
+
488
+ test("clicking a changed file in the bare shell opens its diff, not its contents", async () => {
489
+ const setup = await renderWelcome();
490
+
491
+ await waitForText(setup, "README.md");
492
+ const readme = locateText(setup, "README.md");
493
+ await setup.mockMouse.click(readme.column, readme.row);
494
+
495
+ // a diff shows both the removed old line and the added new line; contents would show only the new
496
+ await waitForText(setup, "A tiny tracked repo.");
497
+ const frame = setup.captureCharFrame();
498
+ expect(frame).toContain("A tiny tracked repo.");
499
+ expect(frame).toContain("edited in the working tree");
500
+ });
501
+
502
+ test("nav mode on the Welcome tab offers only comment and fold; a diff letter types", async () => {
503
+ const setup = await renderReadyApp(
504
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
505
+ { width: 160, height: 28 },
506
+ );
507
+ await waitForText(setup, "quick brown fox");
508
+ const line = locateText(setup, "quick brown fox");
509
+ await setup.mockMouse.click(line.column, line.row);
510
+
511
+ // esc enters nav; the footer names what this surface can do, not the diff commands
512
+ await press(setup, "escape");
513
+ await waitForText(setup, BARE_NAV_HINT);
514
+ expect(setup.captureCharFrame()).not.toContain("x reject");
515
+
516
+ // a diff letter has no command here, so it leaves nav and types, as the footer says
517
+ await pressKey(setup, "d");
518
+ await waitForText(setup, "● d");
519
+ await press(setup, "escape");
520
+ await waitForTextGone(setup, "● d");
521
+
522
+ // c opens a comment on the caret word; z folds the saved card
523
+ await press(setup, "escape");
524
+ await waitForText(setup, BARE_NAV_HINT);
525
+ await pressKey(setup, "c");
526
+ await typeText(setup, "note");
527
+ await waitForText(setup, "● note");
528
+ await pressKey(setup, "RETURN", { meta: true });
529
+ await waitForText(setup, "note");
530
+ await press(setup, "escape");
531
+ await waitForText(setup, BARE_NAV_HINT);
532
+ await pressKey(setup, "z");
533
+ await waitForText(setup, "○ 1 comment ›");
534
+
535
+ setup.renderer.destroy();
536
+ });
537
+
538
+ test("nav mode on a bare changed-file diff has no reject or walk; x types instead", async () => {
539
+ const setup = await renderReadyApp(
540
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
541
+ { width: 160, height: 28 },
542
+ );
543
+ await waitForText(setup, "README.md");
544
+ const readme = locateText(setup, "README.md");
545
+ await setup.mockMouse.click(readme.column, readme.row);
546
+ await waitForText(setup, "edited in the working tree");
547
+ const line = locateText(setup, "edited in the working tree");
548
+ await setup.mockMouse.click(line.column, line.row);
549
+
550
+ await press(setup, "escape");
551
+ await waitForText(setup, BARE_NAV_HINT);
552
+ expect(setup.captureCharFrame()).not.toContain("x reject");
553
+ await pressKey(setup, "x");
554
+ await waitForText(setup, "● x");
555
+ const frame = setup.captureCharFrame();
556
+ expect(frame).toContain("edited in the working tree");
557
+ expect(frame).not.toContain("change rejected");
558
+
559
+ setup.renderer.destroy();
560
+ });
561
+
562
+ test("nav mode on a project file offers only comment and fold", async () => {
563
+ const setup = await renderReadyApp(
564
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
565
+ { width: 160, height: 28 },
566
+ );
567
+ await waitForText(setup, "README.md");
568
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
569
+ await waitForText(setup, "README.md");
570
+ const readme = locateText(setup, "README.md");
571
+ await setup.mockMouse.click(readme.column, readme.row);
572
+ await waitForText(setup, "edited in the working tree");
573
+ const line = locateText(setup, "edited in the working tree");
574
+ await setup.mockMouse.click(line.column, line.row);
575
+
576
+ await press(setup, "escape");
577
+ await waitForText(setup, BARE_NAV_HINT);
578
+ expect(setup.captureCharFrame()).not.toContain("x reject");
579
+ await pressKey(setup, "d");
580
+ await waitForText(setup, "● d");
581
+
582
+ setup.renderer.destroy();
583
+ });
584
+
585
+ test("a bare launch rides a Welcome tab in the editor while the Thread pane waits empty", async () => {
586
+ const setup = await renderWelcome();
587
+
588
+ // the Welcome playground measures its width before it paints, so wait for its copy
589
+ await waitForText(setup, "Getting started");
590
+ const frame = setup.captureCharFrame();
591
+ // the getting-started surface is an editor tab, not the thread pane
592
+ expect(frame.split("\n")[HEADER_ROW]!).toContain("Welcome");
593
+ expect(frame).toContain("Getting started");
594
+ // the Thread pane shows its empty state until a thread is opened
595
+ expect(frame).toContain("Select a thread");
596
+ });
597
+
598
+ test("the Threads sidebar owns the keyboard until a pane is clicked, so nav never touches the editor", async () => {
599
+ const setup = await renderReadyApp(
600
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
601
+ { width: 160, height: 24 },
602
+ );
603
+ await waitForText(setup, "Getting started");
604
+
605
+ // focus starts on the Threads sidebar: a letter drives the inbox, it never drafts in the editor
606
+ await typeText(setup, "zzz");
607
+ expect(setup.captureCharFrame()).not.toContain("zzz");
608
+
609
+ // clicking a line in the Welcome editor focuses that pane; now typing composes there
610
+ const line = locateText(setup, "quick brown fox");
611
+ await setup.mockMouse.click(line.column, line.row);
612
+ await typeText(setup, "note");
613
+ await waitForText(setup, "● note");
614
+
615
+ setup.renderer.destroy();
616
+ });
617
+
618
+ test("typing in the welcome composer never reaches the inbox keys", async () => {
619
+ // a pending thread in the sidebar so the inbox keys (delete, open) have a target to act on
620
+ welcomeServer.core.sessionCreate({
621
+ workspace: { repoRoot: welcomeRepo, branch: "main" },
622
+ artifact: { type: "plan", content: "# Seeded\n", meta: { title: "Seeded Plan" } },
623
+ });
624
+ const setup = await testRender(
625
+ <App home={welcomeHome} sessionId={undefined} cwd={welcomeRepo} />,
626
+ { width: 160, height: 28 },
627
+ );
628
+ await waitForText(setup, "quick brown fox");
629
+
630
+ // open the playground composer, then type letters that are also inbox keys (j, k, d), one at a
631
+ // time as a person would - each keystroke settles a frame, the way real input arrives
632
+ await dragText(setup, "quick brown fox", "quick brown fox", "quick brown fox".length);
633
+ for (const character of "note: jkd") await typeText(setup, character);
634
+ await waitForText(setup, "note: jkd");
635
+
636
+ // the letters landed in the note, not the inbox: no delete confirmation opened
637
+ expect(setup.captureCharFrame()).not.toContain("This removes the plan");
638
+
639
+ // Cmd+Enter saves the note; it must not dispatch openSession and replace the playground
640
+ await pressKey(setup, "RETURN", { meta: true });
641
+ expect(setup.captureCharFrame()).toContain("Getting started");
642
+
643
+ setup.renderer.destroy();
644
+ });
645
+
646
+ test("dismissing the Welcome tab collapses the editor without stranding an empty screen", async () => {
647
+ const setup = await renderWelcome();
648
+
649
+ const welcome = locateText(setup, "Welcome");
650
+ // the close box sits just past the label
651
+ await setup.mockMouse.click(welcome.column + 8, welcome.row);
652
+ await waitForState(
653
+ setup,
654
+ () => !setup.captureCharFrame().includes("comment on agent-authored work"),
655
+ );
656
+
657
+ // the Threads sidebar and the Thread empty state remain - never a blank shell
658
+ const frame = setup.captureCharFrame();
659
+ expect(frame).toContain("cueloop");
660
+ expect(frame).toContain("Select a thread");
661
+ });
662
+
663
+ test("the changed-files and tree toggles switch navigator mode without collapsing", async () => {
664
+ const setup = await renderWelcome();
665
+
666
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
667
+
668
+ // the tree toggle switches to the project view (the launch repo's tree) without collapsing
669
+ await setup.mockMouse.click(treeToggleColumn(setup), HEADER_ROW);
670
+ await waitForText(setup, "src");
671
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
672
+
673
+ // the changed-files toggle switches back, still open
674
+ await setup.mockMouse.click(diffToggleColumn(setup), HEADER_ROW);
675
+ await waitForState(setup, () => !setup.captureCharFrame().includes("src"));
676
+ expect(diffToggleColumn(setup)).toBeGreaterThan(0);
677
+
678
+ // the sidebar toggle closes the region
679
+ await setup.mockMouse.click(rightToggleColumn(setup), HEADER_ROW);
680
+ await waitForState(setup, () => diffToggleColumn(setup) === -1);
681
+ });
682
+
683
+ test("a closed region draws its reopen divider in the header only, not full-height", async () => {
684
+ const setup = await renderWelcome();
685
+
686
+ // close the right region so only the header toggle remains
687
+ await setup.mockMouse.click(rightToggleColumn(setup), HEADER_ROW);
688
+ await waitForState(setup, () => diffToggleColumn(setup) === -1);
689
+
690
+ const lines = setup.captureCharFrame().split("\n");
691
+ // the reopen toggle's divider sits at the far right; find its column on the header row
692
+ const headerDivider = lines[HEADER_ROW]!.lastIndexOf("│");
693
+ expect(headerDivider).toBeGreaterThan(0);
694
+ // that column stays clear below the two-row header - no full-height column rule
695
+ const bodyRows = lines.slice(3).filter((line) => line.length > headerDivider);
696
+ expect(bodyRows.length).toBeGreaterThan(0);
697
+ for (const line of bodyRows) {
698
+ expect(line[headerDivider]).not.toBe("│");
699
+ }
700
+ });
701
+ });