gentle-pi 4.6.0 → 4.7.0

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 (290) hide show
  1. package/README.md +10 -11
  2. package/assets/agents/gentle-ai-explore.md +1 -0
  3. package/assets/agents/gentle-ai-verify.md +5 -2
  4. package/assets/agents/gentle-ai-worker.md +3 -0
  5. package/assets/agents/jd-fix-agent.md +1 -0
  6. package/assets/agents/jd-judge-a.md +1 -0
  7. package/assets/agents/jd-judge-b.md +1 -0
  8. package/assets/design-canvas/canvas.css +13 -1
  9. package/assets/design-canvas/canvas.js +11 -2
  10. package/assets/install-wizard/wizard.js +1 -0
  11. package/assets/migrations/agent-body-history.json +16 -1
  12. package/assets/orchestrator-delegation-reference.md +4 -4
  13. package/assets/orchestrator-delegation.md +1 -1
  14. package/assets/orchestrator-full-delegation-card.md +65 -0
  15. package/assets/orchestrator-full-delegation.md +34 -0
  16. package/assets/orchestrator-memory.md +3 -3
  17. package/assets/orchestrator-prompts.md +1 -1
  18. package/assets/orchestrator-skills.md +1 -1
  19. package/assets/orchestrator-verification.md +7 -5
  20. package/assets/orchestrator.md +3 -3
  21. package/bin/gentle-shell.mjs +164 -56
  22. package/docs/agent-status.md +61 -0
  23. package/docs/bundled-install.md +7 -5
  24. package/docs/delegated-verification.md +29 -7
  25. package/docs/gentle-agents-activity.md +14 -0
  26. package/docs/gentle-shell.md +54 -16
  27. package/docs/install-wizard.md +1 -1
  28. package/docs/permission-modes.md +9 -4
  29. package/docs/readme-reference.md +75 -30
  30. package/docs/render-cache-performance.md +11 -1
  31. package/docs/review-coordinator.md +33 -0
  32. package/docs/review-request-context.md +19 -0
  33. package/docs/review-windows-acl.md +18 -0
  34. package/docs/voice.md +6 -3
  35. package/docs/yolo-mode.md +5 -5
  36. package/extensions/ask-user-choice.ts +1 -0
  37. package/extensions/ask-user-question.ts +1 -0
  38. package/extensions/child-safety.ts +3 -0
  39. package/extensions/gentle-agent-status.ts +99 -0
  40. package/extensions/gentle-agents.ts +326 -34
  41. package/extensions/gentle-ai.ts +1496 -454
  42. package/extensions/gentle-shell.ts +293 -63
  43. package/extensions/gentle-todo.ts +18 -2
  44. package/extensions/gentle-tps.ts +48 -0
  45. package/extensions/quiet-tools.ts +38 -8
  46. package/extensions/skill-registry.ts +175 -18
  47. package/extensions/startup-banner.ts +30 -3
  48. package/lib/agent-profile-pin.ts +3 -3
  49. package/lib/agent-profiles.ts +160 -2
  50. package/lib/agent-status.ts +105 -0
  51. package/lib/agents-config.ts +46 -0
  52. package/lib/agents-history.ts +24 -5
  53. package/lib/agents-messaging.ts +47 -5
  54. package/lib/agents-runner.ts +183 -12
  55. package/lib/auto-permission-runtime.ts +1 -1
  56. package/lib/bounded-writer-admission.ts +13 -1
  57. package/lib/card-content-policy.ts +8 -6
  58. package/lib/command-palette.ts +133 -17
  59. package/lib/context-backstop.ts +14 -5
  60. package/lib/destructive-command-guard.ts +48 -4
  61. package/lib/execution-surface-guard.ts +20 -0
  62. package/lib/exploration-budget.ts +4 -2
  63. package/lib/gentle-ai-binary.ts +1 -1
  64. package/lib/gentle-design.ts +3 -0
  65. package/lib/gentle-shell-bundled.ts +6 -19
  66. package/lib/gentle-shell-launcher.ts +43 -8
  67. package/lib/herdr-activity.ts +14 -2
  68. package/lib/herdr-busy.ts +45 -0
  69. package/lib/image-attachments.ts +33 -0
  70. package/lib/image-disk-cache.ts +137 -0
  71. package/lib/inprocess-reviewer.ts +270 -140
  72. package/lib/jobs-view.ts +198 -11
  73. package/lib/model-routing-authority.ts +22 -4
  74. package/lib/native-choice-list.ts +20 -2
  75. package/lib/native-review-cli.ts +96 -19
  76. package/lib/orchestrator-mode-policy.ts +105 -0
  77. package/lib/questionnaire/questionnaire-view.ts +105 -12
  78. package/lib/rdd-mode-control.ts +32 -0
  79. package/lib/reply-language-anchor.ts +104 -0
  80. package/lib/review-blocker.ts +92 -0
  81. package/lib/review-candidate-symlink-scan.ts +136 -0
  82. package/lib/review-candidate-view-owner.ts +81 -44
  83. package/lib/review-continuation-registry.ts +99 -0
  84. package/lib/review-coordinator.ts +163 -0
  85. package/lib/review-failure-facts.ts +49 -0
  86. package/lib/review-host-relay.ts +46 -10
  87. package/lib/review-integration-v2.ts +7 -1
  88. package/lib/review-relay-phase-timing.ts +45 -0
  89. package/lib/review-start-context.ts +17 -0
  90. package/lib/session-profile-freeze.ts +4 -2
  91. package/lib/shell-bar.ts +140 -58
  92. package/lib/shell-changes.ts +2 -0
  93. package/lib/shell-panel.ts +17 -3
  94. package/lib/shell-sidebar-layout.ts +112 -40
  95. package/lib/shell-sidebar.ts +7 -0
  96. package/lib/shell-todo.ts +10 -3
  97. package/lib/verifier-admission.ts +1 -1
  98. package/lib/visual-customization-policy.ts +36 -16
  99. package/lib/visual-customize-view.ts +216 -21
  100. package/lib/visual-layout-preview.ts +9 -5
  101. package/lib/visual-profiles.ts +2 -2
  102. package/lib/windows-session-transport.ts +53 -2
  103. package/lib/yolo-session-policy.ts +40 -15
  104. package/package.json +2 -1
  105. package/runtime/gentle-ai-binary.mjs +1 -1
  106. package/runtime/gentle-shell-bundled.mjs +6 -19
  107. package/runtime/gentle-shell-launcher.mjs +42 -7
  108. package/runtime/native-review-cli.mjs +93 -16
  109. package/runtime/review-integration-v2.mjs +7 -1
  110. package/scripts/build-full-delegation-card.mjs +175 -0
  111. package/scripts/bundled-install.mjs +38 -8
  112. package/scripts/download-progress.mjs +68 -0
  113. package/scripts/gentle-ai-installer.mjs +41 -18
  114. package/scripts/gentle-ai-proxy.mjs +294 -0
  115. package/scripts/install-gentle-ai.mjs +14 -1
  116. package/scripts/installer-preflight.mjs +5 -5
  117. package/scripts/installer-runner.mjs +27 -12
  118. package/scripts/installer-server.mjs +8 -7
  119. package/scripts/render-cache-host.mjs +72 -0
  120. package/scripts/render-cache-performance-worker.mjs +5 -4
  121. package/scripts/render-cache-performance.mjs +6 -1
  122. package/scripts/run-test-suite.mjs +40 -28
  123. package/scripts/verify-package-files.mjs +12 -2
  124. package/scripts/voice-worker.cjs +32 -6
  125. package/skills/design/SKILL.md +11 -8
  126. package/skills/gentle-ai/SKILL.md +2 -2
  127. package/skills/gentle-ui-design/SKILL.md +46 -0
  128. package/skills/gentle-ui-design/references/adaptive-interfaces.md +46 -0
  129. package/skills/gentle-ui-design/references/browse-and-compare.md +62 -0
  130. package/skills/gentle-ui-design/references/composition-and-feedback.md +56 -0
  131. package/skills/gentle-ui-design/references/task-and-content.md +60 -0
  132. package/skills/skill-registry/SKILL.md +4 -2
  133. package/skills/work-unit-commits/SKILL.md +6 -7
  134. package/tests/agent-home.test.ts +28 -9
  135. package/tests/agent-profiles-workflow.test.ts +163 -0
  136. package/tests/agent-risk-escalation.test.ts +1 -1
  137. package/tests/agent-status.test.ts +143 -0
  138. package/tests/agents-config.test.ts +96 -0
  139. package/tests/agents-history.test.ts +31 -0
  140. package/tests/agents-jobs-frames.test.ts +93 -0
  141. package/tests/agents-prompt-lifecycle-runtime.test.ts +376 -0
  142. package/tests/agents-runner-drain.test.ts +193 -0
  143. package/tests/agents-runner.test.ts +178 -2
  144. package/tests/append-system-prompt-route.test.ts +4 -1
  145. package/tests/ask-user-choice.test.ts +4 -3
  146. package/tests/ask-user-question.test.ts +97 -0
  147. package/tests/auto-permission-runtime.test.ts +1 -1
  148. package/tests/autonomous-guard.test.ts +346 -10
  149. package/tests/bounded-stop-contract.test.ts +43 -3
  150. package/tests/bridge-cost.test.ts +19 -4
  151. package/tests/bundled-install.test.ts +30 -5
  152. package/tests/card-content-policy.test.ts +3 -3
  153. package/tests/chained-pr-skill.test.ts +8 -6
  154. package/tests/child-safety.test.ts +11 -0
  155. package/tests/codegraph-tools.test.ts +11 -5
  156. package/tests/command-palette.test.ts +284 -1
  157. package/tests/delegate-for-reason-contract.test.ts +3 -3
  158. package/tests/design-canvas-assets.test.ts +185 -2
  159. package/tests/destructive-command-guard.test.ts +52 -0
  160. package/tests/download-progress.test.ts +71 -0
  161. package/tests/execution-surface-guard.test.ts +55 -0
  162. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +9 -5
  163. package/tests/fixtures/proxy-tls/proxy.crt +19 -0
  164. package/tests/fixtures/proxy-tls/proxy.key +28 -0
  165. package/tests/fixtures/session-profile-v1/gentle-ai-reviewer.ts +89 -0
  166. package/tests/fixtures/session-profile-v1/replay.ts +53 -6
  167. package/tests/full-delegation-closure.test.ts +131 -0
  168. package/tests/full-delegation-notices.test.ts +76 -0
  169. package/tests/generic-agent-tools.test.ts +3 -3
  170. package/tests/gentle-agent-status.test.ts +74 -0
  171. package/tests/gentle-agents-child-jobs.test.ts +237 -0
  172. package/tests/gentle-agents.test.ts +1070 -12
  173. package/tests/gentle-ai-binary.test.ts +3 -1
  174. package/tests/gentle-ai-elapsed-store.test.ts +19 -0
  175. package/tests/gentle-ai-exploration-budget.test.ts +18 -2
  176. package/tests/gentle-ai-installer.test.ts +134 -51
  177. package/tests/gentle-ai-proxy.test.ts +434 -0
  178. package/tests/gentle-ai.test.ts +113 -38
  179. package/tests/gentle-design.test.ts +21 -0
  180. package/tests/gentle-herdr-activity.test.ts +9 -6
  181. package/tests/gentle-shell-bin.test.ts +123 -0
  182. package/tests/gentle-shell-bundled.test.ts +207 -31
  183. package/tests/gentle-shell-launcher.test.ts +77 -10
  184. package/tests/gentle-shell.test.ts +899 -59
  185. package/tests/gentle-todo.test.ts +19 -2
  186. package/tests/gentle-tps.test.ts +123 -0
  187. package/tests/gentle-ui-design-skill.test.ts +59 -0
  188. package/tests/herdr-busy.test.ts +59 -0
  189. package/tests/herdr-task-summary-policy.test.ts +8 -4
  190. package/tests/image-disk-cache.test.ts +163 -0
  191. package/tests/independent-recovery-delivery.test.ts +83 -0
  192. package/tests/inprocess-reviewer.test.ts +176 -4
  193. package/tests/installer-posix-bootstrap.test.ts +1 -1
  194. package/tests/installer-preflight.test.ts +5 -4
  195. package/tests/installer-runner.test.ts +79 -44
  196. package/tests/installer-server.test.ts +14 -11
  197. package/tests/jobs-view.test.ts +260 -6
  198. package/tests/modal-mouse-boundaries.test.ts +136 -0
  199. package/tests/model-routing-authority.test.ts +178 -2
  200. package/tests/native-choice-list.test.ts +77 -2
  201. package/tests/native-review-capability-contract.test.ts +7 -1
  202. package/tests/native-review-cli.test.ts +269 -1
  203. package/tests/no-self-pause-contract.test.ts +4 -1
  204. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  205. package/tests/orchestrator-budget.test.ts +7 -2
  206. package/tests/orchestrator-delegation-mode.test.ts +153 -0
  207. package/tests/orchestrator-mode-policy.test.ts +175 -0
  208. package/tests/orchestrator-prompt-budget.test.ts +3 -1
  209. package/tests/orchestrator-rdd-ownership.test.ts +2 -2
  210. package/tests/package-manifest.test.ts +11 -9
  211. package/tests/permission-allowlist.test.ts +202 -0
  212. package/tests/pi-update-launcher.test.ts +8 -0
  213. package/tests/pnpm-workspace-config.test.ts +58 -0
  214. package/tests/primary-session-prompt.test.ts +13 -0
  215. package/tests/profile-pin.test.ts +29 -2
  216. package/tests/profile-tier-footer.test.ts +5 -0
  217. package/tests/profiles-panel-delegation-mode.test.ts +422 -0
  218. package/tests/questionnaire-view.test.ts +115 -0
  219. package/tests/quiet-bash-runtime.test.ts +1 -1
  220. package/tests/quiet-tool-rendering.test.ts +48 -0
  221. package/tests/rdd-aware-verification-contract.test.ts +16 -11
  222. package/tests/rdd-customize.test.ts +287 -0
  223. package/tests/rdd-mode-cache.test.ts +450 -0
  224. package/tests/rdd-mode-control.test.ts +407 -0
  225. package/tests/rdd-mode-scope-regression.test.ts +137 -0
  226. package/tests/rdd-off-independent-regression.test.ts +69 -0
  227. package/tests/rdd-status-line.test.ts +18 -0
  228. package/tests/render-cache-performance.test.ts +171 -2
  229. package/tests/reply-language-anchor.test.ts +173 -0
  230. package/tests/review-agent-end-preflight.test.ts +1 -1
  231. package/tests/review-blocker.test.ts +193 -0
  232. package/tests/review-candidate-owner-retry.test.ts +1 -1
  233. package/tests/review-candidate-symlink-scan.test.ts +157 -0
  234. package/tests/review-candidate-view.test.ts +1 -1
  235. package/tests/review-candidate-windows-boundary.test.ts +131 -0
  236. package/tests/review-candidate-windows-probe.test.ts +63 -0
  237. package/tests/review-committed-restart-ack.test.ts +129 -0
  238. package/tests/review-continuation-registry.test.ts +76 -0
  239. package/tests/review-controller-native-routing.test.ts +261 -5
  240. package/tests/review-controller-workspace-root.test.ts +230 -3
  241. package/tests/review-controller.test.ts +96 -11
  242. package/tests/review-coordinator-runtime.test.ts +117 -0
  243. package/tests/review-coordinator.test.ts +195 -0
  244. package/tests/review-failure-facts.test.ts +87 -0
  245. package/tests/review-host-relay-routing.test.ts +258 -4
  246. package/tests/review-host-relay.test.ts +39 -0
  247. package/tests/review-integration-v2.test.ts +46 -3
  248. package/tests/review-json-arguments.test.ts +65 -10
  249. package/tests/review-last-event-closure.test.ts +68 -0
  250. package/tests/review-loadout-rdd-off-sdk.test.ts +65 -31
  251. package/tests/review-owner-identity.test.ts +60 -24
  252. package/tests/review-relay-phase-timing.test.ts +128 -0
  253. package/tests/review-relay-transport-agent.test.ts +12 -2
  254. package/tests/review-reviewer-evidence.test.ts +183 -0
  255. package/tests/review-risk-assessment.test.ts +74 -3
  256. package/tests/review-session-standing-permission-controller.test.ts +21 -1
  257. package/tests/review-start-context.test.ts +19 -0
  258. package/tests/review-tool-prose-budget.test.ts +121 -0
  259. package/tests/run-test-suite.test.ts +122 -1
  260. package/tests/runtime-harness.mjs +4 -1
  261. package/tests/sensitive-path-tools.test.ts +181 -5
  262. package/tests/session-profile-append-controller-pi.test.ts +60 -31
  263. package/tests/session-profile-binding.test.ts +19 -1
  264. package/tests/session-profile-disk-reader-pi.test.ts +58 -16
  265. package/tests/session-profile-v1-compat.test.ts +35 -1
  266. package/tests/shell-bar.test.ts +186 -42
  267. package/tests/shell-panel.test.ts +50 -22
  268. package/tests/shell-sidebar-fullscreen.test.ts +5 -5
  269. package/tests/shell-sidebar-layout.test.ts +294 -23
  270. package/tests/shell-sidebar-scroll-benchmark.test.ts +1 -1
  271. package/tests/shell-surface-transparent.test.ts +89 -0
  272. package/tests/shell-todo.test.ts +12 -0
  273. package/tests/skill-registry.test.ts +838 -5
  274. package/tests/startup-banner.test.ts +152 -1
  275. package/tests/startup-home-repo.test.ts +2 -0
  276. package/tests/support/review-coordinator-runtime.ts +69 -0
  277. package/tests/task-size-routing-contract.test.ts +5 -3
  278. package/tests/verifier-admission.test.ts +49 -0
  279. package/tests/verify-first-launch-contract.test.ts +78 -3
  280. package/tests/visual-customization-policy.test.ts +39 -6
  281. package/tests/visual-customize-view.test.ts +573 -9
  282. package/tests/visual-layout-preview.test.ts +15 -1
  283. package/tests/visual-profiles.test.ts +11 -0
  284. package/tests/voice-worker.test.ts +73 -2
  285. package/tests/windows-session-transport.test.ts +126 -0
  286. package/tests/work-continuity-contract.test.ts +28 -0
  287. package/tests/writer-feature-document-admission.test.ts +92 -0
  288. package/tests/yolo-customize.test.ts +27 -4
  289. package/tests/yolo-mode.test.ts +23 -18
  290. package/tests/yolo-session-policy.test.ts +270 -1
