@deepseek-harness-tui/dsh-tui 0.16.1 → 0.18.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 (488) hide show
  1. package/README.md +213 -34
  2. package/assets/plugin-icon.svg +13 -0
  3. package/assets/windows-installer.cs +308 -0
  4. package/assets/windows-installer.ps1 +17 -0
  5. package/bin/dsh-tui.js +64 -5
  6. package/cli/adapters/dsh/index.mjs +111 -0
  7. package/cli/adapters/dsh/locate.mjs +73 -0
  8. package/cli/adapters/dsh/management-plugin.mjs +111 -0
  9. package/cli/args.mjs +154 -0
  10. package/cli/contracts.d.ts +48 -0
  11. package/cli/engine.mjs +92 -0
  12. package/cli/entry.mjs +48 -0
  13. package/cli/process.mjs +118 -0
  14. package/cli/protocol.mjs +23 -0
  15. package/cli/schema-v1.json +33 -0
  16. package/cordis.patch.yml +3 -1
  17. package/cordis.yml +3 -1
  18. package/guide/dsh-tui-guide/SKILL.md +1 -0
  19. package/guide/dsh-tui-guide/cli.en.md +114 -0
  20. package/guide/dsh-tui-guide/cli.md +114 -0
  21. package/guide/dsh-tui-guide/configuration.en.md +7 -5
  22. package/guide/dsh-tui-guide/configuration.md +7 -5
  23. package/guide/dsh-tui-guide/getting-started.en.md +33 -3
  24. package/guide/dsh-tui-guide/getting-started.md +23 -2
  25. package/guide/dsh-tui-guide/interaction.en.md +50 -17
  26. package/guide/dsh-tui-guide/interaction.md +35 -13
  27. package/guide/dsh-tui-guide/plugins.en.md +63 -11
  28. package/guide/dsh-tui-guide/plugins.md +41 -7
  29. package/guide/dsh-tui-guide/user-guide.en.md +55 -34
  30. package/guide/dsh-tui-guide/user-guide.md +45 -28
  31. package/lib/settings.json +85 -42
  32. package/lib/types/adapter/channel/plugins.d.ts.map +1 -1
  33. package/lib/types/adapter/channel/plugins.js +8 -0
  34. package/lib/types/adapter/channel/ui-policy.d.ts +2 -1
  35. package/lib/types/adapter/channel/ui-policy.d.ts.map +1 -1
  36. package/lib/types/adapter/channel/ui-policy.js +4 -0
  37. package/lib/types/adapter/ports/channel-display.d.ts +10 -0
  38. package/lib/types/adapter/ports/channel-display.d.ts.map +1 -1
  39. package/lib/types/adapter/ports/channel-session.d.ts +2 -0
  40. package/lib/types/adapter/ports/channel-session.d.ts.map +1 -1
  41. package/lib/types/adapter/ports/channel-settings.d.ts +20 -0
  42. package/lib/types/adapter/ports/channel-settings.d.ts.map +1 -1
  43. package/lib/types/adapter/ports/channel-ui.d.ts +22 -2
  44. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  45. package/lib/types/adapter/ports/channel-view.d.ts +11 -1
  46. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  47. package/lib/types/adapter/ports/channel.d.ts +7 -0
  48. package/lib/types/adapter/ports/channel.d.ts.map +1 -1
  49. package/lib/types/adapter/standard/grants.d.ts +60 -0
  50. package/lib/types/adapter/standard/grants.d.ts.map +1 -1
  51. package/lib/types/adapter/standard/grants.js +74 -0
  52. package/lib/types/agent/capabilities.d.ts +2 -0
  53. package/lib/types/agent/capabilities.d.ts.map +1 -1
  54. package/lib/types/agent/events.d.ts +15 -1
  55. package/lib/types/agent/events.d.ts.map +1 -1
  56. package/lib/types/api.d.ts +2 -2
  57. package/lib/types/api.d.ts.map +1 -1
  58. package/lib/types/backends/claude/translate/events.d.ts.map +1 -1
  59. package/lib/types/backends/claude/translate/events.js +2 -1
  60. package/lib/types/backends/codex/auth/status.js +1 -1
  61. package/lib/types/backends/codex/session/controls.d.ts.map +1 -1
  62. package/lib/types/backends/codex/session/controls.js +6 -5
  63. package/lib/types/backends/codex/session/goals.d.ts.map +1 -1
  64. package/lib/types/backends/codex/session/side-query.d.ts.map +1 -1
  65. package/lib/types/backends/codex/translate/events.d.ts.map +1 -1
  66. package/lib/types/backends/codex/translate/events.js +3 -1
  67. package/lib/types/backends/shared/channel-tokens.d.ts.map +1 -1
  68. package/lib/types/backends/shared/channel-tokens.js +9 -8
  69. package/lib/types/channel/history-restore.d.ts.map +1 -1
  70. package/lib/types/channel/history-restore.js +2 -0
  71. package/lib/types/channel/interaction.d.ts.map +1 -1
  72. package/lib/types/channel/interaction.js +1 -0
  73. package/lib/types/channel/projection.d.ts +1 -1
  74. package/lib/types/channel/projection.d.ts.map +1 -1
  75. package/lib/types/channel/projection.js +19 -4
  76. package/lib/types/channel/questions.d.ts +2 -0
  77. package/lib/types/channel/questions.d.ts.map +1 -1
  78. package/lib/types/channel/sanitize.d.ts +14 -0
  79. package/lib/types/channel/sanitize.d.ts.map +1 -1
  80. package/lib/types/channel/sanitize.js +55 -0
  81. package/lib/types/channel/working-directory.d.ts +9 -0
  82. package/lib/types/channel/working-directory.d.ts.map +1 -0
  83. package/lib/types/channel/working-directory.js +7 -0
  84. package/lib/types/commands.d.ts +8 -1
  85. package/lib/types/commands.d.ts.map +1 -1
  86. package/lib/types/commands.js +14 -5
  87. package/lib/types/components/ChatTitle.d.ts +7 -0
  88. package/lib/types/components/ChatTitle.d.ts.map +1 -0
  89. package/lib/types/components/ChatTitle.js +15 -0
  90. package/lib/types/components/CodeBlockFrame.d.ts.map +1 -1
  91. package/lib/types/components/CodeBlockFrame.js +10 -5
  92. package/lib/types/components/CompactionStatusRow.d.ts.map +1 -1
  93. package/lib/types/components/CompactionStatusRow.js +24 -3
  94. package/lib/types/components/GoalTodoPanel.d.ts +73 -6
  95. package/lib/types/components/GoalTodoPanel.d.ts.map +1 -1
  96. package/lib/types/components/GoalTodoPanel.js +165 -17
  97. package/lib/types/components/Markdown.d.ts +9 -1
  98. package/lib/types/components/Markdown.d.ts.map +1 -1
  99. package/lib/types/components/Markdown.js +5 -4
  100. package/lib/types/components/MessageList.d.ts.map +1 -1
  101. package/lib/types/components/MessageList.js +20 -14
  102. package/lib/types/components/PluginGrantList.d.ts +45 -0
  103. package/lib/types/components/PluginGrantList.d.ts.map +1 -0
  104. package/lib/types/components/PluginGrantList.js +126 -0
  105. package/lib/types/components/PluginInstallPane.d.ts.map +1 -1
  106. package/lib/types/components/PluginInstallPane.js +35 -6
  107. package/lib/types/components/PluginManagePane.d.ts.map +1 -1
  108. package/lib/types/components/PluginManagePane.js +65 -8
  109. package/lib/types/components/PromptInput.d.ts +13 -5
  110. package/lib/types/components/PromptInput.d.ts.map +1 -1
  111. package/lib/types/components/PromptInput.js +190 -108
  112. package/lib/types/components/SplitDiffView.d.ts.map +1 -1
  113. package/lib/types/components/SplitDiffView.js +232 -22
  114. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  115. package/lib/types/components/SubagentDashboard.js +10 -0
  116. package/lib/types/components/SubagentDetailScene.d.ts +3 -1
  117. package/lib/types/components/SubagentDetailScene.d.ts.map +1 -1
  118. package/lib/types/components/SubagentDetailScene.js +17 -1
  119. package/lib/types/components/Whale.d.ts.map +1 -1
  120. package/lib/types/components/Whale.js +8 -5
  121. package/lib/types/components/approvals/ApprovalPanel.d.ts +1 -1
  122. package/lib/types/components/approvals/ApprovalPanel.d.ts.map +1 -1
  123. package/lib/types/components/approvals/ApprovalPanel.js +93 -11
  124. package/lib/types/components/bigfont.d.ts.map +1 -1
  125. package/lib/types/components/bigfont.js +2 -1
  126. package/lib/types/components/messages/AssistantToolUseMessage.d.ts +2 -1
  127. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  128. package/lib/types/components/messages/AssistantToolUseMessage.js +24 -11
  129. package/lib/types/components/onboardingModel.d.ts +2 -2
  130. package/lib/types/components/onboardingModel.js +3 -3
  131. package/lib/types/components/onboardingProviderPlan.d.ts +110 -0
  132. package/lib/types/components/onboardingProviderPlan.d.ts.map +1 -0
  133. package/lib/types/components/onboardingProviderPlan.js +78 -0
  134. package/lib/types/components/previewRows.d.ts +19 -0
  135. package/lib/types/components/previewRows.d.ts.map +1 -0
  136. package/lib/types/components/previewRows.js +46 -0
  137. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  138. package/lib/types/components/questions/AskUserQuestionPanel.js +75 -10
  139. package/lib/types/components/sessions/ForeignSessionRow.d.ts +3 -9
  140. package/lib/types/components/sessions/ForeignSessionRow.d.ts.map +1 -1
  141. package/lib/types/components/sessions/ForeignSessionRow.js +6 -10
  142. package/lib/types/components/sessions/SessionListRow.d.ts +4 -9
  143. package/lib/types/components/sessions/SessionListRow.d.ts.map +1 -1
  144. package/lib/types/components/sessions/SessionListRow.js +18 -10
  145. package/lib/types/components/sidePanel/InfoPanel.d.ts.map +1 -1
  146. package/lib/types/components/sidePanel/InfoPanel.js +4 -3
  147. package/lib/types/components/sidePanel/SidePanelLayout.d.ts.map +1 -1
  148. package/lib/types/components/sidePanel/SidePanelLayout.js +5 -5
  149. package/lib/types/components/sidePanel/WorkspacePanel.d.ts.map +1 -1
  150. package/lib/types/components/sidePanel/WorkspacePanel.js +19 -7
  151. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +7 -0
  152. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  153. package/lib/types/components/sidePanel/btw/BtwComposer.js +16 -0
  154. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  155. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +8 -1
  156. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts +7 -1
  157. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  158. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +8 -1
  159. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts +30 -0
  160. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.d.ts.map +1 -0
  161. package/lib/types/components/sidePanel/btw/useBtwComposerPaste.js +94 -0
  162. package/lib/types/components/sidePanel/builtinPanels.d.ts.map +1 -1
  163. package/lib/types/components/sidePanel/builtinPanels.js +36 -18
  164. package/lib/types/components/sidePanel/companion/CompanionPanel.d.ts.map +1 -1
  165. package/lib/types/components/sidePanel/companion/CompanionPanel.js +2 -1
  166. package/lib/types/components/sidePanel/panelMarkdown.d.ts +32 -0
  167. package/lib/types/components/sidePanel/panelMarkdown.d.ts.map +1 -0
  168. package/lib/types/components/sidePanel/panelMarkdown.js +45 -0
  169. package/lib/types/components/sidePanel/pluginPanelAdapter.d.ts.map +1 -1
  170. package/lib/types/components/sidePanel/pluginPanelAdapter.js +6 -1
  171. package/lib/types/components/sidePanel/subagentFailureRead.d.ts +21 -0
  172. package/lib/types/components/sidePanel/subagentFailureRead.d.ts.map +1 -0
  173. package/lib/types/components/sidePanel/subagentFailureRead.js +66 -0
  174. package/lib/types/components/sidePanel/types.d.ts +2 -0
  175. package/lib/types/components/sidePanel/types.d.ts.map +1 -1
  176. package/lib/types/components/sidePanel/useSidePanel.d.ts.map +1 -1
  177. package/lib/types/components/sidePanel/useSidePanel.js +39 -7
  178. package/lib/types/components/trajectory/MiniWake.d.ts +2 -2
  179. package/lib/types/components/trajectory/MiniWake.d.ts.map +1 -1
  180. package/lib/types/components/trajectory/MiniWake.js +7 -3
  181. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  182. package/lib/types/components/workspaces/HomeWorkspaceRow.js +4 -7
  183. package/lib/types/dsh-adapter/backend/session.d.ts +7 -1
  184. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  185. package/lib/types/dsh-adapter/backend/session.js +62 -6
  186. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  187. package/lib/types/dsh-adapter/backend/translate.js +18 -4
  188. package/lib/types/dsh-adapter/backend-admission.d.ts +3 -3
  189. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts +1 -1
  190. package/lib/types/dsh-adapter/channel/agent-view-projection.d.ts.map +1 -1
  191. package/lib/types/dsh-adapter/channel/agent-view-projection.js +3 -1
  192. package/lib/types/dsh-adapter/channel/binding-events.d.ts +5 -1
  193. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  194. package/lib/types/dsh-adapter/channel/binding-events.js +18 -1
  195. package/lib/types/dsh-adapter/channel/command-completions.d.ts.map +1 -1
  196. package/lib/types/dsh-adapter/channel/command-completions.js +6 -8
  197. package/lib/types/dsh-adapter/channel/composer-images.d.ts +11 -1
  198. package/lib/types/dsh-adapter/channel/composer-images.d.ts.map +1 -1
  199. package/lib/types/dsh-adapter/channel/composer-images.js +121 -113
  200. package/lib/types/dsh-adapter/channel/composer-mentions.d.ts.map +1 -1
  201. package/lib/types/dsh-adapter/channel/composer-mentions.js +38 -17
  202. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +1 -1
  203. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  204. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +9 -5
  205. package/lib/types/dsh-adapter/channel/core/actions.d.ts +1 -1
  206. package/lib/types/dsh-adapter/channel/core/actions.d.ts.map +1 -1
  207. package/lib/types/dsh-adapter/channel/core/actions.js +23 -2
  208. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts +10 -1
  209. package/lib/types/dsh-adapter/channel/core/binding-feed.d.ts.map +1 -1
  210. package/lib/types/dsh-adapter/channel/core/binding-feed.js +48 -3
  211. package/lib/types/dsh-adapter/channel/core/compose.d.ts +5 -2
  212. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  213. package/lib/types/dsh-adapter/channel/core/compose.js +7 -0
  214. package/lib/types/dsh-adapter/channel/core/files.d.ts.map +1 -1
  215. package/lib/types/dsh-adapter/channel/core/files.js +2 -1
  216. package/lib/types/dsh-adapter/channel/core/host.d.ts +14 -10
  217. package/lib/types/dsh-adapter/channel/core/host.d.ts.map +1 -1
  218. package/lib/types/dsh-adapter/channel/core/host.js +192 -13
  219. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts +1 -0
  220. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  221. package/lib/types/dsh-adapter/channel/core/local-actions.js +32 -3
  222. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  223. package/lib/types/dsh-adapter/channel/extensions.js +31 -5
  224. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  225. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  226. package/lib/types/dsh-adapter/channel/input-actions.js +34 -0
  227. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +5 -2
  228. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  229. package/lib/types/dsh-adapter/channel/input-delivery.js +31 -4
  230. package/lib/types/dsh-adapter/channel/mentions.d.ts.map +1 -1
  231. package/lib/types/dsh-adapter/channel/mentions.js +21 -7
  232. package/lib/types/dsh-adapter/channel/model-actions.d.ts +1 -1
  233. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  234. package/lib/types/dsh-adapter/channel/model-actions.js +7 -1
  235. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  236. package/lib/types/dsh-adapter/channel/model-selection.js +6 -4
  237. package/lib/types/dsh-adapter/channel/paths.d.ts.map +1 -1
  238. package/lib/types/dsh-adapter/channel/paths.js +11 -9
  239. package/lib/types/dsh-adapter/channel/session-fork.d.ts.map +1 -1
  240. package/lib/types/dsh-adapter/channel/session-fork.js +1 -0
  241. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts +1 -1
  242. package/lib/types/dsh-adapter/channel/session-live-adoption.d.ts.map +1 -1
  243. package/lib/types/dsh-adapter/channel/session-live-adoption.js +6 -1
  244. package/lib/types/dsh-adapter/channel/session-metadata.d.ts.map +1 -1
  245. package/lib/types/dsh-adapter/channel/session-metadata.js +15 -2
  246. package/lib/types/dsh-adapter/channel/session-reset.d.ts +1 -1
  247. package/lib/types/dsh-adapter/channel/session-reset.d.ts.map +1 -1
  248. package/lib/types/dsh-adapter/channel/session-reset.js +7 -1
  249. package/lib/types/dsh-adapter/channel/session-resume.d.ts +1 -1
  250. package/lib/types/dsh-adapter/channel/session-resume.d.ts.map +1 -1
  251. package/lib/types/dsh-adapter/channel/session-resume.js +56 -36
  252. package/lib/types/dsh-adapter/channel/session-rewind.d.ts +1 -1
  253. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  254. package/lib/types/dsh-adapter/channel/session-rewind.js +3 -1
  255. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts +1 -1
  256. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  257. package/lib/types/dsh-adapter/channel/session-tree-actions.js +3 -1
  258. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  259. package/lib/types/dsh-adapter/channel/settings-host.js +10 -3
  260. package/lib/types/dsh-adapter/channel/state.d.ts +1 -1
  261. package/lib/types/dsh-adapter/channel/state.d.ts.map +1 -1
  262. package/lib/types/dsh-adapter/channel/state.js +2 -2
  263. package/lib/types/dsh-adapter/channel/types.d.ts +13 -1
  264. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  265. package/lib/types/dsh-adapter/compat/liveSession.d.ts +3 -3
  266. package/lib/types/dsh-adapter/compat/liveSession.js +3 -3
  267. package/lib/types/dsh-adapter/compat/sessionLog.d.ts +1 -1
  268. package/lib/types/dsh-adapter/compat/sessionLog.d.ts.map +1 -1
  269. package/lib/types/dsh-adapter/compat/sessionLog.js +17 -1
  270. package/lib/types/dsh-adapter/contract.d.ts +7 -5
  271. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  272. package/lib/types/dsh-adapter/contract.js +10 -5
  273. package/lib/types/dsh-adapter/effect-ledger.d.ts +1 -1
  274. package/lib/types/dsh-adapter/effect-ledger.d.ts.map +1 -1
  275. package/lib/types/dsh-adapter/effect-ledger.js +1 -0
  276. package/lib/types/dsh-adapter/entry-slot.d.ts +6 -0
  277. package/lib/types/dsh-adapter/entry-slot.d.ts.map +1 -1
  278. package/lib/types/dsh-adapter/experimental-bundles.d.ts +29 -0
  279. package/lib/types/dsh-adapter/experimental-bundles.d.ts.map +1 -0
  280. package/lib/types/dsh-adapter/experimental-bundles.js +15 -0
  281. package/lib/types/dsh-adapter/grant-file.d.ts +70 -0
  282. package/lib/types/dsh-adapter/grant-file.d.ts.map +1 -0
  283. package/lib/types/dsh-adapter/grant-file.js +178 -0
  284. package/lib/types/dsh-adapter/host-access.d.ts +4 -0
  285. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  286. package/lib/types/dsh-adapter/host-access.js +54 -4
  287. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  288. package/lib/types/dsh-adapter/host-contract.js +2 -2
  289. package/lib/types/dsh-adapter/host-dsh.js +3 -3
  290. package/lib/types/dsh-adapter/index.d.ts +8 -4
  291. package/lib/types/dsh-adapter/index.d.ts.map +1 -1
  292. package/lib/types/dsh-adapter/index.js +17 -12
  293. package/lib/types/dsh-adapter/panels.d.ts +28 -8
  294. package/lib/types/dsh-adapter/panels.d.ts.map +1 -1
  295. package/lib/types/dsh-adapter/panels.js +11 -56
  296. package/lib/types/dsh-adapter/plugin-declaration.d.ts +28 -0
  297. package/lib/types/dsh-adapter/plugin-declaration.d.ts.map +1 -1
  298. package/lib/types/dsh-adapter/plugin-declaration.js +43 -1
  299. package/lib/types/dsh-adapter/plugin-install.d.ts +28 -1
  300. package/lib/types/dsh-adapter/plugin-install.d.ts.map +1 -1
  301. package/lib/types/dsh-adapter/plugin-install.js +160 -13
  302. package/lib/types/dsh-adapter/plugin-manage.d.ts +53 -10
  303. package/lib/types/dsh-adapter/plugin-manage.d.ts.map +1 -1
  304. package/lib/types/dsh-adapter/plugin-manage.js +240 -51
  305. package/lib/types/dsh-adapter/plugin.d.ts +81 -0
  306. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  307. package/lib/types/dsh-adapter/plugin.js +378 -84
  308. package/lib/types/dsh-adapter/plugins-info.d.ts +6 -7
  309. package/lib/types/dsh-adapter/plugins-info.d.ts.map +1 -1
  310. package/lib/types/dsh-adapter/plugins-info.js +99 -31
  311. package/lib/types/dsh-adapter/presets.d.ts +19 -6
  312. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  313. package/lib/types/dsh-adapter/presets.js +69 -12
  314. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  315. package/lib/types/dsh-adapter/process-exit.js +1 -1
  316. package/lib/types/dsh-adapter/providerWizard.d.ts +2 -0
  317. package/lib/types/dsh-adapter/providerWizard.d.ts.map +1 -1
  318. package/lib/types/dsh-adapter/providerWizard.js +11 -5
  319. package/lib/types/dsh-adapter/row-attachment.d.ts +30 -0
  320. package/lib/types/dsh-adapter/row-attachment.d.ts.map +1 -0
  321. package/lib/types/dsh-adapter/row-attachment.js +29 -0
  322. package/lib/types/dsh-adapter/session-tools.d.ts +34 -0
  323. package/lib/types/dsh-adapter/session-tools.d.ts.map +1 -0
  324. package/lib/types/dsh-adapter/session-tools.js +39 -0
  325. package/lib/types/dsh-adapter/settings-sections.d.ts +18 -1
  326. package/lib/types/dsh-adapter/settings-sections.d.ts.map +1 -1
  327. package/lib/types/dsh-adapter/settings-sections.js +73 -0
  328. package/lib/types/dsh-adapter/status.d.ts +88 -1
  329. package/lib/types/dsh-adapter/status.d.ts.map +1 -1
  330. package/lib/types/dsh-adapter/status.js +318 -3
  331. package/lib/types/dsh-adapter/team-mode.d.ts +42 -33
  332. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  333. package/lib/types/dsh-adapter/team-mode.js +76 -112
  334. package/lib/types/dsh-adapter/worktree-tool.d.ts +27 -0
  335. package/lib/types/dsh-adapter/worktree-tool.d.ts.map +1 -0
  336. package/lib/types/dsh-adapter/worktree-tool.js +87 -0
  337. package/lib/types/extensions.d.ts +1 -1
  338. package/lib/types/extensions.d.ts.map +1 -1
  339. package/lib/types/force-production-react.js +3 -3
  340. package/lib/types/heldInputs.d.ts +36 -0
  341. package/lib/types/heldInputs.d.ts.map +1 -0
  342. package/lib/types/heldInputs.js +173 -0
  343. package/lib/types/i18n.d.ts +543 -73
  344. package/lib/types/i18n.d.ts.map +1 -1
  345. package/lib/types/i18n.js +265 -46
  346. package/lib/types/ink/colorize.d.ts +7 -1
  347. package/lib/types/ink/colorize.d.ts.map +1 -1
  348. package/lib/types/ink/colorize.js +29 -8
  349. package/lib/types/ink/components/App.d.ts +2 -1
  350. package/lib/types/ink/components/App.d.ts.map +1 -1
  351. package/lib/types/ink/components/App.js +10 -3
  352. package/lib/types/ink/components/ScrollBox.d.ts.map +1 -1
  353. package/lib/types/ink/components/ScrollBox.js +1 -0
  354. package/lib/types/ink/dom.d.ts +1 -0
  355. package/lib/types/ink/dom.d.ts.map +1 -1
  356. package/lib/types/ink/hooks/use-program-status.d.ts +78 -0
  357. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -0
  358. package/lib/types/ink/hooks/use-program-status.js +96 -0
  359. package/lib/types/ink/ink.d.ts +13 -4
  360. package/lib/types/ink/ink.d.ts.map +1 -1
  361. package/lib/types/ink/ink.js +119 -25
  362. package/lib/types/ink/output.d.ts +17 -2
  363. package/lib/types/ink/output.d.ts.map +1 -1
  364. package/lib/types/ink/output.js +85 -2
  365. package/lib/types/ink/parse-keypress.d.ts +1 -0
  366. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  367. package/lib/types/ink/parse-keypress.js +5 -4
  368. package/lib/types/ink/render-node-to-output.d.ts +2 -0
  369. package/lib/types/ink/render-node-to-output.d.ts.map +1 -1
  370. package/lib/types/ink/render-node-to-output.js +79 -10
  371. package/lib/types/ink/root.d.ts +8 -0
  372. package/lib/types/ink/root.d.ts.map +1 -1
  373. package/lib/types/ink/root.js +12 -3
  374. package/lib/types/ink/screen.d.ts +11 -0
  375. package/lib/types/ink/screen.d.ts.map +1 -1
  376. package/lib/types/ink/screen.js +44 -0
  377. package/lib/types/ink/selection.d.ts +7 -2
  378. package/lib/types/ink/selection.d.ts.map +1 -1
  379. package/lib/types/ink/selection.js +187 -44
  380. package/lib/types/ink/shutdown-input.d.ts +15 -0
  381. package/lib/types/ink/shutdown-input.d.ts.map +1 -0
  382. package/lib/types/ink/shutdown-input.js +28 -0
  383. package/lib/types/ink/sixel-cursor-heal.d.ts +21 -0
  384. package/lib/types/ink/sixel-cursor-heal.d.ts.map +1 -0
  385. package/lib/types/ink/sixel-cursor-heal.js +62 -0
  386. package/lib/types/ink/sixel-graphics.d.ts +6 -0
  387. package/lib/types/ink/sixel-graphics.d.ts.map +1 -1
  388. package/lib/types/ink/sixel-graphics.js +18 -0
  389. package/lib/types/ink/styles.d.ts +8 -1
  390. package/lib/types/ink/styles.d.ts.map +1 -1
  391. package/lib/types/ink/terminal-notification-windows.d.ts +195 -0
  392. package/lib/types/ink/terminal-notification-windows.d.ts.map +1 -0
  393. package/lib/types/ink/terminal-notification-windows.js +433 -0
  394. package/lib/types/ink/terminal-notification.d.ts +3 -1
  395. package/lib/types/ink/terminal-notification.d.ts.map +1 -1
  396. package/lib/types/ink/terminal-notification.js +4 -1
  397. package/lib/types/ink/terminal-querier.d.ts +9 -1
  398. package/lib/types/ink/terminal-querier.d.ts.map +1 -1
  399. package/lib/types/ink/terminal-querier.js +32 -1
  400. package/lib/types/ink/terminal.d.ts +23 -2
  401. package/lib/types/ink/terminal.d.ts.map +1 -1
  402. package/lib/types/ink/terminal.js +32 -2
  403. package/lib/types/ink/termio/osc.d.ts +2 -1
  404. package/lib/types/ink/termio/osc.d.ts.map +1 -1
  405. package/lib/types/ink/termio/osc.js +37 -8
  406. package/lib/types/ink/termio/osc7501.d.ts +102 -0
  407. package/lib/types/ink/termio/osc7501.d.ts.map +1 -0
  408. package/lib/types/ink/termio/osc7501.js +229 -0
  409. package/lib/types/ink/termio/tokenize.js +5 -7
  410. package/lib/types/onboardingDraft.d.ts +143 -0
  411. package/lib/types/onboardingDraft.d.ts.map +1 -0
  412. package/lib/types/onboardingDraft.js +71 -0
  413. package/lib/types/panels.d.ts +1 -1
  414. package/lib/types/panels.d.ts.map +1 -1
  415. package/lib/types/screens/AgentTranscriptScene.d.ts +3 -1
  416. package/lib/types/screens/AgentTranscriptScene.d.ts.map +1 -1
  417. package/lib/types/screens/AgentTranscriptScene.js +5 -1
  418. package/lib/types/screens/Chat.d.ts +6 -6
  419. package/lib/types/screens/Chat.d.ts.map +1 -1
  420. package/lib/types/screens/Chat.js +394 -141
  421. package/lib/types/screens/Launchpad.d.ts +8 -2
  422. package/lib/types/screens/Launchpad.d.ts.map +1 -1
  423. package/lib/types/screens/Launchpad.js +32 -12
  424. package/lib/types/screens/Onboarding.d.ts +22 -3
  425. package/lib/types/screens/Onboarding.d.ts.map +1 -1
  426. package/lib/types/screens/Onboarding.js +606 -36
  427. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  428. package/lib/types/screens/SessionSupervisor.js +31 -21
  429. package/lib/types/screens/Settings.d.ts +5 -1
  430. package/lib/types/screens/Settings.d.ts.map +1 -1
  431. package/lib/types/screens/Settings.js +528 -51
  432. package/lib/types/screens/StatusLine.d.ts +9 -3
  433. package/lib/types/screens/StatusLine.d.ts.map +1 -1
  434. package/lib/types/screens/StatusLine.js +91 -15
  435. package/lib/types/screens/StatusMetrics.d.ts +2 -11
  436. package/lib/types/screens/StatusMetrics.d.ts.map +1 -1
  437. package/lib/types/screens/StatusMetrics.js +20 -14
  438. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  439. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +1 -1
  440. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts +1 -1
  441. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.d.ts.map +1 -1
  442. package/lib/types/screens/sessionSupervisor/useSessionSupervisor.js +13 -21
  443. package/lib/types/sessionMounts.d.ts +14 -0
  444. package/lib/types/sessionMounts.d.ts.map +1 -1
  445. package/lib/types/sessionMounts.js +20 -9
  446. package/lib/types/sessions/format.d.ts +39 -0
  447. package/lib/types/sessions/format.d.ts.map +1 -1
  448. package/lib/types/sessions/format.js +83 -0
  449. package/lib/types/sessions/resumeFailure.d.ts +4 -0
  450. package/lib/types/sessions/resumeFailure.d.ts.map +1 -1
  451. package/lib/types/sessions/resumeFailure.js +12 -4
  452. package/lib/types/sessions/workspaceCounts.d.ts +6 -0
  453. package/lib/types/sessions/workspaceCounts.d.ts.map +1 -0
  454. package/lib/types/sessions/workspaceCounts.js +24 -0
  455. package/lib/types/settings/definitions.d.ts +24 -0
  456. package/lib/types/settings/definitions.d.ts.map +1 -1
  457. package/lib/types/settings/definitions.js +40 -15
  458. package/lib/types/tips.js +2 -2
  459. package/lib/types/tuiDisplayPrefs.d.ts +113 -5
  460. package/lib/types/tuiDisplayPrefs.d.ts.map +1 -1
  461. package/lib/types/tuiDisplayPrefs.js +276 -14
  462. package/lib/types/update.d.ts +15 -14
  463. package/lib/types/update.d.ts.map +1 -1
  464. package/lib/types/update.js +163 -115
  465. package/lib/types/updateProcess.d.ts +28 -0
  466. package/lib/types/updateProcess.d.ts.map +1 -0
  467. package/lib/types/updateProcess.js +135 -0
  468. package/lib/types/utils/inputWordBoundary.d.ts +5 -0
  469. package/lib/types/utils/inputWordBoundary.d.ts.map +1 -0
  470. package/lib/types/utils/inputWordBoundary.js +18 -0
  471. package/lib/types/utils/keymap.d.ts +1 -1
  472. package/lib/types/utils/keymap.d.ts.map +1 -1
  473. package/lib/types/utils/keymap.js +6 -1
  474. package/lib/types/utils/paths.d.ts +15 -0
  475. package/lib/types/utils/paths.d.ts.map +1 -1
  476. package/lib/types/utils/paths.js +25 -0
  477. package/lib/types/windowsInstaller.d.ts +4 -0
  478. package/lib/types/windowsInstaller.d.ts.map +1 -0
  479. package/lib/types/windowsInstaller.js +237 -0
  480. package/locale/en.json +6 -0
  481. package/locale/zh.json +6 -0
  482. package/package.json +130 -111
  483. package/presets/liangshen/custom-bash.mjs +13 -1
  484. package/presets/liangshen/instruction-hint.mjs +4 -1
  485. package/presets/liangshen/skill-search.mjs +14 -2
  486. package/presets/winbash.mjs +16 -4
  487. package/tui-profile/feed/README.md +17 -8
  488. package/tui-profile/feed/first-party.json +1 -1
