gentle-pi 4.5.0 → 4.6.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 (243) hide show
  1. package/README.md +9 -6
  2. package/assets/agents/gentle-ai-verify.md +4 -0
  3. package/assets/agents/gentle-ai-worker.md +1 -0
  4. package/assets/migrations/agent-body-history.json +147 -0
  5. package/assets/orchestrator-delegation-reference.md +3 -3
  6. package/assets/orchestrator-delegation.md +2 -2
  7. package/assets/orchestrator-verification.md +10 -6
  8. package/assets/orchestrator.md +8 -8
  9. package/bin/gentle-shell.mjs +61 -26
  10. package/docs/ci-performance.md +11 -0
  11. package/docs/delegated-verification.md +6 -0
  12. package/docs/fast-mode.md +15 -0
  13. package/docs/gentle-agents-activity.md +8 -0
  14. package/docs/gentle-music.md +6 -3
  15. package/docs/gentle-shell.md +70 -20
  16. package/docs/install-wizard.md +1 -1
  17. package/docs/mcp-status.md +52 -0
  18. package/docs/prompt-budget.md +28 -0
  19. package/docs/readme-reference.md +82 -21
  20. package/docs/session-profile-format.md +20 -5
  21. package/docs/sound-notifications.md +1 -1
  22. package/docs/star-prompt.md +32 -0
  23. package/docs/work-continuity.md +46 -0
  24. package/extensions/ask-user-question.ts +1 -0
  25. package/extensions/codegraph-tools.ts +38 -4
  26. package/extensions/gentle-agents.ts +477 -50
  27. package/extensions/gentle-ai.ts +1046 -191
  28. package/extensions/gentle-fast.ts +61 -0
  29. package/extensions/gentle-guide.ts +174 -0
  30. package/extensions/gentle-herdr-activity.ts +21 -1
  31. package/extensions/gentle-herdr-agent.ts +144 -0
  32. package/extensions/gentle-music.ts +10 -0
  33. package/extensions/gentle-program-identity.ts +61 -0
  34. package/extensions/gentle-shell.ts +642 -97
  35. package/extensions/gentle-star-prompt.ts +334 -0
  36. package/extensions/gentle-stats.ts +5 -5
  37. package/extensions/gentle-todo.ts +42 -22
  38. package/extensions/history/store.ts +18 -12
  39. package/extensions/skill-registry.ts +35 -3
  40. package/extensions/startup-banner.ts +39 -7
  41. package/lib/agent-assets.ts +74 -17
  42. package/lib/agent-profiles.ts +1 -1
  43. package/lib/agents-config.ts +12 -3
  44. package/lib/agents-keys.ts +8 -16
  45. package/lib/agents-protocol.ts +80 -4
  46. package/lib/agents-runner.ts +105 -4
  47. package/lib/agents-view.ts +6 -1
  48. package/lib/agents-widget.ts +132 -9
  49. package/lib/bridge-cost.ts +28 -0
  50. package/lib/codemode-renderer.ts +16 -0
  51. package/lib/command-palette-catalog.ts +1 -0
  52. package/lib/command-palette.ts +21 -8
  53. package/lib/exploration-budget.ts +62 -0
  54. package/lib/gentle-guide.ts +201 -0
  55. package/lib/gentle-shell-launcher.ts +4 -0
  56. package/lib/herdr-activity.ts +9 -3
  57. package/lib/herdr-task-summary-policy.ts +85 -0
  58. package/lib/inprocess-reviewer.ts +33 -13
  59. package/lib/jobs-sidebar-state.ts +5 -6
  60. package/lib/jobs-widget.ts +16 -52
  61. package/lib/keymaps-customize.ts +81 -0
  62. package/lib/keymaps.ts +291 -0
  63. package/lib/model-fallback-notice.ts +61 -0
  64. package/lib/model-fallback-policy.ts +141 -0
  65. package/lib/model-fallback-store.ts +143 -0
  66. package/lib/model-routing-authority.ts +10 -2
  67. package/lib/nan-provider.ts +3 -2
  68. package/lib/native-review-cli.ts +7 -2
  69. package/lib/notification-customize.ts +48 -51
  70. package/lib/openai-fast-tier.ts +22 -0
  71. package/lib/orchestrator-discovery.ts +5 -1
  72. package/lib/orchestrator-fallback.ts +75 -0
  73. package/lib/pasted-image-paths.ts +113 -0
  74. package/lib/questionnaire/questionnaire-view.ts +121 -7
  75. package/lib/review-candidate-view-owner.ts +4 -0
  76. package/lib/review-candidate-view.ts +10 -7
  77. package/lib/review-host-relay.ts +5 -1
  78. package/lib/review-integration-v2.ts +22 -7
  79. package/lib/review-repository.ts +5 -0
  80. package/lib/session-profile-append-controller.ts +21 -6
  81. package/lib/session-profile-authority.ts +119 -0
  82. package/lib/session-profile-binding.ts +54 -5
  83. package/lib/session-profile-freeze.ts +105 -9
  84. package/lib/session-profile-integration.ts +313 -0
  85. package/lib/session-profile-persistence.ts +63 -9
  86. package/lib/shell-bar.ts +171 -56
  87. package/lib/shell-card.ts +26 -6
  88. package/lib/shell-page.ts +120 -0
  89. package/lib/shell-panel.ts +149 -0
  90. package/lib/shell-prompt.ts +53 -1
  91. package/lib/shell-sidebar-layout.ts +98 -25
  92. package/lib/shell-sidebar.ts +54 -1
  93. package/lib/shell-stats.ts +123 -0
  94. package/lib/shell-todo.ts +71 -0
  95. package/lib/shell-usage.ts +12 -2
  96. package/lib/star-prompt.ts +197 -0
  97. package/lib/verifier-admission.ts +18 -8
  98. package/lib/verifier-settle-reminder.ts +64 -0
  99. package/lib/vim-editor-adapter.ts +6 -1
  100. package/lib/visual-customization-policy.ts +41 -6
  101. package/lib/visual-customize-view.ts +164 -26
  102. package/lib/visual-layout-preview.ts +43 -0
  103. package/lib/yolo-session-policy.ts +28 -1
  104. package/package.json +1 -1
  105. package/runtime/gentle-shell-launcher.mjs +4 -0
  106. package/runtime/native-review-cli.mjs +7 -2
  107. package/runtime/review-integration-v2.mjs +22 -7
  108. package/runtime/windows-session-transport.ps1 +60 -3
  109. package/scripts/bootstrap.sh +4 -1
  110. package/scripts/installer-preflight.mjs +1 -1
  111. package/scripts/pi-update.mjs +113 -3
  112. package/scripts/run-test-suite.mjs +17 -1
  113. package/scripts/shell-snapshot.mjs +340 -0
  114. package/scripts/test-packed-runner.mjs +1 -1
  115. package/scripts/update-agent-body-history.mjs +41 -0
  116. package/scripts/verify-installer-tap.mjs +45 -0
  117. package/scripts/verify-package-files.mjs +2 -0
  118. package/skills/gentle-ai/SKILL.md +2 -2
  119. package/skills/tui-design/NOTICE.md +5 -0
  120. package/skills/tui-design/SKILL.md +56 -0
  121. package/skills/tui-design/references/commands.md +75 -0
  122. package/skills/tui-design/references/critique.md +48 -0
  123. package/skills/tui-design/references/design-doc.md +44 -0
  124. package/skills/tui-design/references/terminal-craft.md +64 -0
  125. package/skills/tui-design/references/visual-loop.md +32 -0
  126. package/tests/agents-protocol.test.ts +53 -1
  127. package/tests/agents-runner.test.ts +168 -3
  128. package/tests/agents-view.test.ts +27 -0
  129. package/tests/agents-widget.test.ts +312 -10
  130. package/tests/bounded-scan-contract.test.ts +39 -0
  131. package/tests/bridge-cost.test.ts +32 -0
  132. package/tests/bundled-install.test.ts +6 -4
  133. package/tests/ci-concurrency.test.ts +11 -0
  134. package/tests/ci-merge-base-identity.test.ts +114 -0
  135. package/tests/codegraph-tools.test.ts +69 -0
  136. package/tests/codemode-rendering.test.ts +22 -2
  137. package/tests/command-palette.test.ts +16 -2
  138. package/tests/commit-slice-signal.test.ts +11 -9
  139. package/tests/delegate-for-reason-contract.test.ts +5 -4
  140. package/tests/design-canvas-server.test.ts +6 -2
  141. package/tests/exploration-budget.test.ts +128 -0
  142. package/tests/fixtures/agent-assets/gentle-ai-worker.strict-tdd-era.md +122 -0
  143. package/tests/fixtures/measure-orchestrator-prompt.mjs +2 -1
  144. package/tests/fixtures/primary-session-prompt/gentleman.golden.md +18 -10
  145. package/tests/fixtures/session-profile-v1/replay.ts +125 -0
  146. package/tests/fixtures/session-profile-v1/session-profile-authority.ts +113 -0
  147. package/tests/fixtures/session-profile-v1/session-profile-binding.ts +83 -0
  148. package/tests/fixtures/session-profile-v1/session-profile-disk-reader.ts +182 -0
  149. package/tests/fixtures/session-profile-v1/session-profile-freeze.ts +290 -0
  150. package/tests/fixtures/session-profile-v1/session-profile-persistence.ts +195 -0
  151. package/tests/fixtures/session-profile-v1/v1-inputs.ts +16 -0
  152. package/tests/fixtures/windows-pipe-availability.ps1 +26 -0
  153. package/tests/fixtures/windows-session-bootstrap.ps1 +6 -2
  154. package/tests/gentle-agents.test.ts +416 -21
  155. package/tests/gentle-ai-exploration-budget.test.ts +135 -0
  156. package/tests/gentle-ai.test.ts +1011 -37
  157. package/tests/gentle-fast.test.ts +73 -0
  158. package/tests/gentle-guide.test.ts +208 -0
  159. package/tests/gentle-herdr-activity.test.ts +76 -2
  160. package/tests/gentle-herdr-agent.test.ts +111 -0
  161. package/tests/gentle-music.test.ts +36 -1
  162. package/tests/gentle-program-identity.test.ts +197 -0
  163. package/tests/gentle-shell-bin.test.ts +49 -26
  164. package/tests/gentle-shell-launcher.test.ts +18 -2
  165. package/tests/gentle-shell.test.ts +1068 -37
  166. package/tests/gentle-stats.test.ts +15 -2
  167. package/tests/gentle-todo.test.ts +50 -4
  168. package/tests/herdr-task-summary-policy.test.ts +128 -0
  169. package/tests/history-store-private-mode.test.ts +40 -0
  170. package/tests/image-paste-chips.test.ts +42 -0
  171. package/tests/inprocess-reviewer.test.ts +122 -0
  172. package/tests/installer-posix-bootstrap.test.ts +67 -5
  173. package/tests/installer-server.test.ts +2 -2
  174. package/tests/installer-windows-diagnostics.test.ts +4 -5
  175. package/tests/isolated-config-home.ts +28 -0
  176. package/tests/jobs-widget.test.ts +25 -37
  177. package/tests/keymaps-customize.test.ts +114 -0
  178. package/tests/keymaps.test.ts +103 -0
  179. package/tests/maintainer/mcp-status.maintest.ts +88 -0
  180. package/tests/maintainer/pi-update-source.maintest.ts +116 -0
  181. package/tests/model-fallback-notice.test.ts +45 -0
  182. package/tests/model-fallback-policy.test.ts +83 -0
  183. package/tests/model-fallback-store.test.ts +111 -0
  184. package/tests/nan-provider.test.ts +4 -4
  185. package/tests/no-self-pause-contract.test.ts +19 -0
  186. package/tests/notification-customize.test.ts +58 -34
  187. package/tests/odd-routing-canonical-ratchet.test.ts +3 -3
  188. package/tests/odd-routing-contract.test.ts +1 -1
  189. package/tests/orchestrator-fallback.test.ts +82 -0
  190. package/tests/orchestrator-prompt-budget.test.ts +131 -0
  191. package/tests/package-manifest.test.ts +160 -7
  192. package/tests/pasted-image-paths.test.ts +118 -0
  193. package/tests/persona-reply-language.test.ts +61 -0
  194. package/tests/pi-update-launcher.test.ts +32 -8
  195. package/tests/pi-update-source.test.ts +162 -0
  196. package/tests/profile-fast-tier.test.ts +311 -0
  197. package/tests/profile-tier-footer.test.ts +79 -0
  198. package/tests/questionnaire-view.test.ts +150 -0
  199. package/tests/review-candidate-owner-sweep.test.ts +93 -0
  200. package/tests/review-candidate-view.test.ts +51 -0
  201. package/tests/review-controller-native-routing.test.ts +120 -6
  202. package/tests/review-gate.test.ts +24 -0
  203. package/tests/review-inspect-preflight.test.ts +197 -0
  204. package/tests/review-integration-v2-forward.test.ts +59 -0
  205. package/tests/review-repository.test.ts +52 -1
  206. package/tests/review-sidebar-state.test.ts +5 -5
  207. package/tests/run-test-suite.test.ts +61 -5
  208. package/tests/sensitive-path-tools.test.ts +74 -0
  209. package/tests/session-profile-append-controller.test.ts +63 -0
  210. package/tests/session-profile-authority.test.ts +259 -0
  211. package/tests/session-profile-binding.test.ts +15 -0
  212. package/tests/session-profile-extension.test.ts +615 -0
  213. package/tests/session-profile-freeze.test.ts +110 -2
  214. package/tests/session-profile-integration.test.ts +857 -0
  215. package/tests/session-profile-persistence.test.ts +57 -0
  216. package/tests/session-profile-v1-compat.test.ts +221 -0
  217. package/tests/shell-bar.test.ts +113 -55
  218. package/tests/shell-card.test.ts +13 -1
  219. package/tests/shell-page.test.ts +108 -0
  220. package/tests/shell-panel.test.ts +332 -0
  221. package/tests/shell-prompt.test.ts +54 -0
  222. package/tests/shell-render-cache.test.ts +5 -0
  223. package/tests/shell-sidebar-fullscreen.test.ts +12 -0
  224. package/tests/shell-sidebar-layout.test.ts +159 -27
  225. package/tests/shell-stats.test.ts +90 -0
  226. package/tests/shell-usage.test.ts +14 -0
  227. package/tests/skill-registry.test.ts +68 -1
  228. package/tests/star-prompt.test.ts +470 -0
  229. package/tests/startup-banner.test.ts +57 -1
  230. package/tests/task-size-routing-contract.test.ts +45 -1
  231. package/tests/verifier-settle-reminder.test.ts +281 -0
  232. package/tests/verify-first-launch-contract.test.ts +56 -5
  233. package/tests/verify-installer-tap.test.ts +57 -0
  234. package/tests/vim-editor-adapter.test.ts +2 -2
  235. package/tests/visual-customization-policy.test.ts +61 -7
  236. package/tests/visual-customize-view.test.ts +253 -8
  237. package/tests/visual-layout-preview.test.ts +28 -0
  238. package/tests/windows-session-bootstrap.test.ts +105 -2
  239. package/tests/work-continuity-contract.test.ts +86 -0
  240. package/tests/writer-surfaces.test.ts +12 -10
  241. package/tests/yolo-customize.test.ts +30 -11
  242. package/tests/yolo-mode-runtime.test.ts +4 -2
  243. package/tests/yolo-mode.test.ts +16 -2
