@cueloop/client 0.1.0-alpha.9 → 0.1.0-alpha.90

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