@@ -7,6 +7,7 @@ import Schema from '@deepseek-ai/schemastery';
7
7
  import { Config } from './index.js';
8
8
  import { configValues, createSettingsScope, resolveSettingsNamespace } from './compat/settings.js';
9
9
  import { createChannel } from './channel.js';
10
+ import { channelOwnerCurrent } from './channel/owner.js';
10
11
  import { createDshSession } from './backend/session.js';
11
12
  import { createTuiSettingsService } from './tui-settings.js';
12
13
  import { EDITABLE_CONFIG_KEYS } from '../settings/definitions.js';
@@ -24,8 +25,11 @@ import { registerTuiChannel } from '../adapter/channel/host-registry.js';
24
25
  import { createChildStderrReporter, installChildStderrGuard } from './childStderr.js';
25
26
  import { removeClipboardImageDir } from '../utils/clipboard.js';
26
27
  import { appendCrashLog, serializeCrashDetail, unserializableCrashDetail } from '../utils/crashDetail.js';
28
+ import { pluginManagerOf } from './plugin-manager.js';
27
29
  import { logForDebugging } from '../utils/debug.js';
28
30
  import { createTerminalNotifier } from '../ink/terminal-notification.js';
31
+ import { getTerminalFocused } from '../ink/terminal-focus-state.js';
32
+ import { resolveNotificationMethod } from '../ink/terminal.js';
29
33
  import { isEnvTruthy } from '../utils/envUtils.js';
