@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
@@ -28,6 +28,7 @@ import { suppressInputFor } from './input-suppression.js';
28
28
  import { LogUpdate } from './log-update.js';
29
29
  import { KittyGraphicsManager } from './kitty-graphics.js';
30
30
  import { SixelGraphicsManager } from './sixel-graphics.js';
31
+ import { SixelCursorHeal } from './sixel-cursor-heal.js';
31
32
  import { selectTerminalImageProtocol } from './terminal-image-protocol.js';
32
33
  import { nodeCache } from './node-cache.js';
33
34
  import { optimize } from './optimizer.js';
@@ -38,16 +39,17 @@ import { applyPositionedHighlight, scanPositions } from './render-to-screen.js';
38
39
  import createRenderer from './renderer.js';
39
40
  import { CharPool, cellAt, createScreen, HyperlinkPool, isEmptyCellAt, migrateScreenPools, StylePool } from './screen.js';
40
41
  import { applySearchHighlight } from './transcript-highlight.js';
41
- import { applySelectionOverlay, captureScrolledRows, clearSelection, createSelectionState, extendSelection, findPlainTextUrlAt, getSelectedText, getSelectionCursor, hasSelection, moveFocus, pickFollowForSelection, refreshSelectionFingerprint, selectLineAt, selectWordAt, shiftSelection, shiftSelectionForFollow, shiftSelectionForViewportResize, shiftSelectionForViewportTranslation, startSelection, updateSelection } from './selection.js';
42
+ import { applySelectionOverlay, captureScrolledRows, clearSelection, createSelectionState, extendSelection, findPlainTextUrlAt, getSelectedText, getSelectionCursor, hasSelection, moveFocus, pickFollowForSelection, refreshSelectionFingerprint, refreshSelectionPane, selectLineAt, selectWordAt, shiftSelection, shiftSelectionForFollow, shiftSelectionForViewportResize, shiftSelectionForViewportTranslation, startSelection, updateSelection } from './selection.js';
42
43
  import { isDecstbmSafe, SYNC_OUTPUT_SUPPORTED, serializeDiff, supportsCursorStyleReset, supportsDecrqmProbe, supportsExtendedKeys, supportsWin32InputMode, writeDiffToTerminal } from './terminal.js';
43
44
  import { CURSOR_HOME, cursorMove, cursorPosition, cursorStyle, DISABLE_KITTY_KEYBOARD, DISABLE_MODIFY_OTHER_KEYS, DISABLE_WIN32_INPUT_MODE, ENABLE_KITTY_KEYBOARD, ENABLE_MODIFY_OTHER_KEYS, ENABLE_WIN32_INPUT_MODE, ERASE_SCREEN, ERASE_SCROLLBACK, SGR_RESET } from './termio/csi.js';
44
- import { DBP, DFE, DISABLE_MOUSE_TRACKING, ENABLE_MOUSE_TRACKING, ENTER_ALT_SCREEN, EXIT_ALT_SCREEN, HIDE_CURSOR, SHOW_CURSOR } from './termio/dec.js';
45
+ import { DBP, DFE, DISABLE_MOUSE_TRACKING, ENABLE_MOUSE_TRACKING, ENTER_ALT_SCREEN, ESU, EXIT_ALT_SCREEN, HIDE_CURSOR, SHOW_CURSOR } from './termio/dec.js';
45
46
  import { CLEAR_ITERM2_PROGRESS, CLEAR_TAB_STATUS, setClipboard, supportsTabStatus, wrapForMultiplexer } from './termio/osc.js';
46
47
  import { decrqm, kittyGraphics, terminalCellSizePixels, terminalWindowSizePixels, xtversion } from './terminal-querier.js';
47
48
  import { TerminalWriteProvider } from './useTerminalNotification.js';
48
49
  import { TerminalImagesContext } from './hooks/use-terminal-images.js';
49
50
  import { DEFAULT_TERMINAL_CELL_SIZE, resolveTerminalCellSize } from './terminal-image.js';
50
51
  import { detachHandoffStdin } from './stdin-handoff.js';
52
+ import { claimShutdownInput } from './shutdown-input.js';
51
53
  // Alt-screen: renderer.ts sets cursor.visible = !isTTY || screen.height===0,
52
54
  // which is always false in alt-screen (TTY + content fills screen).
53
55
  // Reusing a frozen object saves 1 allocation per frame.
@@ -79,6 +81,7 @@ function makeAltScreenParkPatch(terminalRows) {
79
81
  }
80
82
  export default class Ink {
81
83
  options;
84
+ shutdownInput;
82
85
  log;
83
86
  terminal;
84
87
  kittyGraphicsManager = new KittyGraphicsManager();
@@ -88,6 +91,8 @@ export default class Ink {
88
91
  dom.markTreeDirty(this.rootNode);
89
92
  this.scheduleRender();
90
93
  });
94
+ sixelCursorHeal = new SixelCursorHeal(() => this.forceRedraw(), message => logForDebugging(message));
95
+ sixelCursorCheckSupported = false;
91
96
  sixelGraphicsSupported = false;
92
97
  kittyGraphicsSupported = false;
93
98
  kittyGraphicsProbeStarted = false;
