@deepseek-harness-tui/dsh-tui 0.17.0 → 0.19.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 (318) hide show
  1. package/README.md +43 -16
  2. package/bin/dsh-tui.js +46 -3
  3. package/cli/adapters/dsh/index.mjs +2 -2
  4. package/guide/dsh-tui-guide/cli.en.md +1 -1
  5. package/guide/dsh-tui-guide/cli.md +1 -1
  6. package/guide/dsh-tui-guide/codex-backend.en.md +2 -2
  7. package/guide/dsh-tui-guide/codex-backend.md +2 -2
  8. package/guide/dsh-tui-guide/configuration.en.md +8 -2
  9. package/guide/dsh-tui-guide/configuration.md +8 -2
  10. package/guide/dsh-tui-guide/getting-started.en.md +174 -6
  11. package/guide/dsh-tui-guide/getting-started.md +125 -15
  12. package/guide/dsh-tui-guide/interaction.en.md +30 -8
  13. package/guide/dsh-tui-guide/interaction.md +18 -5
  14. package/guide/dsh-tui-guide/plugins.en.md +28 -7
  15. package/guide/dsh-tui-guide/plugins.md +18 -5
  16. package/guide/dsh-tui-guide/user-guide.en.md +32 -17
  17. package/guide/dsh-tui-guide/user-guide.md +23 -12
  18. package/lib/settings.json +3 -3
  19. package/lib/types/adapter/channel/ui-policy.d.ts +1 -0
  20. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  21. package/lib/types/adapter/channel/ui-policy.js +1 -0
  22. package/lib/types/adapter/ports/channel-ui.d.ts +10 -2
  23. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  24. package/lib/types/adapter/ports/channel-view.d.ts +31 -5
  25. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  26. package/lib/types/adapter/standard/grants.d.ts +60 -0
  27. package/lib/types/adapter/standard/grants.d.ts.map +1 -1
  28. package/lib/types/adapter/standard/grants.js +74 -0
  29. package/lib/types/agent/events.d.ts +16 -3
  30. package/lib/types/agent/events.d.ts.map +1 -1
  31. package/lib/types/agent/session.d.ts +5 -0
  32. package/lib/types/agent/session.d.ts.map +1 -1
  33. package/lib/types/backends/claude/translate/core.d.ts +2 -2
  34. package/lib/types/backends/claude/translate/core.d.ts.map +1 -1
  35. package/lib/types/backends/claude/translate/core.js +10 -6
  36. package/lib/types/backends/codex/session/commands.d.ts +2 -0
  37. package/lib/types/backends/codex/session/commands.d.ts.map +1 -1
  38. package/lib/types/backends/codex/session/commands.js +8 -4
  39. package/lib/types/backends/codex/session/input.d.ts +11 -7
  40. package/lib/types/backends/codex/session/input.d.ts.map +1 -1
  41. package/lib/types/backends/codex/session/input.js +68 -15
  42. package/lib/types/backends/codex/session/session.d.ts.map +1 -1
  43. package/lib/types/backends/codex/session/session.js +2 -3
  44. package/lib/types/channel/projection.d.ts.map +1 -1
  45. package/lib/types/channel/projection.js +78 -10
  46. package/lib/types/channel/questions.d.ts +19 -3
  47. package/lib/types/channel/questions.d.ts.map +1 -1
  48. package/lib/types/channel/sanitize.d.ts.map +1 -1
  49. package/lib/types/channel/sanitize.js +8 -4
  50. package/lib/types/channel/subagent-failure.d.ts +49 -0
  51. package/lib/types/channel/subagent-failure.d.ts.map +1 -0
  52. package/lib/types/channel/subagent-failure.js +59 -0
  53. package/lib/types/channel/transcript.d.ts +17 -0
  54. package/lib/types/channel/transcript.d.ts.map +1 -1
  55. package/lib/types/channel/transcript.js +35 -0
  56. package/lib/types/commands.js +2 -2
  57. package/lib/types/components/GoalTodoPanel.d.ts +71 -6
  58. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  59. package/lib/types/components/GoalTodoPanel.js +165 -17
  60. package/lib/types/components/MessageList.d.ts.map +1 -1
  61. package/lib/types/components/MessageList.js +14 -9
  62. package/lib/types/components/PluginGrantList.d.ts +45 -0
  63. package/lib/types/components/PluginGrantList.d.ts.map +1 -0
  64. package/lib/types/components/PluginGrantList.js +126 -0
  65. package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
  66. package/lib/types/components/PluginInstallPane.js +35 -6
  67. package/lib/types/components/PluginManagePane.d.ts.map +1 -1
  68. package/lib/types/components/PluginManagePane.js +65 -8
  69. package/lib/types/components/PromptInput.d.ts.map +1 -1
  70. package/lib/types/components/PromptInput.js +63 -8
  71. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  72. package/lib/types/components/SubagentDashboard.js +17 -1
  73. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  74. package/lib/types/components/SubagentDetailScene.js +12 -0
  75. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
  76. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  77. package/lib/types/components/messages/AssistantToolUseMessage.js +16 -7
  78. package/lib/types/components/onboardingModel.d.ts +2 -2
  79. package/lib/types/components/onboardingModel.js +3 -3
  80. package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
  81. package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
  82. package/lib/types/components/onboardingProviderPlan.js +78 -0
  83. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -8
  84. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  85. package/lib/types/components/questions/AskUserQuestionPanel.js +7 -4
  86. package/lib/types/components/questions/PlanReviewPanel.d.ts +3 -6
  87. package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
  88. package/lib/types/components/revealScope.d.ts +15 -0
  89. package/lib/types/components/revealScope.d.ts.map +1 -0
  90. package/lib/types/components/revealScope.js +17 -0
  91. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +41 -1
  92. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  93. package/lib/types/components/sidePanel/btw/BtwComposer.js +123 -6
  94. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  95. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +9 -2
  96. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
  97. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  98. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +9 -2
  99. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
  100. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
  101. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
  102. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  103. package/lib/types/components/sidePanel/builtinPanels.js +14 -2
  104. package/lib/types/components/sidePanel/types.d.ts +2 -0
  105. package/lib/types/components/sidePanel/types.d.ts.map +1 -1
  106. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  107. package/lib/types/components/sidePanel/useSidePanel.js +15 -1
  108. package/lib/types/components/smoothReveal.d.ts +36 -6
  109. package/lib/types/components/smoothReveal.d.ts.map +1 -1
  110. package/lib/types/components/smoothReveal.js +92 -21
  111. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts +4 -14
  112. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  113. package/lib/types/components/workspaces/HomeWorkspaceRow.js +26 -17
  114. package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
  115. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  116. package/lib/types/dsh-adapter/backend/session.js +74 -6
  117. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  118. package/lib/types/dsh-adapter/backend/translate.js +15 -6
  119. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
  120. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
  121. package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
  122. package/lib/types/dsh-adapter/channel/attached-context.d.ts +15 -2
  123. package/lib/types/dsh-adapter/channel/attached-context.d.ts.map +1 -1
  124. package/lib/types/dsh-adapter/channel/attached-context.js +26 -3
  125. package/lib/types/dsh-adapter/channel/binding-events.d.ts +3 -0
  126. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  127. package/lib/types/dsh-adapter/channel/binding-events.js +43 -2
  128. package/lib/types/dsh-adapter/channel/composer-images.d.ts +2 -0
  129. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  130. package/lib/types/dsh-adapter/channel/composer-images.js +10 -2
  131. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  132. package/lib/types/dsh-adapter/channel/composer-mentions.js +22 -7
  133. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +3 -7
  134. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  135. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +16 -6
  136. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +6 -0
  137. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  138. package/lib/types/dsh-adapter/channel/core/binding-feed.js +35 -1
  139. package/lib/types/dsh-adapter/channel/core/compose.d.ts +3 -7
  140. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  141. package/lib/types/dsh-adapter/channel/core/compose.js +6 -1
  142. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  143. package/lib/types/dsh-adapter/channel/core/local-actions.js +3 -26
  144. package/lib/types/dsh-adapter/channel/emitter.js +1 -1
  145. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  146. package/lib/types/dsh-adapter/channel/extensions.js +8 -0
  147. package/lib/types/dsh-adapter/channel/input-actions.d.ts +4 -4
  148. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  149. package/lib/types/dsh-adapter/channel/input-actions.js +59 -5
  150. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +3 -7
  151. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  152. package/lib/types/dsh-adapter/channel/input-delivery.js +21 -8
  153. package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
  154. package/lib/types/dsh-adapter/channel/mentions.js +21 -7
  155. package/lib/types/dsh-adapter/channel/model-actions.d.ts +4 -1
  156. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  157. package/lib/types/dsh-adapter/channel/model-actions.js +26 -9
  158. package/lib/types/dsh-adapter/channel/model-selection.d.ts +27 -2
  159. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  160. package/lib/types/dsh-adapter/channel/model-selection.js +81 -37
  161. package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -1
  162. package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
  163. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  164. package/lib/types/dsh-adapter/channel/paths.js +11 -9
  165. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
  166. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  167. package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
  168. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  169. package/lib/types/dsh-adapter/channel/session-reset.js +3 -1
  170. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
  171. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  172. package/lib/types/dsh-adapter/channel/session-resume.js +10 -3
  173. package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
  174. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  175. package/lib/types/dsh-adapter/channel/session-rewind.js +9 -3
  176. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
  177. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  178. package/lib/types/dsh-adapter/channel/session-tree-actions.js +11 -5
  179. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  180. package/lib/types/dsh-adapter/channel/settings-host.js +6 -3
  181. package/lib/types/dsh-adapter/channel/transcript.d.ts +3 -2
  182. package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
  183. package/lib/types/dsh-adapter/channel/transcript.js +13 -4
  184. package/lib/types/dsh-adapter/channel/types.d.ts +11 -2
  185. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  186. package/lib/types/dsh-adapter/contract.d.ts +27 -3
  187. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  188. package/lib/types/dsh-adapter/contract.js +47 -5
  189. package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
  190. package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
  191. package/lib/types/dsh-adapter/experimental-bundles.d.ts +3 -0
  192. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -1
  193. package/lib/types/dsh-adapter/experimental-bundles.js +4 -0
  194. package/lib/types/dsh-adapter/fresh-agent.d.ts +1 -1
  195. package/lib/types/dsh-adapter/fresh-agent.d.ts.map +1 -1
  196. package/lib/types/dsh-adapter/fresh-agent.js +60 -11
  197. package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
  198. package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
  199. package/lib/types/dsh-adapter/grant-file.js +178 -0
  200. package/lib/types/dsh-adapter/host-access.d.ts +4 -0
  201. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  202. package/lib/types/dsh-adapter/host-access.js +114 -15
  203. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  204. package/lib/types/dsh-adapter/host-contract.d.ts.map +1 -1
  205. package/lib/types/dsh-adapter/host-contract.js +5 -3
  206. package/lib/types/dsh-adapter/host-dsh.d.ts +0 -8
  207. package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
  208. package/lib/types/dsh-adapter/host-dsh.js +27 -6
  209. package/lib/types/dsh-adapter/host-entry.js +4 -0
  210. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  211. package/lib/types/dsh-adapter/index.js +8 -5
  212. package/lib/types/dsh-adapter/oauth/profiles.d.ts.map +1 -1
  213. package/lib/types/dsh-adapter/oauth/profiles.js +14 -1
  214. package/lib/types/dsh-adapter/panels.d.ts +7 -1
  215. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  216. package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
  217. package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
  218. package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
  219. package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
  220. package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
  221. package/lib/types/dsh-adapter/plugin-install.js +160 -13
  222. package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
  223. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  224. package/lib/types/dsh-adapter/plugin-manage.js +240 -51
  225. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  226. package/lib/types/dsh-adapter/plugin.js +203 -58
  227. package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
  228. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  229. package/lib/types/dsh-adapter/plugins-info.js +34 -21
  230. package/lib/types/dsh-adapter/presets.d.ts +41 -10
  231. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  232. package/lib/types/dsh-adapter/presets.js +59 -12
  233. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  234. package/lib/types/dsh-adapter/process-exit.js +1 -1
  235. package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
  236. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  237. package/lib/types/dsh-adapter/providerWizard.js +11 -5
  238. package/lib/types/dsh-adapter/questions.d.ts +3 -4
  239. package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
  240. package/lib/types/dsh-adapter/questions.js +1 -1
  241. package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
  242. package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
  243. package/lib/types/dsh-adapter/row-attachment.js +29 -0
  244. package/lib/types/dsh-adapter/session-list-metadata.js +2 -2
  245. package/lib/types/dsh-adapter/subagents.d.ts +5 -0
  246. package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
  247. package/lib/types/dsh-adapter/subagents.js +22 -1
  248. package/lib/types/dsh-adapter/team-mode.d.ts +17 -10
  249. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  250. package/lib/types/dsh-adapter/team-mode.js +19 -12
  251. package/lib/types/dsh-adapter/tool-scope.d.ts +24 -0
  252. package/lib/types/dsh-adapter/tool-scope.d.ts.map +1 -0
  253. package/lib/types/dsh-adapter/tool-scope.js +127 -0
  254. package/lib/types/dsh-adapter/types.d.ts +2 -1
  255. package/lib/types/dsh-adapter/types.d.ts.map +1 -1
  256. package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
  257. package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
  258. package/lib/types/dsh-adapter/worktree-tool.js +87 -0
  259. package/lib/types/heldInputs.d.ts +75 -0
  260. package/lib/types/heldInputs.d.ts.map +1 -0
  261. package/lib/types/heldInputs.js +409 -0
  262. package/lib/types/i18n.d.ts +577 -34
  263. package/lib/types/i18n.d.ts.map +1 -1
  264. package/lib/types/i18n.js +230 -22
  265. package/lib/types/ink/components/App.d.ts +2 -0
  266. package/lib/types/ink/components/App.d.ts.map +1 -1
  267. package/lib/types/ink/components/App.js +8 -0
  268. package/lib/types/ink/events/input-event.d.ts.map +1 -1
  269. package/lib/types/ink/events/input-event.js +7 -6
  270. package/lib/types/ink/hit-test.d.ts +2 -0
  271. package/lib/types/ink/hit-test.d.ts.map +1 -1
  272. package/lib/types/ink/hit-test.js +10 -0
  273. package/lib/types/ink/hooks/use-program-status.d.ts +1 -1
  274. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -1
  275. package/lib/types/ink/hooks/use-program-status.js +3 -2
  276. package/lib/types/ink/ink.d.ts +1 -0
  277. package/lib/types/ink/ink.d.ts.map +1 -1
  278. package/lib/types/ink/ink.js +5 -2
  279. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  280. package/lib/types/ink/parse-keypress.js +25 -0
  281. package/lib/types/ink/terminal.d.ts +13 -2
  282. package/lib/types/ink/terminal.d.ts.map +1 -1
  283. package/lib/types/ink/terminal.js +29 -5
  284. package/lib/types/onboardingDraft.d.ts +143 -0
  285. package/lib/types/onboardingDraft.d.ts.map +1 -0
  286. package/lib/types/onboardingDraft.js +71 -0
  287. package/lib/types/screens/Chat.d.ts.map +1 -1
  288. package/lib/types/screens/Chat.js +133 -32
  289. package/lib/types/screens/Onboarding.d.ts +22 -3
  290. package/lib/types/screens/Onboarding.d.ts.map +1 -1
  291. package/lib/types/screens/Onboarding.js +606 -36
  292. package/lib/types/screens/SessionSupervisor.d.ts +3 -6
  293. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  294. package/lib/types/screens/SessionSupervisor.js +5 -8
  295. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +1 -2
  296. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  297. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +2 -2
  298. package/lib/types/screens/sessionSupervisor/model.d.ts +1 -1
  299. package/lib/types/screens/sessionSupervisor/model.js +1 -1
  300. package/lib/types/sessionMounts.d.ts +12 -5
  301. package/lib/types/sessionMounts.d.ts.map +1 -1
  302. package/lib/types/sessionMounts.js +33 -6
  303. package/lib/types/settings/definitions.js +2 -2
  304. package/lib/types/update.d.ts +412 -20
  305. package/lib/types/update.d.ts.map +1 -1
  306. package/lib/types/update.js +2094 -193
  307. package/lib/types/updateHost.d.ts +198 -0
  308. package/lib/types/updateHost.d.ts.map +1 -0
  309. package/lib/types/updateHost.js +608 -0
  310. package/lib/types/utils/paths.d.ts +15 -0
  311. package/lib/types/utils/paths.d.ts.map +1 -1
  312. package/lib/types/utils/paths.js +25 -0
  313. package/lib/types/utils/processName.d.ts +16 -0
  314. package/lib/types/utils/processName.d.ts.map +1 -0
  315. package/lib/types/utils/processName.js +27 -0
  316. package/package.json +114 -108
  317. package/tui-profile/feed/README.md +1 -1
  318. package/tui-profile/feed/first-party.json +1 -1