30
34
  import { QuestionStore, bindQuestionStore } from './questions.js';
31
35
  import { prepareQuestionAnswerer } from './questions-answerer.js';
@@ -48,13 +52,14 @@ import { clearResumeTarget, resumeTargetFromArgv, stripResumeArgs, writeResumeTa
48
52
  import { cmdlineArgsOf, initialPromptFromCmdlineArgs } from './startup-args.js';
49
53
  import { readHomePrefs } from '../homePrefs.js';
50
54
  import { handoffEventTag, formatHandoffNotice } from '../handoffEvents.js';
55
+ import { adoptHeldInputs, heldInputsResumeCommand, takeHeldInputs, writeHeldInputs } from '../heldInputs.js';
51
56
  import { armFirstFrameAck, beginHandoffAck, handoffAttemptId, ownsAltScreenExit } from '../handoffAck.js';
52
57
  import { DSH_BACKEND_ID, HOST_NOTICE_ENV, KERNEL_SWITCH_HANDOFF_ENV, RESUME_BACKEND_ENV, RESUME_RETRY_ENV, parseBackendId, readKernelPrefs, resolveRememberedBackend, resolveResumeTarget, writeKernelPrefs } from '../kernelPrefs.js';
53
58
  import { shouldOfferOnboarding } from '../onboardingPrefs.js';
54
59
  import { resolveSessionCwd } from '../utils/workspaceRoot.js';
55
60
  import { LAUNCH_PROMPT_SENT_ENV, beginRestartAttempt, checkForTuiUpdate, installedTuiVersion, isBootDeadlockTarget, isStandaloneRuntime, isVersionNewer, logRestartEvent, resolveDshProfileName, resolveTuiUpdateTarget, restartTui, updateTuiAndRestart, writeHandoffNotice, writeLastRunRecord } from '../update.js';
56
61
  import { getLang, isLang, resolveStartupLang, setLang, t, writeLangPref } from '../i18n.js';
57
- import { applyBtwContextBudget, applyBtwContextTurns, applyCodeFrameStyle, applyCompanionSkin, applyImageBacking, applyMathImageBacking, applyMathImageScale, applyMathRendering, applyMermaidDiagrams, applyPageMargin, applySidePanelOpen, applySidePanelRatio, applySidePanelSplitEnabled, BTW_CONTEXT_BUDGET_MAX, BTW_CONTEXT_BUDGET_MIN, BTW_CONTEXT_TURNS_MAX, BTW_CONTEXT_TURNS_MIN, DEFAULT_PAGE_MARGIN, DEFAULT_SIDE_PANEL_IDS, DEFAULT_STATUS_BAR, isPageMarginMode, normalizeJobGroupFold, normalizePageMargin, normalizeScrollGutter, normalizeSidePanelPanels, normalizeStatusBar, normalizeToolBackground, parsePageMarginSpec, resolveMathRendering, SIDE_PANEL_ID_PATTERN } from '../tuiDisplayPrefs.js';
62
+ import { applyBtwContextBudget, applyBtwContextTurns, applyCodeFrameStyle, applyCompanionSkin, applyImageBacking, applyMathImageBacking, applyMathImageScale, applyMathRendering, applyMermaidDiagrams, applyPageMargin, applySidePanelOpen, applySidePanelPanels, applySidePanelRatio, applySidePanelSplitEnabled, ALL_SIDE_PANELS, BTW_CONTEXT_BUDGET_MAX, BTW_CONTEXT_BUDGET_MIN, BTW_CONTEXT_TURNS_MAX, BTW_CONTEXT_TURNS_MIN, DEFAULT_PAGE_MARGIN, DEFAULT_STATUS_BAR, isPageMarginMode, normalizeJobGroupFold, normalizePageMargin, normalizeScrollGutter, normalizeSidePanelPanels, normalizePluginFieldsOrder, normalizeStatusBar, normalizeToolBackground, parsePageMarginSpec, parsePluginFieldsOrder, parseSidePanelPanels, resolveMathRendering } from '../tuiDisplayPrefs.js';
58
63
  import { draftComboConflicts, effectiveComboString, parseComboDraft, setKeymapOverrides, SHORTCUT_ACTIONS, } from '../utils/keymap.js';
59
64
  import { attachHerdrIntegration } from '../herdr.js';
60
65
  import { logMouseDebug } from '../utils/debug.js';
@@ -74,11 +79,11 @@ import { getHostShortcuts } from './shortcuts.js';
74
79
  import { getHostThemes } from './themes.js';
75
80
  import { attachSessionToWorkspace } from './workspace.js';
76
81
  import { createLocalWorkspaceRuntime, getHostWorkspaceRuntime } from './workspaces.js';
77
- import { getHostSettingsSections, getLocalSettingsSectionsHost } from './settings-sections.js';
78
- import { compositionRoot, withHostRootCapability } from './host-access.js';
82
+ import { trackHostSettingsSection } from './settings-sections.js';
83
+ import { compositionRoot, outsideActivation, withHostRootCapability } from './host-access.js';
84
+ import { createRowAttachment } from './row-attachment.js';
79
85
  import { armAdmissionLoader } from './admission-loader.js';
80
86
  import { assembleBackendsFromProfile } from './backend-assembly.js';
81
- import { applyConfiguredSidePanelPanels, applySidePanelPanelsFromSettings } from './panels.js';
82
87
  import { disposeRootSettled } from './root-dispose.js';
83
88
  import { render, ThemeProvider, AlternateScreen } from '../ui.js';
84
89
  import { PageMargin } from '../components/PageMargin.js';
@@ -86,8 +91,9 @@ import { normalizeSplashFont } from '../components/splashFonts.js';
86
91
  import { normalizeBrandSetting, resolveBrand, setActiveBrand } from '../branding.js';
87
92
  import { SETTING_GROUPS, SHORTCUT_FIELD_META, settingField } from '../settings/definitions.js';
88
93
  import instances from '../ink/instances.js';
94
+ import { getShutdownInput } from '../ink/shutdown-input.js';
89
95
  import { cursorMove, DISABLE_KITTY_KEYBOARD, DISABLE_MODIFY_OTHER_KEYS, DISABLE_WIN32_INPUT_MODE } from '../ink/termio/csi.js';
90
- import { DBP, DFE, DISABLE_MOUSE_TRACKING, EXIT_ALT_SCREEN, SHOW_CURSOR } from '../ink/termio/dec.js';
96
+ import { DBP, DFE, DISABLE_MOUSE_TRACKING, ESU, EXIT_ALT_SCREEN, SHOW_CURSOR } from '../ink/termio/dec.js';
91
97
  import { CLEAR_ITERM2_PROGRESS, CLEAR_TAB_STATUS, supportsTabStatus, wrapForMultiplexer } from '../ink/termio/osc.js';
92
98
  import { addProcessErrorAbsorber, fatalReasonForExit, registerProcessGuardFatalSink } from '../ink/update-overflow-guard.js';
93
99
  import { CHANNEL_UI_LIFETIME_ENDED } from '../adapter/channel/ui.js';
@@ -153,10 +159,153 @@ export function resolveTuiHostMode(stdoutIsTTY = process.stdout.isTTY === true,
153
159
  const explicitTuiLaunch = env.DSH_TUI_LAUNCHER_VERSION !== undefined || isStandaloneRuntime();
154
160
  return explicitTuiLaunch ? 'invalid-explicit-launch' : 'headless-host';
155
161
  }
162
+ /**
163
+ * Create the live task-notification settings around a notifier.
164
+ *
165
+ * The notifier holds the values for the terminal path, and the Windows branch
166
+ * needs the same two before it can decide whether to spawn anything. One writer
167
+ * keeps them in step - `applyDisplay` is the second caller, for a live /settings
168
+ * edit.
169
+ * @param notifier - The terminal notifier to configure.
170
+ * @param initial - The values this launch starts with.
171
+ * @returns The settings and the single function that changes them.
172
+ */
173
+ export function createTaskNotificationSettings(notifier, initial) {
174
+ const settings = { ...initial };
175
+ return {
176
+ settings,
177
+ configure(condition, method) {
178
+ settings.condition = condition ?? 'unfocused';
179
+ settings.method = method ?? 'auto';
180
+ notifier.configure(condition, method);
181
+ },
182
+ };
183
+ }
184
+ /**
185
+ * Ring the terminal for a completion the host's gate already approved.
186
+ *
187
+ * The gate asks whether the terminal is focused; this port runs after the toast's
188
+ * await, which is up to 30 s of PowerShell. Asking the focus question a second
189
+ * time here would drop the bell for a user who came back to the terminal in that
190
+ * window - while the log had already reported it rung (AC-5). The decision
191
+ * travels in instead. `notify()` is synchronous, so the override covers exactly
192
+ * this call.
193
+ * @param notifier - The terminal notifier the host configured.
194
+ * @param settings - The live settings the decision was taken from.
195
+ * @param title - The localized title.
196
+ * @param message - The single-line summary; empty rings for the title alone.
197
+ */
198
+ export function ringTaskCompletion(notifier, settings, title, message) {
199
+ // A later explicit off still cancels sound; merely regaining focus does not.
200
+ notifier.configure(settings.condition === 'unfocused' ? 'always' : settings.condition, 'bel');
201
+ try {
202
+ notifier.notify(title, message);
203
+ }
204
+ finally {
205
+ notifier.configure(settings.condition, settings.method);
206
+ }
207
+ }
208
+ /**
209
+ * Show one task-completion toast and answer for what it did.
210
+ *
211
+ * Exactly one answer reaches the terminal path: `unavailable` rings the bell
212
+ * (AC-5), because the alternative is a notification the user never learns
213
+ * about. `shown` is already delivered and `yielded` belongs to the external
214
+ * notifier (D8/AC-6) — ringing after either would remind the user twice.
215
+ *
216
+ * The transport is a parameter so the regression can drive all three answers
217
+ * without a toast, a registry write or a child process.
218
+ * @param title - The localized title.
219
+ * @param message - The single-line summary; empty shows the title alone.
220
+ * @param backendId - The session that completed; a DSH plugin only covers DSH events.
221
+ * @param delivery - The toast port, and the terminal path to fall back to.
222
+ */
223
+ export async function deliverTaskCompletionOnWindows(title, message, backendId, delivery) {
224
+ let externalNotifierActive = false;
225
+ if (backendId === 'dsh' && delivery.pluginManager !== undefined) {
226
+ try {
227
+ const plugins = await delivery.pluginManager.listPlugins();
228
+ externalNotifierActive = plugins.some(plugin => plugin.enabled && plugin.fiberPhase === 'active'
229
+ && ['@baobaolaodie/cc-dsh-notifier', 'cc-dsh-notifier'].includes(plugin.moduleName));
230
+ }
231
+ catch {
232
+ logForDebugging('external notifier inventory unavailable; using the built-in Windows notification');
233
+ }
234
+ }
235
+ const result = await delivery.toast({
236
+ title,
237
+ message,
238
+ externalNotifierActive,
239
+ canDispatch: delivery.canDispatch,
240
+ });
241
+ if (result.status !== 'unavailable' || delivery.canDispatch?.() === false)
242
+ return;
243
+ // AC-5 wants the bell, not a silent loss - and the reason is what makes the
244
+ // pair "toast missing + bell rang" explainable afterwards. Ring first, then
245
+ // report: the port rings for a completion the gate already approved, and a line
246
+ // written ahead of the action is how the fallback came to log a bell that a
247
+ // second look at the focus had eaten.
248
+ const cause = result.detail === undefined ? result.reason : `${result.reason}: ${result.detail}`;
249
+ delivery.terminal(title, message);
250
+ logForDebugging(`windows toast unavailable (${cause}); using the terminal fallback`);
251
+ }
252
+ /**
253
+ * The production toast port. The Windows module is imported on first use and
254
+ * never at load time, so this path does not pull it in on a host that never
255
+ * delivers a toast. A load that fails answers like any other unavailable
256
+ * transport instead of throwing: this path is fire-and-forget, and the caller
257
+ * still has the bell.
258
+ */
259
+ async function showWindowsToast(input) {
260
+ try {
261
+ const { notifyWindowsToast } = await import('../ink/terminal-notification-windows.js');
262
+ return await notifyWindowsToast(input);
263
+ }
264
+ catch (error) {
265
+ const detail = error instanceof Error ? error.message : String(error);
266
+ logForDebugging(`windows toast transport failed to load (${detail})`);
267
+ return { status: 'unavailable', reason: 'unexpected', detail };
268
+ }
269
+ }
156
270
  export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOptions = {}) {
157
271
  const config = configValues(runtimeConfig);
158
272
  const taskNotifier = createTerminalNotifier(process.stdout);
159
- taskNotifier.configure(config.taskNotifications, config.notificationMethod);
273
+ const { settings: notificationSettings, configure: configureTaskNotifications } = createTaskNotificationSettings(taskNotifier, {
274
+ condition: config.taskNotifications ?? 'unfocused',
275
+ method: config.notificationMethod ?? 'auto',
276
+ });
277
+ configureTaskNotifications(config.taskNotifications, config.notificationMethod);
278
+ /**
279
+ * Whether a task completion is announced at all: the one gate, asked before
280
+ * the Windows transport so a suppressed notification never costs a PowerShell
281
+ * process, and so a delivered toast never also rings the bell. The Windows
282
+ * fallback re-enters through `ringTaskCompletion`, which carries this answer
283
+ * instead of asking the focus question again after the awaits. Explicit off or
284
+ * owner release revokes pending dispatch; an already started host is not recalled.
285
+ */
286
+ const taskCompletionAlertsEnabled = () => process.stdout.isTTY === true
287
+ && notificationSettings.condition !== 'off'
288
+ && !(notificationSettings.condition === 'unfocused' && getTerminalFocused());
289
+ /**
290
+ * Announce a finished task: the channel's `onTaskComplete` payload and gate,
291
+ * with the Windows method resolved first (`auto` picks the toast there, D2).
292
+ */
293
+ const announceTaskCompletion = (preview, backendId) => {
294
+ if (!taskCompletionAlertsEnabled())
295
+ return;
296
+ const title = t('task-complete-notification');
297
+ const message = preview ?? '';
298
+ if (resolveNotificationMethod(notificationSettings.method, process.platform) !== 'windows') {
299
+ taskNotifier.notify(title, message);
300
+ return;
301
+ }
302
+ void deliverTaskCompletionOnWindows(title, message, backendId, {
303
+ pluginManager: pluginManagerOf(ctx),
304
+ canDispatch: () => channelOwnerCurrent(rawChannel) && notificationSettings.condition !== 'off',
305
+ toast: showWindowsToast,
306
+ terminal: (fallbackTitle, fallbackMessage) => ringTaskCompletion(taskNotifier, notificationSettings, fallbackTitle, fallbackMessage),
307
+ });
308
+ };
160
309
  // /restart handoff diagnosis: the replacement process is marked by env and
161
310
  // logs its boot progress to ~/.dsh-tui/restart.log (ordinary launches stay
162
311
  // silent). First line lands before anything in this function can throw.
@@ -335,7 +484,8 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
335
484
  // The host-level tool mount above is intentional for the TUI and for user
336
485
  // presets, but the official Minimal preset is a single-tool trajectory (one
337
486
  // persistent shell: bash on POSIX, pwsh on Windows). Filter only that preset
338
- // at the final assembly boundary. Reading the session on every assembly also
487
+ // (plus create_worktree for liangshen, presets.ts) at the final assembly
488
+ // boundary. Reading the session on every assembly also
339
489
  // makes blank-session /preset switches and resumed sessions behave correctly.
340
490
  // Agent Teams is decided at the same boundary: presets keep their legacy
341
491
  // delegation rows, and a request that carries `spawn_teammate` drops
@@ -824,7 +974,7 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
824
974
  settingsNs: tuiSettingsNs,
825
975
  onTaskComplete: preview => {
826
976
  if (!shadow)
827
- taskNotifier.notify(t('task-complete-notification'), preview);
977
+ announceTaskCompletion(preview, rawChannel.sessionRef.backendId);
828
978
  },
829
979
  settingsService: tuiSettings,
830
980
  // The backend reports its model with its first turn (`system/init`);
@@ -1006,9 +1156,9 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1006
1156
  applySidePanelSplitEnabled(config.sidePanel?.splitEnabled);
1007
1157
  applySidePanelOpen(config.sidePanel?.open);
1008
1158
  applySidePanelRatio(config.sidePanel?.ratio);
1009
- // Registered ids survive: on the profile path a third-party row may have
1010
- // registered its panel before this row applied (./panels.ts).
1011
- applyConfiguredSidePanelPanels(config.sidePanel?.panels);
1159
+ // The stored value only: `*` (the default) lets the registry supply the
1160
+ // plugin panels, so no registration-time merge is needed (issue #1662).
1161
+ applySidePanelPanels(config.sidePanel?.panels);
1012
1162
  applyCompanionSkin(config.companion?.skin);
1013
1163
  applyBtwContextTurns(config.btw?.contextTurns);
1014
1164
  applyBtwContextBudget(config.btw?.contextBudget);
@@ -1091,7 +1241,9 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1091
1241
  // Same no-default rule: applyDisplay resolves `?? config.smoothStreaming ?? true`.
1092
1242
  smoothStreaming: Schema.boolean(),
1093
1243
  taskNotifications: Schema.union(['off', 'unfocused', 'always']),
1094
- notificationMethod: Schema.union(['auto', 'osc9', 'bel']),
1244
+ // Must mirror Config's union (`src/dsh-adapter/index.ts`): a method
1245
+ // missing here is rejected by /settings and never reaches the runtime.
1246
+ notificationMethod: Schema.union(['auto', 'osc9', 'bel', 'windows']),
1095
1247
  // Same no-default rule: applyDisplay resolves `?? config.mermaidDiagrams ?? true`.
1096
1248
  mermaidDiagrams: Schema.boolean(),
1097
1249
  // Code-frame shape; unset keeps the light rail frame.
@@ -1129,6 +1281,8 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1129
1281
  activity: Schema.boolean().default(DEFAULT_STATUS_BAR.activity),
1130
1282
  trajectory: Schema.boolean().default(DEFAULT_STATUS_BAR.trajectory),
1131
1283
  shortcutHint: Schema.boolean().default(DEFAULT_STATUS_BAR.shortcutHint),
1284
+ pluginFields: Schema.boolean().default(DEFAULT_STATUS_BAR.pluginFields),
1285
+ pluginFieldsOrder: Schema.string().default(DEFAULT_STATUS_BAR.pluginFieldsOrder),
1132
1286
  }).default({ ...DEFAULT_STATUS_BAR }),