@@ -4,6 +4,7 @@ import {
4
4
  SESSION_PROFILE_CUSTOM_TYPE,
5
5
  createSessionProfileBind,
6
6
  createSessionProfileClear,
7
+ createSessionProfileStartupBind,
7
8
  readSessionProfileEntry,
8
9
  replaySessionProfileBranch,
9
10
  } from "../lib/session-profile-persistence.ts";
@@ -332,3 +333,59 @@ test("replay sees only caller-supplied active branch, not siblings or later path
332
333
  binding: bind(),
333
334
  });
334
335
  });
336
+
337
+ // A2 record shapes (gentle-shell#2742, section 3).
338
+ const TEAM = { worker: { model: "provider/team" }, orchestrator: { model: "provider/main" } };
339
+ const teamStartup = <O extends string>(origin: O) => ({ origin, name: "team", modelProfiles: TEAM });
340
+
341
+ test("writer emits a startup bind per origin with the full definition, orchestrator included", () => {
342
+ for (const origin of ["local", "repo", "global"] as const) {
343
+ const payload = createSessionProfileStartupBind(origin, "team", TEAM);
344
+ assert.deepEqual(payload, { kind: "bind", ...teamStartup(origin) });
345
+ assert.deepEqual(readSessionProfileEntry(custom(payload)), { status: "bound", binding: payload });
346
+ }
347
+ assert.throws(() => createSessionProfileStartupBind("user" as "local", "team", TEAM));
348
+ assert.throws(() => createSessionProfileStartupBind("global", "../team", TEAM));
349
+ });
350
+
351
+ test("writer records the startup state on an explicit choice and on a clear", () => {
352
+ for (const startup of [teamStartup("repo"), "none"] as const) {
353
+ const payload = createSessionProfileBind("work", {}, startup);
354
+ assert.deepEqual(payload, { ...bind(), startup });
355
+ assert.deepEqual(readSessionProfileEntry(custom(payload)), { status: "bound", binding: payload });
356
+ }
357
+ assert.deepEqual(createSessionProfileClear("none"), { kind: "clear", startup: "none" });
358
+ assert.deepEqual(readSessionProfileEntry(custom({ kind: "clear", startup: "none" })), {
359
+ status: "cleared",
360
+ startup: "none",
361
+ });
362
+ assert.throws(() => createSessionProfileBind("work", {}, teamStartup("user") as never));
363
+ assert.throws(() => createSessionProfileBind("work", {}, { ...teamStartup("local"), modelProfiles: { worker: "bad model" } } as never));
364
+ });
365
+
366
+ test("a malformed startup state is ignored, never invalidating the record", () => {
367
+ const malformed: unknown[] = [
368
+ null,
369
+ "other",
370
+ {},
371
+ teamStartup("user"),
372
+ { ...teamStartup("global"), name: "../team" },
373
+ { ...teamStartup("global"), modelProfiles: { worker: "bad model" } },
374
+ { origin: "global", name: "team" },
375
+ ];
376
+ for (const startup of malformed) {
377
+ assert.deepEqual(readSessionProfileEntry(custom({ ...bind(), startup })), { status: "bound", binding: bind() });
378
+ assert.deepEqual(readSessionProfileEntry(custom({ kind: "clear", startup })), { status: "cleared" });
379
+ }
380
+ // A startup record is its own startup state; a nested one carries no meaning.
381
+ const startupBind = { kind: "bind", ...teamStartup("global") };
382
+ assert.deepEqual(readSessionProfileEntry(custom({ ...startupBind, startup: "none" })), {
383
+ status: "bound",
384
+ binding: startupBind,
385
+ });
386
+ assert.deepEqual(replaySessionProfileBranch([custom(bind()), custom({ kind: "clear", startup: "none" })]), {
387
+ status: "cleared",
388
+ startup: "none",
389
+ entryIndex: 1,
390
+ });
391
+ });
@@ -0,0 +1,221 @@
1
+ import assert from "node:assert/strict";
2
+ import test from "node:test";
3
+ import { profileRoleEntries } from "../lib/agent-profiles.ts";
4
+ import type { AgentModelConfig } from "../lib/model-routing-authority.ts";
5
+ import {
6
+ createSessionProfileBind,
7
+ createSessionProfileClear,
8
+ createSessionProfileStartupBind,
9
+ } from "../lib/session-profile-persistence.ts";
10
+ import { replay, type Transcript } from "./fixtures/session-profile-v1/replay.ts";
11
+
12
+ // v1 compatibility (gentle-shell#2742, section 10): a session resumed by the
13
+ // vendored v1 chain routes like the current modules. This file pins today's
14
+ // record shapes; the A2 shapes join the same table as they land.
15
+
16
+ const FRONTIER: AgentModelConfig = { worker: { model: "anthropic/claude-opus", thinking: "high" } };
17
+ const LOCAL: AgentModelConfig = { worker: { model: "ollama/qwen", thinking: "low" } };
18
+ const TEAM: AgentModelConfig = { worker: { model: "openai/gpt-5" }, orchestrator: { model: "openai/gpt-5" } };
19
+ const profiles = { frontier: FRONTIER, local: LOCAL, team: TEAM };
20
+
21
+ const userBind = (name: string, modelProfiles: AgentModelConfig) => ({ kind: "bind", origin: "user", name, modelProfiles });
22
+
23
+ const transcripts: Record<string, Transcript> = {
24
+ "no record, no defaults": { records: [], defaults: { profiles } },
25
+ "no record, active profile": { records: [], defaults: { profiles, active: "frontier" } },
26
+ "no record, local pin over active": { records: [], defaults: { profiles, active: "frontier", localPin: "local" } },
27
+ "no record, repo declaration, foreign pin": {
28
+ records: [],
29
+ defaults: { profiles, repoDeclaration: "team", foreignPin: "local" },
30
+ },
31
+ "explicit bind": { records: [userBind("local", LOCAL)], defaults: { profiles, active: "frontier" } },
32
+ "explicit bind, definition edited since": {
33
+ records: [userBind("local", { worker: { model: "ollama/llama" } })],
34
+ defaults: { profiles, active: "frontier" },
35
+ },
36
+ "legacy clear after a bind": {
37
+ records: [userBind("local", LOCAL), { kind: "clear" }],
38
+ defaults: { profiles, active: "frontier" },
39
+ },
40
+ "legacy clear, no defaults, foreign pin": {
41
+ records: [{ kind: "clear" }],
42
+ defaults: { profiles, foreignPin: "team" },
43
+ },
44
+ "invalid newest record": {
45
+ records: [userBind("local", LOCAL), { kind: "bind", origin: "user", name: "" }],
46
+ defaults: { profiles, active: "frontier" },
47
+ },
48
+ "unsupported newest record": {
49
+ records: [userBind("local", LOCAL), { kind: "rename", name: "x" }],
50
+ defaults: { profiles, active: "frontier" },
51
+ },
52
+ };
53
+
54
+ for (const [name, transcript] of Object.entries(transcripts)) {
55
+ test(`v1 and current resume route the same: ${name}`, () => {
56
+ assert.deepEqual(replay("current", transcript), replay("v1", transcript));
57
+ });
58
+ }
59
+
60
+ test("v1 replay observes the recorded binding, its label and its routing", () => {
61
+ const observed = replay("v1", transcripts["explicit bind"]!);
62
+ assert.deepEqual(observed, {
63
+ authority: true,
64
+ kind: "explicit",
65
+ label: "local (session)",
66
+ routing: LOCAL,
67
+ foreignRouting: LOCAL,
68
+ notice: undefined,
69
+ });
70
+ });
71
+
72
+ test("v1 replay of a legacy clear freezes the resume-time default", () => {
73
+ const observed = replay("v1", transcripts["legacy clear after a bind"]!);
74
+ assert.equal(observed.kind, "inherited");
75
+ assert.equal(observed.label, "frontier");
76
+ assert.deepEqual(observed.routing, FRONTIER);
77
+ });
78
+
79
+ // A2 shapes, written by the current codec (section 5): the v1 observation is
80
+ // asserted directly, since how the current version reads them is T3's job.
81
+ const startupDefaults = {
82
+ local: { profiles, localPin: "local" },
83
+ repo: { profiles, repoDeclaration: "frontier" },
84
+ global: { profiles, active: "team" },
85
+ } as const;
86
+
87
+ for (const [origin, defaults] of Object.entries(startupDefaults) as Array<[keyof typeof startupDefaults, (typeof startupDefaults)["local"]]>) {
88
+ test(`v1 reads a ${origin} startup bind as bound, with the startup launch routing and no drift notice`, () => {
89
+ const name = { local: "local", repo: "frontier", global: "team" }[origin];
90
+ const definition = profiles[name];
91
+ const started = replay("v1", { records: [], defaults });
92
+ const observed = replay("v1", { records: [createSessionProfileStartupBind(origin, name, definition)], defaults });
93
+ assert.deepEqual(observed, {
94
+ authority: true,
95
+ kind: "explicit",
96
+ label: `${name} (session)`,
97
+ routing: definition,
98
+ foreignRouting: definition,
99
+ notice: undefined,
100
+ });
101
+ // Launch routing ignores the orchestrator key the record carries; the
102
+ // inherited path may hold an absent route field as `undefined`.
103
+ const { orchestrator: _, ...roles } = observed.routing!;
104
+ assert.deepEqual(roles, JSON.parse(JSON.stringify(started.routing)));
105
+ });
106
+ }
107
+
108
+ test("v1 reads a startup-none clear as a legacy clear", () => {
109
+ const defaults = { profiles, foreignPin: "team" };
110
+ const observed = replay("v1", { records: [userBind("local", LOCAL), createSessionProfileClear("none")], defaults });
111
+ assert.equal(observed.kind, "inherited");
112
+ assert.deepEqual(observed, replay("v1", { records: [userBind("local", LOCAL), { kind: "clear" }], defaults }));
113
+ });
114
+
115
+ test("v1 reads an explicit bind with a startup state as bound and ignores the startup state", () => {
116
+ const defaults = { profiles, active: "frontier" };
117
+ for (const startup of [{ origin: "global" as const, name: "team", modelProfiles: TEAM }, "none" as const]) {
118
+ const observed = replay("v1", { records: [createSessionProfileBind("local", LOCAL, startup)], defaults });
119
+ assert.equal(observed.kind, "explicit");
120
+ assert.deepEqual(observed, replay("v1", transcripts["explicit bind"]!));
121
+ }
122
+ });
123
+
124
+ // How the current version reads the A2 shapes (section 4) against v1 (section
125
+ // 5). Launch routing ignores the orchestrator key, so routing compares role
126
+ // entries; kind, label and notices are asserted per version.
127
+ const roles = (config: AgentModelConfig | undefined) =>
128
+ config === undefined ? undefined : JSON.parse(JSON.stringify(Object.fromEntries(profileRoleEntries(config))));
129
+ const launchRouting = (version: "v1" | "current", transcript: Transcript) => {
130
+ const observed = replay(version, transcript);
131
+ return { authority: observed.authority, routing: roles(observed.routing), foreignRouting: roles(observed.foreignRouting) };
132
+ };
133
+
134
+ for (const [origin, defaults] of Object.entries(startupDefaults) as Array<[keyof typeof startupDefaults, (typeof startupDefaults)["local"]]>) {
135
+ const name = { local: "local", repo: "frontier", global: "team" }[origin];
136
+ const label = origin === "global" ? name : `${name} (${origin})`;
137
+ const record = createSessionProfileStartupBind(origin, name, profiles[name]);
138
+ test(`current reads a ${origin} startup bind as the inherited ${label}, with v1 launch routing`, () => {
139
+ const transcript = { records: [record], defaults: { ...defaults, foreignPin: "local" } };
140
+ const observed = replay("current", transcript);
141
+ assert.deepEqual([observed.kind, observed.label, observed.notice], ["inherited", label, undefined]);
142
+ assert.deepEqual(launchRouting("current", transcript), launchRouting("v1", transcript));
143
+ });
144
+ test(`resume of a ${origin} startup bind keeps it after the defaults changed, in both versions`, () => {
145
+ const transcript = { records: [record], defaults: { profiles, active: "local", localPin: name === "local" ? "frontier" : undefined } };
146
+ assert.deepEqual(launchRouting("current", transcript), launchRouting("v1", transcript));
147
+ assert.deepEqual(launchRouting("current", transcript).routing, roles(profiles[name]));
148
+ const notice = replay("current", transcript).notice;
149
+ assert.ok(notice?.includes(`this session keeps "${name}" (${origin})`), "the inherited drift notice");
150
+ assert.equal(replay("v1", transcript).notice, undefined, "v1 finds no definition drift");
151
+ });
152
+ test(`follow mode routes a ${origin} startup bind as v1 does`, () => {
153
+ const transcript = { records: [record], defaults: { profiles, active: "local", foreignPin: "frontier" }, env: { GENTLE_PI_PROFILE_FOLLOW: "1" } };
154
+ assert.deepEqual(launchRouting("current", transcript), launchRouting("v1", transcript));
155
+ assert.deepEqual(launchRouting("current", transcript).foreignRouting, roles(profiles[name]));
156
+ });
157
+ }
158
+
159
+ test("current reads a startup-none clear as no session profile, routing as v1 while the defaults did not change", () => {
160
+ const transcript = { records: [userBind("local", LOCAL), createSessionProfileClear("none")], defaults: { profiles, foreignPin: "team" } };
161
+ const observed = replay("current", transcript);
162
+ assert.deepEqual([observed.kind, observed.label, observed.routing, observed.notice], ["inherited", undefined, undefined, undefined]);
163
+ assert.deepEqual(roles(observed.foreignRouting), roles(TEAM), "a foreign repository uses its own pin");
164
+ assert.deepEqual(observed, replay("v1", transcript));
165
+ });
166
+
167
+ test("gap (section 10): a startup-none clear resumed after an active profile appeared diverges from v1", () => {
168
+ const transcript = { records: [createSessionProfileClear("none")], defaults: { profiles, active: "frontier" } };
169
+ const current = replay("current", transcript);
170
+ assert.deepEqual([current.kind, current.label, current.routing], ["inherited", undefined, undefined], "current keeps no session profile");
171
+ const v1 = replay("v1", transcript);
172
+ assert.deepEqual([v1.kind, v1.label, v1.routing], ["inherited", "frontier", FRONTIER], "v1 routes to the new active profile");
173
+ });
174
+
175
+ test("follow mode resolves the current defaults after a startup-none or legacy clear, as v1 does", () => {
176
+ for (const clear of [createSessionProfileClear("none"), createSessionProfileClear()]) {
177
+ const transcript = { records: [clear], defaults: { profiles, active: "frontier" }, env: { GENTLE_PI_PROFILE_FOLLOW: "1" } };
178
+ assert.deepEqual(replay("current", transcript), replay("v1", transcript));
179
+ assert.deepEqual(replay("current", transcript).routing, FRONTIER);
180
+ }
181
+ });
182
+
183
+ test("current reads an explicit bind with or without a startup state exactly as v1", () => {
184
+ for (const startup of [{ origin: "global" as const, name: "team", modelProfiles: TEAM }, "none" as const, undefined]) {
185
+ const transcript = { records: [createSessionProfileBind("local", LOCAL, startup)], defaults: { profiles, active: "frontier", foreignPin: "team" } };
186
+ assert.deepEqual(replay("current", transcript), replay("v1", transcript));
187
+ }
188
+ });
189
+
190
+ // Clear (section 10): the record sequences the A2 clear writes, by newest entry.
191
+ const teamStartup = { origin: "global" as const, name: "team", modelProfiles: TEAM };
192
+ const invalid = { kind: "bind", origin: "user", name: "" };
193
+ const clearTranscripts: Record<string, Transcript> = {
194
+ "known startup profile": { records: [createSessionProfileBind("local", LOCAL, teamStartup), createSessionProfileStartupBind("global", "team", TEAM)], defaults: { profiles, active: "team", foreignPin: "frontier" } },
195
+ "known no profile": { records: [createSessionProfileBind("local", LOCAL, "none"), createSessionProfileClear("none")], defaults: { profiles, foreignPin: "team" } },
196
+ "unknown startup state": { records: [userBind("local", LOCAL), createSessionProfileClear()], defaults: { profiles, active: "frontier" } },
197
+ "invalid newest entry, startup known": { records: [userBind("local", LOCAL), invalid, createSessionProfileStartupBind("global", "team", TEAM)], defaults: { profiles, active: "team" } },
198
+ "invalid newest entry, startup unknown": { records: [userBind("local", LOCAL), invalid, createSessionProfileClear()], defaults: { profiles, active: "frontier" } },
199
+ "follow mode": { records: [createSessionProfileBind("local", LOCAL, teamStartup), createSessionProfileClear()], defaults: { profiles, active: "frontier" }, env: { GENTLE_PI_PROFILE_FOLLOW: "1" } },
200
+ };
201
+
202
+ for (const [name, transcript] of Object.entries(clearTranscripts)) {
203
+ test(`a clear routes the same in v1 and current: ${name}`, () => {
204
+ assert.deepEqual(launchRouting("current", transcript), launchRouting("v1", transcript));
205
+ assert.equal(replay("current", transcript).authority, true, "the clear restores authority");
206
+ });
207
+ }
208
+
209
+ test("a clear back to a startup profile with an orchestrator raises no v1 definition drift notice", () => {
210
+ const transcript = clearTranscripts["known startup profile"]!;
211
+ const v1 = replay("v1", transcript);
212
+ assert.deepEqual([v1.notice, roles(v1.routing)], [undefined, roles(TEAM)]);
213
+ assert.deepEqual([replay("current", transcript).label, replay("current", transcript).notice], ["team", undefined]);
214
+ });
215
+
216
+ test("a legacy clear after an explicit choice that carried its startup state freezes the defaults at resume, as v1", () => {
217
+ const startup = { origin: "global" as const, name: "team", modelProfiles: TEAM };
218
+ const transcript = { records: [createSessionProfileBind("local", LOCAL, startup), createSessionProfileClear()], defaults: { profiles, active: "frontier" } };
219
+ assert.deepEqual(replay("current", transcript), replay("v1", transcript));
220
+ assert.equal(replay("current", transcript).label, "frontier");
221
+ });
@@ -103,11 +103,11 @@ test("visual visibility hides only selected optional status segments", () => {
103
103
  const settings = { ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, changes: false, modelDetails: false, usageCost: false } };
104
104
  const data = model({ changes: { files: 2, added: 1, deleted: 1 } });
105
105
  assert.doesNotMatch(renderShellBar(data, plainTheme, 160, settings).join(""), /gpt-5\.5|ctx|\$9\.49/);
106
- assert.doesNotMatch(renderShellSidebarBar(data, plainTheme, 50, settings).join(""), /Changes|2 files/);
106
+ assert.doesNotMatch(renderShellSidebarBar(data, plainTheme, 50, settings).join(""), /CHANGES|2 files/);
107
107
  assert.doesNotMatch(renderShellHeaderBar(buildShellHeaderModel(data), plainTheme, 160, undefined, settings).text, /gpt-5\.5|ctx|\$9\.49|usage/);
108
108
  });
