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
@@ -5,6 +5,7 @@ import { Editor, Image, Key, decodeKittyPrintable, getCapabilities, isKeyRelease
5
5
  import { readClipboardImage, type ClipboardImage } from "../lib/clipboard-image.ts";
6
6
  import { readPastedImagePaths } from "../lib/pasted-image-paths.ts";
7
7
  import { describeAttachment, ImageAttachments } from "../lib/image-attachments.ts";
8
+ import { defaultCacheRoot, ImageDiskCache } from "../lib/image-disk-cache.ts";
8
9
  import { execFile, spawnSync } from "node:child_process";
9
10
  import { openInExternalEditor, type ExternalEditorHost } from "../lib/external-editor.ts";
10
11
  import { existsSync, realpathSync, statSync } from "node:fs";
@@ -14,10 +15,11 @@ import { profilesFilePath, profileRoleEntries, readProfilesFileResult } from "..
14
15
  import { resolveSessionProfile, sessionProfileLabel, sessionProfileModelProfiles } from "../lib/session-profile-freeze.ts";
15
16
  import * as os from "node:os";
16
17
  import { dirname, join, resolve } from "node:path";
17
- import { buildShellHeaderModel, renderShellBar, renderShellBelowInputFloat, renderShellBottomOnlyBar, renderShellHeaderChrome, renderShellSidebarBar, renderShellStatusBar, renderShellStatusSections, renderShellTitleRow, type StatusSection, type StatusTarget, keepNativeWorkingRow, shellEnabled, shellHeaderUsageHit, shellJobsCount, type ShellBarModel, type ShellBarTheme } from "../lib/shell-bar.ts";
18
+ import { buildShellHeaderModel, renderShellBar, renderShellBelowInputFloat, renderShellBottomOnlyBar, renderShellHeaderChrome, renderShellSidebarBar, renderShellStatusBar, renderShellStatusSections, renderShellChromeBar, renderShellChromePad, renderShellTitleRow, type StatusSection, type StatusTarget, keepNativeWorkingRow, shellEnabled, shellHeaderUsageHit, shellJobsCount, type ShellBarModel, type ShellBarTheme } from "../lib/shell-bar.ts";
18
19
  import { CHANGE_STATUS, DIFF_MAX_BYTES, DIFF_MAX_LINES, DIFF_TOO_LARGE, WorktreeChangesTracker, changesDigest, renderChangesWidget, type ChangedFile, type ChangesModel, type FileRevision, type GitRunner, type LineCounter, type WorktreeChanges } from "../lib/shell-changes.ts";
19
20
  import { WorktreeChangesView } from "../lib/shell-changes-view.ts";
20
21
  import { createNativeFullscreenInteraction } from "../lib/native-fullscreen-interaction.ts";
22
+ import { windowsProcessTreeKiller, type ProcessTreeKiller } from "../lib/native-review-cli.ts";
21
23
  import { SessionWorktreeRegistry, resolveSessionWorktree, worktreeGitEnvironment, type WorktreeResolver, type WorktreeIdentity } from "../lib/session-worktree-registry.ts";
22
24
  import { CARD_STYLE, CARD_TONE, cardStyle, panelHeaderRow, renderCard, setCardStyle, type Card, type CardTheme } from "../lib/shell-card.ts";
23
25
  import { resolveCardStyle, writeCardStyle } from "../lib/card-style-policy.ts";
@@ -26,12 +28,14 @@ import { CommandPalette, commandsKey, type CommandPaletteResult } from "../lib/c
26
28
  import { buildCommandPaletteGroups } from "../lib/command-palette-catalog.ts";
27
29
  import { buildKeymapRows } from "../lib/keymaps-customize.ts";
28
30
  import { discoverYoloUiAdapter, MODE_STATUS_KEY, YOLO_DISPLAY, YOLO_STATUS_KEY, type YoloDisplay, type YoloUiAdapter } from "../lib/yolo-session-policy.ts";
31
+ import { discoverRddModeControl, type RddModeControl } from "../lib/rdd-mode-control.ts";
32
+ import { NATIVE_REVIEW_MODE_SOURCE } from "../lib/native-review-cli.ts";
29
33
  import { VisualCustomizeView, type CustomizeCategory, type CustomizeRow, type ProfileActions } from "../lib/visual-customize-view.ts";
30
34
  import { deleteVisualProfile, getVisualProfile, listVisualProfiles, resetVisualProfiles, saveVisualProfile } from "../lib/visual-profiles.ts";
31
35
  import { gaugePaintFor } from "../lib/gauge-theme.ts";
32
36
  import type { GaugePaint } from "../lib/shell-gauge.ts";
33
37
  import { sourcePalettePreview } from "../lib/theme-customization.ts";
34
- import { applyVisualPreset, DEFAULT_VISUAL_SETTINGS, DENSITY, HEADER_PLACEMENT, STATUS_PLACEMENT, VISUAL_PRESET, VISUAL_SECTION_KEYS, resolveVisualSettings, visualPresetOf, writeVisualSettings, type VisualPreset } from "../lib/visual-customization-policy.ts";
38
+ import { applyVisualPreset, CHROME_SURFACE, DEFAULT_VISUAL_SETTINGS, DENSITY, HEADER_PLACEMENT, STATUS_PLACEMENT, VISUAL_PRESET, VISUAL_SECTION_KEYS, resolveVisualSettings, visualPresetOf, writeVisualSettings, type VisualPreset } from "../lib/visual-customization-policy.ts";
35
39
  import { BANNER_COLORS, DEFAULT_BANNER_CONFIG, readBannerConfig, readBannerConfigForEdit, writeBannerConfig } from "./startup-banner.ts";
36
40
  import { commandKeymapId, commandKeymapIds, effectiveKey, keymapCommand, keymapLabel, keymapSavedNotice, loadKeymaps, prepareKeymapChange, writeKeymaps, type KeymapBindings, type PiKeybindings } from "../lib/keymaps.ts";
37
41
  import { GentleAiDevBinaryOverrideError, resolveGentleAiDevBinaryOverride } from "../lib/gentle-ai-binary.ts";
@@ -46,6 +50,7 @@ import { isNanAdaptiveReasoningModel } from "../lib/nan-provider.ts";
46
50
  import { resolveAnimationPolicy, writeAnimationPolicy, type AnimationPolicy } from "../lib/animation-policy.ts";
47
51
  import { resolveVimPolicy, writeVimPolicy, type VimPolicy } from "../lib/vim-policy.ts";
48
52
  import { resolveHistoryCapture, writeHistoryCapturePolicy } from "../lib/history-capture-policy.ts";
53
+ import { HERDR_TASK_SUMMARY_CHANGED, resolveHerdrTaskSummarySettings, writeHerdrTaskSummarySettings } from "../lib/herdr-task-summary-policy.ts";
49
54
  import { createRequire } from "node:module";
50
55
  import { createVimEditorAdapter, isAuditedPiEditorVersion } from "../lib/vim-editor-adapter.ts";
51
56
  import { VimNormalEngine } from "../lib/vim-normal-engine.ts";
@@ -128,7 +133,7 @@ import { accountIdFromToken, CODEX_PROVIDER, CODEX_USAGE_URL, NAN_PROVIDER, NAN_
128
133
  import { UsageView } from "../lib/shell-usage-view.ts";
129
134
  import { releaseSidebarHover, setSidebarHover, sidebarHeader, sidebarPart, sidebarState, sidebarStatusBar, VISUAL_SETTINGS_CHANGED, type SidebarRail } from "../lib/shell-sidebar.ts";
130
135
  import { installSidebar, invalidateSidebar, narrowStatusOwner, SIDEBAR_BREAKPOINT, STATUS_OWNER } from "../lib/shell-sidebar-layout.ts";
131
- import { panelSheetBackHit, renderPanelSheet, renderWorkRow, workRowLead } from "../lib/shell-panel.ts";
136
+ import { panelSheetBackHit, renderPanelSheet, renderWorkRow, setChromeSurface, workRowLead } from "../lib/shell-panel.ts";
132
137
  import { installPagePaint, type PageTheme } from "../lib/shell-page.ts";
133
138
  import { layoutSchematic } from "../lib/visual-layout-preview.ts";
134
139
  import { collectSessionStats, type SessionStats } from "../lib/shell-stats.ts";
@@ -1633,29 +1638,81 @@ function renderDoubleEscCancelReport(
1633
1638
  const CHANGES_WIDGET_KEY = "gentle-shell-changes";
1634
1639
  const HEADER_WIDGET_KEY = "gentle-shell-below-input-header";
1635
1640
  const CHANGES_COMMAND_NAME = "gentle:changes";
1641
+ const IMAGES_COMMAND_NAME = "gentle:images";
1636
1642
  const CHANGES_POLL_DEFAULT_MS = 2000;
1637
1643
  const GIT_TIMEOUT_MS = 5000;
1638
1644
  const COMMANDS_COMMAND_NAME = "gentle:commands";
1639
1645
 
1640
- export function shellGitRunner(cwd: string, env: NodeJS.ProcessEnv = process.env, run: typeof execFile = execFile, maxBuffer = Infinity): GitRunner {
1646
+ // If taskkill cannot run (AppLocker, a broken PATH) the direct child can exit
1647
+ // while a descendant still holds the inherited pipes, which keeps execFile from
1648
+ // calling back; cut them after this grace so the scan still settles.
1649
+ const GIT_TREE_KILL_GRACE_MS = 1_000;
1650
+
1651
+ export function shellGitRunner(cwd: string, env: NodeJS.ProcessEnv = process.env, run: typeof execFile = execFile, maxBuffer = Infinity, killProcessTree: ProcessTreeKiller | undefined = process.platform === "win32" ? windowsProcessTreeKiller : undefined): GitRunner {
1641
1652
  // Pi exec cannot replace the inherited environment. Use argv directly and
1642
1653
  // a complete sanitized environment for discovery, status, and lazy diffs.
1643
1654
  const childEnv = worktreeGitEnvironment(env);
1655
+ // A timed-out Git scan on Windows is more than one process: `git` hands the
1656
+ // status work to a descendant, and that descendant survives the direct child
1657
+ // Node itself kills, so a large repository whose scan passes the timeout
1658
+ // leaks another orphaned git.exe on every poll until physical memory is
1659
+ // exhausted (#927). Windows therefore owns the deadline below, so the tree
1660
+ // kill lands while the parent is still alive for taskkill to walk; everywhere
1661
+ // else execFile's own timeout stays exactly as it was.
1662
+ const treeKiller = killProcessTree;
1644
1663
  return (args) => new Promise((resolve) => {
1645
- run("git", ["-C", cwd, ...args], {
1646
- env: childEnv,
1647
- encoding: "utf8",
1648
- shell: false,
1649
- windowsHide: true,
1650
- timeout: GIT_TIMEOUT_MS,
1651
- // Pi exec accumulates output without a maxBuffer cap. In particular,
1652
- // large porcelain inventories must not become partial successful scans.
1653
- // Only a single diff passes a bound, and is told when it hit it.
1654
- maxBuffer,
1655
- }, (error, stdout) => {
1656
- if ((error as { code?: unknown } | null)?.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") return resolve({ stdout, code: 1, truncated: true });
1657
- resolve({ stdout, code: error ? typeof error.code === "number" ? error.code : 1 : 0 });
1658
- });
1664
+ let deadline: ReturnType<typeof setTimeout> | undefined;
1665
+ let grace: ReturnType<typeof setTimeout> | undefined;
1666
+ let settled = false;
1667
+ // A scan that passed its deadline is a failed scan, never a partial
1668
+ // success, even if the direct child exited 0 before its pipes closed.
1669
+ let timedOut = false;
1670
+ const settle = (error: { code?: unknown; killed?: boolean } | null, stdout: string): void => {
1671
+ settled = true;
1672
+ if (deadline !== undefined) clearTimeout(deadline);
1673
+ if (grace !== undefined) clearTimeout(grace);
1674
+ if (error?.code === "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") { resolve({ stdout, code: 1, truncated: true }); return; }
1675
+ const code = timedOut ? 1 : error ? typeof error.code === "number" ? error.code : 1 : 0;
1676
+ // Without a tree killer execFile owns the timeout and reports its kill on the error.
1677
+ resolve({ stdout, code, ...(timedOut || (treeKiller === undefined && error?.killed) ? { timedOut: true } : {}) });
1678
+ };
1679
+ let child: ReturnType<typeof execFile>;
1680
+ try {
1681
+ child = run("git", ["-C", cwd, ...args], {
1682
+ env: childEnv,
1683
+ encoding: "utf8",
1684
+ shell: false,
1685
+ windowsHide: true,
1686
+ ...(treeKiller === undefined ? { timeout: GIT_TIMEOUT_MS } : {}),
1687
+ // Pi exec accumulates output without a maxBuffer cap. In particular,
1688
+ // large porcelain inventories must not become partial successful scans.
1689
+ // Only a single diff passes a bound, and is told when it hit it.
1690
+ maxBuffer,
1691
+ }, (error, stdout) => settle(error, stdout));
1692
+ } catch (error) {
1693
+ // A spawn that throws (invalid options, an injected runner) is a failed scan.
1694
+ settle(error as { code?: unknown }, "");
1695
+ return;
1696
+ }
1697
+ // The callback may already have settled a synchronous run (a fake in
1698
+ // tests, a spawn error), so only arm the deadline while it is pending.
1699
+ if (settled || treeKiller === undefined || child?.pid === undefined) return;
1700
+ const pid = child.pid;
1701
+ deadline = setTimeout(() => {
1702
+ timedOut = true;
1703
+ // taskkill walks the tree from a live parent. If the direct child
1704
+ // already exited, only a descendant can be holding the inherited
1705
+ // pipes, and a PID-based kill would just report "process not found";
1706
+ // the grace below still cuts those pipes so the scan can settle.
1707
+ if (child.exitCode === null && child.signalCode === null) treeKiller(pid);
1708
+ grace = setTimeout(() => {
1709
+ if (child.exitCode === null && child.signalCode === null) child.kill();
1710
+ child.stdout?.destroy();
1711
+ child.stderr?.destroy();
1712
+ }, GIT_TREE_KILL_GRACE_MS);
1713
+ grace.unref?.();
1714
+ }, GIT_TIMEOUT_MS);
1715
+ deadline.unref?.();
1659
1716
  });
1660
1717
  }
1661
1718
 
@@ -1663,7 +1720,7 @@ export async function loadFileDiff(git: GitRunner, file: ChangedFile): Promise<s
1663
1720
  const args = file.status === CHANGE_STATUS.UNTRACKED ? ["diff", "--no-index", "--", "/dev/null", file.path] : ["diff", "HEAD", "--", file.path];
1664
1721
  const result = await git(args);
1665
1722
  if (result.truncated || result.stdout.length > DIFF_MAX_BYTES || result.stdout.split("\n", DIFF_MAX_LINES + 2).length > DIFF_MAX_LINES + 1) return DIFF_TOO_LARGE;
1666
- return result.code === 0 || result.code === 1 ? result.stdout : "";
1723
+ return !result.timedOut && (result.code === 0 || result.code === 1) ? result.stdout : "";
1667
1724
  }
1668
1725
 
1669
1726
  // Untracked files have no numstat; count their lines without reading past the diff bound.
@@ -2000,6 +2057,7 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2000
2057
  const profileReader = createActiveProfileReader(env);
2001
2058
  const deps: ShellDeps = { ...defaultShellDeps, activeProfile: profileReader, ...overrides };
2002
2059
  let closeCustomize: (() => void) | undefined;
2060
+ let customizeGeneration = 0;
2003
2061
  let profilePoll: ReturnType<typeof setInterval> | undefined;
2004
2062
  const stopProfilePoll = () => {
2005
2063
  if (profilePoll) clearInterval(profilePoll);
@@ -2199,21 +2257,29 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2199
2257
  const hint = keyHint("app.tools.expand", options.expanded ? "collapse" : "expand");
2200
2258
  return cardComponent({ title: "Gentle AI", subtitle: "review preflight", body, tone: CARD_TONE.INFO }, theme, { expanded: options.expanded, previewRows: 3, hint });
2201
2259
  });
2202
- // Which IDE chrome the fullscreen shell draws: "wide" while the rail owns the
2203
- // host, "narrow" (mobile) below the rail breakpoint or with Status at the
2204
- // bottom (the minimal edition), undefined for the below-input header, a
2205
- // hidden Status, and regular mode.
2260
+ // The attached narrow fullscreen layout owns the mobile editor and work row
2261
+ // for every header placement. Wide split uses the IDE chrome beside the rail;
2262
+ // wide top and below-input keep their existing chrome-bar paths.
2206
2263
  const chromeMode = (tui: TUI): "wide" | "narrow" | undefined => {
2207
- if (visualSettings.headerPlacement !== "top" || (tui as TUI & { mode?: string }).mode !== "fullscreen" || !tui.terminal) return undefined;
2264
+ if ((tui as TUI & { mode?: string }).mode !== "fullscreen" || !tui.terminal) return undefined;
2208
2265
  const state = sidebarState(tui);
2209
- if (state.active && state.ownsHost?.()) return "wide";
2210
- // The compact chrome replaces the bottom bar, so it only applies while the
2211
- // layout that draws its title row and status bar is installed.
2266
+ if (state.active && state.ownsHost?.()) return visualSettings.headerPlacement === "split" ? "wide" : undefined;
2267
+ // Do not suppress native widgets unless the host can actually draw the bar.
2212
2268
  if (!state.layoutAttached?.()) return undefined;
2269
+ return tui.terminal.columns < SIDEBAR_BREAKPOINT ? "narrow" : undefined;
2270
+ };
2271
+ // Where the chrome bars draw (beside the rail, or with Status hidden or at the
2272
+ // bottom, outside the mobile chrome): every placement there shares the bar
2273
+ // design and the titled-rule editor.
2274
+ // `drawn` asks whether the rail actually painted in the last layout pass: the
2275
+ // editor and footer render after it, while the header renders during it.
2276
+ const chromeBarsShown = (tui: TUI, drawn = false): boolean => {
2277
+ if ((tui as TUI & { mode?: string }).mode !== "fullscreen" || !tui.terminal || chromeMode(tui) === "narrow") return false;
2213
2278
  const placement = visualSettings.statusPlacement;
2214
- // "bottom" (the Light preset) is the minimal edition: the phone layout at any width, no rail.
2215
- if (placement === "bottom") return "narrow";
2216
- return tui.terminal.columns < SIDEBAR_BREAKPOINT && (placement === "auto" || placement === "right") ? "narrow" : undefined;
2279
+ if (placement === "hidden" || placement === "bottom") return true;
2280
+ // The rail owns the host (layout installed) only at 140 columns or wider, with Status auto or right.
2281
+ const state = sidebarState(tui);
2282
+ return Boolean(state.ownsHost?.() && (!drawn || state.active));
2217
2283
  };
2218
2284
  // The live-work digests the mobile work row folds, honoring the Todos switch.
2219
2285
  const workParts = (tui: TUI) => {
@@ -2247,7 +2313,16 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2247
2313
  return [...(row ? [row] : []), ...(cardHidden ? (state.parts.get("agents")?.alert?.(width) ?? []) : [])];
2248
2314
  };
2249
2315
  // The rail's sections as a full-width sheet: /gentle:panel, or a tap on the mobile work row.
2250
- const openPanelSheet = (ctx: ExtensionContext) =>
2316
+ // The sheet leaves the editor's [ Panel ] clickable, so an open sheet is reused
2317
+ // instead of stacking another overlay per click.
2318
+ let openSheet: Promise<null | undefined> | undefined;
2319
+ const openPanelSheet = (ctx: ExtensionContext) => {
2320
+ if (openSheet) return openSheet;
2321
+ const opened = showPanelSheet(ctx).finally(() => { if (openSheet === opened) openSheet = undefined; });
2322
+ openSheet = opened;
2323
+ return opened;
2324
+ };
2325
+ const showPanelSheet = (ctx: ExtensionContext) =>
2251
2326
  ctx.ui.custom<null>(
2252
2327
  (tui, theme, _keybindings, done) => {
2253
2328
  const close = withOverlayRepaint(tui, done);
@@ -2335,6 +2410,10 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2335
2410
  let prompt: GentlePromptEditor | undefined;
2336
2411
  // Images pasted into the current draft; emptied on every submit.
2337
2412
  const imageAttachments = new ImageAttachments();
2413
+ // Opt-in disk cache for tools that need a real file path. Off unless the user
2414
+ // asks for it: `GENTLE_PI_IMAGES_DISK_CACHE=session`. The path is never put in
2415
+ // the prompt; it is readable through /gentle:images only.
2416
+ const imagesDiskCachePolicy = (env.GENTLE_PI_IMAGES_DISK_CACHE ?? "off").trim().toLowerCase() === "session" ? "session" : "off";
2338
2417
  // Set by abortAndDispatchQueued via dispatchQueuedText when an Esc aborts
2339
2418
  // a turn with a non-empty queue; sent exactly once, from agent_settled,
2340
2419
  // once the aborted run has fully settled (issue #1218). Several aborts
@@ -2369,10 +2448,12 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2369
2448
  ctx.ui.notify(`vim: ${result.policy} (decided by ${source})${result.malformed ? "; malformed or unreadable file, falling back to off" : ""}. ${state}.`, result.malformed || (effective !== undefined && effective !== result.policy) ? "warning" : "info");
2370
2449
  };
2371
2450
  let visualSettings = resolveVisualSettings(animationOptions).settings;
2451
+ setChromeSurface(visualSettings.surface);
2372
2452
  let sidebarTui: TUI | undefined;
2373
2453
  let groupedChangesOwner: (width: number) => boolean = () => false;
2374
2454
  const refreshVisual = () => {
2375
2455
  visualSettings = resolveVisualSettings(animationOptions).settings;
2456
+ setChromeSurface(visualSettings.surface);
2376
2457
  if (currentContext && changes) showChanges(currentContext, changes.model, visualSettings.visibility.changes, (width) => groupedChangesOwner(width));
2377
2458
  if (sidebarTui?.terminal) sidebarState(sidebarTui).visibility = { todo: visualSettings.visibility.todo };
2378
2459
  renderHost?.invalidateSidebar?.();
@@ -2449,6 +2530,16 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2449
2530
  },
2450
2531
  });
2451
2532
  pi.on("session_start", async (_event, ctx) => {
2533
+ customizeGeneration++;
2534
+ if (imagesDiskCachePolicy === "session") {
2535
+ const cacheRoot = defaultCacheRoot(env);
2536
+ try {
2537
+ ImageDiskCache.sweepStale(cacheRoot, 7 * 24 * 60 * 60 * 1000);
2538
+ } catch {
2539
+ // A sweep that cannot run must never block the session.
2540
+ }
2541
+ imageAttachments.setCache(new ImageDiskCache({ root: cacheRoot, sessionId: ctx.sessionManager.getSessionId() }));
2542
+ }
2452
2543
  closeCustomize?.();
2453
2544
  runningJobs = undefined;
2454
2545
  adaptiveReasoningNotices.clear();
@@ -2469,6 +2560,7 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2469
2560
  applyCardContent();
2470
2561
  if (!ctx.hasUI) return;
2471
2562
  visualSettings = resolveVisualSettings(animationOptions).settings;
2563
+ setChromeSurface(visualSettings.surface);
2472
2564
  if (!overrides.activeProfile) {
2473
2565
  profileReader.bind(ctx.cwd, deps.resolveWorktree, ctx.sessionManager.getSessionId());
2474
2566
  const sessionId = ctx.sessionManager.getSessionId();
@@ -2522,10 +2614,11 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2522
2614
  const state = sidebarState(tui);
2523
2615
  return Boolean(state.statusHidden?.() || state.headerOwnsStatus?.() || (state.active && state.ownsHost?.()));
2524
2616
  };
2525
- groupedChangesOwner = (width) => belowFloat(width, !footerSuppressed()) !== undefined;
2617
+ // Chrome bars never group Changes: they keep their own row (or the rail).
2618
+ groupedChangesOwner = (width) => !narrowChrome() && !belowChrome() && belowFloat(width, !footerSuppressed()) !== undefined;
2526
2619
  const bottomBar = {
2527
2620
  ...bottom,
2528
- render: (width: number) => belowFloat(width, true)?.rows ?? (statusOwner() === STATUS_OWNER.BOTTOM ? renderShellBottomOnlyBar(footerModel(), theme, width, usageShortcutKey, visualSettings, undefined, gaugePaint(ctx)) : bottom.render(width)),
2621
+ render: (width: number) => bottomStatus() ? [] : belowFloat(width, true)?.rows ?? (statusOwner() === STATUS_OWNER.BOTTOM ? renderShellBottomOnlyBar(footerModel(), theme, width, usageShortcutKey, visualSettings, undefined, gaugePaint(ctx)) : bottom.render(width)),
2529
2622
  handleMouse(event: Parameters<NonNullable<SidebarRail["handleMouse"]>>[0]) {
2530
2623
  if (footerSuppressed() || event.type !== "click" || event.button !== "left") return undefined;
2531
2624
  const chrome = belowFloat(event.width, true);
@@ -2536,21 +2629,26 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2536
2629
  };
2537
2630
  // The rail's Status is a panel: Changes, Review and Integrations, then
2538
2631
  // the key hints that close the rail (the section headers carry none).
2539
- const railHints = [todoKey ? `${todoKey} todos` : "", usageShortcutKey ? `${usageShortcutKey} usage` : "", "/ commands"].filter(Boolean).join(" · ");
2632
+ // The rail carries no key hints row: the Todos header shows its own collapse
2633
+ // key, and the bars carry the usage key.
2634
+ const railHints = undefined;
2540
2635
  // Status sections are clickable like the other rail sections: a header
2541
2636
  // folds its section, the Changes row opens /gentle:changes.
2542
2637
  const statusCollapsed = new Set<StatusSection>();
2543
2638
  let statusHover: StatusSection | "open-changes" | undefined;
2544
2639
  // Keyed by width: the rail and the full-width panel sheet render the same part.
2545
2640
  const statusTargets = new Map<number, StatusTarget[]>();
2641
+ const statusGroups = new Map<number, { groups: Array<{ start: number; end: number }>; loose: number[] }>();
2546
2642
  const statusCard: Component = {
2547
2643
  render(width: number) {
2548
- // The rail drops what the wide chrome's title row and status bar show
2549
- // (session, permission mode) only while that chrome actually draws.
2550
- const view = statusCardVisible() && visualSettings.headerPlacement === "top"
2644
+ // Beside the rail every header placement draws a chrome bar that shows
2645
+ // the permission mode with its icon, so the rail never repeats the raw
2646
+ // mode statuses; the session-and-statuses view stays for other hosts.
2647
+ const view = statusCardVisible()
2551
2648
  ? renderShellStatusSections(withStats(footerModel()), theme, width, visualSettings, railHints, { collapsed: statusCollapsed, hovered: statusHover })
2552
2649
  : renderShellStatusSections(withStats({ ...footerModel(), integrations: undefined, permission: undefined }), theme, width, visualSettings, railHints, { session: true, collapsed: statusCollapsed, hovered: statusHover });
2553
2650
  statusTargets.set(width, view.targets);
2651
+ statusGroups.set(width, { groups: view.groups, loose: view.loose });
2554
2652
  return view.lines;
2555
2653
  },
2556
2654
  invalidate() {
@@ -2605,6 +2703,7 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2605
2703
  return JSON.stringify([footerStatus.key(), [...statusCollapsed], statusHover ?? "", stats ? [stats.turns, stats.toolCalls, stats.cost, stats.spanMs, spend?.runs, spend?.tokens, spend?.cost] : ""]);
2606
2704
  },
2607
2705
  render: (width) => statusRegion.render(width),
2706
+ cardGroups: (width) => statusGroups.get(width),
2608
2707
  handleMouse: (event) => statusRegion.handleMouse(event),
2609
2708
  invalidate: () => statusRegion.invalidate(),
2610
2709
  });
@@ -2679,40 +2778,70 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2679
2778
  // effort, context, cost, usage) plus session identity and the jobs count
2680
2779
  // when Status is absent. Opaque statuses and working state stay excluded.
2681
2780
  const headerBar = (width: number) => renderShellHeaderChrome(buildShellHeaderModel(footerModel(), !statusCardVisible() && (statusOwner() === STATUS_OWNER.HEADER || visualSettings.statusPlacement === "hidden")), theme, width, usageShortcutKey, visualSettings, gaugePaint(ctx));
2682
- // With the rail shown and the header on top, the chrome splits like an
2781
+ // With the rail shown and a split header, the chrome splits like an
2683
2782
  // IDE: a title row with the project identity above, and a status bar
2684
2783
  // with the per-frame counters below (design/shell-rework/02-proposal.html).
2685
- const ideChrome = () => statusCardVisible() && visualSettings.headerPlacement === "top";
2686
- // Mobile (design/shell-rework/05-mobile.html): below the rail breakpoint the
2687
- // same split stays, with the model in the title row and live work folded
2688
- // into one row above the editor.
2784
+ // A top header instead keeps the whole header row above the conversation.
2785
+ const ideChrome = () => statusCardVisible() && visualSettings.headerPlacement === "split";
2786
+ // The split title row and status bar also stay with Status hidden.
2787
+ const splitChrome = () => ideChrome() || (barChrome() && visualSettings.headerPlacement === "split");
2788
+ // Beside the rail the below-input bar is the full-width bottom row, like
2789
+ // split's status bar; the widget under the input steps aside while the
2790
+ // rail is actually drawn.
2791
+ const belowRail = () => fullscreen() && visualSettings.headerPlacement === "below-input" && statusCardVisible();
2792
+ // Beside the rail, the top and below-input headers draw the split status
2793
+ // bar's design (a chrome bar) with a margin row toward the content.
2794
+ // They apply beside the rail and with Status hidden (no rail at all); the
2795
+ // mobile chrome keeps phones and the minimal edition.
2796
+ const fullscreen = () => (tui as TUI & { mode?: string }).mode === "fullscreen";
2797
+ const barChrome = () => chromeBarsShown(tui);
2798
+ // Status at the bottom of a wide terminal: the chrome bars close the screen, and the
2799
+ // previous compact bottom bar steps aside ([ Panel ] opens the Status sections).
2800
+ const bottomStatus = () => barChrome() && visualSettings.statusPlacement === "bottom";
2801
+ const topChrome = () => barChrome() && visualSettings.headerPlacement === "top";
2802
+ // The below-input widget renders after the layout pass, so it can also
2803
+ // require the rail to be actually drawn (a rail that does not fit groups
2804
+ // Changes into the float footer as before).
2805
+ const belowChrome = () => barChrome() && visualSettings.headerPlacement === "below-input" && (visualSettings.statusPlacement === "hidden" || visualSettings.statusPlacement === "bottom" || sidebarState(tui).active === true);
2806
+ // Without the rail the bar also counts the running jobs, as the mobile status bar does.
2807
+ const chromeBar = (width: number) => renderShellChromeBar(footerModel(), theme, width, usageShortcutKey, visualSettings, gaugePaint(ctx), { jobs: !statusCardVisible() });
2808
+ const topHeader = (width: number) => chromeBar(width);
2809
+ // Comfortable centers the split title row between two margin rows.
2810
+ const titleRows = (width: number) => visualSettings.density === "comfortable"
2811
+ ? [renderShellChromePad(theme, width), renderShellTitleRow(footerModel(), theme, width), renderShellChromePad(theme, width)]
2812
+ : [renderShellTitleRow(footerModel(), theme, width)];
2813
+ // Mobile keeps the same work row and editor for all placements. Only split
2814
+ // moves model identity to the title; top and below-input use one shared bar.
2689
2815
  const narrowChrome = () => chromeMode(tui) === "narrow";
2816
+ const narrowSplit = () => narrowChrome() && visualSettings.headerPlacement === "split";
2817
+ const narrowTop = () => narrowChrome() && visualSettings.headerPlacement === "top";
2818
+ const narrowBelow = () => narrowChrome() && visualSettings.headerPlacement === "below-input";
2690
2819
  if (tui.terminal) {
2691
2820
  sidebarState(tui).compactWork = narrowChrome;
2692
- // Both IDE chromes draw a status bar that shows the permission mode.
2693
- sidebarState(tui).statusBarShowsMode = () => chromeMode(tui) !== undefined;
2821
+ // The IDE chromes and the chrome bars show the permission mode with its icon.
2822
+ sidebarState(tui).statusBarShowsMode = () => chromeMode(tui) !== undefined || topChrome() || belowChrome() || splitChrome();
2694
2823
  }
2695
- const statusBarChrome = (width: number) => narrowChrome()
2824
+ const statusBarChrome = (width: number) => narrowSplit()
2696
2825
  ? renderShellStatusBar(footerModel(), theme, width, usageShortcutKey, { ...visualSettings, visibility: { ...visualSettings.visibility, modelDetails: false } }, gaugePaint(ctx), { jobs: true })
2697
- : renderShellStatusBar(footerModel(), theme, width, usageShortcutKey, visualSettings, gaugePaint(ctx));
2826
+ : chromeBar(width);
2698
2827
  const disposeHeader = sidebarHeader(tui, {
2699
2828
  digest: () => footerStatus.key(),
2700
- render: (width) => ideChrome() ? [renderShellTitleRow(footerModel(), theme, width)] : narrowChrome() ? [renderShellTitleRow(footerModel(), theme, width, { model: true })] : headerBar(width).rows,
2829
+ render: (width) => splitChrome() ? titleRows(width) : narrowSplit() ? [renderShellTitleRow(footerModel(), theme, width, { model: true })] : (narrowTop() || topChrome()) ? topHeader(width).rows : headerBar(width).rows,
2701
2830
  invalidate() {},
2702
2831
  handleMouse(event) {
2703
- if (ideChrome() || narrowChrome() || event.type !== "click" || event.button !== "left") return undefined;
2704
- if (!shellHeaderUsageHit(headerBar(event.width), event.x, event.y)) return undefined;
2832
+ if (splitChrome() || narrowSplit() || narrowBelow() || event.type !== "click" || event.button !== "left") return undefined;
2833
+ if (!shellHeaderUsageHit(narrowTop() || topChrome() ? topHeader(event.width) : headerBar(event.width), event.x, event.y)) return undefined;
2705
2834
  void openUsage(ctx);
2706
2835
  return { handled: true, render: true };
2707
2836
  },
2708
2837
  });
2709
2838
  const disposeStatusBar = sidebarStatusBar(tui, {
2710
2839
  digest: () => footerStatus.key(),
2711
- render: (width) => ideChrome() || narrowChrome() ? statusBarChrome(width).rows : [],
2840
+ render: (width) => splitChrome() || narrowSplit() || narrowBelow() ? statusBarChrome(width).rows : belowRail() ? chromeBar(width).rows : [],
2712
2841
  invalidate() {},
2713
2842
  handleMouse(event) {
2714
- if (!(ideChrome() || narrowChrome()) || event.type !== "click" || event.button !== "left") return undefined;
2715
- if (!shellHeaderUsageHit(statusBarChrome(event.width), event.x, event.y)) return undefined;
2843
+ if (!(splitChrome() || narrowSplit() || narrowBelow() || belowRail()) || event.type !== "click" || event.button !== "left") return undefined;
2844
+ if (!shellHeaderUsageHit(belowRail() ? chromeBar(event.width) : statusBarChrome(event.width), event.x, event.y)) return undefined;
2716
2845
  void openUsage(ctx);
2717
2846
  return { handled: true, render: true };
2718
2847
  },
@@ -2727,13 +2856,21 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2727
2856
  let disposed = false;
2728
2857
  ctx.ui.setWidget(HEADER_WIDGET_KEY, () => ({
2729
2858
  render(width: number) {
2730
- if (disposed) return [];
2859
+ if (disposed || narrowChrome()) return [];
2860
+ if (belowRail() && sidebarState(tui).active) return [];
2861
+ if (belowChrome()) return chromeBar(width).rows;
2731
2862
  if (belowFloat(width, false)) return footerSuppressed() ? widgetChrome(width).rows : [];
2732
2863
  return belowHeader() ? headerBar(width).rows : [];
2733
2864
  },
2734
2865
  invalidate() {},
2735
2866
  handleMouse(event) {
2736
- if (disposed) return undefined;
2867
+ if (disposed || narrowChrome()) return undefined;
2868
+ if (belowRail() && sidebarState(tui).active) return undefined;
2869
+ if (belowChrome()) {
2870
+ if (event.type !== "click" || event.button !== "left" || !shellHeaderUsageHit(chromeBar(event.width), event.x, event.y)) return undefined;
2871
+ void openUsage(ctx);
2872
+ return { handled: true, render: true };
2873
+ }
2737
2874
  const grouped = belowFloat(event.width, false);
2738
2875
  if ((grouped ? !footerSuppressed() : !belowHeader()) || event.type !== "click" || event.button !== "left") return undefined;
2739
2876
  if (!shellHeaderUsageHit(widgetChrome(event.width), event.x, event.y)) return undefined;
@@ -2768,8 +2905,12 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2768
2905
  return [truncateToWidth(theme.fg("muted", shellJobsCount(compactRunningJobs.length)), width, "…")];
2769
2906
  }
2770
2907
  const rows = part.render(width);
2771
- // Preserve a shrinkable exterior dock row, outside prompt/completion geometry.
2772
- return rows.length === 0 && (tui as TUI & { mode?: string }).mode === "fullscreen"
2908
+ // Preserve a shrinkable exterior dock row, outside prompt/completion geometry,
2909
+ // only while the float prompt ends the dock. A titled-rule editor (top, split,
2910
+ // mobile) keeps its own bottom row as the margin, and a below-input header follows it.
2911
+ // A split status bar follows the prompt too, so it never needs the exterior row.
2912
+ const promptEndsDock = !(chromeMode(tui) !== undefined || chromeBarsShown(tui, true) || belowHeader());
2913
+ return rows.length === 0 && (tui as TUI & { mode?: string }).mode === "fullscreen" && promptEndsDock
2773
2914
  && resolvePromptLayout(width, cardStyle(), theme.bg?.bind(theme)).background ? [""] : rows;
2774
2915
  },
2775
2916
  handleMouse(event: Parameters<NonNullable<SidebarRail["handleMouse"]>>[0]) {
@@ -2788,8 +2929,10 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2788
2929
  },
2789
2930
  { now: () => deps.now(), doubleEscCancelEnabled: () => doubleEscCancelPolicy === "on", dispatchQueuedText: (text) => { pendingQueuedText = pendingQueuedText === undefined ? text : `${pendingQueuedText}\n\n${text}`; }, vimRuntimeVersion: deps.vimRuntimeVersion, attachments: imageAttachments, readClipboardImage: () => (deps.readClipboardImage ?? readClipboardImage)(),
2790
2931
  // The editor joins the wide IDE chrome while the rail owns the host with the header on top.
2791
- panelChrome: (tui) => chromeMode(tui) !== undefined,
2792
- panelButton: (tui) => chromeMode(tui) === "narrow",
2932
+ panelChrome: (tui) => chromeMode(tui) !== undefined || chromeBarsShown(tui, true),
2933
+ // Without the rail, [ Panel ] opens the Status sections: the mobile chrome,
2934
+ // and a wide terminal with Status at the bottom.
2935
+ panelButton: (tui) => chromeMode(tui) === "narrow" || (visualSettings.statusPlacement === "bottom" && chromeBarsShown(tui, true)),
2793
2936
  topRows: (tui, width, hovered) => panelTopRows(tui, width, ctx.ui.theme, hovered),
2794
2937
  // The mobile work row is the first top row; a tap on it opens the leading section's view.
2795
2938
  onTopRowClick: (tui, index) => { if (chromeMode(tui) === "narrow" && index === 0) openWorkRow(tui, ctx); },
@@ -2832,7 +2975,10 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2832
2975
  return { action: "transform", text: submitted.text, images: [...(event.images ?? []), ...submitted.images] };
2833
2976
  });
2834
2977
  pi.on("session_shutdown", (_event, ctx) => {
2978
+ customizeGeneration++;
2835
2979
  disposeFooter?.();
2980
+ imageAttachments.dispose();
2981
+ imageAttachments.setCache(undefined);
2836
2982
  closeCustomize?.();
2837
2983
  if (review) {
2838
2984
  review = undefined;
@@ -2882,6 +3028,21 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2882
3028
  if (failed > 0) ctx.ui.notify(`Git status failed for ${failed} ${failed === 1 ? "root" : "roots"}; ${failed === 1 ? "its" : "their"} changes are not listed.`, "warning");
2883
3029
  await showChangesOverlay(ctx, { loadDiff: (root, file) => loadFileDiff(deps.gitRunner(root, DIFF_MAX_BYTES), file), worktrees: () => tracker.worktrees, refresh: () => tracker.refresh(), apply: applyChanges, pollMs: changesPollMs(env) });
2884
3030
  };
3031
+ pi.registerCommand(IMAGES_COMMAND_NAME, {
3032
+ description: "List the on-disk paths of images pasted in this draft (needs GENTLE_PI_IMAGES_DISK_CACHE=session).",
3033
+ handler: async (_args, ctx) => {
3034
+ if (imagesDiskCachePolicy !== "session") {
3035
+ ctx.ui.notify("Image disk cache is off. Set GENTLE_PI_IMAGES_DISK_CACHE=session to enable it.", "info");
3036
+ return;
3037
+ }
3038
+ const cached = imageAttachments.cachedPaths(prompt?.getText() ?? "");
3039
+ if (cached.length === 0) {
3040
+ ctx.ui.notify("No pasted images are cached in this draft.", "info");
3041
+ return;
3042
+ }
3043
+ for (const entry of cached) ctx.ui.notify(`${entry.token} ${entry.path}`, "info");
3044
+ },
3045
+ });
2885
3046
  pi.registerCommand(CHANGES_COMMAND_NAME, {
2886
3047
  description: "Browse uncommitted Git changes (working tree vs HEAD, untracked included) in this session's repository and its subagents' worktrees. Press o to open $EDITOR.",
2887
3048
  handler: async (_args, ctx) => openChanges(ctx),
@@ -2950,13 +3111,26 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
2950
3111
  });
2951
3112
  }
2952
3113
  pi.registerCommand("gentle:customize", {
2953
- description: "Configure appearance, audio notifications, Vim editing, session permissions and global Auto/YOLO defaults, and prompt history capture.",
3114
+ description: "Configure appearance, task summary publishing, audio notifications, Vim editing, RDD, session permissions and global Auto/YOLO defaults, and prompt history capture.",
2954
3115
  handler: async (_args, ctx) => {
2955
3116
  if (ctx.mode !== "tui" || !ctx.hasUI) {
2956
3117
  if (ctx.hasUI) ctx.ui.notify("Customization requires an interactive terminal.", "warning");
2957
3118
  return;
2958
3119
  }
2959
3120
  closeCustomize?.();
3121
+ const generation = ++customizeGeneration;
3122
+ // The owner also checks its lifecycle; this binds this particular card
3123
+ // to its caller before discovery and again before handing off the UI.
3124
+ const currentRddSession = (() => {
3125
+ try {
3126
+ const manager = ctx.sessionManager, id = manager.getSessionId(), cwd = ctx.cwd, ui = ctx.ui;
3127
+ if (env.GENTLE_PI_AGENTS_CHILD === "1" || !id || !cwd || (manager.getCwd?.() ?? cwd) !== cwd) return () => false;
3128
+ return () => {
3129
+ try { return customizeGeneration === generation && ctx.mode === "tui" && ctx.hasUI && ctx.ui === ui && ctx.cwd === cwd && ctx.sessionManager === manager && manager.getSessionId() === id && (manager.getCwd?.() ?? cwd) === cwd; }
3130
+ catch { return false; }
3131
+ };
3132
+ } catch { return () => false; }
3133
+ })();
2960
3134
  let closed = false;
2961
3135
  let adapter: YoloUiAdapter | undefined;
2962
3136
  let unobserve: (() => void) | undefined;
@@ -3082,6 +3256,40 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
3082
3256
  reportVim(ctx, result);
3083
3257
  },
3084
3258
  });
3259
+ let rddControl: RddModeControl | undefined;
3260
+ let rddSnapshot: Awaited<ReturnType<RddModeControl["read"]>>;
3261
+ let rddLoading = true;
3262
+ let rddHandoff: RddModeControl | undefined;
3263
+ // Never block the rest of Customize on an unavailable or slow provider.
3264
+ // Rendering only consumes the snapshot, which is refreshed on each open.
3265
+ const refreshRdd = async () => {
3266
+ let control: RddModeControl | undefined;
3267
+ let snapshot: Awaited<ReturnType<RddModeControl["read"]>>;
3268
+ try {
3269
+ control = currentRddSession() ? await discoverRddModeControl(pi) : undefined;
3270
+ snapshot = !closed && currentRddSession() ? await control?.read() : undefined;
3271
+ } catch { /* An incompatible or failing bridge is unavailable. */ }
3272
+ if (closed) return;
3273
+ rddSnapshot = currentRddSession() && snapshot && (snapshot.effective === "on" || snapshot.effective === "off") && Object.values(NATIVE_REVIEW_MODE_SOURCE).includes(snapshot.source) ? snapshot : undefined;
3274
+ rddControl = rddSnapshot ? control : undefined;
3275
+ rddLoading = false;
3276
+ requestCustomizeRender?.();
3277
+ };
3278
+ rows.push({
3279
+ category,
3280
+ label: () => rddSnapshot ? `RDD: ${rddSnapshot.effective} (decided by ${rddSnapshot.source}) · checked on open` : `RDD: ${rddLoading ? "checking" : "unavailable"}`,
3281
+ preview: () => ({ title: "RDD selector", sample: "Enter for fresh status and repository or explicitly machine-wide choices; review consent unchanged." }),
3282
+ action: () => {
3283
+ if (closed || !currentRddSession()) return;
3284
+ if (!rddControl || !rddSnapshot) {
3285
+ ctx.ui.notify(rddLoading ? "RDD status is still being checked." : "RDD is unavailable in this live primary session.", "warning");
3286
+ return;
3287
+ }
3288
+ // The owner's native selector must not sit underneath our overlay.
3289
+ rddHandoff = rddControl;
3290
+ close();
3291
+ },
3292
+ });
3085
3293
  let yoloDisplay: YoloDisplay = YOLO_DISPLAY.unavailable;
3086
3294
  let permissionDisplay = "normal", permissionDefault = "normal";
3087
3295
  let requestYoloRender = () => {};
@@ -3179,15 +3387,34 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
3179
3387
  });
3180
3388
  rows.push(...buildNotificationRows(ctx));
3181
3389
  category = "Layout";
3182
- // Presets set density and visibility together and keep the placements; any switch below still overrides them.
3390
+ const taskSummary = () => resolveHerdrTaskSummarySettings(home);
3391
+ const taskSummaryCurrent = (enabled: boolean) => {
3392
+ const current = taskSummary();
3393
+ return !current.malformed && !current.readError && current.settings.enabled === enabled;
3394
+ };
3395
+ for (const enabled of [true, false]) add(
3396
+ () => `Task summary: ${enabled ? "on" : "off"}${taskSummaryCurrent(enabled) ? " (current)" : ""}`,
3397
+ `Task summary: ${enabled ? "on" : "off"}. Applies now to the active-task summary published to terminal tools (for example Herdr's sidebar).`,
3398
+ () => {
3399
+ const current = taskSummary();
3400
+ if (current.malformed || current.readError) throw new Error(`Cannot update malformed or unreadable task summary preference: ${current.globalFile}`);
3401
+ writeHerdrTaskSummarySettings({ ...current.settings, enabled }, home);
3402
+ pi.events.emit(HERDR_TASK_SUMMARY_CHANGED, { configHome: doubleEscCancelConfigHome });
3403
+ },
3404
+ undefined,
3405
+ { ...explicitChoice("Task summary", enabled ? "on" : "off", () => taskSummaryCurrent(enabled)), hint: "Controls the task summary published to terminal tools" },
3406
+ );
3407
+ // Presets set the visibility switches and keep the placements, the density and the surface; any switch below still overrides them.
3183
3408
  for (const preset of Object.values(VISUAL_PRESET)) add(() => `Preset: ${PRESET_LABEL[preset]}${visualPresetOf(visual()) === preset ? " (current)" : ""}`, pending, () => updateVisual((settings) => applyVisualPreset(settings, preset)), () => layoutPreview(applyVisualPreset(visual(), preset)),
3184
3409
  layoutChoice("Preset", PRESET_LABEL[preset], () => visualPresetOf(visual()) === preset, "Light hides the rail, Power user adds Stats; alt+l cycles them"));
3185
3410
  for (const value of Object.values(STATUS_PLACEMENT)) add(() => `Status placement: ${value}${visual().statusPlacement === value ? " (current)" : ""}`, pending, () => updateVisual((settings) => ({ ...settings, statusPlacement: value })), () => layoutPreview({ ...visual(), statusPlacement: value }),
3186
3411
  layoutChoice("Status", value, () => visual().statusPlacement === value, "Where Status lives; auto uses the rail from 140 columns"));
3187
3412
  for (const value of Object.values(HEADER_PLACEMENT)) add(() => `Header placement: ${value}${visual().headerPlacement === value ? " (current)" : ""}`, pending, () => updateVisual((settings) => ({ ...settings, headerPlacement: value })), () => layoutPreview({ ...visual(), headerPlacement: value }),
3188
- layoutChoice("Header", value, () => visual().headerPlacement === value, "The model, context and cost row: above the conversation or under the input"));
3413
+ layoutChoice("Header", value, () => visual().headerPlacement === value, "The model, context and cost row: top above the conversation, below-input under the input, split into a title row and a bottom status bar"));
3189
3414
  for (const value of Object.values(DENSITY)) add(() => `Density: ${value}${visual().density === value ? " (current)" : ""}`, pending, () => updateVisual((settings) => ({ ...settings, density: value })), () => layoutPreview({ ...visual(), density: value }),
3190
- layoutChoice("Density", value, () => visual().density === value, "Space between rail sections"));
3415
+ layoutChoice("Density", value, () => visual().density === value, "Spacing: comfortable adds gaps between rail sections and a padding row under a top header; compact removes them; minimal also drops the brand and the key hints"));
3416
+ for (const value of Object.values(CHROME_SURFACE)) add(() => `Surface: ${value}${visual().surface === value ? " (current)" : ""}`, pending, () => updateVisual((settings) => ({ ...settings, surface: value })), () => layoutPreview({ ...visual(), surface: value }),
3417
+ layoutChoice("Surface", value, () => visual().surface === value, "Chrome background: transparent (default) lets the terminal background show through; tinted paints the rail, header rows and panel"));
3191
3418
  category = "Cards";
3192
3419
  // One live style for conversation cards, panels, header/footer and prompt.
3193
3420
  const cardStylePreview = { [CARD_STYLE.NEON]: "╭─ ✿ read ─╮ outlined chrome + prompt", [CARD_STYLE.FLOAT]: "▎ ✿ read painted chrome + prompt" };
@@ -3254,7 +3481,7 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
3254
3481
  category = "Profiles";
3255
3482
  rows.push({ category, label: "Visual profiles (preview, save, apply, delete)", preview: () => {
3256
3483
  const saved = catalog()[0];
3257
- return saved ? { title: `${saved.name} · saved profile`, sample: `${saved.visual.headerPlacement === "top" ? "[Header] → [Input]" : "[Input] → [Header]"} [${saved.visual.statusPlacement} status]` } : { title: "No saved profiles", sample: "Enter to save the current appearance" };
3484
+ return saved ? { title: `${saved.name} · saved profile`, sample: `${saved.visual.headerPlacement === "top" ? "[Header] → [Input]" : saved.visual.headerPlacement === "split" ? "[Title] → [Input] → [Status bar]" : "[Input] → [Header]"} [${saved.visual.statusPlacement} status]` } : { title: "No saved profiles", sample: "Enter to save the current appearance" };
3258
3485
  }, action: () => {
3259
3486
  catalog();
3260
3487
  customizeView?.openProfiles();
@@ -3339,16 +3566,19 @@ export default function gentleShell(pi: ExtensionAPI, env: NodeJS.ProcessEnv = p
3339
3566
  requestCustomizeRender = requestYoloRender;
3340
3567
  customizeView = new VisualCustomizeView({ rows, profiles, theme, requestRender: requestYoloRender, rowsAvailable: () => Math.max(0, Math.floor(tui.terminal.rows * 0.85) - 2), onError: (error) => { if (!closed) ctx.ui.notify(`${customizeView?.title() ?? "Customization"}: ${error.message}`, "error"); }, onClose: close });
3341
3568
  const view = customizeView;
3569
+ void refreshRdd();
3342
3570
  // Own interaction lifetime here, leaving the shared view unchanged.
3343
3571
  return {
3344
3572
  render: (width) => closed ? [] : view.render(width),
3345
3573
  handleInput: (data) => { if (!closed) view.handleInput(data); },
3574
+ handleMouse: (event) => closed ? undefined : view.handleMouse(event),
3346
3575
  focus: (label: string) => !closed && view.focus(label),
3347
3576
  invalidate: () => { if (!closed) view.invalidate(); },
3348
3577
  dispose: close,
3349
3578
  };
3350
3579
  }, { overlay: true, overlayOptions: { anchor: "center", width: "70%", minWidth: 60, maxHeight: "85%" } });
3351
3580
  } finally { close(); }
3581
+ if (rddHandoff && currentRddSession()) await rddHandoff.open();
3352
3582
  if (reloadRequested) await ctx.reload();
3353
3583
  },
3354
3584
  });