1133
1287
  // Side-panel preferences. No schema defaults on purpose (same rule as
1134
1288
  // foldTerminalCommand/expandEditor above): a default here would come
@@ -1248,9 +1402,6 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1248
1402
  }
1249
1403
  bootedTerminalImages = lastBootedTerminalImages ?? value.terminalImages ?? config.terminalImages ?? true;
1250
1404
  };
1251
- /** False only during the boot application below: a registered panel absent
1252
- * from its CSV is not a user removal (./panels.ts). */
1253
- let settingsEditsLive = true;
1254
1405
  // The /settings language field writes `lang` through the settings
1255
1406
  // service (user layer): apply it live and mirror it to lang.json so
1256
1407
  // the /lang command and next-boot resolution agree. DSH_TUI_LANG
@@ -1282,7 +1433,7 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1282
1433
  channel.setPromptSessionLabel(value.promptSessionLabel ?? config.promptSessionLabel ?? false);
1283
1434
  channel.setExpandEditor(value.expandEditor ?? config.expandEditor ?? true);
1284
1435
  channel.setSmoothStreaming(value.smoothStreaming ?? config.smoothStreaming ?? true);
1285
- taskNotifier.configure(value.taskNotifications ?? config.taskNotifications, value.notificationMethod ?? config.notificationMethod);
1436
+ configureTaskNotifications(value.taskNotifications ?? config.taskNotifications, value.notificationMethod ?? config.notificationMethod);
1286
1437
  applyMermaidDiagrams(value.mermaidDiagrams ?? config.mermaidDiagrams);