@@ -25,8 +25,11 @@
25
25
  * never notice (stale cached heights → blank bands). Instead the cursors
26
26
  * live here keyed by row identity, the READS happen during render (they feed
27
27
  * the same flattened `text` prop the streaming path already uses), and the
28
- * WRITES happen on the scheduler tick, which bumps a version that
29
- * MessageList subscribes to via useSyncExternalStore. A reveal therefore
28
+ * WRITES happen in two places: the scheduler tick, which bumps a version
29
+ * that MessageList subscribes to via useSyncExternalStore; and the first
30
+ * history read of a row, which registers a caught-up cursor (see
31
+ * RevealReadOptions.active) so a later live continuation of that row does
32
+ * not restart it. A reveal therefore
30
33
  * rides the exact same update pipeline as an arriving chunk: prop change →
31
34
  * memo miss → re-render → post-commit measurement. Render-phase reads are
32
35
  * idempotent and safe to re-run (a discarded concurrent render at worst
@@ -72,23 +75,42 @@ const countCursors = new Map();
72
75
  * Keys whose reveal has COMPLETED (caught up, snapped, or replaced). A
73
76
  * completed key must not re-create a cursor on a later active read — the
74
77
  * content is already fully on screen, and re-revealing would blank it and
75
- * typewrite again. Bounded FIFO: well past the cap these are all ancient
76
- * history (the row ids are gone); dropping the oldest half only risks a
77
- * long-unmounted row re-revealing, which is harmless (it paints full via
78
- * the active=false path anyway once unmounted... and a remounted streaming
79
- * row WANTS the reveal).
78
+ * typewrite again.
79
+ *
80
+ * Deliberately UNBOUNDED. The 2048-entry FIFO this replaced dropped the
81
+ * oldest half, which turns "already painted once" back into "never painted".
82
+ * Its premise — that a forgotten row re-paints full through the
83
+ * `active: false` path — does not hold: `fresh` is set when a live turn
84
+ * settles and is never cleared, so a remounted row keeps claiming
85
+ * liveliness and gets typewritten again from its first character (#1787).
86
+ * Long sessions were exactly the case that overflowed.
87
+ *
88
+ * Growth follows the session, not time: at most a few short keys per row
89
+ * (`a{id}`, `r{id}`, `tool:{callId}`, `tool:{callId}:split`), on rows that
90
+ * stay resident — `foldRows` never drops a row, and the projection's
91
+ * merge/replace paths are the only removers (their ids are never reused, so
92
+ * the leftover keys cost memory but cannot collide). It is every RENDERED
93
+ * row, not only the ones that revealed: a history read registers a caught-up
94
+ * text cursor, and the next tick retires it into `completedReveals`.
95
+ * Measured on V8: 50k `a{id}` keys ≈ 2.4 MB, 50k `tool:{callId}:split`
96
+ * keys ≈ 12.3 MB — second-order next to the ChatRow objects the same
97
+ * session already holds. The contributor guide's long-session memory rule
98
+ * asks for a measured alternative before removing a cache bound; the
99
+ * measurement is above, and the alternative does not exist while `fresh`
100
+ * is never cleared: any count-based bound re-opens #1787 (an evicted
101
+ * off-screen row re-reads as active and typewrites once it scrolls back).
102
+ *
103
+ * It also grows on the render path, which the same guide warns about under
104
+ * its unbounded render-phase collection rule. The distinction from the
105
+ * neighbouring `HEIGHTS_CACHE_MAX` FIFO in MessageList is what an eviction
106
+ * costs there: a forgotten height only mis-estimates geometry and falls
107
+ * back to `DEFAULT_ROW_HEIGHT`, while a forgotten key re-typewrites the
108
+ * row — the exact report this comment exists for. Making `fresh`
109
+ * transactional would lift the constraint; that is a projection change,
110
+ * tracked in #1795.
80
111
  */
81
112
  const completedReveals = new Set();
82
- const COMPLETED_REVEALS_MAX = 2048;
83
113
  function markRevealCompleted(key) {
84
- if (completedReveals.size >= COMPLETED_REVEALS_MAX) {
85
- let drop = COMPLETED_REVEALS_MAX / 2;
86
- for (const old of completedReveals) {
87
- if (drop-- <= 0)
88
- break;
89
- completedReveals.delete(old);
90
- }
91
- }
92
114
  completedReveals.add(key);
93
115
  }
94
116
  // ---------------------------------------------------------------------------
@@ -180,6 +202,51 @@ export function snapReveal(key) {
180
202
  if (textCursors.delete(key) || countCursors.delete(key))
181
203
  markRevealCompleted(key);
182
204
  }
205
+ /** Scope separator: NUL never appears in a row id or a call id, so a scoped
206
+ * key stays unambiguous and one root clears its own entries by prefix. */
207
+ const REVEAL_SCOPE_SEPARATOR = '\u0000';
208
+ /**
209
+ * Key for `key` inside `scope`. Every Chat root owns its reveal memory: ids
210
+ * restart at 0 inside a root, so a sibling root's rebind must not clear (or
211
+ * inherit) another root's completed keys. `undefined` keeps the bare key —
212
+ * single-root scripts, tests, and any caller outside a Chat provider.
213
+ */
214
+ export function scopeRevealKey(scope, key) {
215
+ return scope === undefined ? key : `${scope}${REVEAL_SCOPE_SEPARATOR}${key}`;
216
+ }
217
+ /**
218
+ * Session boundary (agent switch, `/resume`, rewind adopt): row ids restart
219
+ * at 0, so a key from the previous session (`a12`) names a different row in
220
+ * the new one. Drop both the completed memory and any in-flight cursors —
221
+ * replayed rows read with `active: false` and paint complete anyway, while
222
+ * the new session's live rows must be free to animate from scratch. The
223
+ * scheduler, listeners and version store stay intact: the mounted tree keeps
224
+ * subscribing, and clearing both cursor tables stops the timer synchronously.
225
+ *
226
+ * Known residue: a backend `conversation_reset` also restarts row ids, but it
227
+ * is a channel-layer event that never crosses into the UI — that path keeps
228
+ * its stale keys, so the first rows after such a reset paint without a
229
+ * reveal. The old 2048 FIFO used to heal this by accident once a session had
230
+ * revealed past the cap; with no eviction it is permanent until the agent
231
+ * changes. Covering it needs a row-id-regression signal from the channel;
232
+ * tracked in #1795.
233
+ */
234
+ export function resetRevealSession(scope) {
235
+ const prefix = `${scope}${REVEAL_SCOPE_SEPARATOR}`;
236
+ for (const key of [...textCursors.keys()]) {
237
+ if (key.startsWith(prefix))
238
+ textCursors.delete(key);
239
+ }
240
+ for (const key of [...countCursors.keys()]) {
241
+ if (key.startsWith(prefix))
242
+ countCursors.delete(key);
243
+ }
244
+ for (const key of [...completedReveals]) {
245
+ if (key.startsWith(prefix))
246
+ completedReveals.delete(key);
247
+ }
248
+ stopRevealTimerIfIdle();
249
+ }
183
250
  /**
184
251
  * Revealed length of `text` for `key` — the cursor logic of
185
252
  * {@link revealTextOf} without the slice allocation (layout signatures read
@@ -201,8 +268,15 @@ export function revealLengthOf(key, text, options) {
201
268
  // again.
202
269
  if (completedReveals.has(key))
203
270
  return text.length;
204
- if (!options.active)
271
+ if (!options.active) {
272
+ // Painted as history (a settled live row, a replayed row). Remember
273
+ // that the whole text is already on screen: a live continuation reuses
274
+ // this key, and without the caught-up cursor it would fall into the
275
+ // active branch below, create `revealed: 0` and typewrite the row
276
+ // again from its first character. Already complete, so no timer.
277
+ textCursors.set(key, { text, revealed: text.length });
205
278
  return text.length;
279
+ }
206
280
  textCursors.set(key, { text, revealed: 0 });
207
281
  ensureRevealTimer();
208
282
  return 0;
@@ -292,11 +366,8 @@ export function resetRevealForTest() {
292
366
  textCursors.clear();
293
367
  countCursors.clear();
294
368
  completedReveals.clear();
369
+ stopRevealTimerIfIdle();
295
370
  revealListeners.clear();
296
- if (revealTimer !== undefined) {
297
- clearInterval(revealTimer);
298
- revealTimer = undefined;
299
- }
300
371
  revealVersionValue = 0;
301
372
  }
302
373
  /** Whether the shared scheduler currently runs (refcount assertions). */
@@ -4,22 +4,12 @@ import type { ContextMenuEvent } from '../../ink/events/context-menu-event.js';
4
4
  /**
5
5
  * One workspace in the home screen's left rail.
6
6
  *
7
- * Two lines, like every other navigable row in this app: the name line is what
8
- * the user named it, the detail line is where it actually is and how much is in
9
- * it. The path is not decoration — two workspaces can carry the same basename
10
- * (`.../a/work` and `.../b/work`), and the ledger allows duplicate titles, so
11
- * the path is the only thing that tells them apart.
12
- *
13
- * Widths are resolved here rather than left to flexbox for the same reason the
14
- * session rows resolve them: a row must be exactly two lines at every terminal
15
- * width, and a wrapped row destroys the alignment a list is scanned by.
7
+ * A single name-and-count line at every terminal width. The selected
8
+ * workspace path lives above the panes, where it has the full screen width
9
+ * instead of repeating a truncated path under every name.
16
10
  */
17
- export declare function HomeWorkspaceRow({ title, path, home, sessionCount, historyOnly, present, selected, focused, declareCursor, width, onSelect, onMenu, }: {
11
+ export declare function HomeWorkspaceRow({ title, sessionCount, historyOnly, present, selected, focused, declareCursor, width, onSelect, onMenu, }: {
18
12
  title: string;
19
- /** Canonical directory path recorded in the ledger. */
20
- path: string;
21
- /** Home directory, for collapsing the path to `~`. */
22
- home: string;
23
13
  sessionCount: number;
24
14
  /** Derived from session history, without a workspace registration. */
25
15
  historyOnly?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"HomeWorkspaceRow.d.ts","sourceRoot":"","sources":["../../../../src/components/workspaces/HomeWorkspaceRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAI9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,WAAmB,EACnB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,QAAQ,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IAClC,mDAAmD;IACnD,MAAM,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACvC,GAAG,KAAK,CAAC,SAAS,CAuClB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,KAAK,EACL,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC,GAAG,KAAK,CAAC,SAAS,CAoBlB"}
1
+ {"version":3,"file":"HomeWorkspaceRow.d.ts","sourceRoot":"","sources":["../../../../src/components/workspaces/HomeWorkspaceRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAK9E;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,YAAY,EACZ,WAAmB,EACnB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,QAAQ,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IAClC,mDAAmD;IACnD,MAAM,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACvC,GAAG,KAAK,CAAC,SAAS,CAoDlB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,KAAK,EACL,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC,GAAG,KAAK,CAAC,SAAS,CAoBlB"}
@@ -2,40 +2,49 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { Box, Text } from '../../ui.js';
4
4
  import { t } from '../../i18n.js';
5
- import { formatProject, spreadRow, truncateWidth } from '../../sessions/format.js';
5
+ import { stringWidth } from '../../ink/stringWidth.js';
6
+ import { spreadRow, truncateWidth } from '../../sessions/format.js';
6
7
  import { useDeclaredCursor, useNativeCursor } from '../../ink/hooks/use-declared-cursor.js';
7
8
  /**
8
9
  * One workspace in the home screen's left rail.
9
10
  *
10
- * Two lines, like every other navigable row in this app: the name line is what
11
- * the user named it, the detail line is where it actually is and how much is in
12
- * it. The path is not decoration — two workspaces can carry the same basename
13
- * (`.../a/work` and `.../b/work`), and the ledger allows duplicate titles, so
14
- * the path is the only thing that tells them apart.
15
- *
16
- * Widths are resolved here rather than left to flexbox for the same reason the
17
- * session rows resolve them: a row must be exactly two lines at every terminal
18
- * width, and a wrapped row destroys the alignment a list is scanned by.
11
+ * A single name-and-count line at every terminal width. The selected
12
+ * workspace path lives above the panes, where it has the full screen width
13
+ * instead of repeating a truncated path under every name.
19
14
  */
20
- export function HomeWorkspaceRow({ title, path, home, sessionCount, historyOnly = false, present, selected, focused, declareCursor = false, width, onSelect, onMenu, }) {
15
+ export function HomeWorkspaceRow({ title, sessionCount, historyOnly = false, present, selected, focused, declareCursor = false, width, onSelect, onMenu, }) {
21
16
  const [hovered, setHovered] = useState(false);
22
17
  const nativeCursor = useNativeCursor();
23
18
  const cursorRef = useDeclaredCursor({ line: 0, column: 0, active: focused && declareCursor, visible: nativeCursor, hideOnIdle: true });
24
19
  const body = Math.max(8, width - 4);
25
20
  // The pane already labels the count; keep the rail's badge numeric and use
26
21
  // its selected ring rather than a second check mark for the same state.
27
- const badge = present ? String(sessionCount) : `${t('home-workspace-missing')} · ${sessionCount}`;
28
- const name = historyOnly ? `${t('supervisor-history-only')} · ${title}` : title;
29
- const heading = spreadRow(`${selected ? '▣' : '▢'} ${name}`, badge, body);
30
- const detail = formatProject(path, home);
22
+ const count = String(sessionCount);
23
+ const ring = selected ? '▣' : '▢';
24
+ const history = t('supervisor-history-only');
25
+ const shortHistory = t('supervisor-history-only-short');
26
+ const missingBadge = `${t('home-workspace-missing')} · ${count}`;
27
+ const compactMissingBadge = `${t('home-workspace-missing')} ${count}`;
28
+ // Reserve room for the ring, an identifiable name and (where needed) the
29
+ // history marker. Fall back to a warning glyph if the text cannot fit.
30
+ const minimumName = stringWidth(`${ring} ${historyOnly ? `${shortHistory} ` : ''}界…`);
31
+ const fits = (value) => stringWidth(value) + 1 + minimumName <= body;
32
+ const badge = present ? count : fits(missingBadge) ? missingBadge : fits(compactMissingBadge) ? compactMissingBadge : `! ${count}`;
33
+ const nameWidth = Math.max(0, body - stringWidth(badge) - 1);
34
+ const fullName = `${ring} ${historyOnly ? `${history} · ${title}` : title}`;
35
+ // Shorten the history prefix when needed, preserving both the label and
36
+ // the beginning of the project name rather than truncating either away.
37
+ const name = historyOnly && stringWidth(fullName) > nameWidth ? `${ring} ${shortHistory} ${title}` : fullName;
38
+ const headingName = truncateWidth(name, nameWidth);
39
+ const heading = spreadRow(headingName, badge, body);
31
40
  // The cursor (green) outranks the selection ring (green); both outrank the
32
41
  // idle colour. Blue is not part of this ladder at all — see the background.
33
42
  const headingColor = (focused || selected) ? 'success' : present ? 'text' : 'inactive';
34
- return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, paddingX: 1, onClick: onSelect, onContextMenu: onMenu, onMouseEnter: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(true), onMouseLeave: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(false),
43
+ return (_jsx(Box, { flexDirection: "column", flexShrink: 0, paddingX: 1, onClick: onSelect, onContextMenu: onMenu, onMouseEnter: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(true), onMouseLeave: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(false),
35
44
  // Hover is the BLUE prompt — pointer feedback and nothing else, so it
36
45
  // never marks the focused or the selected row. Selection itself is green
37
46
  // in the text, which is why this row draws no box while selected.
38
- backgroundColor: hovered && !focused ? 'userMessageBackgroundHover' : undefined, children: [_jsxs(Box, { ref: cursorRef, height: 1, flexShrink: 0, overflow: "hidden", children: [_jsx(Text, { color: focused ? 'success' : 'subtle', children: focused ? '❯ ' : ' ' }), _jsx(Text, { color: headingColor, bold: focused || selected, children: heading.left }), _jsx(Text, { dimColor: !focused, children: `${' '.repeat(heading.gap)}${heading.right}` })] }), _jsx(Text, { color: (focused || selected) ? 'success' : undefined, dimColor: !(focused || selected), wrap: "truncate-end", children: ` ${truncateWidth(detail, body - 2)}` })] }));
47
+ backgroundColor: hovered && !focused ? 'userMessageBackgroundHover' : undefined, children: _jsxs(Box, { ref: cursorRef, height: 1, flexShrink: 0, overflow: "hidden", children: [_jsx(Text, { color: focused ? 'success' : 'subtle', children: focused ? '❯ ' : ' ' }), _jsx(Text, { color: headingColor, bold: focused || selected, children: heading.left }), _jsx(Text, { dimColor: !focused, children: `${' '.repeat(heading.gap)}${heading.right}` })] }) }));
39
48
  }
40
49
  /**
41
50
  * The `+` row that opens the directory picker.
@@ -56,8 +56,14 @@ export declare function isAgentSession(value: unknown): value is AgentSession;
56
56
  * `AgentSession`. Creating the wrapper acquires nothing: listeners exist only
57
57
  * while `subscribe`/`subscribeRaw` subscriptions are live, and only `dispose()`
58
58
  * releases the handle.
59
+ *
60
+ * `screenOutlivesContext`: the screen showing this session lives longer than
61
+ * `ctx` (the entry's screen over its profile row), so when `ctx` unloads the
62
+ * screen holds this session's queued inputs, and the agent must not run them.
59
63
  */
60
- export declare function createDshSession(ctx: Context, target: DshSessionTarget): AgentSession;
64
+ export declare function createDshSession(ctx: Context, target: DshSessionTarget, options?: {
65
+ readonly screenOutlivesContext?: boolean;
66
+ }): AgentSession;
61
67
  /** The lifetime handle of a DSH session this process created or resumed;
62
68
  * throws when the session borrows its agent (or is not a DSH session). */
63
69
  export declare function dshHandleOf(session: AgentSession): AgentHandle;
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAA+B,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAc,YAAY,EAAoD,MAAM,wBAAwB,CAAA;AAIxH,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExE,OAAO,QAAQ,6BAA6B,CAAC;IAC3C,UAAU,SAAS;QACjB,8CAA8C;QAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;QACrB;4EACoE;QACpE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;QACxC,mEAAmE;QACnE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;QACrB;;8BAEsB;QACtB,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;QACjE,wEAAwE;QACxE,UAAU,IAAI,SAAS,YAAY,EAAE,CAAA;QACrC;;;;WAIG;QACH,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;QACvE,iFAAiF;QACjF,gBAAgB,IAAI,IAAI,CAAA;QACxB,gEAAgE;QAChE,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,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AA;QACrB;;8BAEsB;QACtB,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;QACjE,wEAAwE;QACxE,UAAU,IAAI,SAAS,YAAY,EAAE,CAAA;QACrC;;;;WAIG;QACH,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;QACvE,iFAAiF;QACjF,gBAAgB,IAAI,IAAI,CAAA;QACxB,gEAAgE;QAChE,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAC1D,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;KAC/D;CACF;AAED;2EAC2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,CAAA;AAUhH,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CA8RjJ;AAED;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAI9D"}
@@ -1,4 +1,5 @@
1
1
  import { createUserMessage, MessageId } from '@deepseek-ai/dsh-llm';
2
+ import { t } from '../../i18n.js';
2
3
  import { isTokenDelta, tokenDeltaChars } from '../channel/usage.js';
3
4
  import { snapshotLiveSessionEvents } from '../compat/liveSession.js';
4
5
  import { createDshTranslator } from './translate.js';
@@ -19,8 +20,12 @@ export function isAgentSession(value) {
19
20
  * `AgentSession`. Creating the wrapper acquires nothing: listeners exist only
20
21
  * while `subscribe`/`subscribeRaw` subscriptions are live, and only `dispose()`
21
22
  * releases the handle.
23
+ *
24
+ * `screenOutlivesContext`: the screen showing this session lives longer than
25
+ * `ctx` (the entry's screen over its profile row), so when `ctx` unloads the
26
+ * screen holds this session's queued inputs, and the agent must not run them.
22
27
  */
23
- export function createDshSession(ctx, target) {
28
+ export function createDshSession(ctx, target, options = {}) {
24
29
  const agent = target.agent;
25
30
  const handle = isHandle(target) ? target : target.handle;
26
31
  // The tools registry is read lazily, once per session, on the first
@@ -35,6 +40,20 @@ export function createDshSession(ctx, target) {
35
40
  let disposed = false;
36
41
  /** Inputs this session queued that the inbox has not claimed or discarded. */
37
42
  const pending = new Map();
43
+ /** Set while this session's own call (a cancel, a retraction) drops queued
44
+ * inputs: the inbox reports those discards synchronously, inside the call.
45
+ * Any other discard is the kernel's own (the agent's teardown, a hook or
46
+ * parent cancel). */
47
+ let dropping = false;
48
+ const dropOwn = (drop) => {
49
+ dropping = true;
50
+ try {
51
+ return drop();
52
+ }
53
+ finally {
54
+ dropping = false;
55
+ }
56
+ };
38
57
  /**
39
58
  * One `session/event` listener per subscription period, shared by raw and
40
59
  * translated subscribers. Raw subscribers (the DSH extensions) see each
@@ -132,7 +151,7 @@ export function createDshSession(ctx, target) {
132
151
  capabilities: {
133
152
  pendingRetraction: {
134
153
  remove(clientMessageId) {
135
- const removed = agent.inbox.remove(MessageId(clientMessageId));
154
+ const removed = dropOwn(() => agent.inbox.remove(MessageId(clientMessageId)));
136
155
  if (removed)
137
156
  pending.delete(clientMessageId);
138
157
  return removed;
@@ -163,9 +182,40 @@ export function createDshSession(ctx, target) {
163
182
  disposed = true;
164
183
  listener([{ type: 'session.status', status: 'disposed' }], QUIET);
165
184
  }));
185
+ // Every listener here lives on `ctx`. When its fiber unloads (the
186
+ // dsh-tui row goes with the `agents` service it injects), they go
187
+ // with it, and the agent's closing `agent/status` / `agent/disposed`
188
+ // can no longer arrive: the screen would project the turn forever
189
+ // (#1651). Nothing can reach this agent through this session any
190
+ // more, so report it disposed. An unsubscribe has already cleared
191
+ // `active` when it releases this effect, so it reports nothing.
192
+ // Test doubles that serve only `on` have no fiber to follow.
193
+ own(ctx.effect?.(() => () => {
194
+ if (!active)
195
+ return;
196
+ active = false;
197
+ // The agent can outlive the row (a borrowed agent, a row reloaded
198
+ // alone) and would still run what this session queued, while the
199
+ // screen holds those inputs as never sent: take them back, quietly
200
+ // (the screen holds them from the status below). A screen that
201
+ // unloads with `ctx` holds nothing: a surviving agent keeps them.
202
+ if (options.screenOutlivesContext === true) {
203
+ for (const id of [...pending.keys()]) {
204
+ try {
205
+ if (agent.inbox.remove(MessageId(id)))
206
+ pending.delete(id);
207
+ }
208
+ catch { }
209
+ }
210
+ }
211
+ disposed = true;
212
+ listener([{ type: 'session.status', status: 'disposed' }], QUIET);
213
+ }, 'dsh-tui session listeners') ?? (() => undefined));
166
214
  /**
167
215
  * The inbox removed one message. Both events retire the pending entry;
168
- * the channel retires attached context only for a discard.
216
+ * the channel retires attached context only for a discard. A discard
217
+ * this session did not ask for goes out as `dropped`: the input never
218
+ * ran, and the channel keeps it for the user.
169
219
  * `agent/inbox/claimed` fires while the loop claims the batch, before
170
220
  * the resident `agent/pre-step` listener can append the attachment
171
221
  * (dsh-agent-loop: `inbox.claim()` → claimed event → `agent/pre-step`).
@@ -180,13 +230,27 @@ export function createDshSession(ctx, target) {
180
230
  const items = [...pending.values()];
181
231
  listener([how === 'claimed'
182
232
  ? { type: 'pending.changed', items, claimed: [messageId] }
183
- : { type: 'pending.changed', items, discarded: [messageId] }], QUIET);
233
+ : dropping
234
+ ? { type: 'pending.changed', items, discarded: [messageId] }
235
+ : { type: 'pending.changed', items, dropped: [messageId] }], QUIET);
184
236
  };
185
237
  own(ctx.on('agent/inbox/claimed', payload => retire(payload, 'claimed')));
186
238
  own(ctx.on('agent/inbox/discarded', payload => retire(payload, 'discarded')));
187
239
  const onEvent = (event) => {
188
240
  if (!active)
189
241
  return;
242
+ if (event.type === 'request/context') {
243
+ // A prepared step can still report A after the next route became B.
244
+ // Keep that record in raw history, but do not publish its capacity
245
+ // into B's live view (or warn on it before a later reconciliation).
246
+ const route = event.data;
247
+ const model = agent.model;
248
+ const selected = typeof model?.current === 'function' ? model.current() : undefined;
249
+ if (selected !== undefined && typeof route.provider === 'string' && route.provider !== '' &&
250
+ typeof route.model === 'string' && route.model !== '' &&
251
+ (route.provider !== selected.provider || route.model !== selected.model))
252
+ return;
253
+ }
190
254
  // Legacy per-token chunks arrive as session events; they wake the
191
255
  // renderer frame-coalesced like live stream frames.
192
256
  listener(translator.translateEvent(event), event.type === 'assistant/chunk' ? FRAME : SYNC);
@@ -243,12 +307,16 @@ export function createDshSession(ctx, target) {
243
307
  // and a synchronous throw reaches the caller synchronously (the input
244
308
  // pipeline rolls its bookkeeping back on it).
245
309
  submit(input, placement) {
310
+ // A disposed agent can neither run nor report this input: refuse it
311
+ // instead of queuing a preview nothing will ever retire.
312
+ if (disposed)
313
+ return Promise.resolve({ accepted: false, reason: t('input-session-disposed') });
246
314
  const message = messageFor(input);
247
315
  const queued = placement === 'steer' ? 'steer' : 'followup';
248
316
  pending.set(message.id, { id: message.id, text: input.text, placement: queued });
249
317
  try {
250
318
  if (placement === 'now')
251
- agent.cancel({ kind: 'user' });
319
+ dropOwn(() => agent.cancel({ kind: 'user' }));
252
320
  if (placement === 'steer')
253
321
  agent.steer(message);
254
322
  else
@@ -269,7 +337,7 @@ export function createDshSession(ctx, target) {
269
337
  if (cause === 'user')
270
338
  agent.cancel({ kind: 'user' }, { keepInbox: true });
271
339
  else
272
- agent.cancel({ kind: 'user' });
340
+ dropOwn(() => agent.cancel({ kind: 'user' }));
273
341
  // The kernel cancel settles its bookkeeping synchronously: the answer
274
342
  // is definitive either way (kept ids for a 'user' cancel, an emptied
275
343
  // queue otherwise).
@@ -1 +1 @@
1
- {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../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ultPayload } from '../compat/messa
6
6
  import { transcriptImagesOf } from '../transcript-images.js';
7
7
  import { isTeamToolName, TEAM_SPAWN_TOOL, teamMessageOf, teamToolCallView, teamToolResultView } from '../team-tools.js';
8
8
  import { refineSessionSearchTitle } from '../session-tools.js';
9
+ import { refineWorktreeCallTitle, WORKTREE_TOOL, worktreeResultView } from '../worktree-tool.js';
9
10
  import { teamMailboxAsRelay, withoutTeammateReminder } from '../compat/agent-team-0.2.0.js';
10
11
  /**
11
12
  * DeepSeek's rate windows, injected into the shared projector as its
@@ -123,8 +124,13 @@ const usageDelta = (usage) => usage === undefined
123
124
  /** DSH turn-close reasons; the ones without a shared name keep their label. */
124
125
  const turnEndReason = (reason) => {
125
126
  switch (reason.kind) {
126
- case 'completed':
127
127
  case 'aborted':
128
+ // Older durable logs may lack the nested cancel cause. Only the
129
+ // session's own teardown changes how the turn reads.
130
+ return reason.reason?.kind === 'disposed'
131
+ ? { kind: 'aborted', cause: 'disposed' }
132
+ : { kind: 'aborted' };
133
+ case 'completed':
128
134
  case 'interrupted':
129
135
  case 'blocked':
130
136
  return { kind: reason.kind };
@@ -200,8 +206,10 @@ export function createDshTranslator(deps) {
200
206
  if (tool?.presentCall === undefined)
201
207
  return teamToolCallView(name, rawArgs);
202
208
  // The session-search calls carry a static sentence the card header would
203
- // repeat verbatim; put the query back in the header (session-tools.ts).
204
- return refineSessionSearchTitle(name, tool.presentCall(JSON.parse(rawArgs)), rawArgs);
209
+ // repeat verbatim; put the query back in the header (session-tools.ts),
210
+ // and the branch in a create_worktree header (worktree-tool.ts).
211
+ const view = tool.presentCall(JSON.parse(rawArgs));
212
+ return refineWorktreeCallTitle(name, refineSessionSearchTitle(name, view, rawArgs), rawArgs);
205
213
  }
206
214
  catch {
207
215
  return undefined;
@@ -220,11 +228,12 @@ export function createDshTranslator(deps) {
220
228
  return local;
221
229
  const tool = deps.tools()?.get(name, deps.scope());
222
230
  if (tool?.presentResult === undefined) {
223
- // Only the team tools read the text: skip joining every other result.
224
- if (!isTeamToolName(name))
231
+ // Only the team and worktree tools read the text: skip joining every
232
+ // other result.
233
+ if (!isTeamToolName(name) && name !== WORKTREE_TOOL)
225
234
  return undefined;
226
235
  const text = toolResultPayload(data.message).content.map(item => (item.type === 'text' ? item.text : '')).join('').trim();
227
- return teamToolResultView(name, rawArgs, text);
236
+ return name === WORKTREE_TOOL ? worktreeResultView(name, rawArgs, text) : teamToolResultView(name, rawArgs, text);
228
237
  }
229
238
  return tool.presentResult(JSON.parse(rawArgs), {
230
239
  ...toolResultPayload(data.message),
@@ -18,7 +18,7 @@ type ApprovalStore = {
18
18
  /** Owns detached background handles and the agent-view projection. */
19
19
  export declare function createAgentViewProjection(ctx: Context, deps: {
20
20
  owner: Pick<ChannelOwner, 'current' | 'assertActive' | 'own'>;
21
- binding: Pick<Binding, 'agent' | 'capture' | 'isCurrent' | 'prepare' | 'abandon' | 'waitForDisposal'>;
21
+ binding: Pick<Binding, 'agent' | 'session' | 'capture' | 'isCurrent' | 'prepare' | 'abandon' | 'waitForDisposal'>;
22
22
  cwd(): string;
23
23
  configuredPreset?: string;
24
24
  configuredProvider?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-view-projection.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/agent-view-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAsB,MAAM,wBAAwB,CAAA;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAqBlD,OAAO,EAAqD,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAG7G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACvG,OAAO,KAAK,EAAE,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@ -218,7 +218,9 @@ export function createAgentViewProjection(ctx, deps) {
218
218
  return true;
219
219
  };
220
220
  const attach = async (sessionId) => {
221
- if (sessionId === String(deps.binding.agent.session.id))
221
+ // Same rule as `/resume` (#1651): a foreground whose agent unloaded under
222
+ // the screen has ended, so attaching to its own id reopens the log.
223
+ if (sessionId === String(deps.binding.agent.session.id) && deps.binding.session.status !== 'disposed')
222
224
  return { ok: true };
223
225
  const capture = deps.binding.capture();
224
226
  // A retiring Agent can remain in the registry until its JSONL writer has
@@ -1,8 +1,13 @@
1
1
  import type { AttachedContext } from '../../adapter/ports/channel-view.js';
2
2
  import type { MentionExpansion } from './types.js';
3
3
  /** What a panel hands to {@link AttachedContextRegistry.attach}: the staged
4
- * projection minus the fields the channel derives itself (id/chars/truncated). */
5
- export type AttachedContextInput = Pick<AttachedContext, 'source' | 'sourceId' | 'title' | 'content'>;
4
+ * projection minus the fields the channel derives itself (id/chars). */
5
+ export type AttachedContextInput = Pick<AttachedContext, 'source' | 'sourceId' | 'title' | 'content'> & {
6
+ /** Set by a caller that already capped this body (a retracted row's snapshot
7
+ * re-staged by the composer): the flag must ride along instead of being
8
+ * re-derived from a body that now fills the cap exactly. */
9
+ readonly truncated?: boolean;
10
+ };
6
11
  /**
7
12
  * Cell the registry writes through — the live ChannelState. The list is
8
13
  * REPLACED on every change (never mutated in place), which is both what the
@@ -28,6 +33,14 @@ export declare function buildAttachedContextBlock(context: AttachedContext): str
28
33
  * for. Returns how many blocks were appended (telemetry/assertions).
29
34
  */
30
35
  export declare function appendAttachedContextBlocks(blocks: MentionExpansion['blocks'], contexts: readonly AttachedContext[]): number;
36
+ /**
37
+ * Snapshot-first merge: a dock re-send keeps the contexts its row saved and
38
+ * still carries anything staged while the row sat in the dock. The live chips
39
+ * were already taken by `captureOrigin()`, so dropping them here would lose
40
+ * them for good. A duplicate key is the same panel staged again: the newer
41
+ * staged snapshot replaces the saved one (the user just edited it).
42
+ */
43
+ export declare function mergeAttachedContexts(saved: readonly AttachedContext[], staged: readonly AttachedContext[]): readonly AttachedContext[];
31
44
  /** The ChannelState-facing surface (projection writes + the two actions). */
32
45
  export interface AttachedContextRegistry {
33
46
  /** Stage (or re-stage) one panel context; see the REPLACE note below. */
@@ -1 +1 @@
1
- {"version":3,"file":"attached-context.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/attached-context.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;mFACmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;AAErG;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAA;CAC7C;AAcD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAG1E;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,SAAS,eAAe,EAAE,GACnC,MAAM,CAKR;AAED,6EAA6E;AAC7E,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACzC,mEAAmE;IACnE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,OAAO,IAAI,SAAS,eAAe,EAAE,CAAA;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,qBAAqB,EACnC,IAAI,EAAE,MAAM,IAAI,GACf,uBAAuB,CA4CzB"}
1
+ {"version":3,"file":"attached-context.d.ts","sourceRoot":"","sources":["../../../../src/ds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exts) {
48
48
  }
49
49
  return contexts.length;
50
50
  }
51
+ /** NUL cannot appear in either part, so the join is unambiguous. */
52
+ const keyOf = (sourceId, title) => `${sourceId}\u0000${title}`;
53
+ /**
54
+ * Snapshot-first merge: a dock re-send keeps the contexts its row saved and
55
+ * still carries anything staged while the row sat in the dock. The live chips
56
+ * were already taken by `captureOrigin()`, so dropping them here would lose
57
+ * them for good. A duplicate key is the same panel staged again: the newer
58
+ * staged snapshot replaces the saved one (the user just edited it).
59
+ */
60
+ export function mergeAttachedContexts(saved, staged) {
61
+ if (staged.length === 0)
62
+ return saved;
63
+ // A duplicate key is the same panel staged again: the newer snapshot wins,
64
+ // or the model gets the text the user just replaced. `saved` keeps its
65
+ // order; only its stale copies are swapped out.
66
+ const byKey = new Map(staged.map(context => [keyOf(context.sourceId, context.title), context]));
67
+ const merged = saved.map(context => byKey.get(keyOf(context.sourceId, context.title)) ?? context);
68
+ const savedKeys = new Set(saved.map(context => keyOf(context.sourceId, context.title)));
69
+ const extra = staged.filter(context => !savedKeys.has(keyOf(context.sourceId, context.title)));
70
+ return extra.length === 0 && merged.every((context, index) => context === saved[index]) ? saved : [...merged, ...extra];
71
+ }
51
72
  /**
52
73
  * Registry behind `ChannelUi.attachedContexts` / `attachContext` /
53
74
  * `detachContext`. It owns no state of its own: every entry lives in the
@@ -62,11 +83,13 @@ export function appendAttachedContextBlocks(blocks, contexts) {
62
83
  */
63
84
  export function createAttachedContextRegistry(holder, emit) {
64
85
  let sequence = 0;
65
- /** NUL cannot appear in either part, so the join is unambiguous. */
66
- const keyOf = (sourceId, title) => `${sourceId}\u0000${title}`;
67
86
  return {
68
87
  attach(input) {
69
- const capped = capContent(input.content);
88
+ // A snapshot that is already capped knows whether it was cut; re-deriving
89
+ // the flag from its body would read a cut body as a full one.
90
+ const capped = input.truncated === true
91
+ ? { content: input.content.slice(0, MENTION_MAX_FILE_CHARS), truncated: true }
92
+ : capContent(input.content);
70
93
  const list = holder().attachedContexts;
71
94
  const key = keyOf(input.sourceId, input.title);
72
95
  const index = list.findIndex(item => keyOf(item.sourceId, item.title) === key);