@@ -27,10 +27,12 @@ import { decodeReviewStatusV3 } from "../lib/review-integration-v2.ts";
27
27
  import { REVIEW_SIDEBAR_EVENT } from "../lib/review-sidebar-state.ts";
28
28
  import { isJobsSidebarSnapshot } from "../lib/jobs-sidebar-state.ts";
29
29
  import type { NativeReviewCli } from "../lib/native-review-cli.ts";
30
+ import { chromeSurface, setChromeSurface } from "../lib/shell-panel.ts";
30
31
  import { DEFAULT_VISUAL_SETTINGS, DENSITY, VISUAL_PRESET, VISUAL_SCHEMA, resolveVisualSettings, visualPresetOf, writeVisualSettings } from "../lib/visual-customization-policy.ts";
31
32
  import { resolveAnimationPolicy } from "../lib/animation-policy.ts";
32
33
  import { resolveVimPolicy, writeVimPolicy } from "../lib/vim-policy.ts";
33
34
  import { resolveHistoryCapturePolicy, writeHistoryCapturePolicy } from "../lib/history-capture-policy.ts";
35
+ import { HERDR_TASK_SUMMARY_CHANGED, resolveHerdrTaskSummarySettings, writeHerdrTaskSummarySettings } from "../lib/herdr-task-summary-policy.ts";
34
36
  import { setBundledInstallForTesting } from "../lib/gentle-shell-bundled.ts";
35
37
  import { readBannerConfig } from "../extensions/startup-banner.ts";
36
38
  import { listVisualProfiles, saveVisualProfile } from "../lib/visual-profiles.ts";
@@ -40,6 +42,7 @@ import { resolveCardStyle, writeCardStyle } from "../lib/card-style-policy.ts";
40
42
  import { CARD_CONTENT, cardContent, resolveCardContent, setCardContent, writeCardContent } from "../lib/card-content-policy.ts";
41
43
  import { claimNotificationOwner } from "../lib/notification-service.ts";
42
44
  import { DEFAULT_NOTIFICATION_SETTINGS } from "../lib/notification-policy.ts";
45
+ import { SUPER_YOLO_STATUS_TEXT, yoloBannerContent } from "../lib/yolo-session-policy.ts";
43
46
 
44
47
 
45
48
  // Vim fixtures claim the installed pi-tui release, which the adapter gate