1287
1438
  applyCodeFrameStyle(value.codeFrameStyle ?? config.codeFrameStyle);
1288
1439
  applyMathRendering(resolveMathRendering(value, config));
@@ -1297,12 +1448,9 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1297
1448
  applySidePanelSplitEnabled(value.sidePanel?.splitEnabled ?? config.sidePanel?.splitEnabled);
1298
1449
  applySidePanelOpen(value.sidePanel?.open ?? config.sidePanel?.open);
1299
1450
  applySidePanelRatio(value.sidePanel?.ratio ?? config.sidePanel?.ratio);
1300
- // A registered panel missing from a live edit was unticked in /settings.
1301
- const panelsCsv = value.sidePanel?.panels ?? config.sidePanel?.panels;
1302
- if (settingsEditsLive)
1303
- applySidePanelPanelsFromSettings(panelsCsv);
1304
- else
1305
- applyConfiguredSidePanelPanels(panelsCsv);
1451
+ // The stored value only: registration never rewrites it, so every apply
1452
+ // (boot or live, same CSV or a new one) is idempotent (issue #1662).
1453
+ applySidePanelPanels(value.sidePanel?.panels ?? config.sidePanel?.panels);
1306
1454
  applyCompanionSkin(value.companion?.skin ?? config.companion?.skin);
