@deepseek-harness-tui/dsh-tui 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/README.md +35 -10
  2. package/bin/dsh-tui.js +46 -3
  3. package/guide/dsh-tui-guide/codex-backend.en.md +2 -2
  4. package/guide/dsh-tui-guide/codex-backend.md +2 -2
  5. package/guide/dsh-tui-guide/configuration.en.md +7 -2
  6. package/guide/dsh-tui-guide/configuration.md +7 -2
  7. package/guide/dsh-tui-guide/getting-started.en.md +168 -4
  8. package/guide/dsh-tui-guide/getting-started.md +121 -14
  9. package/guide/dsh-tui-guide/interaction.en.md +11 -10
  10. package/guide/dsh-tui-guide/interaction.md +5 -4
  11. package/guide/dsh-tui-guide/user-guide.en.md +6 -5
  12. package/guide/dsh-tui-guide/user-guide.md +6 -5
  13. package/lib/settings.json +1 -1
  14. package/lib/types/adapter/ports/channel-ui.d.ts +10 -7
  15. package/lib/types/adapter/ports/channel-ui.d.ts.map +1 -1
  16. package/lib/types/adapter/ports/channel-view.d.ts +28 -5
  17. package/lib/types/adapter/ports/channel-view.d.ts.map +1 -1
  18. package/lib/types/agent/events.d.ts +12 -5
  19. package/lib/types/agent/events.d.ts.map +1 -1
  20. package/lib/types/agent/session.d.ts +5 -0
  21. package/lib/types/agent/session.d.ts.map +1 -1
  22. package/lib/types/backends/claude/translate/core.d.ts +2 -2
  23. package/lib/types/backends/claude/translate/core.d.ts.map +1 -1
  24. package/lib/types/backends/claude/translate/core.js +10 -6
  25. package/lib/types/backends/codex/session/commands.d.ts +2 -0
  26. package/lib/types/backends/codex/session/commands.d.ts.map +1 -1
  27. package/lib/types/backends/codex/session/commands.js +8 -4
  28. package/lib/types/backends/codex/session/input.d.ts +11 -7
  29. package/lib/types/backends/codex/session/input.d.ts.map +1 -1
  30. package/lib/types/backends/codex/session/input.js +68 -15
  31. package/lib/types/backends/codex/session/session.d.ts.map +1 -1
  32. package/lib/types/backends/codex/session/session.js +2 -3
  33. package/lib/types/channel/projection.d.ts.map +1 -1
  34. package/lib/types/channel/projection.js +78 -10
  35. package/lib/types/channel/questions.d.ts +19 -3
  36. package/lib/types/channel/questions.d.ts.map +1 -1
  37. package/lib/types/channel/sanitize.d.ts.map +1 -1
  38. package/lib/types/channel/sanitize.js +8 -4
  39. package/lib/types/channel/subagent-failure.d.ts +49 -0
  40. package/lib/types/channel/subagent-failure.d.ts.map +1 -0
  41. package/lib/types/channel/subagent-failure.js +59 -0
  42. package/lib/types/channel/transcript.d.ts +17 -0
  43. package/lib/types/channel/transcript.d.ts.map +1 -1
  44. package/lib/types/channel/transcript.js +35 -0
  45. package/lib/types/commands.js +1 -1
  46. package/lib/types/components/MessageList.d.ts.map +1 -1
  47. package/lib/types/components/MessageList.js +11 -7
  48. package/lib/types/components/PromptInput.d.ts.map +1 -1
  49. package/lib/types/components/PromptInput.js +61 -6
  50. package/lib/types/components/SubagentDashboard.d.ts.map +1 -1
  51. package/lib/types/components/SubagentDashboard.js +7 -1
  52. package/lib/types/components/messages/AssistantToolUseMessage.d.ts.map +1 -1
  53. package/lib/types/components/messages/AssistantToolUseMessage.js +5 -2
  54. package/lib/types/components/questions/AskUserQuestionPanel.d.ts +5 -8
  55. package/lib/types/components/questions/AskUserQuestionPanel.d.ts.map +1 -1
  56. package/lib/types/components/questions/AskUserQuestionPanel.js +7 -4
  57. package/lib/types/components/questions/PlanReviewPanel.d.ts +3 -6
  58. package/lib/types/components/questions/PlanReviewPanel.d.ts.map +1 -1
  59. package/lib/types/components/revealScope.d.ts +15 -0
  60. package/lib/types/components/revealScope.d.ts.map +1 -0
  61. package/lib/types/components/revealScope.js +17 -0
  62. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts +34 -1
  63. package/lib/types/components/sidePanel/btw/BtwComposer.d.ts.map +1 -1
  64. package/lib/types/components/sidePanel/btw/BtwComposer.js +108 -7
  65. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.d.ts.map +1 -1
  66. package/lib/types/components/sidePanel/btw/BtwPanelAdapter.js +1 -1
  67. package/lib/types/components/sidePanel/btw/BtwThreadScene.d.ts.map +1 -1
  68. package/lib/types/components/sidePanel/btw/BtwThreadScene.js +1 -1
  69. package/lib/types/components/smoothReveal.d.ts +36 -6
  70. package/lib/types/components/smoothReveal.d.ts.map +1 -1
  71. package/lib/types/components/smoothReveal.js +92 -21
  72. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts +4 -14
  73. package/lib/types/components/workspaces/HomeWorkspaceRow.d.ts.map +1 -1
  74. package/lib/types/components/workspaces/HomeWorkspaceRow.js +26 -17
  75. package/lib/types/dsh-adapter/backend/session.d.ts.map +1 -1
  76. package/lib/types/dsh-adapter/backend/session.js +12 -0
  77. package/lib/types/dsh-adapter/backend/translate.d.ts.map +1 -1
  78. package/lib/types/dsh-adapter/backend/translate.js +6 -1
  79. package/lib/types/dsh-adapter/channel/attached-context.d.ts +15 -2
  80. package/lib/types/dsh-adapter/channel/attached-context.d.ts.map +1 -1
  81. package/lib/types/dsh-adapter/channel/attached-context.js +26 -3
  82. package/lib/types/dsh-adapter/channel/binding-events.d.ts +3 -0
  83. package/lib/types/dsh-adapter/channel/binding-events.d.ts.map +1 -1
  84. package/lib/types/dsh-adapter/channel/binding-events.js +43 -2
  85. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts +2 -6
  86. package/lib/types/dsh-adapter/channel/context-bookkeeping.d.ts.map +1 -1
  87. package/lib/types/dsh-adapter/channel/context-bookkeeping.js +7 -1
  88. package/lib/types/dsh-adapter/channel/core/compose.d.ts +2 -6
  89. package/lib/types/dsh-adapter/channel/core/compose.d.ts.map +1 -1
  90. package/lib/types/dsh-adapter/channel/core/compose.js +1 -1
  91. package/lib/types/dsh-adapter/channel/core/local-actions.d.ts.map +1 -1
  92. package/lib/types/dsh-adapter/channel/core/local-actions.js +3 -26
  93. package/lib/types/dsh-adapter/channel/emitter.js +1 -1
  94. package/lib/types/dsh-adapter/channel/extensions.d.ts.map +1 -1
  95. package/lib/types/dsh-adapter/channel/extensions.js +8 -0
  96. package/lib/types/dsh-adapter/channel/input-actions.d.ts +2 -2
  97. package/lib/types/dsh-adapter/channel/input-actions.d.ts.map +1 -1
  98. package/lib/types/dsh-adapter/channel/input-actions.js +34 -10
  99. package/lib/types/dsh-adapter/channel/input-delivery.d.ts +3 -7
  100. package/lib/types/dsh-adapter/channel/input-delivery.d.ts.map +1 -1
  101. package/lib/types/dsh-adapter/channel/input-delivery.js +14 -5
  102. package/lib/types/dsh-adapter/channel/model-actions.d.ts +4 -1
  103. package/lib/types/dsh-adapter/channel/model-actions.d.ts.map +1 -1
  104. package/lib/types/dsh-adapter/channel/model-actions.js +26 -9
  105. package/lib/types/dsh-adapter/channel/model-selection.d.ts +27 -2
  106. package/lib/types/dsh-adapter/channel/model-selection.d.ts.map +1 -1
  107. package/lib/types/dsh-adapter/channel/model-selection.js +81 -37
  108. package/lib/types/dsh-adapter/channel/model-switch.d.ts +1 -1
  109. package/lib/types/dsh-adapter/channel/model-switch.d.ts.map +1 -1
  110. package/lib/types/dsh-adapter/channel/session-rewind.d.ts.map +1 -1
  111. package/lib/types/dsh-adapter/channel/session-rewind.js +6 -2
  112. package/lib/types/dsh-adapter/channel/session-tree-actions.d.ts.map +1 -1
  113. package/lib/types/dsh-adapter/channel/session-tree-actions.js +8 -4
  114. package/lib/types/dsh-adapter/channel/settings-host.d.ts.map +1 -1
  115. package/lib/types/dsh-adapter/channel/settings-host.js +6 -3
  116. package/lib/types/dsh-adapter/channel/transcript.d.ts +3 -2
  117. package/lib/types/dsh-adapter/channel/transcript.d.ts.map +1 -1
  118. package/lib/types/dsh-adapter/channel/transcript.js +13 -4
  119. package/lib/types/dsh-adapter/channel/types.d.ts +11 -2
  120. package/lib/types/dsh-adapter/channel/types.d.ts.map +1 -1
  121. package/lib/types/dsh-adapter/contract.d.ts +26 -3
  122. package/lib/types/dsh-adapter/contract.d.ts.map +1 -1
  123. package/lib/types/dsh-adapter/contract.js +44 -5
  124. package/lib/types/dsh-adapter/fresh-agent.d.ts +1 -1
  125. package/lib/types/dsh-adapter/fresh-agent.d.ts.map +1 -1
  126. package/lib/types/dsh-adapter/fresh-agent.js +60 -11
  127. package/lib/types/dsh-adapter/host-access.d.ts.map +1 -1
  128. package/lib/types/dsh-adapter/host-access.js +60 -11
  129. package/lib/types/dsh-adapter/host-contract.d.ts +1 -1
  130. package/lib/types/dsh-adapter/host-contract.d.ts.map +1 -1
  131. package/lib/types/dsh-adapter/host-contract.js +4 -2
  132. package/lib/types/dsh-adapter/host-dsh.d.ts +0 -8
  133. package/lib/types/dsh-adapter/host-dsh.d.ts.map +1 -1
  134. package/lib/types/dsh-adapter/host-dsh.js +27 -6
  135. package/lib/types/dsh-adapter/host-entry.js +4 -0
  136. package/lib/types/dsh-adapter/oauth/profiles.d.ts.map +1 -1
  137. package/lib/types/dsh-adapter/oauth/profiles.js +14 -1
  138. package/lib/types/dsh-adapter/plugin.d.ts.map +1 -1
  139. package/lib/types/dsh-adapter/plugin.js +143 -44
  140. package/lib/types/dsh-adapter/presets.d.ts +38 -11
  141. package/lib/types/dsh-adapter/presets.d.ts.map +1 -1
  142. package/lib/types/dsh-adapter/presets.js +46 -17
  143. package/lib/types/dsh-adapter/process-exit.d.ts +1 -1
  144. package/lib/types/dsh-adapter/process-exit.js +1 -1
  145. package/lib/types/dsh-adapter/questions.d.ts +3 -4
  146. package/lib/types/dsh-adapter/questions.d.ts.map +1 -1
  147. package/lib/types/dsh-adapter/questions.js +1 -1
  148. package/lib/types/dsh-adapter/session-list-metadata.js +2 -2
  149. package/lib/types/dsh-adapter/subagents.d.ts +5 -0
  150. package/lib/types/dsh-adapter/subagents.d.ts.map +1 -1
  151. package/lib/types/dsh-adapter/subagents.js +22 -1
  152. package/lib/types/dsh-adapter/team-mode.d.ts +17 -10
  153. package/lib/types/dsh-adapter/team-mode.d.ts.map +1 -1
  154. package/lib/types/dsh-adapter/team-mode.js +19 -12
  155. package/lib/types/dsh-adapter/tool-scope.d.ts +24 -0
  156. package/lib/types/dsh-adapter/tool-scope.d.ts.map +1 -0
  157. package/lib/types/dsh-adapter/tool-scope.js +127 -0
  158. package/lib/types/dsh-adapter/types.d.ts +2 -1
  159. package/lib/types/dsh-adapter/types.d.ts.map +1 -1
  160. package/lib/types/heldInputs.d.ts +55 -16
  161. package/lib/types/heldInputs.d.ts.map +1 -1
  162. package/lib/types/heldInputs.js +277 -41
  163. package/lib/types/i18n.d.ts +227 -11
  164. package/lib/types/i18n.d.ts.map +1 -1
  165. package/lib/types/i18n.js +60 -5
  166. package/lib/types/ink/components/App.d.ts +2 -0
  167. package/lib/types/ink/components/App.d.ts.map +1 -1
  168. package/lib/types/ink/components/App.js +8 -0
  169. package/lib/types/ink/events/input-event.d.ts.map +1 -1
  170. package/lib/types/ink/events/input-event.js +7 -6
  171. package/lib/types/ink/hit-test.d.ts +2 -0
  172. package/lib/types/ink/hit-test.d.ts.map +1 -1
  173. package/lib/types/ink/hit-test.js +10 -0
  174. package/lib/types/ink/hooks/use-program-status.d.ts +1 -1
  175. package/lib/types/ink/hooks/use-program-status.d.ts.map +1 -1
  176. package/lib/types/ink/hooks/use-program-status.js +3 -2
  177. package/lib/types/ink/ink.d.ts +1 -0
  178. package/lib/types/ink/ink.d.ts.map +1 -1
  179. package/lib/types/ink/ink.js +5 -2
  180. package/lib/types/ink/parse-keypress.d.ts.map +1 -1
  181. package/lib/types/ink/parse-keypress.js +25 -0
  182. package/lib/types/ink/terminal.d.ts +13 -2
  183. package/lib/types/ink/terminal.d.ts.map +1 -1
  184. package/lib/types/ink/terminal.js +29 -5
  185. package/lib/types/screens/Chat.d.ts.map +1 -1
  186. package/lib/types/screens/Chat.js +43 -2
  187. package/lib/types/screens/SessionSupervisor.d.ts +3 -6
  188. package/lib/types/screens/SessionSupervisor.d.ts.map +1 -1
  189. package/lib/types/screens/SessionSupervisor.js +5 -8
  190. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts +1 -2
  191. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.d.ts.map +1 -1
  192. package/lib/types/screens/sessionSupervisor/ForeignSessionPanes.js +2 -2
  193. package/lib/types/screens/sessionSupervisor/model.d.ts +1 -1
  194. package/lib/types/screens/sessionSupervisor/model.js +1 -1
  195. package/lib/types/sessionMounts.d.ts +12 -5
  196. package/lib/types/sessionMounts.d.ts.map +1 -1
  197. package/lib/types/sessionMounts.js +33 -6
  198. package/lib/types/update.d.ts +412 -20
  199. package/lib/types/update.d.ts.map +1 -1
  200. package/lib/types/update.js +2094 -193
  201. package/lib/types/updateHost.d.ts +198 -0
  202. package/lib/types/updateHost.d.ts.map +1 -0
  203. package/lib/types/updateHost.js +608 -0
  204. package/lib/types/utils/processName.d.ts +16 -0
  205. package/lib/types/utils/processName.d.ts.map +1 -0
  206. package/lib/types/utils/processName.js +27 -0
  207. package/package.json +111 -108
  208. package/tui-profile/feed/README.md +1 -1
  209. package/tui-profile/feed/first-party.json +1 -1