@@ -638,7 +641,7 @@ test("jobs snapshots feed their own rail card, keep one compact fallback, and re
638
641
  publish("shell-session", [{ id: "job-2", label: "Fresh tail", startedAt: 1, status: "exited", endedAt: Date.now(), exitCode: 0 }]);
639
642
  tui.terminal.columns = 80;
640
643
  assert.match(jobs.render(46).join("\n"), /Fresh tail/, "the finished tail still paints the card");
641
- assert.doesNotMatch(statusbar.render(80).join("\n"), /⧗ 1 job/, "the compact count is running-only");
644
+ assert.doesNotMatch(header.render(80).join("\n"), /⧗ 1 job/, "the compact count is running-only");
642
645
  tui.terminal.columns = 160;
643
646
  publish("shell-session", [{ id: "job-0", label: "Stale tail", startedAt: 1, status: "exited", endedAt: 5, exitCode: 0 }]);
644
647
  assert.doesNotMatch(jobs.render(46).join("\n"), /Stale tail/, "a finished job past the TTL paints nothing");
@@ -650,14 +653,15 @@ test("jobs snapshots feed their own rail card, keep one compact fallback, and re
650
653
  state.active = false;
651
654
  tui.terminal.columns = 80;
652
655
  publish("shell-session", [{ id: "job-1", label: "CI for PR 1860", startedAt: 1 }]);
653
- assert.match(statusbar.render(80).join("\n"), /1 job/, "the mobile status bar preserves the count of a running job");
656
+ assert.match(header.render(80).join("\n"), /1 job/, "the mobile top bar preserves the count of a running job");
657
+ assert.deepEqual(statusbar.render(80), [], "mobile top does not duplicate the jobs count below the input");
654
658
  const before = jobs.render(46).join("\n");
655
659
  publish("foreign", []);
656
660
  publish("shell-session", [{ label: "invalid" }]);
657
661
  assert.equal(jobs.render(46).join("\n"), before);
658
662
  publish("shell-session", []);
659
663
  assert.doesNotMatch(jobs.render(46).join("\n"), /Jobs|CI for PR/);
660
- assert.doesNotMatch(statusbar.render(80).join("\n"), /1 job/);
664
+ assert.doesNotMatch(header.render(80).join("\n"), /1 job/);
661
665
  publish("shell-session", [{ id: "job-2", label: "Build runtime", startedAt: 2 }]);
662
666
  await fire(handlers, "session_start", ctx);
663
667
  assert.doesNotMatch(state.parts.get("jobs")!.render(46).join("\n"), /Build runtime/);
@@ -719,9 +723,9 @@ test("the fullscreen Status rail and header refresh the effective agent profile
719
723
  assert.equal(typeof rail.digest, "function", "the Status card paints live state and must declare a digest");
720
724
  assert.doesNotMatch(rail.render(46).join("\n"), /gpt-5\.5/, "model now lives in the header, not the Status card");
721
725
 
722
- // Integrations exposes the same effective agent profile as the header.
726
+ // The bar carries the effective agent profile next to the model; Integrations no longer lists it.
723
727
  const header = sidebarState(tui as unknown as TUI).parts.get("header") as SidebarRail;
724
- assert.match(rail.render(46).join("\n"), /Agent profile: team/);
728
+ assert.doesNotMatch(rail.render(46).join("\n"), /Agent profile/);
725
729
  assert.match(header.render(160).join("\n"), /team/);
726
730
  const beforeProfile = header.digest?.();
727
731
  const beforeRailProfile = live();
@@ -729,7 +733,6 @@ test("the fullscreen Status rail and header refresh the effective agent profile
729
733
  assert.notEqual(header.digest?.(), beforeProfile, "a profile switch changes the header digest");
730
734
  assert.notEqual(live(), beforeRailProfile, "a profile switch changes the Status digest");
731
735
  assert.match(header.render(160).join("\n"), /other/);
732
- assert.match(rail.render(46).join("\n"), /Agent profile: other/);
733
736
  profile = undefined;
734
737
  assert.doesNotMatch(header.render(160).join("\n"), /team|other/);
735
738
  assert.doesNotMatch(rail.render(46).join("\n"), /Agent profile:/);
@@ -917,7 +920,7 @@ test("profile polling refreshes both fullscreen surfaces only on change and stop
917
920
  try {
918
921
  const timer = intervals.find((entry) => entry.delay === 2000);
919
922
  assert.ok(timer, "UI session installs the 2000ms profile refresh");
920
- assert.match(status(), /Agent profile: team/, "Integrations shows the effective agent profile");
923
+ assert.doesNotMatch(status(), /Agent profile/, "Integrations no longer lists the profile; the bar does");
921
924
  assert.match(header(), /team/);
922
925
  const before = tui.requestRender.mock.callCount();
923
926
  timer.tick();
@@ -927,7 +930,7 @@ test("profile polling refreshes both fullscreen surfaces only on change and stop
927
930
  timer.tick();
928
931
  assert.equal(tui.requestRender.mock.callCount(), before + 1);
929
932
  assert.match(header(), /other \(local\)/);
930
- assert.match(status(), /Agent profile: other \(local\)/, "profile polling also refreshes Integrations");
933
+
931
934
  timer.tick();
932
935
  assert.equal(tui.requestRender.mock.callCount(), before + 1);
933
936
  const afterBind = resolutions;
@@ -2393,6 +2396,26 @@ test("visual customization and Vim register once and remain independently discov
2393
2396
  assert.equal(JSON.parse(readFileSync(join(home, "vim.json"), "utf8")).policy, "on");
2394
2397
  });
2395
2398
 
2399
+ test("/gentle:customize forwards a mouse click through its command overlay", async (t) => {
2400
+ const home = scopedDoubleEscCancelConfigHome(t);
2401
+ const { pi, commands } = fakePi();
2402
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
2403
+ const { ctx, ui, overlayReady } = fakeContext();
2404
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
2405
+ await overlayReady;
2406
+ const view = ui.overlayView as unknown as { render(width: number): string[]; handleMouse(event: TuiMouseEvent): { handled?: boolean } | undefined; handleInput(data: string): void };
2407
+ try {
2408
+ const frame = view.render(100);
2409
+ const y = frame.findIndex(row => row.includes("performance"));
2410
+ assert.ok(y >= 0);
2411
+ const x = visibleWidth(frame[y]!.slice(0, frame[y]!.indexOf("performance")));
2412
+ assert.equal(resolveAnimationPolicy({ gentlePiConfigHome: home }).policy, "quality");
2413
+ assert.equal(view.handleMouse({ type: "click", button: "left", x, y, screenX: x + 10, screenY: y + 5, width: 100, height: frame.length, shift: false, alt: false, ctrl: false })?.handled, true);
2414
+ await new Promise<void>(resolve => setImmediate(resolve));
2415
+ assert.equal(resolveAnimationPolicy({ gentlePiConfigHome: home }).policy, "performance");
2416
+ } finally { view.handleInput("\x1b"); await pending; }
2417
+ });
2418
+
2396
2419
  test("/gentle:customize has a Keymaps category that saves a key and reloads on request", async () => {
2397
2420
  const home = mkdtempSync(join(tmpdir(), "gentle-shell-keymaps-"));
2398
2421
  isolatedConfigHomes.push(home);
@@ -3566,6 +3589,100 @@ test("customize History rows persist prompt history capture and keep stored hist
3566
3589
  ui.overlayView!.handleInput("\x1b"); await pending;
3567
3590
  });
3568
3591
 
3592
+ test("customize Layout offers explicit task summary choices without saving on navigation", async (t) => {
3593
+ const home = scopedDoubleEscCancelConfigHome(t);
3594
+ const { pi, commands } = fakePi();
3595
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
3596
+ const { ctx, ui, overlayReady } = fakeContext();
3597
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
3598
+ await overlayReady;
3599
+ try {
3600
+ assert.ok(findCustomizeRow(ui, "Task summary: on (current)"));
3601
+ assert.ok(findCustomizeRow(ui, "Task summary: off"));
3602
+ const frame = ui.overlayView!.render(180).join("\n");
3603
+ assert.match(frame, /Layout ·/);
3604
+ assert.match(frame, /Task summary\s+● on\s+› off/);
3605
+ assert.match(frame, /task summary published to terminal tools/i);
3606
+ ui.overlayView!.handleInput("\x1b[D");
3607
+ ui.overlayView!.handleInput("\x1b[C");
3608
+ await new Promise<void>(resolve => setImmediate(resolve));
3609
+ assert.equal(existsSync(join(home, "herdr-task-summary.json")), false);
3610
+ } finally { ui.closeOverlay?.(); await pending; }
3611
+ });
3612
+
3613
+ test("customize task summary persists only enabled then emits once per choice for the same home", async (t) => {
3614
+ const home = scopedDoubleEscCancelConfigHome(t);
3615
+ const options = { gentlePiConfigHome: home };
3616
+ writeHerdrTaskSummarySettings({ enabled: true, summaryColor: "success", continuationColor: "warning" }, options);
3617
+ const { pi, commands } = fakePi();
3618
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
3619
+ const events: unknown[] = [];
3620
+ const saved: boolean[] = [];
3621
+ pi.events.on(HERDR_TASK_SUMMARY_CHANGED, payload => {
3622
+ events.push(payload);
3623
+ saved.push(resolveHerdrTaskSummarySettings(options).settings.enabled);
3624
+ });
3625
+ const { ctx, ui, overlayReady } = fakeContext();
3626
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
3627
+ await overlayReady;
3628
+ try {
3629
+ for (const enabled of [false, true]) {
3630
+ await customizeAction(ui, `Task summary: ${enabled ? "on" : "off"}`);
3631
+ assert.deepEqual(resolveHerdrTaskSummarySettings(options).settings, { enabled, summaryColor: "success", continuationColor: "warning" });
3632
+ assert.ok(findCustomizeRow(ui, `Task summary: ${enabled ? "on" : "off"} (current)`));
3633
+ assert.match(ui.notices.at(-1)!, /applies now.*active-task summary published to terminal tools/i);
3634
+ }
3635
+ assert.deepEqual(events, [{ configHome: home }, { configHome: home }]);
3636
+ assert.deepEqual(saved, [false, true], "each listener sees the completed write");
3637
+ assert.equal(existsSync(join(home, "visual-customization.json")), false);
3638
+ } finally { ui.closeOverlay?.(); await pending; }
3639
+ });
3640
+
3641
+ for (const [kind, bytes] of [["malformed", "{"], ["unreadable oversized", " ".repeat(4097)]] as const) {
3642
+ test(`customize task summary refuses ${kind} storage without events or overwritten bytes`, async (t) => {
3643
+ const home = scopedDoubleEscCancelConfigHome(t);
3644
+ const file = join(home, "herdr-task-summary.json");
3645
+ const { pi, commands } = fakePi();
3646
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
3647
+ let events = 0;
3648
+ pi.events.on(HERDR_TASK_SUMMARY_CHANGED, () => { events++; });
3649
+ const { ctx, ui, overlayReady } = fakeContext();
3650
+ const notices: Array<{ message: string; type: unknown }> = [];
3651
+ const notify = ctx.ui.notify.bind(ctx.ui);
3652
+ ctx.ui.notify = (message, type) => { notices.push({ message, type }); notify(message, type); };
3653
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
3654
+ await overlayReady;
3655
+ try {
3656
+ // Re-read at activation: a file can become invalid while the card is open.
3657
+ writeFileSync(file, bytes);
3658
+ await customizeAction(ui, "Task summary: off");
3659
+ assert.match(notices.at(-1)!.message, /malformed or unreadable task summary preference/i);
3660
+ assert.equal(notices.at(-1)!.type, "error");
3661
+ assert.equal(events, 0);
3662
+ assert.equal(readFileSync(file, "utf8"), bytes);
3663
+ } finally { ui.closeOverlay?.(); await pending; }
3664
+ });
3665
+ }
3666
+
3667
+ test("customize task summary leaves the previous Layout controls working independently", async (t) => {
3668
+ const home = scopedDoubleEscCancelConfigHome(t);
3669
+ const { pi, commands } = fakePi();
3670
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
3671
+ const { ctx, ui, overlayReady } = fakeContext();
3672
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
3673
+ await overlayReady;
3674
+ try {
3675
+ assert.ok(findCustomizeRow(ui, "Task summary: off"));
3676
+ for (const label of ["Preset: Light", "Status placement: bottom", "Header placement: split", "Density: compact", "Surface: tinted"]) await customizeAction(ui, label);
3677
+ const settings = resolveVisualSettings({ gentlePiConfigHome: home }).settings;
3678
+ assert.equal(settings.statusPlacement, "bottom");
3679
+ assert.equal(settings.headerPlacement, "split");
3680
+ assert.equal(settings.density, "compact");
3681
+ assert.equal(settings.surface, "tinted");
3682
+ assert.equal(existsSync(join(home, "herdr-task-summary.json")), false);
3683
+ } finally { ui.closeOverlay?.(); await pending; }
3684
+ });
3685
+
3569
3686
  test("customize Cards rows persist the card style and switch live conversation cards", async (t) => {
3570
3687
  const home = scopedDoubleEscCancelConfigHome(t);
3571
3688
  const found = cardStyle();
@@ -3608,23 +3725,23 @@ test("customize Cards rows persist the card content level and switch the live qu
3608
3725
  t.after(() => setCardContent(previous));
3609
3726
  const { pi, commands } = fakePi();
3610
3727
  gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
3611
- assert.equal(cardContent(), CARD_CONTENT.DEFAULT, "no preference file means default");
3728
+ assert.equal(cardContent(), CARD_CONTENT.MINIMAL, "no preference file means minimal, the default");
3612
3729
  const { ctx, ui, overlayReady } = fakeContext();
3613
3730
  const pending = commands.get("gentle:customize")!.handler("", ctx);
3614
3731
  await overlayReady;
3615
- assert.ok(findCustomizeRow(ui, "Card content: default (current)"));
3616
- assert.ok(findCustomizeRow(ui, "Card content: minimal"));
3617
- assert.equal(existsSync(join(home, "card-content.json")), false, "highlighting never applies");
3618
- await customizeAction(ui, "Card content: minimal");
3619
- await new Promise<void>(resolve => setImmediate(resolve));
3620
- assert.equal(resolveCardContent({ gentlePiConfigHome: home }).content, "minimal");
3621
- assert.equal(cardContent(), CARD_CONTENT.MINIMAL, "the live slot follows the choice");
3622
- assert.match(ui.notices.at(-1)!, /Card content: minimal/);
3623
3732
  assert.ok(findCustomizeRow(ui, "Card content: minimal (current)"));
3624
3733
  assert.ok(findCustomizeRow(ui, "Card content: default"));
3734
+ assert.equal(existsSync(join(home, "card-content.json")), false, "highlighting never applies");
3625
3735
  await customizeAction(ui, "Card content: default");
3736
+ await new Promise<void>(resolve => setImmediate(resolve));
3626
3737
  assert.equal(resolveCardContent({ gentlePiConfigHome: home }).content, "default");
3627
- assert.equal(cardContent(), CARD_CONTENT.DEFAULT);
3738
+ assert.equal(cardContent(), CARD_CONTENT.DEFAULT, "the live slot follows the choice");
3739
+ assert.match(ui.notices.at(-1)!, /Card content: default/);
3740
+ assert.ok(findCustomizeRow(ui, "Card content: default (current)"));
3741
+ assert.ok(findCustomizeRow(ui, "Card content: minimal"));
3742
+ await customizeAction(ui, "Card content: minimal");
3743
+ assert.equal(resolveCardContent({ gentlePiConfigHome: home }).content, "minimal");
3744
+ assert.equal(cardContent(), CARD_CONTENT.MINIMAL);
3628
3745
  ui.overlayView!.handleInput("\x1b"); await pending;
3629
3746
  });
3630
3747
 
@@ -3633,6 +3750,7 @@ test("T3 live style Cards action refreshes cached TODO and Status in both direct
3633
3750
  const previous = cardStyle();
3634
3751
  t.after(() => setCardStyle(previous));
3635
3752
  writeCardStyle(CARD_STYLE.NEON, { gentlePiConfigHome: home });
3753
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "split" }, { gentlePiConfigHome: home });
3636
3754
  const { pi, handlers, commands } = fakePi();
3637
3755
  gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home }, { activeProfile: () => "team" });
3638
3756
  const { ctx, ui, overlayReady } = fakeContext();
@@ -3676,8 +3794,12 @@ test("T3 live style Cards action refreshes cached TODO and Status in both direct
3676
3794
  // The wide chrome: the title row on top and one status bar row as the last layout entry.
3677
3795
  const wide = root[node]() as unknown as { entries: { component: { render(width: number): string[] } }[] };
3678
3796
  assert.equal(wide.entries.length, 3, "title row, transcript with the rail, status bar");
3679
- assert.match(stripAnsi(frame.header), /^ ✿ repo \/repo .*team $/);
3680
- assert.match(stripAnsi(wide.entries[2]!.component.render(160).join("\n")), /^ main .*ctx .*usage/);
3797
+ const [titleAbove, titleRow, titleBelow] = stripAnsi(frame.header).split("\n");
3798
+ assert.match(titleRow!, /^ ✿ repo \/repo .*Release notes $/, "the title row keeps the session; the profile rides the status bar");
3799
+ assert.equal(titleAbove!.trim() + titleBelow!.trim(), "", "comfortable centers the title row between two margin rows");
3800
+ const [statusMargin, statusRow, statusBelow] = stripAnsi(wide.entries[2]!.component.render(160).join("\n")).split("\n");
3801
+ assert.equal(statusMargin!.trim() + statusBelow!.trim(), "", "and the status bar too");
3802
+ assert.match(statusRow!, /^ main .*ctx .*usage/);
3681
3803
  const neon = { ...frame };
3682
3804
  paint();
3683
3805
  assert.equal(todoRenders, 1, "unchanged frame uses cached TODO");
@@ -3963,7 +4085,7 @@ test("below-input header remains a fullscreen widget without the rail and follow
3963
4085
  } finally { footer.dispose(); }
3964
4086
  });
3965
4087
 
3966
- test("narrow fullscreen with a below-input header shows only the bottom bar, carrying the header's data and extension statuses", async (t) => {
4088
+ test("narrow fullscreen with a below-input header shows only the bottom bar, carrying the header's data without extension statuses", async (t) => {
3967
4089
  const home = scopedDoubleEscCancelConfigHome(t);
3968
4090
  const { pi, handlers, commands } = fakePi();
3969
4091
  gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
@@ -3983,12 +4105,12 @@ test("narrow fullscreen with a below-input header shows only the bottom bar, car
3983
4105
  await customizeAction(ui, "Header placement: below-input");
3984
4106
  assert.deepEqual(widget(tui, plainTheme).render(100), [], "no second status row below the input at narrow width");
3985
4107
  const narrow = footer.render(100);
3986
- assert.equal(narrow.length, 2);
4108
+ assert.equal(narrow.length, 1, "integrations live only in the rail");
3987
4109
  assert.match(narrow[0]!, /Gentle Shell/, "bottom-only bar reuses the header row");
3988
4110
  assert.match(narrow[0]!, /ctx .* 45%/);
3989
4111
  assert.match(narrow[0]!, /\$0\.000 sub/);
3990
4112
  assert.match(narrow[0]!, /usage/);
3991
- assert.match(narrow[1]!, /MCP: 2 servers/, "extension statuses survive on their own line");
4113
+ assert.doesNotMatch(narrow.join("\n"), /MCP: 2 servers/, "no extension statuses in the bottom bar");
3992
4114
  assert.ok(narrow.every((line) => visibleWidth(line) <= 100));
3993
4115
  for (const width of [60, 80]) {
3994
4116
  tui.terminal.columns = width;
@@ -4002,7 +4124,7 @@ test("narrow fullscreen with a below-input header shows only the bottom bar, car
4002
4124
  tui.terminal.columns = 100;
4003
4125
  await customizeAction(ui, "Status placement: hidden");
4004
4126
  assert.deepEqual(footer.render(100), [], "hidden never paints a bottom bar");
4005
- assert.equal(widget(tui, plainTheme).render(100).length, 2, "with no bottom bar the below-input header stays");
4127
+ assert.equal(widget(tui, plainTheme).render(100).length, 3, "with no bottom bar the below-input header stays, centered between its margin rows");
4006
4128
  tui.mode = "regular";
4007
4129
  await customizeAction(ui, "Status placement: bottom");
4008
4130
  assert.equal(footer.render(100).length, 1, "regular mode keeps the compact bar");
@@ -4016,7 +4138,8 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4016
4138
  t.after(() => setCardStyle(previous));
4017
4139
  const home = scopedDoubleEscCancelConfigHome(t);
4018
4140
  writeCardStyle("float", { gentlePiConfigHome: home });
4019
- writeVisualSettings({ ...resolveVisualSettings({ gentlePiConfigHome: home }).settings, headerPlacement: "below-input" }, { gentlePiConfigHome: home });
4141
+ // The painted float group is the tinted surface's.
4142
+ writeVisualSettings({ ...resolveVisualSettings({ gentlePiConfigHome: home }).settings, headerPlacement: "below-input", surface: "tinted" }, { gentlePiConfigHome: home });
4020
4143
  const { pi, handlers, commands } = fakePi([{ numstat: "2\t0\tlib/live.ts\n", porcelain: " M lib/live.ts\0" }, { numstat: "3\t0\tlib/live.ts\n", porcelain: " M lib/live.ts\0" }]);
4021
4144
  gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
4022
4145
  const { ctx, ui, overlayReady } = fakeContext();
@@ -4035,7 +4158,7 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4035
4158
  const click = (x: number, y: number, width: number): TuiMouseEvent => ({ type: "click", button: "left", x, y, screenX: x, screenY: y, width, height: 6, shift: false, alt: false, ctrl: false } as TuiMouseEvent);
4036
4159
  try {
4037
4160
  const withoutChanges = footer.render(139);
4038
- assert.equal(withoutChanges.length, 5);
4161
+ assert.equal(withoutChanges.length, 4, "the edge, padding, header row and padding; statuses stay in the rail");
4039
4162
  assert.deepEqual(header.render(139), []);
4040
4163
  const initialUsageX = stripAnsi(withoutChanges[2]!).indexOf("usage");
4041
4164
  assert.equal(footer.handleMouse?.(click(initialUsageX, 3, 139)), undefined);
@@ -4047,10 +4170,10 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4047
4170
  for (const width of [139, 140, 240]) {
4048
4171
  tui.terminal.columns = width;
4049
4172
  const rows = footer.render(width);
4050
- assert.equal(rows.length, 6);
4173
+ assert.equal(rows.length, 5, "edge, padding, Changes, header row and padding; statuses stay in the rail");
4051
4174
  assert.match(stripAnsi(rows[2]!), /1 file · \+2 −0/);
4052
4175
  assert.match(stripAnsi(rows[3]!), /Gentle Shell/);
4053
- assert.match(stripAnsi(rows[4]!), /^ MCP ready/);
4176
+ assert.doesNotMatch(stripAnsi(rows.join("\n")), /MCP ready/);
4054
4177
  assert.ok(rows.slice(1).every((row) => row.startsWith(bg)));
4055
4178
  assert.deepEqual(changes.render(width), []);
4056
4179
  assert.deepEqual(header.render(width), []);
@@ -4069,10 +4192,10 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4069
4192
  await changesSettled();
4070
4193
  assert.notEqual(railHeader.digest!(), statusDigest, "Git changes update the grouped digest");
4071
4194
  assert.match(stripAnsi(footer.render(240).join("\n")), /\+3 −0/);
4072
- assert.match(stripAnsi(footer.render(240).join("\n")), /MCP updated/);
4195
+ assert.doesNotMatch(stripAnsi(footer.render(240).join("\n")), /MCP updated/, "statuses stay in the rail");
4073
4196
  state.active = true;
4074
4197
  state.ownsHost = () => true;
4075
- assert.deepEqual(footer.render(240), [""], "suppressed float footer leaves an unpainted exterior dock row");
4198
+ assert.deepEqual(footer.render(240), [], "the below-input header follows the prompt, so the suppressed footer adds no exterior row");
4076
4199
  assert.deepEqual(footer.render(9), [], "narrow fallback does not add spacing");
4077
4200
  hasBackground = false;
4078
4201
  assert.deepEqual(footer.render(240), [], "missing background retains the legacy dock");
@@ -4080,13 +4203,18 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4080
4203
  setCardStyle(CARD_STYLE.NEON);
4081
4204
  assert.deepEqual(footer.render(240), [], "neon retains the legacy dock");
4082
4205
  setCardStyle(CARD_STYLE.FLOAT);
4083
- const grouped = header.render(240);
4084
- assert.equal(grouped.length, 5, "rail owns statuses; widget owns Changes/header only");
4206
+ // Beside the rail the below-input bar is the full-width bottom row, like split's
4207
+ // status bar: the widget under the input steps aside.
4208
+ assert.deepEqual(header.render(240), [], "the widget under the input steps aside");
4209
+ assert.equal(header.handleMouse?.(click(2, 0, 240)), undefined);
4210
+ const statusbar = state.parts.get("statusbar")!;
4211
+ const grouped = statusbar.render(240);
4212
+ assert.equal(grouped.length, 3, "rail owns statuses and Changes; the bottom row draws the centered chrome bar");
4085
4213
  assert.doesNotMatch(stripAnsi(grouped.join("\n")), /MCP updated/);
4086
4214
  assert.deepEqual(widget("gentle-shell-changes").render(240), []);
4087
- const usageX = stripAnsi(grouped[3]!).indexOf("usage");
4088
- assert.equal(header.handleMouse?.(click(usageX, 2, 240)), undefined);
4089
- assert.equal(header.handleMouse?.(click(usageX, 3, 240))?.handled, true);
4215
+ const usageX = stripAnsi(grouped[1]!).indexOf("usage");
4216
+ assert.equal(statusbar.handleMouse?.(click(usageX, 0, 240)), undefined, "the margin row is not a target");
4217
+ assert.equal(statusbar.handleMouse?.(click(usageX, 1, 240))?.handled, true);
4090
4218
  ui.closeOverlay?.();
4091
4219
  state.active = false;
4092
4220
  for (const width of [9, 10]) {
@@ -4114,20 +4242,22 @@ test("T4d unified float footer uses one live owner and restores legacy Changes o
4114
4242
  await overlayReady;
4115
4243
  for (let attempt = 0; attempt < 100 && ui.overlayView === previousView; attempt++) await new Promise<void>((resolve) => setTimeout(resolve, 5));
4116
4244
  await customizeAction(ui, "Status placement: hidden");
4117
- assert.deepEqual(footer.render(240), [""], "hidden float status retains exterior dock spacing");
4118
- assert.equal(header.render(240).length, 5);
4245
+ assert.deepEqual(footer.render(240), [], "the below-input header still follows the prompt with Status hidden: no exterior row");
4246
+ // Status hidden draws the chrome bar too: a margin row, then the status bar row.
4247
+ assert.equal(header.render(240).length, 3);
4248
+ assert.match(stripAnsi(header.render(240)[1]!), /ctx .*usage/);
4119
4249
  assert.doesNotMatch(stripAnsi(header.render(240).join("\n")), /MCP updated/);
4250
+ assert.equal(widget("gentle-shell-changes").render(240).length, 1, "Changes keep their own row beside a chrome bar");
4120
4251
  await customizeAction(ui, "Section changes: hidden");
4121
- assert.equal(header.render(240).length, 4);
4252
+ assert.equal(header.render(240).length, 3);
4122
4253
  assert.equal(ui.widgets.has("gentle-shell-changes"), false);
4123
4254
  await customizeAction(ui, "Section changes: shown");
4124
4255
  await customizeAction(ui, "Header placement: top");
4125
4256
  assert.deepEqual(header.render(240), []);
4126
4257
  assert.equal(widget("gentle-shell-changes").render(240).length, 1, "top placement restores standalone Changes");
4127
4258
  const above = railHeader.render(240);
4128
- assert.equal(above.length, 4);
4129
- assert.match(stripAnsi(above[1]!), /Gentle Shell/);
4130
- assert.equal(stripAnsi(above[3]!), "▔".repeat(240));
4259
+ assert.equal(above.length, 3, "the top chrome bar centered between two margin rows");
4260
+ assert.match(stripAnsi(above[1]!), /ctx .*usage/);
4131
4261
  ui.overlayView!.handleInput("\x1b");
4132
4262
  await pending;
4133
4263
  } finally {
@@ -5357,6 +5487,76 @@ test("loadFileDiff asks git for a HEAD diff, or a no-index diff for untracked fi
5357
5487
  ]);
5358
5488
  });
5359
5489
 
5490
+ test("loadFileDiff discards partial output after the shell Git deadline", async (t) => {
5491
+ for (const { status, exitCode, error, expectedArgs } of [
5492
+ { status: CHANGE_STATUS.MODIFIED, exitCode: 0, error: null, expectedArgs: ["diff", "HEAD", "--", "file.txt"] },
5493
+ { status: CHANGE_STATUS.UNTRACKED, exitCode: null, error: Object.assign(new Error("different"), { code: 1 }), expectedArgs: ["diff", "--no-index", "--", "/dev/null", "file.txt"] },
5494
+ ]) {
5495
+ await t.test(status, async (t) => {
5496
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5497
+ const events: string[] = [];
5498
+ const partial = "@@ -0,0 +1 @@\n+partial";
5499
+ let calledArgs: readonly string[] = [];
5500
+ const fake = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5501
+ void command; void options;
5502
+ calledArgs = args;
5503
+ return {
5504
+ pid: 8, exitCode, signalCode: null,
5505
+ kill() { events.push("kill"); },
5506
+ stdout: { destroy() { events.push("stdout"); callback(error, partial, ""); } },
5507
+ stderr: { destroy() { events.push("stderr"); } },
5508
+ } as unknown as import("node:child_process").ChildProcess;
5509
+ }) as typeof import("node:child_process").execFile;
5510
+ const run = shellGitRunner("/repo", {}, fake, Infinity, () => events.push("tree"));
5511
+ const diff = loadFileDiff(async (args) => {
5512
+ const result = await run(args);
5513
+ assert.equal(result.code, 1);
5514
+ assert.equal(result.stdout, partial, "diagnostic output remains available to other consumers");
5515
+ return result;
5516
+ }, { path: "file.txt", added: 1, deleted: 0, status });
5517
+ t.mock.timers.tick(5_000);
5518
+ t.mock.timers.tick(1_000);
5519
+ assert.deepEqual(calledArgs, ["-C", "/repo", ...expectedArgs]);
5520
+ assert.deepEqual(events, exitCode === null ? ["tree", "kill", "stdout", "stderr"] : ["stdout", "stderr"]);
5521
+ assert.equal(await diff, "", "a timed-out partial diff must not be displayed");
5522
+ });
5523
+ }
5524
+ });
5525
+
5526
+ test("loadFileDiff discards partial output after execFile's deadline", { skip: process.platform === "win32" }, async (t) => {
5527
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5528
+ const partial = "@@ -0,0 +1 @@\n+partial";
5529
+ const fake = ((command: string, args: readonly string[], options: { timeout?: number }, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5530
+ void command; void args;
5531
+ assert.equal(options.timeout, 5_000);
5532
+ setTimeout(() => callback(Object.assign(new Error("timed out"), { code: null, killed: true, signal: "SIGTERM" }), partial, ""), options.timeout);
5533
+ }) as typeof import("node:child_process").execFile;
5534
+ const run = shellGitRunner("/repo", {}, fake);
5535
+ const diff = loadFileDiff(async (args) => {
5536
+ const result = await run(args);
5537
+ assert.equal(result.code, 1);
5538
+ assert.equal(result.stdout, partial);
5539
+ return result;
5540
+ }, { path: "file.txt", added: 1, deleted: 0, status: CHANGE_STATUS.MODIFIED });
5541
+ t.mock.timers.tick(5_000);
5542
+ assert.equal(await diff, "", "a timed-out partial diff must not be displayed");
5543
+ });
5544
+
5545
+ test("loadFileDiff preserves completed shell Git results and bounded output", async () => {
5546
+ for (const { status, error, stdout, expected } of [
5547
+ { status: CHANGE_STATUS.MODIFIED, error: null, stdout: "+tracked\n", expected: "+tracked\n" },
5548
+ { status: CHANGE_STATUS.UNTRACKED, error: Object.assign(new Error("different"), { code: 1 }), stdout: "+new\n", expected: "+new\n" },
5549
+ { status: CHANGE_STATUS.MODIFIED, error: Object.assign(new Error("max buffer"), { code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER" }), stdout: "+partial", expected: DIFF_TOO_LARGE },
5550
+ ]) {
5551
+ const fake = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5552
+ void command; void args; void options;
5553
+ callback(error, stdout, "");
5554
+ }) as typeof import("node:child_process").execFile;
5555
+ const run = shellGitRunner("/repo", {}, fake, DIFF_MAX_BYTES, () => assert.fail("completed Git must not be killed"));
5556
+ assert.equal(await loadFileDiff(run, { path: "file.txt", added: 1, deleted: 0, status }), expected);
5557
+ }
5558
+ });
5559
+
5360
5560
  test("loadFileDiff replaces one oversized diff with a short open-in-editor line", async () => {
5361
5561
  const answer = (stdout: string, truncated?: boolean) => async () => ({ stdout, code: 0, ...(truncated ? { truncated } : {}) });
5362
5562
  const file = { path: "big.ts", added: 1, deleted: 0, status: CHANGE_STATUS.MODIFIED };
@@ -5386,6 +5586,169 @@ test("shell Git runner hides initial and repeated background polling children",
5386
5586
  }
5387
5587
  });
5388
5588
 
5589
+ // #927: on Windows a status scan that passes the timeout leaves its real work
5590
+ // running in a git descendant, because Node's own timeout kill reaches only the
5591
+ // direct child. The shell runner must kill the whole tree itself, so repeated
5592
+ // timeouts cannot pile up orphaned git.exe processes until RAM is exhausted.
5593
+ test("a shell Git scan that passes its timeout kills the whole process tree", async (t) => {
5594
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5595
+ const killed: number[] = [];
5596
+ const kill = (pid: number) => killed.push(pid);
5597
+ const fake = (answer: (callback: (error: Error | null, stdout: string, stderr: string) => void) => void, pid: number) => ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5598
+ void command; void args; void options;
5599
+ answer(callback);
5600
+ return { pid, exitCode: null, signalCode: null, kill() {} } as unknown as import("node:child_process").ChildProcess;
5601
+ }) as typeof import("node:child_process").execFile;
5602
+
5603
+ // A scan that never answers is tree-killed once the timeout elapses.
5604
+ void shellGitRunner("/big-repo", { PATH: process.env.PATH }, fake(() => {}, 4242), Infinity, kill)(["status", "--porcelain=v1", "--untracked-files=all", "-z"]);
5605
+ assert.deepEqual(killed, [], "nothing is killed before the timeout");
5606
+ t.mock.timers.tick(60_000);
5607
+ assert.deepEqual(killed, [4242], "the timed-out scan kills its whole process tree");
5608
+
5609
+ // A scan that answers never arms the killer at all, even long after.
5610
+ await shellGitRunner("/big-repo", { PATH: process.env.PATH }, fake((callback) => callback(null, "", ""), 7), Infinity, kill)(["status"]);
5611
+ t.mock.timers.tick(60_000);
5612
+ assert.deepEqual(killed, [4242], "a completed scan never kills a tree");
5613
+ });
5614
+
5615
+ // A descendant that inherited the pipes can hold a timed-out scan open after the
5616
+ // direct child exits, so the runner cuts them instead of waiting forever.
5617
+ test("a timed-out scan whose child never exits has its pipes cut", (t) => {
5618
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5619
+ const events: string[] = [];
5620
+ const hung = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5621
+ void command; void args; void options; void callback;
5622
+ return {
5623
+ pid: 5,
5624
+ exitCode: null,
5625
+ signalCode: null,
5626
+ kill() { events.push("kill"); },
5627
+ stdout: { destroy() { events.push("stdout"); } },
5628
+ stderr: { destroy() { events.push("stderr"); } },
5629
+ } as unknown as import("node:child_process").ChildProcess;
5630
+ }) as typeof import("node:child_process").execFile;
5631
+
5632
+ void shellGitRunner("/big-repo", { PATH: process.env.PATH }, hung, Infinity, () => events.push("tree"))(["status"]);
5633
+ t.mock.timers.tick(5_000);
5634
+ assert.deepEqual(events, ["tree"], "the tree kill lands when the scan passes its timeout");
5635
+ t.mock.timers.tick(5_000);
5636
+ assert.deepEqual(events, ["tree", "kill", "stdout", "stderr"], "then the pipes are cut so the scan can settle");
5637
+ });
5638
+
5639
+ // Cutting the pipes makes execFile report the dead child's own exit code, so a
5640
+ // timed-out scan can arrive as a clean exit with a truncated porcelain. The
5641
+ // deadline has to win over that: a partial inventory must never read as success.
5642
+ test("a timed-out scan that ends with exit 0 still reports failure", async (t) => {
5643
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5644
+ let answer: ((error: Error | null, stdout: string, stderr: string) => void) | undefined;
5645
+ const fake = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5646
+ void command; void args; void options;
5647
+ answer = callback;
5648
+ return {
5649
+ pid: 8,
5650
+ exitCode: null,
5651
+ signalCode: null,
5652
+ kill() {},
5653
+ stdout: { destroy() { answer?.(null, "partial porcelain", ""); } },
5654
+ stderr: { destroy() {} },
5655
+ } as unknown as import("node:child_process").ChildProcess;
5656
+ }) as typeof import("node:child_process").execFile;
5657
+
5658
+ const scan = shellGitRunner("/big-repo", { PATH: process.env.PATH }, fake, Infinity, () => {})(["status", "--porcelain=v1", "-z"]);
5659
+ t.mock.timers.tick(5_000);
5660
+ t.mock.timers.tick(5_000);
5661
+ const result = await scan;
5662
+ assert.equal(result.code, 1, "a scan that passed its deadline is a failure, not a partial success");
5663
+ assert.equal(result.stdout, "partial porcelain", "the partial output is still available for diagnostics");
5664
+ });
5665
+
5666
+ test("a timed-out scan whose direct child already exited skips the tree kill", async (t) => {
5667
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5668
+ const events: string[] = [];
5669
+ let answer: ((error: Error | null, stdout: string, stderr: string) => void) | undefined;
5670
+ // execFile answers only once every inherited pipe has closed, so the scan
5671
+ // must stay pending until the last one is cut.
5672
+ const closed = new Set<string>();
5673
+ const cutPipe = (name: "stdout" | "stderr") => {
5674
+ events.push(name);
5675
+ closed.add(name);
5676
+ if (closed.size === 2) answer?.(null, "", "");
5677
+ };
5678
+ let settled = false;
5679
+ // taskkill walks the tree from a live parent, so with the direct child gone
5680
+ // the call can only answer "process not found": the pipes are all that is left.
5681
+ const exited = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5682
+ void command; void args; void options;
5683
+ answer = callback;
5684
+ return {
5685
+ pid: 6,
5686
+ exitCode: 0,
5687
+ signalCode: null,
5688
+ kill() { events.push("kill"); },
5689
+ stdout: { destroy() { cutPipe("stdout"); } },
5690
+ stderr: { destroy() { cutPipe("stderr"); } },
5691
+ } as unknown as import("node:child_process").ChildProcess;
5692
+ }) as typeof import("node:child_process").execFile;
5693
+
5694
+ const scan = shellGitRunner("/big-repo", { PATH: process.env.PATH }, exited, Infinity, () => events.push("tree"))(["status"]);
5695
+ void scan.then(() => { settled = true; });
5696
+ t.mock.timers.tick(5_000);
5697
+ assert.deepEqual(events, [], "an exited direct child is not killed again");
5698
+ await Promise.resolve();
5699
+ assert.equal(settled, false, "the deadline alone does not settle the scan while a pipe is open");
5700
+ t.mock.timers.tick(5_000);
5701
+ assert.deepEqual(events, ["stdout", "stderr"], "the pipes are still cut so the scan can settle");
5702
+ assert.equal((await scan).code, 1, "a timed-out scan stays a failure after the pipes are cut");
5703
+ });
5704
+
5705
+ // The next two edge cases come from #1691 by @dnlrsls: a spawn that fails
5706
+ // before or after the child exists must settle as a failed scan and never
5707
+ // leave a deadline armed to tree-kill a process that was never running.
5708
+ test("a shell Git scan whose spawn throws synchronously resolves as a failure without killing", async (t) => {
5709
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5710
+ const killed: number[] = [];
5711
+ const throwing = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5712
+ void command; void args; void options; void callback;
5713
+ throw new Error("spawn failed");
5714
+ }) as unknown as typeof import("node:child_process").execFile;
5715
+
5716
+ for (const killer of [(pid: number) => killed.push(pid), undefined]) {
5717
+ const result = await shellGitRunner("/repo", { PATH: process.env.PATH }, throwing, Infinity, killer)(["status"]);
5718
+ assert.equal(result.code, 1, "a spawn that throws is a failed scan, not a rejected promise");
5719
+ assert.equal(result.stdout, "");
5720
+ }
5721
+ t.mock.timers.tick(60_000);
5722
+ assert.deepEqual(killed, [], "no deadline is left to kill a tree that never started");
5723
+ });
5724
+
5725
+ test("a shell Git scan whose spawn errors asynchronously before the deadline never kills the tree", async (t) => {
5726
+ t.mock.timers.enable({ apis: ["setTimeout"] });
5727
+ const events: string[] = [];
5728
+ let answer: ((error: Error | null, stdout: string, stderr: string) => void) | undefined;
5729
+ const fake = ((command: string, args: readonly string[], options: Record<string, unknown>, callback: (error: Error | null, stdout: string, stderr: string) => void) => {
5730
+ void command; void args; void options;
5731
+ answer = callback;
5732
+ return {
5733
+ pid: 9,
5734
+ exitCode: null,
5735
+ signalCode: null,
5736
+ kill() { events.push("kill"); },
5737
+ stdout: { destroy() { events.push("stdout"); } },
5738
+ stderr: { destroy() { events.push("stderr"); } },
5739
+ } as unknown as import("node:child_process").ChildProcess;
5740
+ }) as typeof import("node:child_process").execFile;
5741
+
5742
+ const scan = shellGitRunner("/repo", { PATH: process.env.PATH }, fake, Infinity, () => events.push("tree"))(["status"]);
5743
+ t.mock.timers.tick(1_000);
5744
+ answer?.(Object.assign(new Error("spawn git ENOENT"), { code: "ENOENT" }), "", "");
5745
+ const result = await scan;
5746
+ assert.equal(result.code, 1, "an asynchronous spawn error is a failed scan");
5747
+ assert.equal(result.timedOut, undefined, "the scan failed before its deadline");
5748
+ t.mock.timers.tick(60_000);
5749
+ assert.deepEqual(events, [], "the deadline was cleared, so nothing is killed or cut");
5750
+ });
5751
+
5389
5752
  test("openInExternalEditor stops the TUI around the editor and honors $VISUAL over $EDITOR", () => {
5390
5753
  const events: string[] = [];
5391
5754
  const host = { stop: () => events.push("stop"), start: () => events.push("start"), requestRender: (force?: boolean) => events.push(`render:${force}`) };
@@ -7044,6 +7407,179 @@ test("pasted image chips warn instead of sending images a text-only model reject
7044
7407
  assert.ok(ui.notices.some((notice) => /1 pasted image was not sent: the current model does not accept images/.test(notice)));
7045
7408
  });
7046
7409
 
7410
+ async function mobilePlacementFixture(t: TestContext, headerPlacement: "top" | "split" | "below-input", statusPlacement: "auto" | "bottom" | "hidden", columns: number, density: "comfortable" | "compact" | "minimal" = "compact") {
7411
+ const home = scopedDoubleEscCancelConfigHome(t);
7412
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement, statusPlacement, density }, { gentlePiConfigHome: home });
7413
+ const { pi, handlers, commands } = fakePi();
7414
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { activeProfile: () => undefined });
7415
+ const { ctx, ui, overlayReady } = fakeContext();
7416
+ (ctx.model as unknown as { provider: string }).provider = "test";
7417
+ await fire(handlers, "session_start", ctx);
7418
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
7419
+ const root = { render: () => ["conversation"], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
7420
+ const tui = { mode: "fullscreen", terminal: { rows: 32, columns }, layoutRoot: root, requestRender() {} };
7421
+ const statuses = new Map([["gentle:mode", "Permissions: SUPER-YOLO"], ["gentle:yolo", SUPER_YOLO_STATUS_TEXT]]);
7422
+ const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void })(tui, plainTheme, {
7423
+ getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {},
7424
+ });
7425
+ const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
7426
+ t.after(async () => { editor.dispose(); footer.dispose(); await fire(handlers, "session_shutdown", ctx); });
7427
+ root[node]();
7428
+ const state = sidebarState(tui as unknown as TUI);
7429
+ const widget = (ui.widgets.get("gentle-shell-below-input-header") as () => SidebarRail)();
7430
+ const banner = (yoloBannerContent("tui", SUPER_YOLO_STATUS_TEXT) as (tui: TUI) => { render(width: number): string[] })(tui as unknown as TUI);
7431
+ const layoutRows = () => {
7432
+ const layout = root[node]() as unknown as { entries?: Array<{ component: { render(width: number): string[] } }> };
7433
+ return (layout.entries ?? []).map(({ component }) => component.render(columns).map(stripAnsi).join("\n"));
7434
+ };
7435
+ return { tui, ui, ctx, commands, overlayReady, footer, editor, state, widget, banner, layoutRows };
7436
+ }
7437
+
7438
+ async function checkMobilePanel(f: Awaited<ReturnType<typeof mobilePlacementFixture>>, width: number) {
7439
+ const rows = f.editor.render(width).map(stripAnsi);
7440
+ assert.match(rows[0]!, /^─ ✿ waiting for input/, "mobile uses the titled-rule editor");
7441
+ assert.match(rows[1]!, /^› /, "the input keeps its modern prompt");
7442
+ const x = rows[0]!.indexOf("[ Panel ]");
7443
+ assert.ok(x >= 0, "the Panel control is visible without live work");
7444
+ const click = () => f.editor.handleMouse({ type: "click", button: "left", x, y: 0, screenX: x, screenY: 0, width, height: rows.length, shift: false, alt: false, ctrl: false });
7445
+ const before = f.ui.customOptions!.length;
7446
+ assert.equal(click()?.handled, true);
7447
+ assert.match(stripAnsi(f.ui.overlayView!.render(width)[0]!), /^ ✿ Panel/, "the control opens the existing sheet");
7448
+ f.ui.overlayView!.handleInput("\x1b");
7449
+ await new Promise((resolve) => setImmediate(resolve));
7450
+ assert.equal(click()?.handled, true);
7451
+ assert.equal(f.ui.customOptions!.length, before + 2, "after closing, Panel opens a fresh sheet");
7452
+ f.ui.overlayView!.handleInput("\x1b");
7453
+ await new Promise((resolve) => setImmediate(resolve));
7454
+ }
7455
+
7456
+ function checkMobileBar(f: Awaited<ReturnType<typeof mobilePlacementFixture>>, rows: string[], width: number) {
7457
+ const text = rows.map(stripAnsi).join("\n");
7458
+ assert.match(text, /main/);
7459
+ assert.match(text, /💥 SUPER-YOLO/);
7460
+ assert.match(text, /ctx/);
7461
+ assert.match(text, /\$0\.000 sub/);
7462
+ assert.deepEqual(f.banner.render(width), [], "the bar, not a duplicate YOLO banner, owns the permission indicator");
7463
+ assert.ok(rows.every((row) => visibleWidth(row) <= width));
7464
+ return text;
7465
+ }
7466
+
7467
+ function checkMobileUsageClick(f: Awaited<ReturnType<typeof mobilePlacementFixture>>, part: SidebarRail, width: number) {
7468
+ const rows = part.render(width).map(stripAnsi);
7469
+ const y = rows.findIndex((row) => row.includes("usage"));
7470
+ assert.ok(y >= 0, "usage remains visible at this width");
7471
+ const x = visibleWidth(rows[y]!.slice(0, rows[y]!.indexOf("usage")));
7472
+ const click = (cx: number, cy: number): TuiMouseEvent => ({ type: "click", button: "left", x: cx, y: cy, screenX: cx, screenY: cy, width, height: rows.length, shift: false, alt: false, ctrl: false });
7473
+ assert.equal(part.handleMouse?.(click(width - 1, y)), undefined, "the trailing edge is not a usage target");
7474
+ assert.equal(part.handleMouse?.(click(x, y + 1)), undefined, "another row is not a usage target");
7475
+ const before = f.ui.customOptions!.length;
7476
+ assert.equal(part.handleMouse?.(click(x, y))?.handled, true, "the rendered usage segment opens Usage");
7477
+ assert.equal(f.ui.customOptions!.length, before + 1);
7478
+ f.ui.closeOverlay?.();
7479
+ }
7480
+
7481
+ test("mobile top is one upper status bar while split retains title and lower status", async (t) => {
7482
+ for (const width of [80, 120]) for (const status of ["auto", "bottom", "hidden"] as const) {
7483
+ const density = status === "auto" ? "comfortable" : status === "hidden" ? "minimal" : "compact";
7484
+ const top = await mobilePlacementFixture(t, "top", status, width, density);
7485
+ const topRows = top.state.parts.get("header")!.render(width);
7486
+ const topText = checkMobileBar(top, topRows, width);
7487
+ assert.equal(topRows.length, density === "comfortable" ? 3 : 1, "density controls only the bar's margins");
7488
+ assert.match(topText, /gpt-5\.5 · medium/, "the single bar owns the model when it fits");
7489
+ if (width === 120) assert.match(topText, /✿ repo/, "the single bar keeps project identity when it fits");
7490
+ assert.deepEqual(top.state.parts.get("statusbar")!.render(width), [], "top has no lower status bar");
7491
+ assert.match(top.layoutRows()[0]!, /SUPER-YOLO/, "the mounted top bar is above the conversation");
7492
+ assert.equal(top.layoutRows().length, 2, "the mounted layout has no lower bar");
7493
+ assert.deepEqual(top.widget.render(width), []);
7494
+ assert.deepEqual(top.footer.render(width), []);
7495
+ if (width === 120) checkMobileUsageClick(top, top.state.parts.get("header")!, width);
7496
+ await checkMobilePanel(top, width);
7497
+ const split = await mobilePlacementFixture(t, "split", status, width, density);
7498
+ const title = split.state.parts.get("header")!.render(width).map(stripAnsi).join("\n");
7499
+ assert.match(title, /✿ repo/);
7500
+ assert.match(title, /gpt-5\.5 · medium/);
7501
+ const lower = checkMobileBar(split, split.state.parts.get("statusbar")!.render(width), width);
7502
+ assert.doesNotMatch(lower, /gpt-5\.5|✿ repo/, "split never repeats title identity or model");
7503
+ assert.match(split.layoutRows()[0]!, /✿ repo/);
7504
+ assert.match(split.layoutRows().at(-1)!, /SUPER-YOLO/, "split mounts status below the conversation");
7505
+ assert.deepEqual(split.widget.render(width), []);
7506
+ assert.deepEqual(split.footer.render(width), []);
7507
+ await checkMobilePanel(split, width);
7508
+ }
7509
+ });
7510
+
7511
+ test("mobile below-input keeps the modern Panel editor and one lower status bar", async (t) => {
7512
+ for (const width of [80, 120]) for (const status of ["auto", "bottom", "hidden"] as const) {
7513
+ const density = status === "auto" ? "comfortable" : status === "hidden" ? "minimal" : "compact";
7514
+ const f = await mobilePlacementFixture(t, "below-input", status, width, density);
7515
+ await checkMobilePanel(f, width);
7516
+ const lower = [...f.state.parts.get("statusbar")!.render(width), ...f.widget.render(width), ...f.footer.render(width)];
7517
+ const text = checkMobileBar(f, lower, width);
7518
+ assert.equal(lower.length, density === "comfortable" ? 3 : 1, "density controls only the bar's margins");
7519
+ assert.equal((text.match(/SUPER-YOLO/g) ?? []).length, 1, "exactly one lower bar paints the permission mode");
7520
+ assert.match(text, /gpt-5\.5 · medium/);
7521
+ if (width === 120) {
7522
+ assert.match(text, /✿ repo/);
7523
+ checkMobileUsageClick(f, f.state.parts.get("statusbar")!, width);
7524
+ }
7525
+ assert.match(f.layoutRows().at(-1)!, /SUPER-YOLO/, "below-input mounts its bar below the editor dock");
7526
+ assert.equal(f.layoutRows().length, 2, "below-input does not mount a top header");
7527
+ }
7528
+ });
7529
+
7530
+ test("mobile placement changes move one bar live without losing Panel or duplicating permission", async (t) => {
7531
+ const f = await mobilePlacementFixture(t, "top", "auto", 120);
7532
+ const pending = f.commands.get("gentle:customize")!.handler("", f.ctx);
7533
+ await f.overlayReady;
7534
+ try {
7535
+ for (const placement of ["split", "below-input", "top"] as const) {
7536
+ await customizeAction(f.ui, `Header placement: ${placement}`);
7537
+ const mounted = f.layoutRows();
7538
+ assert.equal(mounted.length, placement === "split" ? 3 : 2);
7539
+ assert.match(placement === "top" ? mounted[0]! : mounted.at(-1)!, /SUPER-YOLO/);
7540
+ assert.equal((mounted.join("\n").match(/SUPER-YOLO/g) ?? []).length, 1);
7541
+ assert.deepEqual(f.widget.render(120), []);
7542
+ assert.deepEqual(f.footer.render(120), []);
7543
+ assert.deepEqual(f.banner.render(120), []);
7544
+ assert.match(stripAnsi(f.editor.render(120)[0]!), /\[ Panel \]/);
7545
+ }
7546
+ } finally {
7547
+ f.ui.overlayView!.handleInput("\x1b");
7548
+ await pending;
7549
+ }
7550
+ });
7551
+
7552
+ test("mobile below-input retains Changes when the chrome bar owns the footer", async (t) => {
7553
+ const previous = cardStyle();
7554
+ t.after(() => setCardStyle(previous));
7555
+ const home = scopedDoubleEscCancelConfigHome(t);
7556
+ writeCardStyle(CARD_STYLE.FLOAT, { gentlePiConfigHome: home });
7557
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input", surface: "tinted" }, { gentlePiConfigHome: home });
7558
+ const { pi, handlers } = fakePi([{ numstat: "2\t0\tlib/live.ts\n", porcelain: " M lib/live.ts\0" }]);
7559
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home, GENTLE_PI_SHELL_CHANGES_WATCH_MS: "off" }, { activeProfile: () => undefined });
7560
+ const { ctx, ui } = fakeContext();
7561
+ (ctx.model as unknown as { provider: string }).provider = "test";
7562
+ await fire(handlers, "session_start", ctx);
7563
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
7564
+ const root = { render: () => [], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
7565
+ const tui = { mode: "fullscreen", terminal: { rows: 32, columns: 120 }, layoutRoot: root, requestRender() {} };
7566
+ const theme = { ...plainTheme, bg: (_role: string, text: string) => `\x1b[48;5;22m${text}\x1b[49m`, getBgAnsi: () => "\x1b[48;5;22m" };
7567
+ const footer = (ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => SidebarRail & { dispose(): void })(tui, theme, {
7568
+ getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {},
7569
+ });
7570
+ t.after(async () => { footer.dispose(); await fire(handlers, "session_shutdown", ctx); });
7571
+ root[node]();
7572
+ await fire(handlers, "agent_end", ctx);
7573
+ await changesSettled();
7574
+ const changes = (ui.widgets.get("gentle-shell-changes") as (tui: unknown, theme: ShellBarTheme) => SidebarRail)(tui, theme);
7575
+ const widget = (ui.widgets.get("gentle-shell-below-input-header") as () => SidebarRail)();
7576
+ const status = sidebarState(tui as unknown as TUI).parts.get("statusbar")!;
7577
+ const visible = [...changes.render(120), ...footer.render(120), ...widget.render(120), ...status.render(120)].map(stripAnsi).join("\n");
7578
+ assert.match(visible, /1 file · \+2 −0/, "the uncommitted Changes remain visible");
7579
+ assert.equal((visible.match(/1 file/g) ?? []).length, 1, "Changes have only one owner");
7580
+ assert.match(visible, /ctx.*\$0\.000 sub/, "the lower chrome still carries the counters");
7581
+ });
7582
+
7047
7583
  test("the installed editor draws the panel frame in the wide and mobile IDE chrome and the frame in regular mode", () => {
7048
7584
  const previous = cardStyle();
7049
7585
  const { pi, handlers } = fakePi();
@@ -7116,8 +7652,8 @@ test("mobile folds live work into one row above the editor that opens /gentle:pa
7116
7652
  (ui.overlayView as unknown as { handleInput(data: string): void }).handleInput("\x1b");
7117
7653
  editor.dispose();
7118
7654
  const header = state.parts.get("header")!;
7119
- assert.match(stripAnsi(header.render(56).join("\n")), /^ ✿ repo .*· /, "the mobile title row carries the model");
7120
- assert.match(stripAnsi(state.parts.get("statusbar")!.render(56).join("\n")), /^ main/, "the mobile status bar leads with the branch");
7655
+ assert.match(stripAnsi(header.render(56).join("\n")), /main.*ctx/, "the mobile top bar carries the branch and counters");
7656
+ assert.deepEqual(state.parts.get("statusbar")!.render(56), [], "top has no separate lower bar");
7121
7657
  void commands.get("gentle:panel")!.handler("", ctx);
7122
7658
  await new Promise((resolve) => setImmediate(resolve));
7123
7659
  const sheet = openPanelLines(ui);
@@ -7165,7 +7701,7 @@ test("a tap on a mobile work row led by an agent opens /gentle:agents instead of
7165
7701
  }
7166
7702
  });
7167
7703
 
7168
- test("customize presets set density and visibility together, mark the current one, and keep the placements", async (t) => {
7704
+ test("customize presets set the visibility, mark the current one, and keep the placements and the density", async (t) => {
7169
7705
  const home = scopedDoubleEscCancelConfigHome(t);
7170
7706
  const { pi, commands } = fakePi();
7171
7707
  gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
@@ -7176,21 +7712,25 @@ test("customize presets set density and visibility together, mark the current on
7176
7712
  assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral\s+○ Power user/, "the default density and visibility are the Neutral preset");
7177
7713
  await customizeAction(ui, "Preset: Light");
7178
7714
  const light = resolveVisualSettings({ gentlePiConfigHome: home }).settings;
7179
- assert.equal(light.density, "minimal");
7715
+ assert.equal(light.density, "comfortable", "a preset never changes the density");
7180
7716
  assert.equal(light.visibility.todo, false);
7181
7717
  assert.equal(light.visibility.changes, false);
7182
7718
  assert.equal(light.headerPlacement, "below-input", "the preset keeps the chosen header placement");
7183
7719
  assert.equal(light.statusPlacement, "bottom", "Light is the minimal edition without the rail");
7184
7720
  assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+● Light/);
7185
7721
  await customizeAction(ui, "Preset: Power user");
7186
- assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.density, "comfortable", "Power user keeps Neutral's spacing");
7722
+ assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.density, "comfortable", "Power user keeps the density");
7187
7723
  assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.visibility.stats, true, "and adds Stats");
7188
7724
  assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+○ Neutral\s+● Power user/);