1307
1455
  applyBtwContextTurns(value.btw?.contextTurns ?? config.btw?.contextTurns);
1308
1456
  applyBtwContextBudget(value.btw?.contextBudget ?? config.btw?.contextBudget);
@@ -1331,13 +1479,27 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1331
1479
  // re-apply — unrelated settings edits must not disturb a live /effort
1332
1480
  // choice mid-session.
1333
1481
  let lastEffortDefault = undefined;
1482
+ /** True only while boot's first settings snapshot is applied: a capability
1483
+ * backend restores its own effort at boot, and that first apply must not
1484
+ * overwrite it (#1688). */
1485
+ let bootApplication = false;
1334
1486
  const applyEffortDefault = (value) => {
1335
1487
  const next = value.effortDefault ?? null;
1336
1488
  if (next === lastEffortDefault)
1337
1489
  return;
1338
- lastEffortDefault = next;
1339
1490
  const level = next === null || next === 'auto' ? undefined : next;
1340
- channel.setDefaultEffort(level);
1491
+ // Capability backends restore their own effort. Boot is not a live edit:
1492
+ // Auto and resumed sessions keep that selection until the user changes it.
1493
+ const preserve = bootApplication && backendStart !== undefined && (level === undefined || backendStart.resumedSessionId !== undefined);
1494
+ if (!preserve && backendStart !== undefined && !channel.ready) {
1495
+ lastEffortDefault = undefined;
1496
+ return;
1497
+ }
1498
+ if (!preserve && channel.setDefaultEffort(level) === false) {
1499
+ lastEffortDefault = undefined;
1500
+ return;
1501
+ }
1502
+ lastEffortDefault = next;
1341
1503
  };
1342
1504
  const apply = (next) => {
1343
1505
  applyLayout(next);
@@ -1376,9 +1538,30 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1376
1538
  notifyChannel(t('settings-fullscreen-migrated'), { color: 'warning' });
1377
1539
  }
1378
1540
  const { fullscreen: staleFullscreen, ...migratedSettings } = bootSettings;
1379
- settingsEditsLive = false;
1541
+ bootApplication = true;
1380
1542
  apply(fullscreenMigration === 'unset' ? migratedSettings : bootSettings);
1381
- settingsEditsLive = true;
1543
+ bootApplication = false;
1544
+ if (backendStart !== undefined)
1545
+ settingsCtx.effect(() => {
1546
+ let active = true;
1547
+ let generation = channel.ready ? channel.agentBindingGeneration : undefined;
1548
+ const stop = channel.subscribe(() => {
1549
+ if (!channel.ready || (lastEffortDefault !== undefined && generation === channel.agentBindingGeneration))
1550
+ return;
1551
+ // Adoption publishes several synchronous updates before its binding generation.
1552
+ queueMicrotask(() => {
1553
+ if (!active || !channel.ready)
1554
+ return;
1555
+ if (generation !== undefined && generation !== channel.agentBindingGeneration) {
1556
+ lastEffortDefault = scope.get().effortDefault ?? null;
1557
+ }
1558
+ generation = channel.agentBindingGeneration;
1559
+ if (lastEffortDefault === undefined)
1560
+ applyEffortDefault(scope.get());
1561
+ });
1562
+ });
1563
+ return () => { active = false; stop(); };
1564
+ });
1382
1565
  let lastTerminalImages = bootSettings.terminalImages ?? config.terminalImages ?? true;
1383
1566
  let lastLaunchpad = bootSettings.launchpad ?? config.launchpad ?? true;