@@ -1,8 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Box, Text, InputCaret } from '../../../ui.js';
2
+ import { Box, Text, InputCaret, useTerminalSize } from '../../../ui.js';
3
3
  import { t } from '../../../i18n.js';
4
4
  import { actionMatches } from '../../../utils/keymap.js';
5
- import { flattenPasteInline } from '../../../channel/sanitize.js';
5
+ import { flattenInline, flattenPasteInline } from '../../../channel/sanitize.js';
6
+ import { stringWidth } from '../../../ink/stringWidth.js';
7
+ import { getGraphemeSegmenter } from '../../../utils/intl.js';
6
8
  import { nextCodePoint, previousCodePoint } from '../../AgentMessageComposer.js';
7
9
  /**
8
10
  * 单行 composer 的键语义。返回 null = 未消费(面板形态交宿主回退键,
@@ -69,13 +71,112 @@ export function btwComposerKey(state, input, key) {
69
71
  if (key.end === true)
70
72
  return { state: { ...state, caret: state.text.length } };
71
73
  if (input !== '' && key.ctrl !== true && key.meta !== true) {
72
- return { state: { text: state.text.slice(0, caret) + input + state.text.slice(caret), caret: caret + input.length } };
74
+ // 整块文本不一定带 isPasted:忽略 bracketed paste 的终端会把换行原样
75
+ // 送进这里,而单行窗口的 Text 会按 LF 折出第二行(被 overflow 裁掉、
76
+ // caret 与可见文本脱节)。等长压平后再插,caret 偏移保持不变。
77
+ const typed = flattenInline(input);
78
+ return { state: { text: state.text.slice(0, caret) + typed + state.text.slice(caret), caret: caret + typed.length } };
73
79
  }
74
80
  return null;
75
81
  }
76
- export function BtwComposer({ state, focused, busy, notice, onActivate, }) {
82
+ /**
83
+ * 单行输入框的窗口(issue #1812):按显示列把草稿裁成 head + at + tail,
84
+ * caret 始终留在框内;两侧被裁时各补一个 `…`,让人知道那边还有字。
85
+ *
86
+ * 不能只靠 `wrap="truncate"`:截断把节点的宽度夹到可用宽度,排在它后面的
87
+ * `InputCaret` 必然落到框右缘之外。所以先算窗口再上屏。按字素累计列宽,
88
+ * CJK / 宽字符 / emoji 整格取舍,不在中间劈开;草稿由面板与全屏共享,另一个
89
+ * 编辑面可能把这个 caret 留在字素中间,此时吸附到后一个边界,绝不显示半个字。
90
+ */
91
+ export function composerWindow(text, caret, budget) {
92
+ const width = Math.max(1, budget);
93
+ const cells = [];
94
+ const starts = [];
95
+ for (const { segment, index } of getGraphemeSegmenter().segment(text)) {
96
+ cells.push(segment);
97
+ starts.push(index);
98
+ }
99
+ const clamped = Math.max(0, Math.min(caret, text.length));
100
+ // caret 之前的完整字素个数:caret 正好落在边界上取它;落在字素中间则
101
+ // 取后一个边界(那个字素整个留在 head 里,caret 画在它之后)。
102
+ let index = cells.length;
103
+ for (let i = 0; i < starts.length; i += 1) {
104
+ if (starts[i] >= clamped) {
105
+ index = i;
106
+ break;
107
+ }
108
+ }
109
+ const at = cells[index] ?? ' ';
110
+ const atWidth = stringWidth(at);
111
+ // 两侧各自还需要多少列:用来决定分配,也让「某侧其实放得下」时不浪费 `…`。
112
+ let leftNeed = 0;
113
+ for (let i = 0; i < index; i += 1)
114
+ leftNeed += stringWidth(cells[i]);
115
+ let rightNeed = 0;
116
+ for (let i = index + 1; i < cells.length; i += 1)
117
+ rightNeed += stringWidth(cells[i]);
118
+ const fitsAll = leftNeed + rightNeed <= width - atWidth;
119
+ /** 按给定预留列数做一次分配:两侧都超框时 caret 居中。 */
120
+ const allocate = (reserveLeft, reserveRight) => {
121
+ const content = Math.max(0, width - atWidth - reserveLeft - reserveRight);
122
+ // 两侧都有字时分一半(零头给左侧),否则整行给有字的那一侧。
123
+ let headLimit = leftNeed > 0 && rightNeed > 0 ? Math.ceil(content / 2) : content;
124
+ headLimit = Math.min(headLimit, leftNeed);
125
+ // 右侧用不完自己的份额:余量还给左侧(最多到它需要的量)。
126
+ if (rightNeed < content - headLimit)
127
+ headLimit = Math.min(leftNeed, content - rightNeed);
128
+ let head = index;
129
+ let headWidth = 0;
130
+ while (head > 0) {
131
+ const cellWidth = stringWidth(cells[head - 1]);
132
+ if (headWidth + cellWidth > headLimit)
133
+ break;
134
+ headWidth += cellWidth;
135
+ head -= 1;
136
+ }
137
+ const tailLimit = content - headWidth;
138
+ let tail = index + 1;
139
+ let tailWidth = 0;
140
+ while (tail < cells.length) {
141
+ const cellWidth = stringWidth(cells[tail]);
142
+ if (tailWidth + cellWidth > tailLimit)
143
+ break;
144
+ tailWidth += cellWidth;
145
+ tail += 1;
146
+ }
147
+ return { head, tail, headWidth, tailWidth };
148
+ };
149
+ // 两侧各留 1 列给 `…`,再按实际裁没裁掉把多余的预留收回来。预算连两个
150
+ // `…` 都不够时(极窄档)干脆不画:指示符不能把 caret 挤出框。
151
+ const room = Math.max(0, width - atWidth);
152
+ let reserveLeft = !fitsAll && index > 0 ? 1 : 0;
153
+ let reserveRight = !fitsAll && rightNeed > 0 ? 1 : 0;
154
+ if (reserveLeft + reserveRight > room) {
155
+ reserveLeft = 0;
156
+ reserveRight = 0;
157
+ }
158
+ let layout = allocate(reserveLeft, reserveRight);
159
+ // 收预留只会多出内容,不会让另一侧变得更紧,所以各检查一次就稳定。
160
+ if (layout.head === 0 && reserveLeft > 0) {
161
+ reserveLeft = 0;
162
+ layout = allocate(reserveLeft, reserveRight);
163
+ }
164
+ if (layout.tail === cells.length && reserveRight > 0) {
165
+ reserveRight = 0;
166
+ layout = allocate(reserveLeft, reserveRight);
167
+ }
168
+ return {
169
+ head: cells.slice(layout.head, index).join(''),
170
+ at,
171
+ tail: cells.slice(index + 1, layout.tail).join(''),
172
+ clippedLeft: reserveLeft === 1,
173
+ clippedRight: reserveRight === 1,
174
+ };
175
+ }
176
+ export function BtwComposer({ state, focused, busy, notice, width, onActivate, }) {
177
+ const { columns } = useTerminalSize();
77
178
  const { text, caret } = state;
78
- const shown = Math.min(caret, text.length);
79
- const afterCaret = nextCodePoint(text, shown);
80
- return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { width: "100%", flexShrink: 0, borderStyle: "round", borderColor: focused ? 'accent' : undefined, onClick: onActivate === undefined ? undefined : () => onActivate(), children: _jsxs(Box, { flexDirection: "row", flexShrink: 0, paddingLeft: 1, paddingRight: 1, children: [_jsx(Text, { color: focused ? 'accent' : undefined, bold: true, children: '›' }), _jsx(Text, { children: ' ' }), focused ? (_jsxs(_Fragment, { children: [_jsxs(Box, { flexDirection: "row", flexShrink: 1, minWidth: 0, children: [_jsx(Text, { wrap: "truncate", children: text.slice(0, shown) }), _jsx(InputCaret, { children: text.slice(shown, afterCaret) || ' ' }), text.slice(afterCaret) !== '' ? _jsx(Text, { wrap: "truncate", children: text.slice(afterCaret) }) : null] }), _jsx(Box, { flexGrow: 1, flexShrink: 0, children: _jsx(Text, { children: " " }) }), _jsx(Box, { flexShrink: 0, children: _jsxs(Text, { dimColor: true, children: [" ", t('btw-input-hint-edit')] }) })] })) : (_jsx(Text, { dimColor: true, wrap: "truncate", children: text === '' ? t('btw-input-placeholder') : text }))] }) }), notice !== undefined && (_jsx(Text, { color: notice.failure ? 'error' : undefined, wrap: "truncate", children: notice.text }))] }));
179
+ // 边框 2 + 左右 padding 2 + 「› 」2 = 6 列不属于草稿。
180
+ const view = composerWindow(text, caret, Math.max(1, (width ?? columns) - 6));
181
+ return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, children: [_jsx(Box, { width: "100%", flexShrink: 0, borderStyle: "round", borderColor: focused ? 'accent' : undefined, onClick: onActivate === undefined ? undefined : () => onActivate(), children: _jsxs(Box, { flexDirection: "row", height: 1, flexShrink: 1, minWidth: 0, paddingLeft: 1, paddingRight: 1, children: [_jsx(Box, { flexShrink: 0, children: _jsx(Text, { color: focused ? 'accent' : undefined, bold: true, children: '›' }) }), _jsx(Box, { flexShrink: 0, children: _jsx(Text, { children: ' ' }) }), focused ? (text === '' ? (_jsxs(_Fragment, { children: [_jsx(InputCaret, { children: ' ' }), _jsx(Box, { flexGrow: 1, flexShrink: 0, children: _jsx(Text, { children: " " }) }), _jsx(Box, { flexShrink: 1, minWidth: 0, children: _jsxs(Text, { dimColor: true, wrap: "truncate", children: [" ", t('btw-input-hint-edit')] }) })] })) : (_jsxs(Box, { flexDirection: "row", flexShrink: 1, minWidth: 0, height: 1, overflow: "hidden", children: [view.clippedLeft ? _jsx(Text, { wrap: "truncate", children: '…' }) : null, _jsx(Text, { wrap: "truncate", children: view.head }), _jsx(InputCaret, { children: view.at }), _jsx(Text, { wrap: "truncate", children: view.tail }), view.clippedRight ? _jsx(Text, { wrap: "truncate", children: '…' }) : null] }))) : (_jsx(Text, { dimColor: true, wrap: "truncate", children: text === '' ? t('btw-input-placeholder') : text }))] }) }), notice !== undefined && (_jsx(Text, { color: notice.failure ? 'error' : undefined, wrap: "truncate", children: notice.text }))] }));
81
182
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BtwPanelAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwPanelAdapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,OAAO,KAAK,EAAmB,UAAU,EAAE,MAAM,aAAa,CAAA;AAY9D,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,SAAS,CAoRhG"}
1
+ {"version":3,"file":"BtwPanelAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwPanelAdapter.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,OAAO,KAAK,EAAmB,UAAU,EAAE,MAAM,aAAa,CAAA;AAY9D,wBAAgB,eAAe,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,GAAG,KAAK,CAAC,SAAS,CAqRhG"}
@@ -285,5 +285,5 @@ export function BtwPanelAdapter({ width, height, focused, visible }) {
285
285
  panelStore.setHint('btw', hintText);
286
286
  return () => { panelStore.setHint('btw', ''); };
287
287
  }, [hintText]);