109
109
 
110
- test("Status keeps RDD beside structured groups while running jobs moved to their own card", () => {
110
+ test("Status keeps the Review section beside Changes while running jobs live in their own section", () => {
111
111
  const data = model({ jobs: [
112
112
  { id: "job-2", label: "CI for PR 1860", startedAt: 2 },
113
113
  { id: "job-1", label: "Build runtime", startedAt: 1 },
@@ -115,10 +115,10 @@ test("Status keeps RDD beside structured groups while running jobs moved to thei
115
115
  for (const width of [30, 60]) {
116
116
  const lines = renderShellSidebarBar(data, plainTheme, width);
117
117
  const text = lines.join("\n");
118
- // Running jobs live in their own sidebar card; the Status card never
119
- // prints them, so the two surfaces cannot duplicate one job.
120
- assert.doesNotMatch(text, /Jobs|CI for PR 1860|Build runtime/);
121
- assert.match(text, /🌹 RDD/);
118
+ // Running jobs live in their own rail section; Status never prints
119
+ // them, so the two surfaces cannot duplicate one job.
120
+ assert.doesNotMatch(text, /JOBS|CI for PR 1860|Build runtime/);
121
+ assert.match(text, /▾ REVIEW/);
122
122
  assert.ok(lines.every((line) => visibleWidth(line) <= width));
123
123
  }
124
124
  });
@@ -147,33 +147,33 @@ test("bottom-only and hidden below-input chrome retain a compact jobs count", (t
147
147
  assert.ok(rows.every((line) => visibleWidth(line) <= 80));
148
148
  });
149
149
 
150
- test("Status title stays plain without an active review", () => {
150
+ test("Status opens with Changes and shows no Review section without an active review", () => {
151
151
  const lines = renderShellSidebarBar(model(), plainTheme, 60);
152
- assert.match(lines[0], /^╭─ ✿ Status ─+╮$/);
153
- assert.doesNotMatch(lines.slice(1).join("\n"), /🌹 RDD/);
152
+ assert.match(lines[0], /^▾ CHANGES/);
153
+ assert.doesNotMatch(lines.slice(1).join("\n"), /REVIEW/);
154
154
  });
155
155
 
156
- test("Status title stays plain above the review lifecycle block", () => {
156
+ test("the Review section lists the lifecycle state and the candidate scope", () => {
157
157
  const lines = renderShellSidebarBar(model({ review: { state: "reviewing", scope: "first.ts +2 files" } }), plainTheme, 60);
158
- assert.match(lines[0], /^╭─ ✿ Status ─+╮$/);
159
- assert.match(lines.slice(1).join("\n"), /🌹 RDD[\s\S]*Reviewers running…[\s\S]*first\.ts \+2 files/);
158
+ assert.match(lines[0], /^▾ CHANGES/);
159
+ assert.match(lines.slice(1).join("\n"), /▾ REVIEW[\s\S]*Reviewers running…[\s\S]*first\.ts \+2 files/);
160
160
  });
161
161
 
162
162
  test("review lifecycle block omits the scope line when the candidate scope is unknown", () => {
163
163
  const known = renderShellSidebarBar(model({ review: { state: "checking", scope: "first.ts" } }), plainTheme, 60);
164
164
  const unknown = renderShellSidebarBar(model({ review: { state: "checking", scope: REVIEW_SCOPE_UNAVAILABLE } }), plainTheme, 60);
165
165
  const text = unknown.join("\n");
166
- assert.match(text, /🌹 RDD[\s\S]*Updating…/);
166
+ assert.match(text, /▾ REVIEW[\s\S]*Updating…/);
167
167
  assert.doesNotMatch(text, /Candidate scope unavailable/);
168
168
  assert.equal(unknown.length, known.length - 1);
169
169
  });
170
170
 
171
171
  test("rdd visibility hides only the review lifecycle block", () => {
172
172
  const data = model({ review: { state: "reviewing", scope: "first.ts +2" }, changes: { files: 2, added: 1, deleted: 1 } });
173
- assert.match(renderShellSidebarBar(data, plainTheme, 60, DEFAULT_VISUAL_SETTINGS).join("\n"), /🌹 RDD[\s\S]*Reviewers running…/);
173
+ assert.match(renderShellSidebarBar(data, plainTheme, 60, DEFAULT_VISUAL_SETTINGS).join("\n"), /▾ REVIEW[\s\S]*Reviewers running…/);
174
174
  const hidden = renderShellSidebarBar(data, plainTheme, 60, { ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, rdd: false } }).join("\n");
175
- assert.doesNotMatch(hidden, /🌹 RDD|Reviewers running|first\.ts \+2 files/);
176
- assert.match(hidden, /Changes[\s\S]*2 files/);
175
+ assert.doesNotMatch(hidden, /REVIEW|Reviewers running|first\.ts \+2 files/);
176
+ assert.match(hidden, /CHANGES[\s\S]*2 files/);
177
177
  });
178
178
 
179
179
  test("Status and review lifecycle block respect terminal width", () => {
@@ -181,7 +181,7 @@ test("Status and review lifecycle block respect terminal width", () => {
181
181
  for (const review of [undefined, { state: "reviewing" as const, scope: "first.ts +2 files" }, { state: "approved" as const, scope: REVIEW_SCOPE_UNAVAILABLE }]) {
182
182
  const lines = renderShellSidebarBar(model({ review }), plainTheme, width);
183
183
  for (const line of lines) assert.ok(visibleWidth(line) <= width, `${width}: ${line}`);
184
- if (width >= 20) assert.match(lines[0], /^╭─ ✿ Status ─+╮$/);
184
+ if (width >= 20) assert.match(lines[0], /^▾ CHANGES/);
185
185
  }
186
186
  }
187
187
  });
@@ -347,47 +347,91 @@ test("shellEnabled honors GENTLE_PI_SHELL=0", () => {
347
347
  assert.equal(shellEnabled({ GENTLE_PI_SHELL: "false" }), false);
348
348
  });
349
349
 
350
- test("renderShellSidebarBar paints the Status card frame with border and the title with accent", () => {
351
- const lines = renderShellSidebarBar(model(), taggedTheme, 46);
352
- assert.match(lines[0], /^<border>╭<\/border>/);
353
- assert.match(lines[0], /<accent>✿ Status<\/accent>/);
354
- assert.match(lines[lines.length - 1], /^<border>╰<\/border>/);
350
+ test("renderShellSidebarBar draws panel section headers, never a card frame", () => {
351
+ const lines = renderShellSidebarBar(model(), taggedTheme, 160);
352
+ assert.match(lines[0], /^<muted>▾<\/muted> <text>.*CHANGES.*<\/text>/);
353
+ assert.doesNotMatch(lines.join("\n"), /[╭╮╰╯│]/u);
355
354
  });
356
355
 
357
- test("sidebar unifies project, captured changes and integrations in one frame", () => {
356
+ test("the rail Status orders Changes before Integrations and keeps the location out", () => {
358
357
  const data = model({ changes: { files: 2, added: 7, deleted: 3 }, statuses: ["MCP connected"] });
359
358
  const lines = renderShellSidebarBar(data, plainTheme, 46);
360
359
  const text = lines.join("\n");
361
- assert.equal(lines.filter((line) => line.startsWith("╭")).length, 1);
362
360
  let previous = -1;
363
- for (const heading of ["Status", "Project", "Changes", "Integrations"]) {
361
+ for (const heading of ["CHANGES", "INTEGRATIONS"]) {
364
362
  const index = text.indexOf(heading);
365
363
  assert.ok(index > previous, heading);
366
364
  previous = index;
367
365
  }
368
- assert.match(text, /2 files.*\+7.*−3/);
366
+ assert.match(text, /2 files/);
367
+ assert.match(text, /\+7 −3/);
369
368
  assert.match(text, /\/gentle:changes/);
370
- assert.match(text, /main/);
369
+ assert.match(text, /MCP connected/);
370
+ assert.doesNotMatch(text, /main|Branch|Project/, "location lives in the header row, once");
371
371
  for (const width of [1, 8, 24, 46]) assert.ok(renderShellSidebarBar(data, plainTheme, width).every((line) => visibleWidth(line) <= width));
372
372
  const empty = renderShellSidebarBar(model(), plainTheme, 46).join("\n");
373
- assert.match(empty, /No captured changes/);
374
- assert.match(empty, /Integrations/);
373
+ assert.match(empty, /no captured changes/);
374
+ assert.match(empty, /INTEGRATIONS/);
375
375
  });
376
376
 
377
- test("sidebar profile wraps long names without changing the compact bar", () => {
378
- const profile = "team-" + "x".repeat(59);
377
+ test("Integrations shows the effective agent profile without changing its count or status order", () => {
378
+ const data = model({
379
+ profile: "alpha (session)",
380
+ permission: { mode: "AUTO", detail: "confirm before action" },
381
+ statuses: ["compact status"],
382
+ integrations: ["MCP connected", "Engram ready"],
383
+ });
384
+ const rows = () => renderShellSidebarBar(data, plainTheme, 60).map((line) => line.trimEnd());
385
+ const initial = rows();
386
+ const at = initial.findIndex((line) => line.startsWith("▾ INTEGRATIONS"));
387
+ assert.match(initial[at]!, /INTEGRATIONS\s+3$/);
388
+ assert.deepEqual(initial.slice(at + 1), [
389
+ " Agent profile: alpha (session)",
390
+ " - permissions confirm before action",
391
+ " - MCP connected",
392
+ " - Engram ready",
393
+ ]);
394
+ data.profile = "beta (repo)";
395
+ const updated = rows().join("\n");
396
+ assert.match(updated, /INTEGRATIONS[\s\S]*Agent profile: beta \(repo\)/);
397
+ assert.doesNotMatch(updated, /alpha \(session\)/);
398
+
399
+ data.profile = undefined;
400
+ const absent = rows();
401
+ const absentAt = absent.findIndex((line) => line.startsWith("▾ INTEGRATIONS"));
402
+ assert.match(absent[absentAt]!, /INTEGRATIONS\s+3$/);
403
+ assert.deepEqual(absent.slice(absentAt + 1), [" - permissions confirm before action", " - MCP connected", " - Engram ready"]);
404
+ for (const profile of ["", " \t\n", "\x1b[31m\x1b[0m"]) {
405
+ data.profile = profile;
406
+ assert.deepEqual(rows(), absent, "an empty sanitized profile leaves prior output unchanged");
407
+ }
408
+ const onlyProfile = renderShellSidebarBar(model({ profile: "solo (local)" }), plainTheme, 60).map((line) => line.trimEnd());
409
+ const onlyAt = onlyProfile.findIndex((line) => line.startsWith("▾ INTEGRATIONS"));
410
+ assert.match(onlyProfile[onlyAt]!, /INTEGRATIONS\s+none$/);
411
+ assert.deepEqual(onlyProfile.slice(onlyAt + 1), [" Agent profile: solo (local)", " no status reported"]);
412
+ });
413
+
414
+ test("the rail wraps and sanitizes long agent profiles, leaving the compact bar unchanged", () => {
415
+ const profile = `team-${"x".repeat(59)}\x1b[31m\nops\t界unit\x07\x1b[0m (repo)`;
379
416
  const base = model();
380
417
  const active = model({ profile });
381
- for (const width of [24, 46]) {
382
- const lines = renderShellSidebarBar(active, plainTheme, width);
418
+ const settings = { ...DEFAULT_VISUAL_SETTINGS, visibility: { ...DEFAULT_VISUAL_SETTINGS.visibility, changes: false } };
419
+ for (const width of [16, 24, 46]) {
420
+ const lines = renderShellSidebarBar(active, plainTheme, width, settings);
383
421
  assert.ok(lines.every((line) => visibleWidth(line) <= width));
384
- assert.match(lines.join("\n"), /Profile/);
385
- assert.ok(lines.join("").replace(/[│\s]/g, "").includes(profile));
422
+ assert.ok(lines.every((line) => !/[\x00-\x1f\x7f-\x9f]/.test(line)), "profile controls must not reach the terminal");
423
+ const text = lines.slice(1).join("").replace(/\s/g, "");
424
+ assert.ok(text.includes(`Agentprofile:team-${"x".repeat(59)}ops界unit(repo)`), "the complete sanitized profile survives wrapping");
386
425
  }
426
+ const ansiTheme = { ...plainTheme, fg: (role: string, value: string) => `\x1b[${role === "muted" ? 90 : 37}m${value}\x1b[0m` };
427
+ const colored = renderShellSidebarBar(active, ansiTheme, 24, settings);
428
+ assert.ok(colored.every((line) => visibleWidth(line) <= 24));
429
+ assert.match(colored.join(""), /\x1b\[90mAgent profile:\x1b\[0m/);
430
+ assert.ok(colored.slice(1).map(stripAnsi).join("").replace(/\s/g, "").includes(`Agentprofile:team-${"x".repeat(59)}ops界unit(repo)`));
387
431
  assert.deepEqual(renderShellBar(active, plainTheme, 120), renderShellBar(base, plainTheme, 120));
388
432
  });
389
433
 
390
- test("sidebar Status card drops Model, Effort, Context, Cost and Usage, keeping Project, Changes and Integrations", () => {
434
+ test("the rail Status drops model, usage and session identity, keeping Changes and Integrations", () => {
391
435
  const usage = {
392
436
  provider: "openai-codex",
393
437
  plan: "pro",
@@ -396,17 +440,8 @@ test("sidebar Status card drops Model, Effort, Context, Cost and Usage, keeping
396
440
  };
397
441
  const data = model({ profile: "team", sessionName: "session", usage, changes: { files: 1, added: 2, deleted: 1 }, statuses: ["MCP connected"] });
398
442
  const text = renderShellSidebarBar(data, plainTheme, 60).join("\n");
399
- assert.doesNotMatch(text, /Usage/);
400
- assert.doesNotMatch(text, /Model/);
401
- assert.doesNotMatch(text, /Effort/);
402
- assert.doesNotMatch(text, /Context/);
403
- assert.doesNotMatch(text, /Cost/);
404
- assert.doesNotMatch(text, /\$9\.49/);
405
- assert.doesNotMatch(text, /codex 5h/);
406
- for (const heading of ["Status", "Project", "Changes", "Integrations"]) assert.match(text, new RegExp(heading));
407
- assert.match(text, /Branch.*main/);
408
- assert.match(text, /Session.*session/);
409
- assert.match(text, /Profile.*team/);
443
+ for (const absent of [/Usage/, /Model/, /Effort/, /Context/, /Cost/, /\$9\.49/, /codex 5h/, /Branch/, /Session/]) assert.doesNotMatch(text, absent);
444
+ for (const heading of ["CHANGES", "INTEGRATIONS"]) assert.match(text, new RegExp(heading));
410
445
  });
411
446
 
412
447
  // The live header row above the fullscreen rail: identity on the left (brand,
@@ -521,6 +556,31 @@ test("renderShellHeaderBar shows every usage window with its gauge and the short
521
556
  assert.equal(text.slice(usageSpan.start, usageSpan.end), "usage 5h ▰▰▱▱▱▱▱▱ 26% · week ▰▱▱▱▱▱▱▱ 12% · alt+u");
522
557
  });
523
558
 
559
+ test("header retains effort without location when it fits beside full usage windows", () => {
560
+ const header = buildShellHeaderModel(model({ cwd: "~/work/" + "x".repeat(80), profile: "current", usage: USAGE_TWO_WINDOWS }));
561
+ for (const density of ["minimal", "compact", "comfortable"] as const) {
562
+ const settings = { ...DEFAULT_VISUAL_SETTINGS, density };
563
+ const right = "ctx ▰▰▰▰▱▱▱▱ 45% ⟡ $9.49 sub ⟡ usage 5h ▰▰▱▱▱▱▱▱ 26% · week ▰▱▱▱▱▱▱▱ 12% · alt+u";
564
+ const left = density === "minimal" ? "gpt-5.5 · medium" : "✿ Gentle Shell ⟡ gpt-5.5 · medium";
565
+ const width = visibleWidth(left) + 2 + visibleWidth(right);
566
+ const result = renderShellHeaderBar(header, plainTheme, width, "alt+u", settings);
567
+ assert.equal(result.text, left + " " + right, density);
568
+ assert.ok(result.usageSpan);
569
+ assert.equal(result.text.slice(result.usageSpan.start, result.usageSpan.end), right.slice(right.indexOf("usage")));
570
+
571
+ const narrower = renderShellHeaderBar(header, plainTheme, width - 1, "alt+u", settings).text;
572
+ assert.match(narrower, /gpt-5\.5/);
573
+ assert.doesNotMatch(narrower, /medium|current|~\/work/);
574
+ assert.ok(narrower.endsWith(right), "model-only fallback preserves full usage");
575
+ assert.equal(visibleWidth(narrower), width - 1);
576
+
577
+ const withoutEffort = renderShellHeaderBar({ ...header, effort: undefined }, plainTheme, width, "alt+u", settings).text;
578
+ assert.doesNotMatch(withoutEffort, /medium|current|~\/work/);
579
+ assert.ok(withoutEffort.endsWith(right));
580
+ assert.equal(visibleWidth(withoutEffort), width);
581
+ }
582
+ });
583
+
524
584
  test("renderShellHeaderBar shows 'usage · <shortcut>' with no data, and drops the hint when the shortcut is disabled", () => {
525
585
  const withHint = renderShellHeaderBar(buildShellHeaderModel(model({ usage: undefined })), plainTheme, 140, "alt+u");
526
586
  assert.match(withHint.text, /usage · alt\+u$/);
@@ -573,16 +633,14 @@ test("renderShellHeaderRule paints one full-width line in the editor frame color
573
633
  assert.equal(renderShellHeaderRule(plainTheme, -3), "", "negative widths clamp to an empty rule");
574
634
  });
575
635
 
576
- test("the sidebar Status card in the float style is a float panel two rows taller than neon, with a separator row after the header", (t) => {
636
+ test("the rail Status is the same panel in the neon and float card styles", (t) => {
637
+ // Card styles dress transcript cards; the rail panel has its own surface.
577
638
  const theme = withBackground(plainTheme);
578
- const neon = renderShellSidebarBar(model({ review: { state: "reviewing", scope: "first.ts +2 files" } }), theme, 60);
639
+ const data = model({ review: { state: "reviewing", scope: "first.ts +2 files" } });
640
+ const neon = renderShellSidebarBar(data, theme, 60);
579
641
  useCardStyle(t, CARD_STYLE.FLOAT);
580
- const float = renderShellSidebarBar(model({ review: { state: "reviewing", scope: "first.ts +2 files" } }), theme, 60);
581
- assert.equal(float.length, neon.length + 2);
582
- assert.equal(stripAnsi(float[1]!), ` ▎ ✿ Status${" ".repeat(49)}`);
583
- assert.equal(stripAnsi(float[2]!), ` ▎${" ".repeat(57)} `, "a blank separator row follows the header");
584
- assertFloatRows(float, 60);
585
- assert.deepEqual(float.slice(3, -1).map(bodyText), neon.slice(1, -1).map(bodyText));
642
+ assert.deepEqual(renderShellSidebarBar(data, theme, 60), neon);
643
+ assert.match(stripAnsi(neon[0]!), /^▾ CHANGES/);
586
644
  });
587
645
 
588
646
  // The float top bar has full-width painted padding above and below its
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
2
2
  import test from "node:test";
3
3
  import { visibleWidth } from "@earendil-works/pi-tui";
4
4
  import {
5
- CARD_STYLE, CARD_TONE, cardAwaitingResult, cardRunningLine, cardStyle, cardTopRows, markCardResult, panelExtraRows, panelHeaderRow, renderCard, setCardStyle,
5
+ CARD_STYLE, CARD_TONE, cardAwaitingResult, cardRunningLine, cardStyle, cardTopRows, headingFits, markCardResult, panelExtraRows, panelHeaderRow, renderCard, setCardStyle,
6
6
  type Card, type CardStyle, type CardTone,
7
7
  } from "../lib/shell-card.ts";
8
8
  import { stripAnsi } from "../lib/terminal-theme.ts";
@@ -493,3 +493,15 @@ test("a call card awaits its result until pi finishes the row or a result render
493
493
  assert.equal(cardRunningLine(CARD_TONE.WARNING, plainTheme, 20), `│ running…${" ".repeat(8)} │`);
494
494
  for (const width of [0, 1, 2, 3, 4, 5, 6, 7, 8]) assert.ok(visibleWidth(cardRunningLine(CARD_TONE.WARNING, plainTheme, width)) <= width);
495
495
  });
496
+
497
+ test("headingFits says whether a composed subtitle still leaves room for the key hint", () => {
498
+ const card: Card = { title: "Agent status", subtitle: "explore", body: [], tone: CARD_TONE.INFO, glyph: "◎" };
499
+ const hint = "expand";
500
+ // cardTop needs title + glyph, the separator and subtitle, the frame columns and the hinted tail.
501
+ const needed = visibleWidth("◎ Agent status") + 3 + visibleWidth("explore") + 5 + visibleWidth(hint) + 2;
502
+ assert.equal(headingFits(card, hint, needed), true, "exactly enough columns still shows the hint");
503
+ assert.equal(headingFits(card, hint, needed - 1), false, "one column short is a no");
504
+ assert.equal(headingFits(card, undefined, needed - (visibleWidth(hint) + 2)), true, "without a hint exactly the head columns are enough");
505
+ assert.equal(headingFits(card, undefined, needed - (visibleWidth(hint) + 3)), false, "and one column less is still a no");
506
+ assert.equal(headingFits({ ...card, subtitle: undefined }, hint, needed - 9), true, "no subtitle frees its separator and columns");
507
+ });