1384
1567
  settingsCtx.effect(() => scope.watch(next => {
@@ -1440,12 +1623,11 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1440
1623
  // dsh-tui-* host-seam insert list right after load (issue #557), which
1441
1624
  // left this registration silently skipped and /settings read-only.
1442
1625
  // channel.ts reads through the same fallback, so both sides meet in the
1443
- // same registry either way.
1444
- // The in-process DSH kernel registers into the local host first and moves
1445
- // the section to the composition's service once it exists.
1446
- let rehomeSettingsSection = () => undefined;
1626
+ // same registry either way — but which registry that is can still change
1627
+ // after this registration: the service row may activate later, or reload
1628
+ // into an empty state. trackHostSettingsSection follows it, so the section
1629
+ // never strands in the registry /settings stopped reading.
1447
1630
  {
1448
- let settingsSections = getHostSettingsSections(ctx.get('tuiSettingsSections')) ?? getLocalSettingsSectionsHost(ctx);
1449
1631
  const tuiSection = {
1450
1632
  ns: tuiSettingsNs,
1451
1633
  title: 'dsh-tui',
@@ -1587,11 +1769,12 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1587
1769
  },
1588
1770
  {
1589
1771
  ...settingField('effortDefault'),
1772
+ optionsSource: 'effort',
1590
1773
  format(value) {
1591
1774
  // Unset in settings.yaml: show what a boot would actually start
1592
1775
  // on (the persisted /effort choice → the cordis effort default)
1593
1776
  // instead of a misleading blank.
1594
- if (value === undefined || value === null || value === 'auto') {
1777
+ if (value === undefined || value === null) {
1595
1778
  return readEffortPref() ?? config.effort ?? 'auto';
1596
1779
  }
1597
1780
  return String(value);
@@ -1652,6 +1835,28 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1652
1835
  {
1653
1836
  ...settingField('statusBar.shortcutHint'),
1654
1837
  },
1838
+ {
1839
+ ...settingField('statusBar.pluginFields'),
1840
+ },
1841
+ {
1842
+ ...settingField('statusBar.pluginFieldsOrder'),
1843
+ // An empty draft means "show none" here, not the editor's default
1844
+ // "clear" (which would fall back to `*` and silently re-show every
1845
+ // field). `*` stays reachable by typing it, and an illegal shape
1846
+ // (`a`, `a;b`, a duplicate key) blocks the save instead of being
1847
+ // normalized into something the user did not ask for.
1848
+ parse(text) {
1849
+ return parsePluginFieldsOrder(text).mode === 'invalid'
1850
+ ? undefined
1851
+ : { kind: 'set', value: normalizePluginFieldsOrder(text) };
1852
+ },
1853
+ // Unset in the user layer: show the value the footer actually uses
1854
+ // (the schema default, `*`) instead of a blank row that would read
1855
+ // as "none" next to the all-unchecked boxes.
1856
+ format(value) {
1857
+ return normalizePluginFieldsOrder(value);
1858
+ },
1859
+ },
1655
1860
  {
1656
1861
  ...settingField('sidePanel.splitEnabled'),
1657
1862
  format(value) {
@@ -1689,24 +1894,28 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1689
1894
  },
1690
1895
  {
1691
1896
  ...settingField('sidePanel.panels'),
1692
- placeholder: DEFAULT_SIDE_PANEL_IDS,
1897
+ placeholder: ALL_SIDE_PANELS,
1693
1898
  format(value) {
1694
- // Unset in the user layer: show the effective list.
1695
- return typeof value === 'string' && value.trim() !== ''
1696
- ? value
1697
- : config.sidePanel?.panels ?? DEFAULT_SIDE_PANEL_IDS;
1899
+ // Project what the store actually uses: a hand-edited value with
1900
+ // an unusable token must not read differently here than it does
1901
+ // in the PanelBar, so it is normalized exactly like the store
1902
+ // normalizes it. Unset in the user layer: the effective config
1903
+ // value (`*` by default), which the picker reads as "everything
1904
+ // checked".
1905
+ return normalizeSidePanelPanels(typeof value === 'string' && value.trim() !== '' ? value : config.sidePanel?.panels);
1698
1906
  },
1699
1907
  parse(text) {
1700
- const draft = text.trim();
1701
- if (draft === '')
1908
+ const parsed = parseSidePanelPanels(text);
1909
+ if (parsed.mode === 'empty')
1702
1910
  return { kind: 'clear' };
1703
- // Strict gate: every token must be a well-formed panel id. The
1704
- // store would drop a typo silently, so a draft that does not
1705
- // round-trip is refused instead of saved as something else.
1706
- const tokens = draft.split(',').map(token => token.trim().toLowerCase()).filter(token => token !== '');
1707
- if (tokens.length === 0 || tokens.some(token => !SIDE_PANEL_ID_PATTERN.test(token)))
1911
+ if (parsed.mode === 'all')
1912
+ return { kind: 'set', value: ALL_SIDE_PANELS };
1913
+ // Strict gate: a malformed token (or a list embedding `*`, or a
1914
+ // temporary address no later run could honour) is refused instead
1915
+ // of saved as something else.
1916
+ if (parsed.mode === 'invalid')
1708
1917
  return undefined;
1709
- return { kind: 'set', value: normalizeSidePanelPanels(draft) };
1918
+ return { kind: 'set', value: parsed.ids.join(',') };
1710
1919
  },
1711
1920
  },
1712
1921
  {
@@ -1785,16 +1994,8 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1785
1994
  },
1786
1995
  ],
1787
1996
  };
1788
- let unregister = settingsSections.register(tuiSection);
1789
- ctx.effect(() => () => { unregister(); });
1790
- rehomeSettingsSection = () => {
1791
- const service = getHostSettingsSections(ctx.get('tuiSettingsSections'));
1792
- if (service === undefined || service === settingsSections)
1793
- return;
1794
- unregister();
1795
- settingsSections = service;
1796
- unregister = service.register(tuiSection);
1797
- };
1997
+ const disposeSection = trackHostSettingsSection(ctx, tuiSection);
1998
+ ctx.effect(() => () => { disposeSection(); });
1798
1999
  }
1799
2000
  // DSH approval seam: the permission layer asks ApprovalService.request(),
1800
2001
  // which dispatches an `approval/request` waterfall. With no answerer the
@@ -1848,6 +2049,10 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
1848
2049
  // The standalone entry has no `ctx.cmdlineArgs` (its argv is the app's); a
1849
2050
  // replacement keeps the arguments but the first process sent their prompt.
1850
2051
  const initialPrompt = launchPromptSent ? '' : initialPromptFromCmdlineArgs(cmdlineArgs ?? process.argv.slice(2));
2052
+ // The queue a /restart carried over: held, never auto-sent (heldInputs.ts).
2053
+ const stopHeldInputs = adoptHeldInputs(channel);
2054
+ if (stopHeldInputs !== undefined)
2055
+ ctx.effect(() => stopHeldInputs, 'dsh-tui held inputs after startup');
1851
2056
  if (initialPrompt) {
1852
2057
  // A placeholder session refuses sends and nothing replays them after
1853
2058
  // adoption: hold the prompt until the channel is ready.
@@ -2027,7 +2232,15 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2027
2232
  });
2028
2233
  }
2029
2234
  refreshLastRunRecord();
2030
- void finishExit(ctx, instance, bootedFullscreen, t('restart-starting'), undefined, () => runRestart(ctx, profile, handoffSessionId(), handoffHint, { kernel: backendChoice }, exitSeam));
2235
+ // The queue dies with this process (the kernel records it canceled);
2236
+ // the replacement parks the same texts as held dock rows (#1651).
2237
+ const heldEnv = writeHeldInputs(channel.pending.map(item => item.text));
2238
+ void finishExit(ctx, instance, bootedFullscreen,
2239
+ // This line is the one the user actually sees before the terminal is
2240
+ // handed over (the composer's toast dies with the unmount): a
2241
+ // mid-turn restart must say that the running turn is interrupted,
2242
+ // not promise a clean resume.
2243
+ t(channel.working ? 'restart-during-turn' : 'restart-starting'), undefined, () => runRestart(ctx, profile, handoffSessionId(), handoffHint, { kernel: backendChoice, env: heldEnv }, exitSeam));
2031
2244
  return;
2032
2245
  }
2033
2246
  // Judge against the live session behind the channel (channel.agentId),
@@ -2301,12 +2514,10 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2301
2514
  onPluginManage: createPluginManageEntry(ctx, {
2302
2515
  profileName: profile ?? resolveDshProfileName(),
2303
2516
  }),
2304
- // `/team [status] | on | off`: the Agent Teams bundle through the same
2305
- // lifecycle flow (team-mode.ts).
2517
+ // `/team [status]`: the live team report (team-mode.ts). The bundle switch
2518
+ // is `/plugin enable|disable`, which shares the lifecycle flow.
2306
2519
  onTeamCommand: createTeamCommandEntry(ctx, {
2307
2520
  profileName: profile ?? resolveDshProfileName(),
2308
- // The host reports `unknown` when it has no version: read the installed one.
2309
- kernelVersion: entrySlot?.kernelVersion === 'unknown' ? undefined : entrySlot?.kernelVersion,
2310
2521
  }),
2311
2522
  kernelPinned: backendPinned,
2312
2523
  // Only a `dsh --profile <name>` launch has a profile installation for
@@ -2502,10 +2713,10 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2502
2713
  };
2503
2714
  /**
2504
2715
  * Services composed after the mount: re-read what the screen took as values
2505
- * at mount (Chat's stores, theme host, toast sink, /settings section).
2716
+ * at mount (Chat's stores, theme host, toast sink). The /settings section
2717
+ * follows its registry on its own (trackHostSettingsSection).
2506
2718
  */
2507
2719
  const refreshHostServices = () => {
2508
- rehomeSettingsSection();
2509
2720
  bindToastSink();
2510
2721
  if (!exited)
2511
2722
  instance?.rerender(buildTree());
@@ -2540,6 +2751,36 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2540
2751
  catch {
2541
2752
  }
2542
2753
  };
2754
+ // The row's seams (presets, ask_user, approvals, the assembly filters)
2755
+ // live on the row and unload with it: a row that comes back mounts them again.
2756
+ const rowAttachment = createRowAttachment({
2757
+ closed: () => compositionFailed || exited,
2758
+ ready: () => channel.ready,
2759
+ mountSeams: async (dshCtx) => {
2760
+ await installPresets(dshCtx);
2761
+ const seams = mountDshQuestionSeams(dshCtx);
2762
+ if (seams.notice !== undefined)
2763
+ notifyChannel(seams.notice, { color: 'error' });
2764
+ if (seams.registration.kind === 'waterfall')
2765
+ seams.registration.register(channel);
2766
+ mountDshApprovals(dshCtx);
2767
+ refreshHostServices();
2768
+ },
2769
+ readConfig: (rowRuntimeConfig) => { rowFacts.config = configValues(rowRuntimeConfig); },
2770
+ ended: () => channel.status === 'disposed',
2771
+ // The resume path reopens the session on the entry's own context, so
2772
+ // a later unload of the row can no longer take the agent along. It
2773
+ // runs as the entry's action: the row's activation only triggered it.
2774
+ reopen: async () => {
2775
+ const result = await outsideActivation(() => channel.resumeTo(channel.sessionId));
2776
+ if (result.ok)
2777
+ notifyChannel(t('session-reattached'));
2778
+ },
2779
+ failed: (error) => {
2780
+ logForDebugging(`dsh-tui: reopening the session after its row came back failed (${error instanceof Error ? error.message : String(error)})`);
2781
+ },
2782
+ });
2783
+ entrySlot.reattachDsh = rowAttachment.reattach;
2543
2784
  entrySlot.attachDsh = async (rowCtx, rowRuntimeConfig) => {
2544
2785
  const dshCtx = rowCtx;
2545
2786
  // The composition failed (its row is on screen), or the process is
@@ -2549,14 +2790,7 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2549
2790
  try {
2550
2791
  const rowConfig = configValues(rowRuntimeConfig);
2551
2792
  rowFacts.config = rowConfig;
2552
- await installPresets(dshCtx);
2553
- const seams = mountDshQuestionSeams(dshCtx);
2554
- if (seams.notice !== undefined)
2555
- notifyChannel(seams.notice, { color: 'error' });
2556
- if (seams.registration.kind === 'waterfall')
2557
- seams.registration.register(channel);
2558
- mountDshApprovals(dshCtx);
2559
- refreshHostServices();
2793
+ await rowAttachment.mount(dshCtx);
2560
2794
  const rowRoute = { provider: rowConfig.provider, model: rowConfig.model };
2561
2795
  // The same startup/deployment split the plugin's own boot makes (issue #67).
2562
2796
  const { startupRoute: rowStartupRoute, deploymentRoute: rowDeploymentRoute } = startupRoutes(dshCtx, rowRoute);
@@ -2573,7 +2807,7 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2573
2807
  const created = await openOnRow(undefined, { cwd });
2574
2808
  await takeOpened(created);
2575
2809
  refreshLastRunRecord();
2576
- return createDshSession(dshCtx, { agent: created.agent, handle: created.handle });
2810
+ return createDshSession(dshCtx, { agent: created.agent, handle: created.handle }, { screenOutlivesContext: true });
2577
2811
  };
2578
2812
  // The entry mounted on rebuilt defaults: the row's own `workspace` /
2579
2813
  // `cwd` decide the session directory, with `apply`'s precedence. A
@@ -2597,7 +2831,7 @@ export async function apply(ctx, runtimeConfig, configOwner = ctx, runtimeOption
2597
2831
  ? undefined
2598
2832
  : rowConfig.sessionId ?? resumeTargetFromArgv(cmdlineArgsOf(dshCtx) ?? process.argv.slice(2));
2599
2833
  const opened = await openOnRow(rowSessionId, startupMeta);
2600
- const session = createDshSession(dshCtx, { agent: opened.agent, handle: opened.handle });
2834
+ const session = createDshSession(dshCtx, { agent: opened.agent, handle: opened.handle }, { screenOutlivesContext: true });
2601
2835
  // The composition failed while this opened: close the unadoptable session.
2602
2836
  if (compositionFailed) {
2603
2837
  await session.dispose().catch(() => undefined);
@@ -2938,6 +3172,7 @@ export function isExitResumable(deps) {
2938
3172
  * Exported for scripts/verify-shutdown-fallback.
2939
3173
  */
2940
3174
  export async function finishExit(ctx, instance, fullscreen, notice, stderrNotice, done, options = {}) {
3175
+ const input = options.shutdownInput ?? getShutdownInput(instance);
2941
3176
  try {
2942
3177
  // Resolve the Ink runtime twice: the instances map is keyed by stdout
2943
3178
  // identity, so a replaced/overridden stdout misses it; the render()
@@ -2945,7 +3180,10 @@ export async function finishExit(ctx, instance, fullscreen, notice, stderrNotice
2945
3180
  // a missed lookup skipped detachForShutdown, leaving the stdin pump,
2946
3181
  // TTY handlers and querier alive so the self-heal probe re-wrote
2947
3182
  // ENABLE_MOUSE_TRACKING after DISABLE_MOUSE_TRACKING had been sent).
2948
- const fromMap = readInkShutdownState(instances.get(process.stdout));
3183
+ const mapped = instances.get(input?.stdout ?? process.stdout);
3184
+ const fromMap = input === undefined || mapped?.shutdownInput === input
3185
+ ? readInkShutdownState(mapped)
3186
+ : undefined;
2949
3187
  const fromHandle = instance === undefined ? undefined : readInkShutdownState(instance);
2950
3188
  // A handle that exposes neither detach hook is not an Ink runtime we can
2951
3189
  // latch (e.g. the fake render handles in shutdown regressions) — treat it
@@ -2992,6 +3230,7 @@ export async function finishExit(ctx, instance, fullscreen, notice, stderrNotice
2992
3230
  // first frame, and the old process will close the alternate screen.
2993
3231
  const exitAlt = fullscreen && !(options.keepAltScreen === true) && ownsAltScreenExit() ? EXIT_ALT_SCREEN : '';
2994
3232
  const cleanup = [
3233
+ ESU,
2995
3234
  exitAlt,
2996
3235
  cursor,
2997
3236
  DISABLE_MOUSE_TRACKING,
@@ -3006,7 +3245,11 @@ export async function finishExit(ctx, instance, fullscreen, notice, stderrNotice
3006
3245
  ].join('');
3007
3246
  const suffix = notice === undefined ? '' : `${notice}\n`;
3008
3247
  const restoreFrame = options.keepAltScreen === true ? '\x1b[2J\x1b[H' : '';
3009
- await writeStream(process.stdout, `${restoreFrame}${cleanup}\r\n${suffix}`);
3248
+ // A replacement may already own the terminal. Its modes and frame must
3249
+ // survive old-root disposal; a stale exit notice also belongs to that root.
3250
+ if (input?.ownsInput() !== false) {
3251
+ await writeStream(input?.stdout ?? process.stdout, `${restoreFrame}${cleanup}\r\n${suffix}`);
3252
+ }
3010
3253
  // Re-drain AFTER the cleanup sequences have landed (#507): terminal
3011
3254
  // replies and mouse packets already in flight when the exit started
3012
3255
  // keep arriving while cleanup is being written — the detach-time drain
@@ -3016,14 +3259,21 @@ export async function finishExit(ctx, instance, fullscreen, notice, stderrNotice
3016
3259
  // environment; 50ms proved too tight there) while staying well inside
3017
3260
  // the exit window the user already waits through.
3018
3261
  await new Promise(resolve => setTimeout(resolve, 150));
3019
- runtime?.drainStdin?.();
3020
- if (stderrNotice !== undefined) {
3262
+ if (input !== undefined)
3263
+ input.drain();
3264
+ else
3265
+ runtime?.drainStdin?.();
3266
+ if (stderrNotice !== undefined && input?.ownsInput() !== false) {
3021
3267
  await writeStream(process.stderr, `\n${stderrNotice}\n`);
3022
3268
  }
3023
3269
  }
3024
3270
  catch {
3025
- ctx.logger.debug('dsh-tui: terminal cleanup failed; continuing with process shutdown');
3271
+ try {
3272
+ ctx.logger.debug('dsh-tui: terminal cleanup failed; continuing with process shutdown');
3273
+ }
3274
+ catch { /* a failed diagnostic must not swallow the exit action */ }
3026
3275
  }
3276
+ input?.release();
3027
3277
  // Filesystem-only: the exported clipboard images live in a per-process
3028
3278
  // temp directory that nothing else removes.
3029
3279
  removeClipboardImageDir();
@@ -3134,6 +3384,26 @@ function superviseReplacement(exitSeam, options) {
3134
3384
  }
3135
3385
  function runRestart(ctx, profile, sessionId, hint = id => resumeCommand(profile, id), options = {}, exitSeam) {
3136
3386
  logRestartEvent('runRestart: entered, disposing cordis root');
3387
+ // A wedged turn makes the root dispose wait forever: the agent teardown
3388
+ // waits for the loop to reach quiescence, and a tool that ignores its
3389
+ // AbortSignal never settles (dsh-agent-loop drains every dispatched tool on
3390
+ // abort). Spawning the replacement then would race this process for the
3391
+ // session mount, so the only honest answer is the resume hint the user can
3392
+ // run after this process is gone.
3393
+ // Held texts no replacement took (a stall, a failed spawn) stay on disk for
3394
+ // the resume command, which names their file; without a session to resume
3395
+ // they go. A replacement that ran took them already.
3396
+ const dropHeldInputs = () => { takeHeldInputs({ ...options.env }); };
3397
+ const resumeLine = (id) => heldInputsResumeCommand(hint(id), options.env);
3398
+ const ended = () => {
3399
+ if (sessionId === '')
3400
+ dropHeldInputs();
3401
+ return preservedSessionTail(sessionId, resumeLine);
3402
+ };
3403
+ const stalled = () => {
3404
+ writeHandoffNotice(`\ndsh-tui restart timed out while stopping the current turn.${ended()}`);
3405
+ process.exit(1);
3406
+ };
3137
3407
  disposeRootAndThen(ctx, () => {
3138
3408
  logRestartEvent('runRestart: root disposed, starting restartTui');
3139
3409
  const supervision = superviseReplacement(exitSeam, options);
@@ -3148,31 +3418,55 @@ function runRestart(ctx, profile, sessionId, hint = id => resumeCommand(profile,
3148
3418
  void restartTui(sessionId, supervision).then(restartCode => {
3149
3419
  logRestartEvent('runRestart: restartTui resolved', { restartCode });
3150
3420
  if (restartCode !== 0) {
3151
- writeHandoffNotice(`\ndsh-tui restart failed to spawn (exit ${restartCode}).${preservedSessionTail(sessionId, hint)}`);
3421
+ writeHandoffNotice(`\ndsh-tui restart failed to spawn (exit ${restartCode}).${ended()}`);
3422
+ }
3423
+ else {
3424
+ dropHeldInputs();
3152
3425
  }
3153
3426
  process.exit(restartCode);
3154
3427
  }, restartError => {
3155
3428
  const message = restartError instanceof Error ? restartError.message : String(restartError);
3156
3429
  logRestartEvent('runRestart: restartTui rejected', { message });
3157
- writeHandoffNotice(`\ndsh-tui restart failed: ${message}.${preservedSessionTail(sessionId, hint)}`);
3430
+ writeHandoffNotice(`\ndsh-tui restart failed: ${message}.${ended()}`);
3158
3431
  process.exit(1);
3159
3432
  });
3160
- });
3433
+ }, stalled);
3161
3434
  }
3162
3435
  function runUpdate(ctx, profile, sessionId, targetVersion, kernel, hint = id => resumeCommand(profile, id), exitSeam) {
3436
+ const recovery = preservedSessionTail(sessionId, hint);
3163
3437
  disposeRootAndThen(ctx, () => {
3438
+ logRestartEvent('update: starting', { profile, targetVersion });
3439
+ writeHandoffNotice(`\ndsh-tui: installation starts. Check/repair an interrupted installation before resuming.${recovery}`);
3164
3440
  if (profile === undefined) {
3165
- process.stderr.write(`\n${t('update-aborted-no-profile')}\n`);
3441
+ writeHandoffNotice(`\n${t('update-aborted-no-profile')}${recovery}`);
3166
3442
  process.exit(1);
3167
3443
  }
3168
- void updateTuiAndRestart(sessionId, profile, targetVersion, kernel, superviseReplacement(exitSeam, {})).then(({ updateCode, restartCode }) => {
3444
+ const cancellation = new AbortController();
3445
+ const supervision = superviseReplacement(exitSeam, {});
3446
+ const replacementRequest = exitSeam?.request;
3447
+ if (exitSeam !== undefined)
3448
+ exitSeam.request = () => {
3449
+ cancellation.abort();
3450
+ // Installer owns its cancellation deadline. Entry fallback disposal
3451
+ // must not kill this process before the owned installer tree settles.
3452
+ return 'supervising';
3453
+ };
3454
+ const onSpawn = supervision.onSpawn;
3455
+ supervision.onSpawn = child => {
3456
+ if (exitSeam !== undefined)
3457
+ exitSeam.request = replacementRequest;
3458
+ onSpawn?.(child);
3459
+ };
3460
+ void updateTuiAndRestart(sessionId, profile, targetVersion, kernel, supervision, cancellation.signal).then(({ updateCode, restartCode }) => {
3461
+ logRestartEvent('update: finished', { updateCode, restartCode });
3169
3462
  if (updateCode !== 0) {
3170
- process.stderr.write(`\ndsh-tui update failed (exit ${updateCode}).${preservedSessionTail(sessionId, hint)}`);
3463
+ writeHandoffNotice(`\ndsh-tui update failed (exit ${updateCode}). Check/repair the installation before resuming.${preservedSessionTail(sessionId, hint)}`);
3171
3464
  }
3172
3465
  process.exit(restartCode);
3173
3466
  }, updateError => {
3467
+ logRestartEvent('update: rejected');
3174
3468
  const message = updateError instanceof Error ? updateError.message : String(updateError);
3175
- process.stderr.write(`\ndsh-tui update failed: ${message}.${preservedSessionTail(sessionId, hint)}`);
3469
+ writeHandoffNotice(`\ndsh-tui update failed: ${message}. Check/repair the installation before resuming.${preservedSessionTail(sessionId, hint)}`);
3176
3470
  process.exit(1);
3177
3471
  });
3178
3472
  });