288
- return (_jsxs(Box, { flexDirection: "column", width: "100%", height: height, overflow: "hidden", children: [header, _jsx(BtwThreadView, { thread: thread, width: width, height: Math.max(3, height - (header === null ? 4 : 6)), alive: visible, selectedTurnId: listActive ? selectedId ?? undefined : undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus && focused && visible, busy: busy, notice: notice === undefined || notice === null ? undefined : notice, onActivate: activateComposer })] }));
288
+ return (_jsxs(Box, { flexDirection: "column", width: "100%", height: height, overflow: "hidden", children: [header, _jsx(BtwThreadView, { thread: thread, width: width, height: Math.max(3, height - (header === null ? 4 : 6)), alive: visible, selectedTurnId: listActive ? selectedId ?? undefined : undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus && focused && visible, busy: busy, notice: notice === undefined || notice === null ? undefined : notice, width: width, onActivate: activateComposer })] }));
289
289
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BtwThreadScene.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwThreadScene.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAQtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAEhE,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,OAAO,EACP,WAAW,EACX,qBAAqB,GACtB,EAAE;IACD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IAC/C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS,CAAA;CAC5E,GAAG,KAAK,CAAC,SAAS,CA0KlB"}
1
+ {"version":3,"file":"BtwThreadScene.d.ts","sourceRoot":"","sources":["../../../../../src/components/sidePanel/btw/BtwThreadScene.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAA;AAQtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAEhE,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,OAAO,EACP,WAAW,EACX,qBAAqB,GACtB,EAAE;IACD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAA;IAC5B,iCAAiC;IACjC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAA;IAC/C;;;OAGG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,GAAG,SAAS,CAAA;CAC5E,GAAG,KAAK,CAAC,SAAS,CA2KlB"}
@@ -182,5 +182,5 @@ export function BtwThreadScene({ channel, onClose, onFocusChat, readClipboardOve
182
182
  event.stopImmediatePropagation();
183
183
  }
184
184
  });