@@ -121,6 +126,7 @@ export default class Ink {
121
126
  isDetachedForShutdown = false;
122
127
  shutdownCleanup;
123
128
  isPaused = false;
129
+ rawModeRecoveryTimer;
124
130
  container;
125
131
  rootNode;
126
132
  focusManager;
@@ -229,6 +235,13 @@ export default class Ink {
229
235
  }
230
236
  constructor(options) {
231
237
  this.options = options;
238
+ this.shutdownInput = claimShutdownInput(options.stdin, options.stdout, () => {
239
+ drainStdin(options.stdin);
240
+ try {
241
+ options.drainStdin?.();
242
+ }
243
+ catch { /* a revoked device must not abort cleanup */ }
244
+ }, () => this.unmount());
232
245
  autoBind(this);
233
246
  if (options.stdin.isTTY) {
234
247
  // Keep this listener through teardown: a pending libuv TTY read can
@@ -289,9 +302,11 @@ export default class Ink {
289
302
  if (options.stdout.isTTY) {
290
303
  options.stdout.on('resize', this.handleResize);
291
304
  process.on('SIGCONT', this.handleResume);
305
+ this.startRawModeRecovery();
292
306
  this.unsubscribeTTYHandlers = () => {
293
307
  options.stdout.off('resize', this.handleResize);
294
308
  process.off('SIGCONT', this.handleResume);
309
+ this.stopRawModeRecovery();
295
310
  };
296
311
  }
297
312
  this.rootNode = dom.createNode('ink-root');
@@ -397,6 +412,7 @@ export default class Ink {
397
412
  // blank→paint flicker). useVirtualScroll's height scaling already bounds
398
413
  // the per-resize cost; synchronous handling keeps dimensions consistent.
399
414
  handleResize = () => {
415
+ this.sixelCursorHeal.reset();
400
416
  const cols = this.options.stdout.columns || 80;
401
417
  const rows = this.options.stdout.rows || 24;
402
418
  // Duplicate resize events normally leave both layout and surface intact.
@@ -492,6 +508,7 @@ export default class Ink {
492
508
  */
493
509
  enterAlternateScreen() {
494
510
  this.pause();
511
+ this.sixelCursorHeal.reset();
495
512
  this.app?.querier.suspend();
496
513
  if (this.terminalQueryResumeTimer !== null) {
497
514
  clearTimeout(this.terminalQueryResumeTimer);
@@ -751,7 +768,7 @@ export default class Ink {
751
768
  // and this frame's wheel drain translates normally.
752
769
  const viewportResizes = consumeViewportResizes();
753
770
  if (viewportResizes.length > 0 && this.selection.anchor) {
754
- const resize = pickFollowForSelection(viewportResizes, this.selection.anchor.row);
771
+ const resize = pickFollowForSelection(viewportResizes, this.selection.anchor.row, this.selection.anchor.col);
755
772
  // Terminal resize rebuilds the screen at new dimensions; the
756
773
  // selection's screen-buffer coords are stale against the previous
757
774
  // frame's buffer and band capture would read garbage. Chrome-mount
@@ -792,7 +809,7 @@ export default class Ink {
792
809
  // (screen-local) so only anchor shifts — selection grows toward the
793
810
  // mouse as the anchor walks up. After release, both ends are text-
794
811
  // anchored and move as a block.
795
- const follow = pickFollowForSelection(consumeFollowScroll(), this.selection.anchor?.row ?? null);
812
+ const follow = pickFollowForSelection(consumeFollowScroll(), this.selection.anchor?.row ?? null, this.selection.anchor?.col);
796
813
  // pickFollowForSelection already checked anchor-in-viewport (that IS
797
814
  // the "selection is on scrollbox content" guard — footer/prompt
798
815
  // selections on static text match no viewport and follow nothing).
@@ -866,6 +883,14 @@ export default class Ink {
866
883
  callWithUpdateOverflowGuard('selection.notify', cb);
867
884
  }
868
885
  }
886
+ // Resolve pane geometry after scroll/viewport translations: the old row
887
+ // number can otherwise denote a different-width diff row in this frame.
888
+ const hadPaneSelection = hasSelection(this.selection);
889
+ selectionCoordinated = refreshSelectionPane(this.selection, frame.screen, this.frontFrame.screen) || selectionCoordinated;
890
+ if (hadPaneSelection && !hasSelection(this.selection)) {
891
+ for (const cb of this.selectionListeners)
892
+ callWithUpdateOverflowGuard('selection.notify', cb);
893
+ }
869
894
  // Selection overlay: invert cell styles in the screen buffer itself,
870
895
  // so the diff picks up selection as ordinary cell changes and
871
896
  // LogUpdate remains a pure diff engine.
@@ -1024,6 +1049,14 @@ export default class Ink {
1024
1049
  optimized.unshift({ type: 'stdout', content: sixelFrame.erase });
1025
1050
  if (graphicsOutput !== '') {
1026
1051
  optimized.push({ type: 'stdout', content: graphicsOutput });
1052
+ const expected = this.sixelGraphicsManager.cursorAfterPaint;
1053
+ if (sixelActive && this.sixelCursorCheckSupported && expected !== undefined &&
1054
+ this.measuredImageCellSize !== undefined && this.app !== null &&
1055
+ !this.terminalQueriesSuspended && process.env.DSH_TUI_SIXEL_CURSOR_HEAL !== '0') {
1056
+ const request = this.sixelCursorHeal.prepare(this.app.querier, expected);
1057
+ if (request !== '')
1058
+ optimized.push({ type: 'stdout', content: request });
1059
+ }
1027
1060
  }
1028
1061
  optimized.push(this.altScreenParkPatch);
1029
1062
  }
@@ -1236,17 +1269,39 @@ export default class Ink {
1236
1269
  this.cursorIdleNode = null;
1237
1270
  this.cursorIdleHidden = false;
1238
1271
  }
1272
+ reassertOwnedRawMode = () => {
1273
+ if (!this.options.stdout.isTTY || this.isUnmounted || this.isPaused)
1274
+ return;
1275
+ try {
1276
+ this.app?.reassertRawMode();
1277
+ }
1278
+ catch { /* revoked TTY; retry only while owned */ }
1279
+ };
1280
+ startRawModeRecovery() {
1281
+ if (!this.options.stdout.isTTY || this.isUnmounted || this.isPaused || this.rawModeRecoveryTimer !== undefined)
1282
+ return;
1283
+ // Cooked mode can suppress readable until Enter. Recover independently
1284
+ // of input, without periodically rewriting DEC modes or the viewport.
1285
+ this.rawModeRecoveryTimer = setInterval(this.reassertOwnedRawMode, 5000);
1286
+ this.rawModeRecoveryTimer.unref();
1287
+ }
1288
+ stopRawModeRecovery() {
1289
+ clearInterval(this.rawModeRecoveryTimer);
1290
+ this.rawModeRecoveryTimer = undefined;
1291
+ }
1239
1292
  pause() {
1240
1293
  // Flush pending React updates and render before pausing.
1241
1294
  // @ts-ignore -- runtime/type-definition mismatch: flushSyncFromReconciler exists in react-reconciler 0.31 but not in @types/react-reconciler
1242
1295
  reconciler.flushSyncFromReconciler();
1243
1296
  this.renderNow();
1244
1297
  this.isPaused = true;
1298
+ this.stopRawModeRecovery();
1245
1299
  this.resetCursorIdle();
1246
1300
  this.notifyTerminalImagesChange();
1247
1301
  }
1248
1302
  resume() {
1249
1303
  this.isPaused = false;
1304
+ this.startRawModeRecovery();
1250
1305
  this.nativeCursorVisible = null;
1251
1306
  this.notifyTerminalImagesChange();
1252
1307
  this.renderNow();
@@ -1346,6 +1401,8 @@ export default class Ink {
1346
1401
  setAltScreenActive(active, mouseTracking = false) {
1347
1402
  if (this.altScreenActive === active)
1348
1403
  return;
1404
+ if (!active)
1405
+ this.sixelCursorHeal.reset();
1349
1406
  const resetOldPointerContext = () => {
1350
1407
  // Fire leave handlers before dropping the set — a bare clear strands
1351
1408
  // old rows with hovered=true. resetPointerState also emits dragend for
@@ -1359,7 +1416,7 @@ export default class Ink {
1359
1416
  if (!active) {
1360
1417
  resetOldPointerContext();
1361
1418
  const deleteImages = this.kittyGraphicsManager.deleteAll() + this.sixelGraphicsManager.clear();
1362
- if (deleteImages !== '')
1419
+ if (deleteImages !== '' && this.shutdownInput.ownsInput())
1363
1420
  this.options.stdout.write(deleteImages);
1364
1421
  }
1365
1422
  this.altScreenActive = active;
@@ -1416,8 +1473,8 @@ export default class Ink {
1416
1473
  return this.altScreenMouseTracking;
1417
1474
  }
1418
1475
  /**
1419
- * Re-assert terminal modes after a gap (>5s stdin silence or event-loop
1420
- * stall). Catches tmux detach→attach, ssh reconnect, and laptop
1476
+ * Re-assert terminal modes after a gap (>5s stdin silence).
1477
+ * Catches tmux detach→attach, ssh reconnect, and laptop
1421
1478
  * sleep/wake — none of which send SIGCONT. The terminal may reset DEC
1422
1479
  * private modes on reconnect; this method restores them.
1423
1480
  *
@@ -1431,16 +1488,16 @@ export default class Ink {
1431
1488
  * Ctrl+C/Ctrl+D leak as escape sequences. The alt-screen
1432
1489
  * re-entry (ERASE_SCREEN + frame reset) is NOT idempotent — it blanks the
1433
1490
  * screen — so it's opt-in via includeAltScreen. The stdin-gap caller fires
1434
- * on ordinary >5s idle + keypress and must not erase; the event-loop stall
1435
- * detector fires on genuine sleep/wake and opts in. tmux attach / ssh
1491
+ * on ordinary >5s idle + keypress and must not erase. The independent
1492
+ * raw-mode timer restores termios only, without re-entering alt. tmux attach / ssh
1436
1493
  * reconnect typically send a resize, which already covers alt-screen via
1437
1494
  * handleResize.
1438
1495
  */
1439
1496
  reassertTerminalModes = (includeAltScreen = false) => {
1440
1497
  if (!this.options.stdout.isTTY)
1441
1498
  return;
1442
- // Shutdown latch: the >5s idle-gap trigger (or an event-loop stall
1443
- // detector firing during the dispose window) must not re-assert mouse
1499
+ // Shutdown latch: an idle-gap trigger during the dispose window must
1500
+ // not re-assert mouse
1444
1501
  // tracking after the exit cleanup disabled it (issue #522).
1445
1502
  if (this.isUnmounted)
1446
1503
  return;
@@ -1449,6 +1506,7 @@ export default class Ink {
1449
1506
  // start seeing CSI-u sequences again.
1450
1507
  if (this.isPaused)
1451
1508
  return;
1509
+ this.reassertOwnedRawMode();
1452
1510
  // Extended keys — re-assert if enabled (App.tsx enables these on
1453
1511
  // allowlisted terminals at raw-mode entry; a terminal reset clears them).
1454
1512
  // Pop-before-push keeps Kitty stack depth at 1 instead of accumulating
@@ -1499,6 +1557,7 @@ export default class Ink {
1499
1557
  detachForShutdown() {
1500
1558
  if (this.isUnmounted)
1501
1559
  return this.shutdownCleanup;
1560
+ this.sixelCursorHeal.dispose();
1502
1561
  this.isDetachedForShutdown = true;
1503
1562
  this.isUnmounted = true;
1504
1563
  this.resetCursorIdle();
@@ -1518,7 +1577,7 @@ export default class Ink {
1518
1577
  // the renderer's own ordered stream, matching the rest of this shutdown
1519
1578
  // path and leaving unmount's synchronous cleanup safely idempotent.
1520
1579
  const deleteImages = this.kittyGraphicsManager.deleteAll() + this.sixelGraphicsManager.dispose();
1521
- if (deleteImages !== '' && this.options.stdout.isTTY) {
1580
+ if (deleteImages !== '' && this.options.stdout.isTTY && this.shutdownInput.ownsInput()) {
1522
1581
  this.options.stdout.write(deleteImages);
1523
1582
  }
1524
1583
  this.app?.detachForShutdown();
@@ -1532,7 +1591,8 @@ export default class Ink {
1532
1591
  // never runs — a detached instance would stay in the map and a later
1533
1592
  // instances.get(stdout) lookup (Chat's reanchorViewport plumbing) could
1534
1593
  // hand out a dead renderer. Remove the mapping here too.
1535
- instances.delete(this.options.stdout);
1594
+ if (instances.get(this.options.stdout) === this)
1595
+ instances.delete(this.options.stdout);
1536
1596
  // `detachForShutdown()` deliberately makes later `unmount()` calls a
1537
1597
  // no-op, so release process-level output patches here rather than relying
1538
1598
  // on unmount() to do it. The shutdown continuation may run an updater
@@ -1548,7 +1608,7 @@ export default class Ink {
1548
1608
  // when stdin is piped.
1549
1609
  const stdin = this.options.stdin;
1550
1610
  this.drainStdin();
1551
- if (stdin.isTTY && stdin.isRaw && stdin.setRawMode) {
1611
+ if (this.shutdownInput.ownsInput() && stdin.isTTY && stdin.isRaw && stdin.setRawMode) {
1552
1612
  try {
1553
1613
  stdin.setRawMode(false);
1554
1614
  }
@@ -1589,6 +1649,8 @@ export default class Ink {
1589
1649
  * the listeners and pause the pump so the child is the sole reader.
1590
1650
  */
1591
1651
  detachStdinForHandoff() {
1652
+ if (!this.shutdownInput.ownsInput())
1653
+ return;
1592
1654
  const stdin = this.options.stdin;
1593
1655
  try {
1594
1656
  this.drainStdin();
@@ -1605,7 +1667,7 @@ export default class Ink {
1605
1667
  }
1606
1668
  /** @see drainStdin */
1607
1669
  drainStdin() {
1608
- drainStdin(this.options.stdin);
1670
+ this.shutdownInput.drain();
1609
1671
  }
1610
1672
  /**
1611
1673
  * Self-heal after a terminal-side mode reset. Windows conpty drops DEC
@@ -1807,6 +1869,7 @@ export default class Ink {
1807
1869
  /** Refocus = first observable moment after a conpty-side mode reset. */
1808
1870
  handleTerminalFocusProbe = (focused) => {
1809
1871
  if (focused) {
1872
+ this.reassertOwnedRawMode();
1810
1873
  this.probeAltScreenHealth();
1811
1874
  // Refocus is a safe boundary: the OS delivered the focus event, so no
1812
1875
  // button can be held (a held button would have generated motion or a
@@ -1869,6 +1932,10 @@ export default class Ink {
1869
1932
  if (mode?.status === 3)
1870
1933
  return;
1871
1934
  this.sixelGraphicsManager.setDisplayMode(mode?.status === 1);
1935
+ // Restrict the expected cursor semantics to Windows Terminal/ConPTY,
1936
+ // with a confirmed controllable sixel display mode and measured cells.
1937
+ this.sixelCursorCheckSupported = (!!process.env.WT_SESSION || /Windows ?Terminal|ConPTY/iu.test(identity?.name ?? '')) &&
1938
+ (mode?.status === 1 || mode?.status === 2);
1872
1939
  }
1873
1940
  // Ghostty 1.3.1 can segfault while inflating a valid RGBA upload.
1874
1941
  // Resolve identity in this batch (also over SSH) before images go live.
@@ -2623,7 +2690,7 @@ export default class Ink {
2623
2690
  // After detachForShutdown the exit funnel owns the terminal restore: a late
2624
2691
  // commit (e.g. <AlternateScreen>'s cleanup) must not write control sequences.
2625
2692
  writeRaw(data) {
2626
- if (this.isDetachedForShutdown) {
2693
+ if (this.isDetachedForShutdown || !this.shutdownInput.ownsInput()) {
2627
2694
  // Length only: a dropped write may carry clipboard (OSC 52) content.
2628
2695
  logMouseDebug('stdout: raw write after shutdown detach dropped', { len: data.length });
2629
2696
  return;
@@ -2658,7 +2725,7 @@ export default class Ink {
2658
2725
  };
2659
2726
  render(node) {
2660
2727
  this.currentNode = node;
2661
- const tree = _jsx(App, { ref: this.setAppRef, stdin: this.options.stdin, stdout: this.options.stdout, stderr: this.options.stderr, exitOnCtrlC: this.options.exitOnCtrlC, onExit: this.unmount, terminalColumns: this.terminalColumns, terminalRows: this.terminalRows, selection: this.selection, onSelectionChange: this.notifySelectionChange, onClickAt: this.dispatchClick, onContextMenuAt: this.dispatchContextMenu, onHoverAt: this.dispatchHover, onWheelAt: this.dispatchWheelAt, getHyperlinkAt: this.getHyperlinkAt, onOpenHyperlink: this.openHyperlink, onMultiClick: this.handleMultiClick, onSelectionStart: this.handleSelectionStart, onSelectionDrag: this.handleSelectionDrag, onDragTargetAt: this.findDragTargetAt, onDragDispatch: this.dispatchDrag, onPointerGestureChange: this.setPointerGestureActive, onProtocolCandidateChange: this.setProtocolCandidateActive, onReleaseTail: this.drainReleaseTail, onClickProbe: this.clickProbeAtBatchTail, onStdinResume: this.reassertTerminalModes, onTerminalFocus: this.handleTerminalFocusProbe, onCursorDeclaration: this.setCursorDeclaration, dispatchKeyboardEvent: this.dispatchKeyboardEvent, children: _jsx(TerminalWriteProvider, { value: this.writeRaw, children: _jsx(TerminalImagesContext.Provider, { value: this.terminalImages, children: node }) }) });
2728
+ const tree = _jsx(App, { ref: this.setAppRef, stdin: this.options.stdin, ownsStdin: this.shutdownInput.ownsInput, stdout: this.options.stdout, stderr: this.options.stderr, exitOnCtrlC: this.options.exitOnCtrlC, onExit: this.unmount, terminalColumns: this.terminalColumns, terminalRows: this.terminalRows, selection: this.selection, onSelectionChange: this.notifySelectionChange, onClickAt: this.dispatchClick, onContextMenuAt: this.dispatchContextMenu, onHoverAt: this.dispatchHover, onWheelAt: this.dispatchWheelAt, getHyperlinkAt: this.getHyperlinkAt, onOpenHyperlink: this.openHyperlink, onMultiClick: this.handleMultiClick, onSelectionStart: this.handleSelectionStart, onSelectionDrag: this.handleSelectionDrag, onDragTargetAt: this.findDragTargetAt, onDragDispatch: this.dispatchDrag, onPointerGestureChange: this.setPointerGestureActive, onProtocolCandidateChange: this.setProtocolCandidateActive, onReleaseTail: this.drainReleaseTail, onClickProbe: this.clickProbeAtBatchTail, onStdinResume: this.reassertTerminalModes, onTerminalFocus: this.handleTerminalFocusProbe, onCursorDeclaration: this.setCursorDeclaration, dispatchKeyboardEvent: this.dispatchKeyboardEvent, children: _jsx(TerminalWriteProvider, { value: this.writeRaw, children: _jsx(TerminalImagesContext.Provider, { value: this.terminalImages, children: node }) }) });
2662
2729
  // @ts-ignore -- runtime/type-definition mismatch: updateContainerSync exists in react-reconciler but not in @types/react-reconciler
2663
2730
  reconciler.updateContainerSync(tree, this.container, null, noop);
2664
2731
  // @ts-ignore -- runtime/type-definition mismatch: flushSyncWork exists in react-reconciler but not in @types/react-reconciler
@@ -2668,6 +2735,17 @@ export default class Ink {
2668
2735
  if (this.isUnmounted) {
2669
2736
  return;
2670
2737
  }
2738
+ if (!this.shutdownInput.ownsInput()) {
2739
+ // Release this tree without resetting terminal modes now owned elsewhere.
2740
+ const cleanup = this.detachForShutdown();
2741
+ void Promise.resolve(cleanup).then(() => {
2742
+ if (error instanceof Error)
2743
+ this.rejectExitPromise(error);
2744
+ else
2745
+ this.resolveExitPromise();
2746
+ }, cleanupError => this.rejectExitPromise(error instanceof Error ? error : cleanupError));
2747
+ return;
2748
+ }
2671
2749
  // The final frame render is best-effort: a mid-state React commit can
2672
2750
  // throw (agent still working at the exact exit moment). It must NOT
2673
2751
  // skip the synchronous cleanup block below — a skipped DISABLE_*
@@ -2677,7 +2755,10 @@ export default class Ink {
2677
2755
  this.renderNow();
2678
2756
  }
2679
2757
  catch (renderError) {
2680
- logError(renderError instanceof Error ? renderError : new Error(String(renderError)));
2758
+ try {
2759
+ logError(renderError instanceof Error ? renderError : new Error(String(renderError)));
2760
+ }
2761
+ catch { /* diagnostics must not skip terminal cleanup */ }
2681
2762
  }
2682
2763
  this.resetCursorIdle();
2683
2764
  this.unsubscribeExit();
@@ -2688,8 +2769,13 @@ export default class Ink {
2688
2769
  this.unsubscribeTTYHandlers?.();
2689
2770
  // Non-TTY environments don't handle erasing ansi escapes well, so it's better to
2690
2771
  // only render last frame of non-static output
2691
- const diff = this.log.renderPreviousOutput_DEPRECATED(this.frontFrame);
2692
- const lastFrame = serializeDiff(this.terminal, optimize(diff));
2772
+ let lastFrame = '';
2773
+ try {
2774
+ const diff = this.log.renderPreviousOutput_DEPRECATED(this.frontFrame);
2775
+ lastFrame = serializeDiff(this.terminal, optimize(diff));
2776
+ }
2777
+ catch { /* a failed final diff must not skip terminal cleanup */ }
2778
+ this.sixelCursorHeal.dispose();
2693
2779
  const sixelCleanup = this.sixelGraphicsManager.dispose();
2694
2780
  // Clean up terminal modes synchronously before process exit.
2695
2781
  // React's componentWillUnmount won't run in time when process.exit() is called,
@@ -2714,6 +2800,8 @@ export default class Ink {
2714
2800
  if (lastFrame !== '') {
2715
2801
  writeSync(stdoutFd, lastFrame);
2716
2802
  }
2803
+ // A missing final diff has no frame tail to close synchronized output.
2804
+ writeSync(stdoutFd, ESU);
2717
2805
  const deleteImages = this.kittyGraphicsManager.deleteAll() + sixelCleanup;
2718
2806
  if (deleteImages !== '') {
2719
2807
  writeSync(stdoutFd, deleteImages);
@@ -2766,7 +2854,8 @@ export default class Ink {
2766
2854
  reconciler.updateContainerSync(null, this.container, null, noop);
2767
2855
  // @ts-ignore -- runtime/type-definition mismatch: flushSyncWork exists in react-reconciler but not in @types/react-reconciler
2768
2856
  reconciler.flushSyncWork();
2769
- instances.delete(this.options.stdout);
2857
+ if (instances.get(this.options.stdout) === this)
2858
+ instances.delete(this.options.stdout);
2770
2859
  // Free the root yoga node, then clear its reference. Children are already
2771
2860
  // freed by the reconciler's removeChildFromContainer; using .free() (not
2772
2861
  // .freeRecursive()) avoids double-freeing them.
@@ -2942,7 +3031,9 @@ export function drainStdin(stdin = process.stdin) {
2942
3031
  }
2943
3032
  // No /dev/tty on Windows; CONIN$ doesn't support O_NONBLOCK semantics.
2944
3033
  // Windows Terminal also doesn't buffer mouse reports the same way.
2945
- if (process.platform === 'win32')
3034
+ // A custom input may name another PTY; only its explicit device hook
3035
+ // may drain beyond the Node buffer. Never fall back to an unrelated TTY.
3036
+ if (process.platform === 'win32' || stdin !== process.stdin)
2946
3037
  return;
2947
3038
  // termios is per-device: flip stdin to raw so canonical-mode line
2948
3039
  // buffering doesn't hide partial input from the non-blocking read.
@@ -2953,12 +3044,15 @@ export function drainStdin(stdin = process.stdin) {
2953
3044
  // reads (64KB) — a real mouse burst is a few hundred bytes; the cap
2954
3045
  // guards against a terminal that ignores O_NONBLOCK.
2955
3046
  let fd = -1;
3047
+ let changedRaw = false;
2956
3048
  try {
2957
3049
  // setRawMode inside try: on revoked TTY (SIGHUP/SSH disconnect) the
2958
3050
  // ioctl throws EBADF — same recovery path as openSync/readSync below.
2959
- if (!wasRaw)
2960
- tty.setRawMode?.(true);
2961
3051
  fd = openSync('/dev/tty', fsConstants.O_RDONLY | fsConstants.O_NONBLOCK);
3052
+ if (!wasRaw && tty.setRawMode) {
3053
+ tty.setRawMode(true);
3054
+ changedRaw = true;
3055
+ }
2962
3056
  const buf = Buffer.alloc(1024);
2963
3057
  for (let i = 0; i < 64; i++) {
2964
3058
  if (readSync(fd, buf, 0, buf.length, null) <= 0)
@@ -2978,7 +3072,7 @@ export function drainStdin(stdin = process.stdin) {
2978
3072
  /* ignore */
2979
3073
  }
2980
3074
  }
2981
- if (!wasRaw) {
3075
+ if (changedRaw) {
2982
3076
  try {
2983
3077
  tty.setRawMode?.(false);
2984
3078
  }
@@ -87,7 +87,18 @@ type Options = {
87
87
  previousImages?: readonly TerminalImagePlacement[];
88
88
  };
89
89
  /** A queued paint operation: write, clip, unclip, blit, clear, shade, noSelect, or shift. */
90
- export type Operation = WriteOperation | ClipOperation | UnclipOperation | BlitOperation | ClearOperation | ShadeOperation | NoSelectOperation | CopyRegionOperation | SoftWrapRowOperation | ShiftOperation;
90
+ export type Operation = WriteOperation | ClipOperation | UnclipOperation | BlitOperation | ClearOperation | ShadeOperation | NoSelectOperation | CopyRegionOperation | SoftWrapRowOperation | {
91
+ type: 'selectionPane';
92
+ region: Rectangle;
93
+ id: string;
94
+ viewport: boolean;
95
+ } | {
96
+ type: 'selectionOcclusion';
97
+ region: Rectangle;
98
+ keep: ReadonlySet<string>;
99
+ source?: Screen;
100
+ below?: Set<string>;
101
+ } | ShiftOperation;
91
102
  /**
92
103
  * Restyle the cells already in the region at this point of the paint
93
104
  * order: a modal layer's backdrop. Applied in sequence like a write, so
@@ -174,6 +185,7 @@ type NoSelectOperation = {
174
185
  /** Row `y` continues the row above; negative contentEnd restores a separator. */
175
186
  type SoftWrapRowOperation = {
176
187
  type: 'softWrapRow';
188
+ x: number;
177
189
  y: number;
178
190
  contentEnd: number;
179
191
  };
@@ -280,7 +292,10 @@ export default class Output {
280
292
  * @param region - the region to mark.
281
293
  */
282
294
  /** Mark row `y` as a wrap continuation (see Styles.softWrapContinuation). */
283
- softWrapRow(y: number, contentEnd: number): void;
295
+ softWrapRow(y: number, contentEnd: number, x?: number): void;
296
+ selectionPane(region: Rectangle, id: string, viewport?: boolean): void;
297
+ /** A later opaque surface hides both pane ownership and earlier gutters. */
298
+ selectionOcclusion(region: Rectangle, keep: ReadonlySet<string>, source?: Screen): void;
284
299
  noSelect(region: Rectangle): void;
285
300
  /**
286
301
  * Record a fully visible, frame-budgeted image request. Rejected placements
@@ -1 +1 @@
1
- {"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../../src/ink/output.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,sBAAsB,CAAA;AAChE,OAAO,EAkBL,KAAK,MAAM,EACX,KAAK,SAAS,EAIf,MAAM,aAAa,CAAA;AAGpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAIL,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAA;AAG5B;;;;;;;;;GASG;AACH,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;CAC9B,CAAA;AAsCD;;;;GAIG;AACH,qBAAa,SAAS;IACpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,KAAK,CAAI;IAEjB;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,GAAG,SAAS;IAS9C;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,IAAI;IAuBpD,mEAAmE;IACnE,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,qCAAqC;IACrC,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAED;;;;GAIG;AACH,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,C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aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAQ3E;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAQtB,uCAAuC;IACvC,MAAM,IAAI,IAAI;IAOd;;;OAGG;IACH,GAAG,IAAI,MAAM;CAqUd"}
@@ -522,10 +522,42 @@ export default class Output {
522
522
  * @param region - the region to mark.
523
523
  */
524
524
  /** Mark row `y` as a wrap continuation (see Styles.softWrapContinuation). */
525
- softWrapRow(y, contentEnd) {
526
- this.operations.push({ type: 'softWrapRow', y, contentEnd });
525
+ softWrapRow(y, contentEnd, x = 0) {
526
+ this.operations.push({ type: 'softWrapRow', x, y, contentEnd });
527
+ }
528
+ selectionPane(region, id, viewport = false) {
529
+ const clip = this.imageClips.at(-1);
530
+ const x = Math.ceil(Math.max(0, region.x, clip?.x1 ?? 0));
531
+ const y = Math.ceil(Math.max(0, region.y, clip?.y1 ?? 0));
532
+ const right = Math.floor(Math.min(this.width, region.x + region.width, clip?.x2 ?? this.width));
533
+ const bottom = Math.floor(Math.min(this.height, region.y + region.height, clip?.y2 ?? this.height));
534
+ if (right > x && bottom > y)
535
+ this.operations.push({ type: 'selectionPane', id, viewport, region: { x, y, width: right - x, height: bottom - y } });
536
+ }
537
+ /** A later opaque surface hides both pane ownership and earlier gutters. */
538
+ selectionOcclusion(region, keep, source) {
539
+ const clip = this.imageClips.at(-1);
540
+ const x = Math.ceil(Math.max(0, region.x, clip?.x1 ?? 0));
541
+ const y = Math.ceil(Math.max(0, region.y, clip?.y1 ?? 0));
542
+ const right = Math.floor(Math.min(this.width, region.x + region.width, clip?.x2 ?? this.width));
543
+ const bottom = Math.floor(Math.min(this.height, region.y + region.height, clip?.y2 ?? this.height));
544
+ if (right > x && bottom > y)
545
+ this.operations.push({ type: 'selectionOcclusion', keep, source, region: { x, y, width: right - x, height: bottom - y } });
527
546
  }
528
547
  noSelect(region) {
548
+ // Masks are applied after all paint operations, when the clip stack
549
+ // has unwound. Capture the visible part now so a long decorated run
550
+ // cannot exclude selectable cells on a neighboring surface.
551
+ const clip = this.imageClips.at(-1);
552
+ if (clip !== undefined) {
553
+ const x = Math.ceil(Math.max(0, region.x, clip.x1 ?? 0));
554
+ const y = Math.ceil(Math.max(0, region.y, clip.y1 ?? 0));
555
+ const right = Math.floor(Math.min(this.width, region.x + region.width, clip.x2 ?? this.width));
556
+ const bottom = Math.floor(Math.min(this.height, region.y + region.height, clip.y2 ?? this.height));
557
+ if (right <= x || bottom <= y)
558
+ return;
559
+ region = { x, y, width: right - x, height: bottom - y };
560
+ }
529
561
  this.operations.push({ type: 'noSelect', region });
530
562
  }
531
563
  /**
@@ -759,6 +791,13 @@ export default class Output {
759
791
  */
760
792
  get() {
761
793
  const screen = this.screen;
794
+ const paneWrap = (row, x, end, wrap) => {
795
+ for (const rows of screen.selectionPanes?.values() ?? []) {
796
+ const span = rows.get(row);
797
+ if (span && x < span.end && end > span.start)
798
+ span.wrap = wrap;
799
+ }
800
+ };
762
801
  const screenWidth = this.width;
763
802
  const screenHeight = this.height;
764
803
  // Track blit vs write cell counts for debugging
@@ -861,6 +900,21 @@ export default class Output {
861
900
  shiftRows(screen, operation.top, operation.bottom, operation.n, operation.columnX, operation.columnWidth);
862
901
  continue;
863
902
  }
903
+ case 'selectionOcclusion':
904
+ operation.below = new Set(screen.selectionPanes?.keys());
905
+ continue;
906
+ case 'selectionPane': {
907
+ // Ownership follows paint order, just like noSelect/copyRegion.
908
+ // A cached child contributes its spans through its own blit.
909
+ screen.selectionPanes ??= new Map();
910
+ let rows = screen.selectionPanes.get(operation.id);
911
+ if (!rows)
912
+ screen.selectionPanes.set(operation.id, rows = new Map());
913
+ for (let row = operation.region.y; row < operation.region.y + operation.region.height; row++) {
914
+ rows.set(row, { start: operation.region.x, end: operation.region.x + operation.region.width, wrap: 0, viewport: operation.viewport });
915
+ }
916
+ continue;
917
+ }
864
918
  case 'softWrapRow': {
865
919
  // Paint order: the marker lands where the producer asked for it, and
866
920
  // the write case above resets it when a later operation repaints that
@@ -869,6 +923,7 @@ export default class Output {
869
923
  if (operation.y > 0 && operation.y < screen.height) {
870
924
  const contentEnd = Math.max(1, Math.abs(operation.contentEnd));
871
925
  screen.softWrap[operation.y] = operation.contentEnd < 0 ? -contentEnd : contentEnd;
926
+ paneWrap(operation.y, operation.x, contentEnd, screen.softWrap[operation.y]);
872
927
  }
873
928
  continue;
874
929
  }
@@ -971,6 +1026,7 @@ export default class Output {
971
1026
  // onto the previous line.
972
1027
  swBits[lineY] = 0;
973
1028
  }
1029
+ paneWrap(lineY, x, contentEnd, swBits[lineY]);
974
1030
  offsetY++;
975
1031
  }
976
1032
  continue;
@@ -987,6 +1043,33 @@ export default class Output {
987
1043
  const { x, y, width, height } = operation.region;
988
1044
  markNoSelectRegion(screen, x, y, width, height);
989
1045
  }
1046
+ else if (operation.type === 'selectionOcclusion') {
1047
+ const { x, y, width, height } = operation.region;
1048
+ for (let row = y; row < y + height; row++) {
1049
+ const offset = row * screen.width + x;
1050
+ screen.noSelect.fill(0, offset, offset + width);
1051
+ if (operation.source)
1052
+ screen.noSelect.set(operation.source.noSelect.subarray(offset, offset + width), offset);
1053
+ for (const id of operation.below ?? []) {
1054
+ if (operation.keep.has(id))
1055
+ continue;
1056
+ const rows = screen.selectionPanes?.get(id);
1057
+ const span = rows?.get(row);
1058
+ if (span && x < span.end && x + width > span.start) {
1059
+ const excluded = [...(span.excluded ?? []), { start: Math.max(x, span.start), end: Math.min(x + width, span.end) }].sort((a, b) => a.start - b.start);
1060
+ const merged = [];
1061
+ for (const range of excluded) {
1062
+ const last = merged.at(-1);
1063
+ if (last && last.end >= range.start)
1064
+ last.end = Math.max(last.end, range.end);
1065
+ else
1066
+ merged.push({ ...range });
1067
+ }
1068
+ rows.set(row, { ...span, excluded: merged });
1069
+ }
1070
+ }
1071
+ }
1072
+ }
990
1073
  }
991
1074
  // Blits carry the previous frame's region texts; keep only the ones a
992
1075
  // cell still references, or the map grows by every redrawn formula.
@@ -51,6 +51,7 @@ export type TerminalResponse =
51
51
  type: 'cursorPosition';
52
52
  row: number;
53
53
  col: number;
54
+ page?: number;
54
55
  }
55
56
  /** XTWINOPS: physical pixels for one cell or the terminal text area. */
56
57
  | {