7189
7725
  await customizeAction(ui, "Section stats: hidden");
7190
7726
  assert.ok(findCustomizeRow(ui, "Preset: Neutral"));
7191
7727
  assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral/, "Power user without Stats is Neutral again");
7192
7728
  await customizeAction(ui, "Density: minimal");
7193
- assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+○ Neutral\s+○ Power user/, "a hand-tuned mix matches no preset");
7729
+ assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral/, "changing the density keeps the preset selected");
7730
+ await customizeAction(ui, "Preset: Power user");
7731
+ assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.density, "minimal", "switching presets keeps the chosen density");
7732
+ await customizeAction(ui, "Section todo: hidden");
7733
+ assert.equal(visualPresetOf(resolveVisualSettings({ gentlePiConfigHome: home }).settings), undefined, "a hand-tuned visibility mix matches no preset");
7194
7734
  ui.overlayView!.handleInput("\x1b");
7195
7735
  await pending;
7196
7736
  });
@@ -7198,7 +7738,7 @@ test("customize presets set density and visibility together, mark the current on
7198
7738
  test("customize presets survive session switches and a fresh extension with the same config home", async (t) => {
7199
7739
  const shared = { ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "below-input" as const };
7200
7740
  const cases = [
7201
- { name: "Light", actions: ["Preset: Light"], settings: { ...shared, statusPlacement: "bottom" as const, density: DENSITY.MINIMAL, visibility: { ...shared.visibility, changes: false, todo: false } }, marker: /Preset\s+● Light\s+○ Neutral\s+○ Power user/ },
7741
+ { name: "Light", actions: ["Preset: Light"], settings: { ...shared, statusPlacement: "bottom" as const, visibility: { ...shared.visibility, changes: false, todo: false } }, marker: /Preset\s+● Light\s+○ Neutral\s+○ Power user/ },
7202
7742
  { name: "Neutral after Light", actions: ["Preset: Light", "Preset: Neutral"], settings: { ...shared, visibility: { ...shared.visibility } }, marker: /Preset\s+○ Light\s+● Neutral\s+○ Power user/ },
7203
7743
  { name: "Power user", actions: ["Preset: Power user"], settings: { ...shared, visibility: { ...shared.visibility, stats: true } }, marker: /Preset\s+○ Light\s+○ Neutral\s+● Power user/ },
7204
7744
  { name: "Power user by arrow with launcher config home", actions: ["Preset: Power user"], settings: { ...shared, visibility: { ...shared.visibility, stats: true } }, marker: /Preset\s+○ Light\s+○ Neutral\s+● Power user/, launcher: true, move: true },
@@ -7221,7 +7761,9 @@ test("customize presets survive session switches and a fresh extension with the
7221
7761
  assert.equal(resolved.malformed, false);
7222
7762
  assert.equal(resolved.readError, false);
7223
7763
  assert.deepEqual(resolved.settings, scenario.settings);
7224
- assert.deepEqual(JSON.parse(readFileSync(join(home, "visual-customization.json"), "utf8")), { schema: VISUAL_SCHEMA, ...scenario.settings });
7764
+ // The default surface is not stored.
7765
+ const { surface: _surface, ...stored } = scenario.settings;
7766
+ assert.deepEqual(JSON.parse(readFileSync(join(home, "visual-customization.json"), "utf8")), { schema: VISUAL_SCHEMA, ...stored });
7225
7767
  };
7226
7768
  const checkRestored = async (shell: ReturnType<typeof fakePi>, current: ReturnType<typeof fakeContext>) => {
7227
7769
  const { ctx, ui, overlayReady } = current;
@@ -7346,7 +7888,7 @@ test("a hidden Todos section stays hidden in the mobile work row and the panel s
7346
7888
  }
7347
7889
  });
7348
7890
 
7349
- test("Status at the bottom with the header on top draws the minimal IDE chrome on a wide terminal, without the rail", async () => {
7891
+ test("Status at the bottom keeps Agents and Todos as cards and the chrome bars on a wide terminal, and the minimal edition below the rail breakpoint", async () => {
7350
7892
  const { pi, handlers } = fakePi();
7351
7893
  const home = mkdtempSync(join(tmpdir(), "shell-light-"));
7352
7894
  try {
@@ -7366,12 +7908,18 @@ test("Status at the bottom with the header on top draws the minimal IDE chrome o
7366
7908
  });
7367
7909
  const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
7368
7910
  try {
7369
- assert.equal(state.compactWork?.(), true, "the minimal edition folds live work like a phone");
7370
- assert.deepEqual(footer.render(180), [], "the old compact bottom bar steps aside for the status bar");
7371
- assert.deepEqual(todo.render(180), [], "the Todos card folds into the work row");
7372
- assert.match(stripAnsi(state.parts.get("header")!.render(180).join("\n")), /^ ✿ repo /, "the title row draws");
7373
- assert.match(stripAnsi(state.parts.get("statusbar")!.render(180).join("\n")), /^ main /, "the status bar draws");
7374
- assert.match(stripAnsi(editor.render(180)[0]!), /▸ ◐ Run the suite/, "the work row sits right above the editor");
7911
+ assert.notEqual(state.compactWork?.(), true, "a wide bottom Status does not fold live work behind [ Panel ]");
7912
+ assert.deepEqual(todo.render(180), ["TODO CARD"], "the Todos card stays");
7913
+ assert.match(stripAnsi(state.parts.get("header")!.render(180)[1]!), /^ ✿ repo \S+ │ main .*ctx/, "the centered top bar includes project identity and live values");
7914
+ assert.deepEqual(state.parts.get("statusbar")!.render(180), [], "no split status bar");
7915
+ assert.deepEqual(footer.render(180), [], "no integration reports anything, so there is no bottom Status row");
7916
+ assert.doesNotMatch(stripAnsi(editor.render(180)[0]!), /▸ ◐ Run the suite/, "no work row above the editor");
7917
+ tui.terminal.columns = 120;
7918
+ assert.equal(state.compactWork?.(), true, "below the rail breakpoint the minimal edition folds live work like a phone");
7919
+ assert.deepEqual(todo.render(120), [], "the Todos card folds into the work row");
7920
+ assert.match(stripAnsi(state.parts.get("header")!.render(120).join("\n")), /✿ repo .*main .*ctx/, "the single top bar carries identity and status");
7921
+ assert.deepEqual(state.parts.get("statusbar")!.render(120), [], "top has no separate lower bar");
7922
+ assert.match(stripAnsi(editor.render(120)[0]!), /▸ ◐ Run the suite/, "the work row sits right above the editor");
7375
7923
  } finally {
7376
7924
  editor.dispose();
7377
7925
  todo.dispose();
@@ -7397,9 +7945,12 @@ test("an agent question keeps its row above the framed editor while the rail hid
7397
7945
  host.mode = "fullscreen";
7398
7946
  state.active = true;
7399
7947
  state.ownsHost = () => true;
7948
+ const attached = state.layoutAttached;
7949
+ state.layoutAttached = () => true;
7400
7950
  const rows = editor.render(80).map(stripAnsi);
7401
7951
  assert.match(rows[0]!, /explore asked: Which file\?/, "the question sits right above the editor");
7402
- assert.match(rows[1]!, /^╭/, "the below-input header keeps the framed editor");
7952
+ assert.match(rows[1]!, /^─ ✿ waiting for input/, "beside the rail the below-input bar comes with the titled-rule editor");
7953
+ state.layoutAttached = attached;
7403
7954
  state.active = false;
7404
7955
  assert.doesNotMatch(editor.render(80).map(stripAnsi).join("\n"), /explore asked/, "without the rail the Agents card lists the question itself");
7405
7956
  } finally {
@@ -7524,8 +8075,8 @@ test("alt+l cycles the visual presets Light → Neutral → Power user → Light
7524
8075
  }
7525
8076
  assert.deepEqual(seen, [VISUAL_PRESET.POWER_USER, VISUAL_PRESET.LIGHT, VISUAL_PRESET.NEUTRAL]);
7526
8077
  assert.match(ui.notices.at(-1) ?? "", /Preset: Neutral/);
7527
- // A hand-tuned mix starts the cycle from Neutral.
7528
- writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, density: DENSITY.MINIMAL }, { gentlePiConfigHome: home });
8078
+ // A hand-tuned visibility mix starts the cycle from Neutral; the density never decides the preset.
8079
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, rdd: false } }, { gentlePiConfigHome: home });
7529
8080
  await shortcut.handler(ctx);
7530
8081
  assert.equal(preset(), VISUAL_PRESET.NEUTRAL);
7531
8082
 
@@ -7607,3 +8158,292 @@ test("Customize groups every setting like Layout while navigation keeps stores u
7607
8158
  assert.equal(snapshot(), before, "browsing an off/on option cannot write a preference");
7608
8159
  ui.overlayView!.handleInput("\x1b"); await pending;
7609
8160
  });
8161
+
8162
+ test("#2890: a wide top header shows the whole header row above the conversation and keeps the YOLO banner", async (t) => {
8163
+ const home = scopedDoubleEscCancelConfigHome(t);
8164
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "top" }, { gentlePiConfigHome: home });
8165
+ const { pi, handlers } = fakePi();
8166
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home }, { activeProfile: () => "team" });
8167
+ const { ctx, ui } = fakeContext();
8168
+ await fire(handlers, "session_start", ctx);
8169
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8170
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
8171
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8172
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8173
+ const footer = factory(tui, plainTheme as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8174
+ t.after(() => footer.dispose());
8175
+ type Node = { type: string; entries: { component: { render(width: number): string[]; [key: symbol]: () => Node } }[] };
8176
+ const layout = root[node]() as unknown as Node;
8177
+ assert.equal(layout.type, "vstack", "the top bar spans both conversation and rail");
8178
+ const columns = layout.entries[1]!.component[node]();
8179
+ assert.equal(columns.type, "hstack", "both columns start below the complete header");
8180
+ const header = stripAnsi(layout.entries[0]!.component.render(160).join("\n"));
8181
+ assert.match(header, /✿ repo \S+ │ main/, "the full-width top bar includes project identity");
8182
+ assert.match(header, /ctx/, "context sits in the top header");
8183
+ assert.match(header, /\$/, "cost sits in the top header");
8184
+ assert.equal(sidebarState(tui as unknown as TUI).statusBarShowsMode?.(), true, "the bar shows the permission mode with its icon, so the banner steps aside");
8185
+ const status = stripAnsi(sidebarState(tui as unknown as TUI).parts.get("footer")!.render(48).join("\n"));
8186
+ assert.doesNotMatch(status, /▾ SESSION/, "the bar replaces the session block; the rail keeps its sections");
8187
+ });
8188
+
8189
+ test("customize Layout → Surface switches the chrome between tinted and transparent live and persists it", async (t) => {
8190
+ const home = scopedDoubleEscCancelConfigHome(t);
8191
+ const previous = chromeSurface();
8192
+ t.after(() => setChromeSurface(previous));
8193
+ const { pi, commands } = fakePi();
8194
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
8195
+ const { ctx, ui, overlayReady } = fakeContext();
8196
+ const pending = commands.get("gentle:customize")!.handler("", ctx);
8197
+ await overlayReady;
8198
+ await customizeAction(ui, "Surface: transparent");
8199
+ assert.equal(resolveVisualSettings({ gentlePiConfigHome: home }).settings.surface, "transparent");
8200
+ assert.equal(chromeSurface(), "transparent", "the live chrome follows the choice");
8201
+ assert.match(ui.overlayView!.render(90).join("\n"), /Surface\s+○ tinted\s+● transparent/);
8202
+ assert.match(ui.overlayView!.render(90).join("\n"), /Preset\s+○ Light\s+● Neutral/, "the surface is not part of a preset");
8203
+ await customizeAction(ui, "Surface: tinted");
8204
+ assert.equal(chromeSurface(), "tinted");
8205
+ ui.overlayView!.handleInput("\x1b");
8206
+ await pending;
8207
+ });
8208
+
8209
+ test("a wide top header is the split title row's panel row with the whole header row, and the float footer adds its exterior row only when the float prompt ends the dock", async (t) => {
8210
+ const previous = cardStyle();
8211
+ t.after(() => setCardStyle(previous));
8212
+ const cases = [
8213
+ { header: "top", status: "auto", exterior: false },
8214
+ { header: "split", status: "auto", exterior: false },
8215
+ { header: "below-input", status: "auto", exterior: false },
8216
+ // Every bar placement draws the titled-rule editor, whose own bottom row is the margin.
8217
+ { header: "top", status: "hidden", exterior: false },
8218
+ { header: "below-input", status: "hidden", exterior: false },
8219
+ { header: "split", status: "hidden", exterior: false },
8220
+ ] as const;
8221
+ for (const { header, status, exterior } of cases) {
8222
+ const home = scopedDoubleEscCancelConfigHome(t);
8223
+ writeCardStyle(CARD_STYLE.FLOAT, { gentlePiConfigHome: home });
8224
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: header, statusPlacement: status, surface: "tinted" }, { gentlePiConfigHome: home });
8225
+ const { pi, handlers } = fakePi();
8226
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home }, { activeProfile: () => "team" });
8227
+ const { ctx, ui } = fakeContext();
8228
+ await fire(handlers, "session_start", ctx);
8229
+ const painted = { ...plainTheme, bg: (role: string, text: string) => `\x1b[48;5;${role === "customMessageBg" ? 171 : 120}m${text}\x1b[49m` };
8230
+ (ctx.ui as unknown as MutablePromptThemeHost).theme = painted as unknown as typeof ctx.ui.theme;
8231
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8232
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
8233
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8234
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8235
+ const footer = factory(tui, painted as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => new Map(), getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8236
+ t.after(() => footer.dispose());
8237
+ root[node]();
8238
+ const state = sidebarState(tui as unknown as TUI);
8239
+ if (status === "auto") {
8240
+ assert.equal(state.statusBarShowsMode?.(), true, `${header}: a chrome bar shows the permission mode, so the YOLO banner steps aside`);
8241
+ }
8242
+ if (header === "top" && status === "auto") {
8243
+ const rows = state.parts.get("header")!.render(160);
8244
+ assert.equal(rows.length, 3, "the status bar row centered between two margin rows");
8245
+ for (const row of rows) assert.match(row, /\x1b\[48;5;171m/, "the rail's panel surface, not the float card");
8246
+ assert.match(stripAnsi(rows[1]!), /^ ✿ repo \S+ │ main .*ctx .*usage/, "the full-width top bar includes identity and live values");
8247
+ }
8248
+ if (header === "split") {
8249
+ const title = state.parts.get("header")!.render(160);
8250
+ assert.equal(title.length, 3, "the title row centered between two margin rows");
8251
+ const bar = state.parts.get("statusbar")!.render(160);
8252
+ assert.equal(bar.length, 3, "the status bar centered between two margin rows");
8253
+ assert.match(stripAnsi(bar[1]!), /^ main .*ctx/);
8254
+ }
8255
+ if (status === "hidden") {
8256
+ assert.equal(state.statusBarShowsMode?.(), true, `${header}/hidden: the bar shows the permission mode`);
8257
+ if (header === "below-input") {
8258
+ const rows = (ui.widgets.get("gentle-shell-below-input-header") as () => { render(width: number): string[] })().render(160);
8259
+ assert.equal(rows.length, 3, "hidden below-input: the status bar row centered between two margin rows");
8260
+ assert.match(stripAnsi(rows[1]!), /^ ✿ repo \S+ │ main .*ctx .*usage/);
8261
+ } else if (header === "top") {
8262
+ const rows = state.parts.get("header")!.render(160);
8263
+ assert.equal(rows.length, 3, "hidden top: the status bar row centered between two margin rows");
8264
+ assert.match(stripAnsi(rows[1]!), /^ ✿ repo \S+ │ main .*ctx .*usage/, "hidden top: identity and live values share the bar");
8265
+ } else {
8266
+ assert.equal(state.parts.get("header")!.render(160).length, 3, "hidden split: the title row centered between two margin rows");
8267
+ const bar = state.parts.get("statusbar")!.render(160);
8268
+ assert.equal(bar.length, 3, "hidden split: the status bar centered between two margin rows");
8269
+ assert.match(stripAnsi(bar[1]!), /^ main .*ctx .*usage/);
8270
+ }
8271
+ }
8272
+ if (header === "below-input" && status === "auto") {
8273
+ const widget = (ui.widgets.get("gentle-shell-below-input-header") as () => { render(width: number): string[] })();
8274
+ assert.deepEqual(widget.render(110), [], "beside the rail the widget under the input steps aside");
8275
+ const rows = state.parts.get("statusbar")!.render(160);
8276
+ assert.equal(rows.length, 3, "the full-width bottom row: the status bar row centered between two margin rows");
8277
+ assert.match(stripAnsi(rows[1]!), /^ ✿ repo \S+ │ main .*ctx .*usage/);
8278
+ }
8279
+ assert.deepEqual(footer.render(160), exterior ? [""] : [], `${header}/${status}: ${exterior ? "the float prompt ends the dock" : "no extra row under the input"}`);
8280
+ }
8281
+ });
8282
+
8283
+ test("Status bottom at a wide width keeps the bar design, shows Agents and Todos as cards and [ Panel ], and shows no integrations", async (t) => {
8284
+ for (const header of ["top", "below-input", "split"] as const) {
8285
+ const home = scopedDoubleEscCancelConfigHome(t);
8286
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: header, statusPlacement: "bottom" }, { gentlePiConfigHome: home });
8287
+ const { pi, handlers } = fakePi();
8288
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home }, { activeProfile: () => "team" });
8289
+ const { ctx, ui } = fakeContext();
8290
+ await fire(handlers, "session_start", ctx);
8291
+ const painted = { ...plainTheme, bg: (role: string, text: string) => `\x1b[48;5;${role === "customMessageBg" ? 171 : 120}m${text}\x1b[49m` };
8292
+ (ctx.ui as unknown as MutablePromptThemeHost).theme = painted as unknown as typeof ctx.ui.theme;
8293
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8294
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
8295
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8296
+ const statuses = new Map([["gentle-pi", "🧠 gentle-pi · ready"]]);
8297
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8298
+ const footer = factory(tui, painted as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8299
+ t.after(() => footer.dispose());
8300
+ root[node]();
8301
+ const state = sidebarState(tui as unknown as TUI);
8302
+ const editor = (ui.editorFactory as (tui: unknown, theme: unknown, keybindings: unknown) => GentlePromptEditor)(tui, editorTheme, fakeKeybindings);
8303
+ t.after(() => editor.dispose());
8304
+ assert.match(stripAnsi(editor.render(160)[0]!), /^─ ✿ waiting for input/, `${header}: the titled-rule editor, not the float prompt`);
8305
+ assert.match(stripAnsi(editor.render(160)[0]!), /\[ Panel \]/, `${header}: without the rail, [ Panel ] opens the Status sections`);
8306
+ assert.match(stripAnsi(editor.render(160)[1]!), /^› /);
8307
+ assert.notEqual(state.compactWork?.(), true, `${header}: no minimal-edition fold; Agents and Todos keep their cards`);
8308
+ assert.equal(state.statusBarShowsMode?.(), true, `${header}: a chrome bar shows the permission mode`);
8309
+ const statusRow = (rows: string[]) => rows.map(stripAnsi).find((row) => row.includes("gentle-pi · ready"));
8310
+ if (header === "split") assert.match(state.parts.get("statusbar")!.render(160).map(stripAnsi).join("\n"), /ctx .*usage/, "split: the status bar");
8311
+ if (header === "top") assert.match(stripAnsi(state.parts.get("header")!.render(160)[1]!), /^ ✿ repo \S+ │ main .*ctx .*usage/, "top: the chrome bar includes project identity");
8312
+ assert.equal(statusRow([...footer.render(160), ...state.parts.get("statusbar")!.render(160)]), undefined, `${header}: no integrations row`);
8313
+ assert.deepEqual(footer.render(160), [], `${header}: the previous compact bottom bar steps aside and nothing replaces it`);
8314
+ }
8315
+ });
8316
+
8317
+ test("beside the rail no header placement repeats the raw permission-mode statuses in Integrations", async (t) => {
8318
+ for (const header of ["top", "below-input", "split"] as const) {
8319
+ const home = scopedDoubleEscCancelConfigHome(t);
8320
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: header }, { gentlePiConfigHome: home });
8321
+ const { pi, handlers } = fakePi();
8322
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home }, { activeProfile: () => "team" });
8323
+ const { ctx, ui } = fakeContext();
8324
+ await fire(handlers, "session_start", ctx);
8325
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8326
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", entries: [] }) };
8327
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8328
+ const statuses = new Map([["gentle:mode", "Permissions: SUPER-YOLO"], ["gentle:yolo", "💥 SUPER YOLO ON — no permission prompts; private paths stay blocked"], ["gentle-pi", "🧠 gentle-pi · ready"]]);
8329
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8330
+ const footer = factory(tui, plainTheme as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8331
+ t.after(() => footer.dispose());
8332
+ root[node]();
8333
+ const rail = stripAnsi(sidebarState(tui as unknown as TUI).parts.get("footer")!.render(48).join("\n"));
8334
+ assert.doesNotMatch(rail, /Permissions: SUPER-YOLO|SUPER YOLO ON/, `${header}: the bar shows the mode; the rail does not repeat it`);
8335
+ assert.match(rail, /gentle-pi · ready/, `${header}: other integrations stay`);
8336
+ assert.match(rail, /no permission prompts/, `${header}: the rail still says what the mode means`);
8337
+ }
8338
+ });
8339
+
8340
+ test("repeated [ Panel ] or /gentle:panel opens never stack sheets: one stays open until it closes", async () => {
8341
+ const { pi, commands } = fakePi();
8342
+ gentleShell(pi, {});
8343
+ const { ctx, ui } = fakeContext();
8344
+ const open = () => commands.get("gentle:panel")!.handler("", ctx);
8345
+ const before = ui.customOptions!.length;
8346
+ const first = open();
8347
+ const again = [open(), open(), open()];
8348
+ await new Promise((resolve) => setImmediate(resolve));
8349
+ assert.equal(ui.customOptions!.length, before + 1, "four clicks open one sheet");
8350
+ ui.overlayView!.handleInput("\x1b");
8351
+ await Promise.all([first, ...again]);
8352
+ const reopened = open();
8353
+ await new Promise((resolve) => setImmediate(resolve));
8354
+ assert.equal(ui.customOptions!.length, before + 2, "after one escape the sheet opens again");
8355
+ ui.overlayView!.handleInput("\x1b");
8356
+ await reopened;
8357
+ });
8358
+
8359
+ test("on a transparent rail a click on a section card's title folds that section, and the rail has no key hints row", async (t) => {
8360
+ const home = scopedDoubleEscCancelConfigHome(t);
8361
+ const previous = cardStyle();
8362
+ t.after(() => setCardStyle(previous));
8363
+ for (const style of [CARD_STYLE.NEON, CARD_STYLE.FLOAT]) {
8364
+ writeCardStyle(style, { gentlePiConfigHome: home });
8365
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "split" }, { gentlePiConfigHome: home });
8366
+ const { pi, handlers } = fakePi();
8367
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
8368
+ const { ctx, ui } = fakeContext();
8369
+ await fire(handlers, "session_start", ctx);
8370
+ const painted = { ...plainTheme, bg: (_role: string, text: string) => `\x1b[48;5;22m${text}\x1b[49m` };
8371
+ (ctx.ui as unknown as MutablePromptThemeHost).theme = painted as unknown as typeof ctx.ui.theme;
8372
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8373
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", gap: 0, entries: [] }) };
8374
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8375
+ const statuses = new Map([["gentle-pi", "🧠 gentle-pi · ready"]]);
8376
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8377
+ const footer = factory(tui, painted as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8378
+ t.after(() => footer.dispose());
8379
+ type Node = { type?: string; entries?: { component: unknown }[] };
8380
+ const findRail = (value: unknown): { render(width: number): string[]; handleMouse(event: unknown): { handled?: boolean } | undefined } | undefined => {
8381
+ const component = value as { [key: symbol]: () => Node; handleMouse?: unknown; getContentWidth?: unknown };
8382
+ if (typeof component?.getContentWidth === "function") return component as never;
8383
+ const layout = typeof component?.[node] === "function" ? component[node]() : undefined;
8384
+ for (const entry of layout?.entries ?? []) { const found = findRail(entry.component); if (found) return found; }
8385
+ return undefined;
8386
+ };
8387
+ const rail = findRail(root)!;
8388
+ assert.ok(rail, `${style}: the rail is mounted`);
8389
+ const text = () => rail.render(50).map(stripAnsi);
8390
+ assert.doesNotMatch(text().join("\n"), /alt\+u usage|\/ commands/, `${style}: the rail has no key hints row`);
8391
+ const title = text().findIndex((row) => row.includes("INTEGRATIONS"));
8392
+ assert.ok(title >= 0 && text().some((row) => row.includes("gentle-pi · ready")), `${style}: Integrations shows its rows`);
8393
+ const click = (x: number, y: number) => ({ type: "click", button: "left", x, y, screenX: 110 + x, screenY: y, width: 50, height: 38, shift: false, alt: false, ctrl: false });
8394
+ assert.equal(rail.handleMouse(click(6, title))?.handled, true, `${style}: the card title row takes the click`);
8395
+ root[node]();
8396
+ assert.ok(!text().some((row) => row.includes("gentle-pi · ready")), `${style}: the click folded Integrations`);
8397
+ const folded = text().findIndex((row) => row.includes("INTEGRATIONS"));
8398
+ assert.equal(rail.handleMouse(click(1, folded))?.handled, true, `${style}: the card's left edge on the title row also folds`);
8399
+ root[node]();
8400
+ assert.ok(text().some((row) => row.includes("gentle-pi · ready")), `${style}: a second click unfolds it`);
8401
+ await fire(handlers, "session_shutdown", ctx);
8402
+ }
8403
+ });
8404
+
8405
+ test("on a transparent rail hovering a section card's title paints it in the hover role, like the other rail controls", async (t) => {
8406
+ const home = scopedDoubleEscCancelConfigHome(t);
8407
+ const previous = cardStyle();
8408
+ t.after(() => setCardStyle(previous));
8409
+ for (const style of [CARD_STYLE.NEON, CARD_STYLE.FLOAT]) {
8410
+ writeCardStyle(style, { gentlePiConfigHome: home });
8411
+ writeVisualSettings({ ...DEFAULT_VISUAL_SETTINGS, headerPlacement: "split" }, { gentlePiConfigHome: home });
8412
+ const { pi, handlers } = fakePi();
8413
+ gentleShell(pi, { GENTLE_PI_CONFIG_HOME: home });
8414
+ const { ctx, ui } = fakeContext();
8415
+ await fire(handlers, "session_start", ctx);
8416
+ // The hover role as real SGR, the way a terminal theme paints it.
8417
+ // Every role paints, so a leaked or overridden hover shows up as in a terminal.
8418
+ const painted = { ...plainTheme, fg: (role: string, text: string) => `\x1b[${role === "warning" ? 33 : 37}m${text}\x1b[39m`, bg: (_role: string, text: string) => `\x1b[48;5;22m${text}\x1b[49m` };
8419
+ (ctx.ui as unknown as MutablePromptThemeHost).theme = painted as unknown as typeof ctx.ui.theme;
8420
+ const node = Symbol.for("@earendil-works/pi-tui/layout-node");
8421
+ const root = { render: () => ["transcript"], invalidate() {}, [node]: () => ({ type: "vstack", gap: 0, entries: [] }) };
8422
+ const tui = { mode: "fullscreen", terminal: { rows: 40, columns: 160 }, layoutRoot: root, requestRender() {} };
8423
+ const statuses = new Map([["gentle-pi", "🧠 gentle-pi · ready"]]);
8424
+ const factory = ui.footerFactory as (tui: unknown, theme: ShellBarTheme, data: unknown) => { render(width: number): string[]; dispose(): void };
8425
+ const footer = factory(tui, painted as unknown as ShellBarTheme, { getGitBranch: () => "main", getExtensionStatuses: () => statuses, getAvailableProviderCount: () => 1, onBranchChange: () => () => {} });
8426
+ t.after(() => footer.dispose());
8427
+ type Node = { entries?: { component: unknown }[] };
8428
+ const findRail = (value: unknown): { render(width: number): string[]; handleMouse(event: unknown): { handled?: boolean } | undefined } | undefined => {
8429
+ const component = value as { [key: symbol]: () => Node; getContentWidth?: unknown };
8430
+ if (typeof component?.getContentWidth === "function") return component as never;
8431
+ const layout = typeof component?.[node] === "function" ? component[node]() : undefined;
8432
+ for (const entry of layout?.entries ?? []) { const found = findRail(entry.component); if (found) return found; }
8433
+ return undefined;
8434
+ };
8435
+ const rail = findRail(root)!;
8436
+ const plain = (row: string) => stripAnsi(row);
8437
+ // The hover role opens right before the title text, with no other color in between.
8438
+ const hovered = /\x1b\[33mINTEGRATIONS/;
8439
+ const title = rail.render(50).findIndex((row) => plain(row).includes("INTEGRATIONS"));
8440
+ assert.doesNotMatch(rail.render(50)[title]!, hovered, `${style}: not hovered yet`);
8441
+ const move = (x: number, y: number) => ({ type: "move", button: "none", x, y, screenX: 110 + x, screenY: y, width: 50, height: 38, shift: false, alt: false, ctrl: false });
8442
+ assert.ok(rail.handleMouse(move(8, title))?.handled, `${style}: the title row takes the hover`);
8443
+ root[node]();
8444
+ const row = rail.render(50).find((line) => plain(line).includes("INTEGRATIONS"))!;
8445
+ assert.match(row, hovered, `${style}: the hovered card title is painted in the hover role`);
8446
+ assert.equal((plain(row).match(/[▾▸✿]/g) ?? []).length, 1, `${style}: one glyph, the section's own`);
8447
+ await fire(handlers, "session_shutdown", ctx);
8448
+ }
8449
+ });