185
- return (_jsxs(Box, { flexDirection: "column", width: columns, height: rows, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", width: "100%", height: 1, flexShrink: 0, children: [_jsx(Text, { color: "warning", bold: true, children: t('btw-fullscreen-title') }), _jsx(Text, { dimColor: true, wrap: "truncate", children: ' ' + t('btw-scene-hints') })] }), _jsx(BtwThreadView, { thread: thread, width: columns - 2, height: Math.max(3, rows - 4), alive: true, selectedTurnId: composerFocus ? undefined : selectedId ?? undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus, busy: busy, notice: notice === null ? undefined : notice, onActivate: activateComposer })] }));
185
+ return (_jsxs(Box, { flexDirection: "column", width: columns, height: rows, paddingX: 1, children: [_jsxs(Box, { flexDirection: "row", width: "100%", height: 1, flexShrink: 0, children: [_jsx(Text, { color: "warning", bold: true, children: t('btw-fullscreen-title') }), _jsx(Text, { dimColor: true, wrap: "truncate", children: ' ' + t('btw-scene-hints') })] }), _jsx(BtwThreadView, { thread: thread, width: columns - 2, height: Math.max(3, rows - 4), alive: true, selectedTurnId: composerFocus ? undefined : selectedId ?? undefined, onSelectTurn: selectTurn, scrollHandleRef: scrollRef }), _jsx(BtwComposer, { state: { text: thread?.draft ?? '', caret }, focused: composerFocus, busy: busy, notice: notice === null ? undefined : notice, width: columns - 2, onActivate: activateComposer })] }));
186
186
  }
@@ -12,18 +12,48 @@ export declare function subscribeReveal(listener: () => void): () => void;
12
12
  export declare function getRevealVersion(): number;
13
13
  /** Force-complete (and forget) a cursor: expanded card, replaced view, … */
14
14
  export declare function snapReveal(key: string): void;
15
+ /**
16
+ * Key for `key` inside `scope`. Every Chat root owns its reveal memory: ids
17
+ * restart at 0 inside a root, so a sibling root's rebind must not clear (or
18
+ * inherit) another root's completed keys. `undefined` keeps the bare key —
19
+ * single-root scripts, tests, and any caller outside a Chat provider.
20
+ */
21
+ export declare function scopeRevealKey(scope: string | undefined, key: string): string;
22
+ /**
23
+ * Session boundary (agent switch, `/resume`, rewind adopt): row ids restart
24
+ * at 0, so a key from the previous session (`a12`) names a different row in
25
+ * the new one. Drop both the completed memory and any in-flight cursors —
26
+ * replayed rows read with `active: false` and paint complete anyway, while
27
+ * the new session's live rows must be free to animate from scratch. The
28
+ * scheduler, listeners and version store stay intact: the mounted tree keeps
29
+ * subscribing, and clearing both cursor tables stops the timer synchronously.
30
+ *
31
+ * Known residue: a backend `conversation_reset` also restarts row ids, but it
32
+ * is a channel-layer event that never crosses into the UI — that path keeps
33
+ * its stale keys, so the first rows after such a reset paint without a
34
+ * reveal. The old 2048 FIFO used to heal this by accident once a session had
35
+ * revealed past the cap; with no eviction it is permanent until the agent
36
+ * changes. Covering it needs a row-id-regression signal from the channel;
37
+ * tracked in #1795.
38
+ */
39
+ export declare function resetRevealSession(scope: string): void;
15
40
  export type RevealReadOptions = {
16
41
  /** Master switch (settings `dsh-tui.smoothStreaming`); false = full text. */
17
42
  enabled: boolean;
18
43
  /**
19
44
  * Whether this content arrived "just now" (live streaming row, freshly
20
45
  * settled row, live-created tool card). The FIRST read with active=true
21
- * creates the cursor at zero — that is what turns a one-shot
22
- * non-streaming delivery into a smooth paint. Reading with active=false
23
- * (history / replayed content) never creates one: replaying a transcript
24
- * must not typewrite every row. `active` only matters for cursor creation;
25
- * settling mid-reveal deliberately keeps revealing (the "non-streaming
26
- * becomes streaming" contract).
46
+ * creates the cursor at zero — that is what turns a one-shot non-streaming
47
+ * delivery into a smooth paint. A first TEXT read with active=false
48
+ * (history / replayed content) paints the whole text and registers a
49
+ * caught-up cursor (revealed == text.length, no timer), so replaying a
50
+ * transcript typewrites nothing while a later live continuation of the same
51
+ * row starts at the painted length instead of zero. The count reader
52
+ * (`revealLinesOf`) has no such cursor: an inactive read just returns the
53
+ * total, and the next active read starts a fresh cursor. `active` decides
54
+ * where a new cursor starts, not whether one exists; settling mid-reveal
55
+ * deliberately keeps revealing (the "non-streaming becomes streaming"
56
+ * contract).
27
57
  */
28
58
  active: boolean;
29
59
  };
@@ -1 +1 @@
1
- {"version":3,"file":"smoothReveal.d.ts","sourceRoot":"","sources":["../../../src/components/smoothReveal.ts"],"names":[],"mappings":"AA0CA,oEAAoE;AACpE,eAAO,MAAM,eAAe,QAAY,CAAA;AACxC,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAA;AAChC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAiID,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKhE;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAMD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;;;;;OASG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAiC5F;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAI1F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAqC5F;AAMD,wEAAwE;AACxE,wBAAgB,kBAAkB,IAAI,IAAI,CAUzC;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
1
+ {"version":3,"file":"smoothReveal.d.ts","sourceRoot":"","sources":["../../../src/components/smoothReveal.ts"],"names":[],"mappings":"AA6CA,oEAAoE;AACpE,eAAO,MAAM,eAAe,QAAY,CAAA;AACxC,gFAAgF;AAChF,eAAO,MAAM,eAAe,IAAI,CAAA;AAChC,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,IAAI,CAAA;AAEtC,kEAAkE;AAClE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD;AAqJD,oEAAoE;AACpE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKhE;AAED,wEAAwE;AACxE,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,4EAA4E;AAC5E,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAE5C;AAMD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAYtD;AAMD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;;;;;;;;;;OAcG;IACH,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAyC5F;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAI1F;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAqC5F;AAMD,wEAAwE;AACxE,wBAAgB,kBAAkB,IAAI,IAAI,CAOzC;AAED,yEAAyE;AACzE,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
@@ -25,8 +25,11 @@
25
25
  * never notice (stale cached heights → blank bands). Instead the cursors
26
26
  * live here keyed by row identity, the READS happen during render (they feed
27
27
  * the same flattened `text` prop the streaming path already uses), and the
28
- * WRITES happen on the scheduler tick, which bumps a version that
29
- * MessageList subscribes to via useSyncExternalStore. A reveal therefore
28
+ * WRITES happen in two places: the scheduler tick, which bumps a version
29
+ * that MessageList subscribes to via useSyncExternalStore; and the first
30
+ * history read of a row, which registers a caught-up cursor (see
31
+ * RevealReadOptions.active) so a later live continuation of that row does
32
+ * not restart it. A reveal therefore
30
33
  * rides the exact same update pipeline as an arriving chunk: prop change →
31
34
  * memo miss → re-render → post-commit measurement. Render-phase reads are
32
35
  * idempotent and safe to re-run (a discarded concurrent render at worst
@@ -72,23 +75,42 @@ const countCursors = new Map();
72
75
  * Keys whose reveal has COMPLETED (caught up, snapped, or replaced). A
73
76
  * completed key must not re-create a cursor on a later active read — the
74
77
  * content is already fully on screen, and re-revealing would blank it and
75
- * typewrite again. Bounded FIFO: well past the cap these are all ancient
76
- * history (the row ids are gone); dropping the oldest half only risks a
77
- * long-unmounted row re-revealing, which is harmless (it paints full via
78
- * the active=false path anyway once unmounted... and a remounted streaming
79
- * row WANTS the reveal).
78
+ * typewrite again.
79
+ *
80
+ * Deliberately UNBOUNDED. The 2048-entry FIFO this replaced dropped the
81
+ * oldest half, which turns "already painted once" back into "never painted".
82
+ * Its premise — that a forgotten row re-paints full through the
83
+ * `active: false` path — does not hold: `fresh` is set when a live turn
84
+ * settles and is never cleared, so a remounted row keeps claiming
85
+ * liveliness and gets typewritten again from its first character (#1787).
86
+ * Long sessions were exactly the case that overflowed.
87
+ *
88
+ * Growth follows the session, not time: at most a few short keys per row
89
+ * (`a{id}`, `r{id}`, `tool:{callId}`, `tool:{callId}:split`), on rows that
90
+ * stay resident — `foldRows` never drops a row, and the projection's
91
+ * merge/replace paths are the only removers (their ids are never reused, so
92
+ * the leftover keys cost memory but cannot collide). It is every RENDERED
93
+ * row, not only the ones that revealed: a history read registers a caught-up
94
+ * text cursor, and the next tick retires it into `completedReveals`.
95
+ * Measured on V8: 50k `a{id}` keys ≈ 2.4 MB, 50k `tool:{callId}:split`
96
+ * keys ≈ 12.3 MB — second-order next to the ChatRow objects the same
97
+ * session already holds. The contributor guide's long-session memory rule
98
+ * asks for a measured alternative before removing a cache bound; the
99
+ * measurement is above, and the alternative does not exist while `fresh`
100
+ * is never cleared: any count-based bound re-opens #1787 (an evicted
101
+ * off-screen row re-reads as active and typewrites once it scrolls back).
102
+ *
103
+ * It also grows on the render path, which the same guide warns about under
104
+ * its unbounded render-phase collection rule. The distinction from the
105
+ * neighbouring `HEIGHTS_CACHE_MAX` FIFO in MessageList is what an eviction
106
+ * costs there: a forgotten height only mis-estimates geometry and falls
107
+ * back to `DEFAULT_ROW_HEIGHT`, while a forgotten key re-typewrites the
108
+ * row — the exact report this comment exists for. Making `fresh`
109
+ * transactional would lift the constraint; that is a projection change,
110
+ * tracked in #1795.
80
111
  */
81
112
  const completedReveals = new Set();
82
- const COMPLETED_REVEALS_MAX = 2048;
83
113
  function markRevealCompleted(key) {
84
- if (completedReveals.size >= COMPLETED_REVEALS_MAX) {
85
- let drop = COMPLETED_REVEALS_MAX / 2;
86
- for (const old of completedReveals) {
87
- if (drop-- <= 0)
88
- break;
89
- completedReveals.delete(old);
90
- }
91
- }
92
114
  completedReveals.add(key);
93
115
  }
94
116
  // ---------------------------------------------------------------------------
@@ -180,6 +202,51 @@ export function snapReveal(key) {
180
202
  if (textCursors.delete(key) || countCursors.delete(key))
181
203
  markRevealCompleted(key);
182
204
  }
205
+ /** Scope separator: NUL never appears in a row id or a call id, so a scoped
206
+ * key stays unambiguous and one root clears its own entries by prefix. */
207
+ const REVEAL_SCOPE_SEPARATOR = '\u0000';
208
+ /**
209
+ * Key for `key` inside `scope`. Every Chat root owns its reveal memory: ids
210
+ * restart at 0 inside a root, so a sibling root's rebind must not clear (or
211
+ * inherit) another root's completed keys. `undefined` keeps the bare key —
212
+ * single-root scripts, tests, and any caller outside a Chat provider.
213
+ */
214
+ export function scopeRevealKey(scope, key) {
215
+ return scope === undefined ? key : `${scope}${REVEAL_SCOPE_SEPARATOR}${key}`;
216
+ }
217
+ /**
218
+ * Session boundary (agent switch, `/resume`, rewind adopt): row ids restart
219
+ * at 0, so a key from the previous session (`a12`) names a different row in
220
+ * the new one. Drop both the completed memory and any in-flight cursors —
221
+ * replayed rows read with `active: false` and paint complete anyway, while
222
+ * the new session's live rows must be free to animate from scratch. The
223
+ * scheduler, listeners and version store stay intact: the mounted tree keeps
224
+ * subscribing, and clearing both cursor tables stops the timer synchronously.
225
+ *
226
+ * Known residue: a backend `conversation_reset` also restarts row ids, but it
227
+ * is a channel-layer event that never crosses into the UI — that path keeps
228
+ * its stale keys, so the first rows after such a reset paint without a
229
+ * reveal. The old 2048 FIFO used to heal this by accident once a session had
230
+ * revealed past the cap; with no eviction it is permanent until the agent
231
+ * changes. Covering it needs a row-id-regression signal from the channel;
232
+ * tracked in #1795.
233
+ */
234
+ export function resetRevealSession(scope) {
235
+ const prefix = `${scope}${REVEAL_SCOPE_SEPARATOR}`;
236
+ for (const key of [...textCursors.keys()]) {
237
+ if (key.startsWith(prefix))
238
+ textCursors.delete(key);
239
+ }
240
+ for (const key of [...countCursors.keys()]) {
241
+ if (key.startsWith(prefix))
242
+ countCursors.delete(key);
243
+ }
244
+ for (const key of [...completedReveals]) {
245
+ if (key.startsWith(prefix))
246
+ completedReveals.delete(key);
247
+ }
248
+ stopRevealTimerIfIdle();
249
+ }
183
250
  /**
184
251
  * Revealed length of `text` for `key` — the cursor logic of
185
252
  * {@link revealTextOf} without the slice allocation (layout signatures read
@@ -201,8 +268,15 @@ export function revealLengthOf(key, text, options) {
201
268
  // again.
202
269
  if (completedReveals.has(key))
203
270
  return text.length;
204
- if (!options.active)
271
+ if (!options.active) {
272
+ // Painted as history (a settled live row, a replayed row). Remember
273
+ // that the whole text is already on screen: a live continuation reuses
274
+ // this key, and without the caught-up cursor it would fall into the
275
+ // active branch below, create `revealed: 0` and typewrite the row
276
+ // again from its first character. Already complete, so no timer.
277
+ textCursors.set(key, { text, revealed: text.length });
205
278
  return text.length;
279
+ }
206
280
  textCursors.set(key, { text, revealed: 0 });
207
281
  ensureRevealTimer();
208
282
  return 0;
@@ -292,11 +366,8 @@ export function resetRevealForTest() {
292
366
  textCursors.clear();
293
367
  countCursors.clear();
294
368
  completedReveals.clear();
369
+ stopRevealTimerIfIdle();
295
370
  revealListeners.clear();
296
- if (revealTimer !== undefined) {
297
- clearInterval(revealTimer);
298
- revealTimer = undefined;
299
- }
300
371
  revealVersionValue = 0;
301
372
  }
302
373
  /** Whether the shared scheduler currently runs (refcount assertions). */
@@ -4,22 +4,12 @@ import type { ContextMenuEvent } from '../../ink/events/context-menu-event.js';
4
4
  /**
5
5
  * One workspace in the home screen's left rail.
6
6
  *
7
- * Two lines, like every other navigable row in this app: the name line is what
8
- * the user named it, the detail line is where it actually is and how much is in
9
- * it. The path is not decoration — two workspaces can carry the same basename
10
- * (`.../a/work` and `.../b/work`), and the ledger allows duplicate titles, so
11
- * the path is the only thing that tells them apart.
12
- *
13
- * Widths are resolved here rather than left to flexbox for the same reason the
14
- * session rows resolve them: a row must be exactly two lines at every terminal
15
- * width, and a wrapped row destroys the alignment a list is scanned by.
7
+ * A single name-and-count line at every terminal width. The selected
8
+ * workspace path lives above the panes, where it has the full screen width
9
+ * instead of repeating a truncated path under every name.
16
10
  */
17
- export declare function HomeWorkspaceRow({ title, path, home, sessionCount, historyOnly, present, selected, focused, declareCursor, width, onSelect, onMenu, }: {
11
+ export declare function HomeWorkspaceRow({ title, sessionCount, historyOnly, present, selected, focused, declareCursor, width, onSelect, onMenu, }: {
18
12
  title: string;
19
- /** Canonical directory path recorded in the ledger. */
20
- path: string;
21
- /** Home directory, for collapsing the path to `~`. */
22
- home: string;
23
13
  sessionCount: number;
24
14
  /** Derived from session history, without a workspace registration. */
25
15
  historyOnly?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"HomeWorkspaceRow.d.ts","sourceRoot":"","sources":["../../../../src/components/workspaces/HomeWorkspaceRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAI9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,YAAY,EACZ,WAAmB,EACnB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,uDAAuD;IACvD,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,QAAQ,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IAClC,mDAAmD;IACnD,MAAM,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACvC,GAAG,KAAK,CAAC,SAAS,CAuClB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,KAAK,EACL,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC,GAAG,KAAK,CAAC,SAAS,CAoBlB"}
1
+ {"version":3,"file":"HomeWorkspaceRow.d.ts","sourceRoot":"","sources":["../../../../src/components/workspaces/HomeWorkspaceRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAA;AAGvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAA;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAA;AAK9E;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,YAAY,EACZ,WAAmB,EACnB,OAAO,EACP,QAAQ,EACR,OAAO,EACP,aAAqB,EACrB,KAAK,EACL,QAAQ,EACR,MAAM,GACP,EAAE;IACD,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,MAAM,CAAA;IACpB,sEAAsE;IACtE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAA;IACjB,uBAAuB;IACvB,OAAO,EAAE,OAAO,CAAA;IAChB,gEAAgE;IAChE,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,uEAAuE;IACvE,QAAQ,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;IAClC,mDAAmD;IACnD,MAAM,CAAC,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,CAAA;CACvC,GAAG,KAAK,CAAC,SAAS,CAoDlB;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,KAAK,EACL,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAA;CACjC,GAAG,KAAK,CAAC,SAAS,CAoBlB"}
@@ -2,40 +2,49 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
3
  import { Box, Text } from '../../ui.js';
4
4
  import { t } from '../../i18n.js';
5
- import { formatProject, spreadRow, truncateWidth } from '../../sessions/format.js';
5
+ import { stringWidth } from '../../ink/stringWidth.js';
6
+ import { spreadRow, truncateWidth } from '../../sessions/format.js';
6
7
  import { useDeclaredCursor, useNativeCursor } from '../../ink/hooks/use-declared-cursor.js';
7
8
  /**
8
9
  * One workspace in the home screen's left rail.
9
10
  *
10
- * Two lines, like every other navigable row in this app: the name line is what
11
- * the user named it, the detail line is where it actually is and how much is in
12
- * it. The path is not decoration — two workspaces can carry the same basename
13
- * (`.../a/work` and `.../b/work`), and the ledger allows duplicate titles, so
14
- * the path is the only thing that tells them apart.
15
- *
16
- * Widths are resolved here rather than left to flexbox for the same reason the
17
- * session rows resolve them: a row must be exactly two lines at every terminal
18
- * width, and a wrapped row destroys the alignment a list is scanned by.
11
+ * A single name-and-count line at every terminal width. The selected
12
+ * workspace path lives above the panes, where it has the full screen width
13
+ * instead of repeating a truncated path under every name.
19
14
  */
20
- export function HomeWorkspaceRow({ title, path, home, sessionCount, historyOnly = false, present, selected, focused, declareCursor = false, width, onSelect, onMenu, }) {
15
+ export function HomeWorkspaceRow({ title, sessionCount, historyOnly = false, present, selected, focused, declareCursor = false, width, onSelect, onMenu, }) {
21
16
  const [hovered, setHovered] = useState(false);
22
17
  const nativeCursor = useNativeCursor();
23
18
  const cursorRef = useDeclaredCursor({ line: 0, column: 0, active: focused && declareCursor, visible: nativeCursor, hideOnIdle: true });
24
19
  const body = Math.max(8, width - 4);
25
20
  // The pane already labels the count; keep the rail's badge numeric and use
26
21
  // its selected ring rather than a second check mark for the same state.
27
- const badge = present ? String(sessionCount) : `${t('home-workspace-missing')} · ${sessionCount}`;
28
- const name = historyOnly ? `${t('supervisor-history-only')} · ${title}` : title;
29
- const heading = spreadRow(`${selected ? '▣' : '▢'} ${name}`, badge, body);
30
- const detail = formatProject(path, home);
22
+ const count = String(sessionCount);
23
+ const ring = selected ? '▣' : '▢';
24
+ const history = t('supervisor-history-only');
25
+ const shortHistory = t('supervisor-history-only-short');
26
+ const missingBadge = `${t('home-workspace-missing')} · ${count}`;
27
+ const compactMissingBadge = `${t('home-workspace-missing')} ${count}`;
28
+ // Reserve room for the ring, an identifiable name and (where needed) the
29
+ // history marker. Fall back to a warning glyph if the text cannot fit.
30
+ const minimumName = stringWidth(`${ring} ${historyOnly ? `${shortHistory} ` : ''}界…`);
31
+ const fits = (value) => stringWidth(value) + 1 + minimumName <= body;
32
+ const badge = present ? count : fits(missingBadge) ? missingBadge : fits(compactMissingBadge) ? compactMissingBadge : `! ${count}`;
33
+ const nameWidth = Math.max(0, body - stringWidth(badge) - 1);
34
+ const fullName = `${ring} ${historyOnly ? `${history} · ${title}` : title}`;
35
+ // Shorten the history prefix when needed, preserving both the label and
36
+ // the beginning of the project name rather than truncating either away.
37
+ const name = historyOnly && stringWidth(fullName) > nameWidth ? `${ring} ${shortHistory} ${title}` : fullName;
38
+ const headingName = truncateWidth(name, nameWidth);
39
+ const heading = spreadRow(headingName, badge, body);
31
40
  // The cursor (green) outranks the selection ring (green); both outrank the
32
41
  // idle colour. Blue is not part of this ladder at all — see the background.
33
42
  const headingColor = (focused || selected) ? 'success' : present ? 'text' : 'inactive';
34
- return (_jsxs(Box, { flexDirection: "column", flexShrink: 0, paddingX: 1, onClick: onSelect, onContextMenu: onMenu, onMouseEnter: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(true), onMouseLeave: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(false),
43
+ return (_jsx(Box, { flexDirection: "column", flexShrink: 0, paddingX: 1, onClick: onSelect, onContextMenu: onMenu, onMouseEnter: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(true), onMouseLeave: onSelect === undefined && onMenu === undefined ? undefined : () => setHovered(false),
35
44
  // Hover is the BLUE prompt — pointer feedback and nothing else, so it
36
45
  // never marks the focused or the selected row. Selection itself is green
37
46
  // in the text, which is why this row draws no box while selected.
38
- backgroundColor: hovered && !focused ? 'userMessageBackgroundHover' : undefined, children: [_jsxs(Box, { ref: cursorRef, height: 1, flexShrink: 0, overflow: "hidden", children: [_jsx(Text, { color: focused ? 'success' : 'subtle', children: focused ? '❯ ' : ' ' }), _jsx(Text, { color: headingColor, bold: focused || selected, children: heading.left }), _jsx(Text, { dimColor: !focused, children: `${' '.repeat(heading.gap)}${heading.right}` })] }), _jsx(Text, { color: (focused || selected) ? 'success' : undefined, dimColor: !(focused || selected), wrap: "truncate-end", children: ` ${truncateWidth(detail, body - 2)}` })] }));
47
+ backgroundColor: hovered && !focused ? 'userMessageBackgroundHover' : undefined, children: _jsxs(Box, { ref: cursorRef, height: 1, flexShrink: 0, overflow: "hidden", children: [_jsx(Text, { color: focused ? 'success' : 'subtle', children: focused ? '❯ ' : ' ' }), _jsx(Text, { color: headingColor, bold: focused || selected, children: heading.left }), _jsx(Text, { dimColor: !focused, children: `${' '.repeat(heading.gap)}${heading.right}` })] }) }));
39
48
  }
40
49
  /**
41
50
  * The `+` row that opens the directory picker.
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAA+B,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAc,YAAY,EAAoD,MAAM,wBAAwB,CAAA;AAKxH,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExE,OAAO,QAAQ,6BAA6B,CAAC;IAC3C,UAAU,SAAS;QACjB,8CAA8C;QAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;QACrB;4EACoE;QACpE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;QACxC,mEAAmE;QACnE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;QACrB;;8BAEsB;QACtB,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;QACjE,wEAAwE;QACxE,UAAU,IAAI,SAAS,YAAY,EAAE,CAAA;QACrC;;;;WAIG;QACH,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;QACvE,iFAAiF;QACjF,gBAAgB,IAAI,IAAI,CAAA;QACxB,gEAAgE;QAChE,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAC1D,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;KAC/D;CACF;AAED;2EAC2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,CAAA;AAUhH,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CAmRjJ;AAED;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAI9D"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAA+B,MAAM,uBAAuB,CAAA;AACpF,OAAO,KAAK,EAAc,YAAY,EAAoD,MAAM,wBAAwB,CAAA;AAKxH,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAExE,OAAO,QAAQ,6BAA6B,CAAC;IAC3C,UAAU,SAAS;QACjB,8CAA8C;QAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;QACrB;4EACoE;QACpE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;QACxC,mEAAmE;QACnE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;QACrB;;8BAEsB;QACtB,YAAY,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,GAAG,MAAM,IAAI,CAAA;QACjE,wEAAwE;QACxE,UAAU,IAAI,SAAS,YAAY,EAAE,CAAA;QACrC;;;;WAIG;QACH,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,UAAU,EAAE,CAAA;QACvE,iFAAiF;QACjF,gBAAgB,IAAI,IAAI,CAAA;QACxB,gEAAgE;QAChE,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;QAC1D,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;KAC/D;CACF;AAED;2EAC2E;AAC3E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,CAAA;AAUhH,wEAAwE;AACxE,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAIpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE;IAAE,QAAQ,CAAC,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CA8RjJ;AAED;2EAC2E;AAC3E,wBAAgB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,WAAW,CAI9D"}
@@ -239,6 +239,18 @@ export function createDshSession(ctx, target, options = {}) {
239
239
  const onEvent = (event) => {
240
240
  if (!active)
241
241
  return;
242
+ if (event.type === 'request/context') {
243
+ // A prepared step can still report A after the next route became B.
244
+ // Keep that record in raw history, but do not publish its capacity
245
+ // into B's live view (or warn on it before a later reconciliation).
246
+ const route = event.data;
247
+ const model = agent.model;
248
+ const selected = typeof model?.current === 'function' ? model.current() : undefined;
249
+ if (selected !== undefined && typeof route.provider === 'string' && route.provider !== '' &&
250
+ typeof route.model === 'string' && route.model !== '' &&
251
+ (route.provider !== selected.provider || route.model !== selected.model))
252
+ return;
253
+ }
242
254
  // Legacy per-token chunks arrive as session events; they wake the
243
255
  // renderer frame-coalesced like live stream frames.
244
256
  listener(translator.translateEvent(event), event.type === 'assistant/chunk' ? FRAME : SYNC);
@@ -1 +1 @@
1
- {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,0BAA0B,CAAA;AAC/F,OAAO,EAAa,KAAK,UAAU,EAAqB,KAAK,cAAc,EAA0D,MAAM,uBAAuB,CAAA;AAElK,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAI3D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAQ1F,MAAM,WAAW,iBAAiB;IAChC;;0DAEsD;IACtD,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAAA;IACtC;4EACwE;IACxE,KAAK,IAAI,OAAO,CAAA;IAChB;+DAC2D;IAC3D,WAAW,IAAI,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAmEtD;AA6FD,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB;4BAoL1B,YAAY,KAAG,SAAS,UAAU,EAAE;4BAgKpC,oBAAoB,KAAG,SAAS,UAAU,EAAE;8BAmB1C,SAAS,YAAY,EAAE,KAAG,SAAS,UAAU,EAAE;iBAW9D,IAAI;4BAxUS,MAAM,WAAW,MAAM,KAAG,YAAY,GAAG,SAAS;8BAgBhD,MAAM,WAAW,MAAM,QAAQ,YAAY,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,KAAG,cAAc,GAAG,SAAS;EAgUjI;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
1
+ {"version":3,"file":"translate.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/backend/translate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAElE,OAAO,KAAK,EAAE,YAAY,EAAqC,MAAM,0BAA0B,CAAA;AAC/F,OAAO,EAAa,KAAK,UAAU,EAAqB,KAAK,cAAc,EAA0D,MAAM,uBAAuB,CAAA;AAElK,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAI3D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAQ1F,MAAM,WAAW,iBAAiB;IAChC;;0DAEsD;IACtD,KAAK,IAAI,iBAAiB,GAAG,SAAS,CAAA;IACtC;4EACwE;IACxE,KAAK,IAAI,OAAO,CAAA;IAChB;+DAC2D;IAC3D,WAAW,IAAI,OAAO,CAAA;CACvB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAmEtD;AAkGD,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB;4BAoL1B,YAAY,KAAG,SAAS,UAAU,EAAE;4BAgKpC,oBAAoB,KAAG,SAAS,UAAU,EAAE;8BAmB1C,SAAS,YAAY,EAAE,KAAG,SAAS,UAAU,EAAE;iBAW9D,IAAI;4BAxUS,MAAM,WAAW,MAAM,KAAG,YAAY,GAAG,SAAS;8BAgBhD,MAAM,WAAW,MAAM,QAAQ,YAAY,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,KAAG,cAAc,GAAG,SAAS;EAgUjI;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -124,8 +124,13 @@ const usageDelta = (usage) => usage === undefined
124
124
  /** DSH turn-close reasons; the ones without a shared name keep their label. */
125
125
  const turnEndReason = (reason) => {
126
126
  switch (reason.kind) {
127
- case 'completed':
128
127
  case 'aborted':
128
+ // Older durable logs may lack the nested cancel cause. Only the
129
+ // session's own teardown changes how the turn reads.
130
+ return reason.reason?.kind === 'disposed'
131
+ ? { kind: 'aborted', cause: 'disposed' }
132
+ : { kind: 'aborted' };
133
+ case 'completed':
129
134
  case 'interrupted':
130
135
  case 'blocked':
131
136
  return { kind: reason.kind };
@@ -1,8 +1,13 @@
1
1
  import type { AttachedContext } from '../../adapter/ports/channel-view.js';
2
2
  import type { MentionExpansion } from './types.js';
3
3
  /** What a panel hands to {@link AttachedContextRegistry.attach}: the staged
4
- * projection minus the fields the channel derives itself (id/chars/truncated). */
5
- export type AttachedContextInput = Pick<AttachedContext, 'source' | 'sourceId' | 'title' | 'content'>;
4
+ * projection minus the fields the channel derives itself (id/chars). */
5
+ export type AttachedContextInput = Pick<AttachedContext, 'source' | 'sourceId' | 'title' | 'content'> & {
6
+ /** Set by a caller that already capped this body (a retracted row's snapshot
7
+ * re-staged by the composer): the flag must ride along instead of being
8
+ * re-derived from a body that now fills the cap exactly. */
9
+ readonly truncated?: boolean;
10
+ };
6
11
  /**
7
12
  * Cell the registry writes through — the live ChannelState. The list is
8
13
  * REPLACED on every change (never mutated in place), which is both what the
@@ -28,6 +33,14 @@ export declare function buildAttachedContextBlock(context: AttachedContext): str
28
33
  * for. Returns how many blocks were appended (telemetry/assertions).
29
34
  */
30
35
  export declare function appendAttachedContextBlocks(blocks: MentionExpansion['blocks'], contexts: readonly AttachedContext[]): number;
36
+ /**
37
+ * Snapshot-first merge: a dock re-send keeps the contexts its row saved and
38
+ * still carries anything staged while the row sat in the dock. The live chips
39
+ * were already taken by `captureOrigin()`, so dropping them here would lose
40
+ * them for good. A duplicate key is the same panel staged again: the newer
41
+ * staged snapshot replaces the saved one (the user just edited it).
42
+ */
43
+ export declare function mergeAttachedContexts(saved: readonly AttachedContext[], staged: readonly AttachedContext[]): readonly AttachedContext[];
31
44
  /** The ChannelState-facing surface (projection writes + the two actions). */
32
45
  export interface AttachedContextRegistry {
33
46
  /** Stage (or re-stage) one panel context; see the REPLACE note below. */
@@ -1 +1 @@
1
- {"version":3,"file":"attached-context.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/attached-context.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;mFACmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC,CAAA;AAErG;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAA;CAC7C;AAcD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAG1E;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,SAAS,eAAe,EAAE,GACnC,MAAM,CAKR;AAED,6EAA6E;AAC7E,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACzC,mEAAmE;IACnE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,OAAO,IAAI,SAAS,eAAe,EAAE,CAAA;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,qBAAqB,EACnC,IAAI,EAAE,MAAM,IAAI,GACf,uBAAuB,CA4CzB"}
1
+ {"version":3,"file":"attached-context.d.ts","sourceRoot":"","sources":["../../../../src/dsh-adapter/channel/attached-context.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;yEACyE;AACzE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG;IACtG;;iEAE6D;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAC7B,CAAA;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,gBAAgB,EAAE,SAAS,eAAe,EAAE,CAAA;CAC7C;AAcD;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAG1E;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,EAClC,QAAQ,EAAE,SAAS,eAAe,EAAE,GACnC,MAAM,CAKR;AAKD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,MAAM,EAAE,SAAS,eAAe,EAAE,GACjC,SAAS,eAAe,EAAE,CAU5B;AAED,6EAA6E;AAC7E,MAAM,WAAW,uBAAuB;IACtC,yEAAyE;IACzE,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAA;IACzC,mEAAmE;IACnE,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,OAAO,IAAI,SAAS,eAAe,EAAE,CAAA;CACtC;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,qBAAqB,EACnC,IAAI,EAAE,MAAM,IAAI,GACf,uBAAuB,CA8CzB"}