@drscrewdriver/dsh-better-display 0.3.3-fork.1

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 (390) hide show
  1. package/CHANGELOG.md +259 -0
  2. package/DESIGN.md +72 -0
  3. package/LICENSE +24 -0
  4. package/README.en.md +55 -0
  5. package/README.md +55 -0
  6. package/THIRD_PARTY_NOTICES.md +65 -0
  7. package/compat/harness-rc2.json +99 -0
  8. package/cordis.patch.yml +5 -0
  9. package/cordis.yml +4 -0
  10. package/docs/official-rendering-bridge.md +65 -0
  11. package/dshx.yml +5 -0
  12. package/lib/client.js +49292 -0
  13. package/lib/client.js.map +1 -0
  14. package/lib/dsh-better-display.js +101 -0
  15. package/lib/types/client/Blocks.d.ts +49 -0
  16. package/lib/types/client/Blocks.d.ts.map +1 -0
  17. package/lib/types/client/Blocks.js +143 -0
  18. package/lib/types/client/Blocks.js.map +1 -0
  19. package/lib/types/client/ChoreographedFlow.d.ts +22 -0
  20. package/lib/types/client/ChoreographedFlow.d.ts.map +1 -0
  21. package/lib/types/client/ChoreographedFlow.js +218 -0
  22. package/lib/types/client/ChoreographedFlow.js.map +1 -0
  23. package/lib/types/client/ClosedProcessSummary.d.ts +9 -0
  24. package/lib/types/client/ClosedProcessSummary.d.ts.map +1 -0
  25. package/lib/types/client/ClosedProcessSummary.js +16 -0
  26. package/lib/types/client/ClosedProcessSummary.js.map +1 -0
  27. package/lib/types/client/DiffPanel.d.ts +13 -0
  28. package/lib/types/client/DiffPanel.d.ts.map +1 -0
  29. package/lib/types/client/DiffPanel.js +115 -0
  30. package/lib/types/client/DiffPanel.js.map +1 -0
  31. package/lib/types/client/LiveFold.d.ts +10 -0
  32. package/lib/types/client/LiveFold.d.ts.map +1 -0
  33. package/lib/types/client/LiveFold.js +39 -0
  34. package/lib/types/client/LiveFold.js.map +1 -0
  35. package/lib/types/client/McpAppFrame.d.ts +32 -0
  36. package/lib/types/client/McpAppFrame.d.ts.map +1 -0
  37. package/lib/types/client/McpAppFrame.js +193 -0
  38. package/lib/types/client/McpAppFrame.js.map +1 -0
  39. package/lib/types/client/OfficialContent.d.ts +25 -0
  40. package/lib/types/client/OfficialContent.d.ts.map +1 -0
  41. package/lib/types/client/OfficialContent.js +53 -0
  42. package/lib/types/client/OfficialContent.js.map +1 -0
  43. package/lib/types/client/Reader.d.ts +3 -0
  44. package/lib/types/client/Reader.d.ts.map +1 -0
  45. package/lib/types/client/Reader.js +603 -0
  46. package/lib/types/client/Reader.js.map +1 -0
  47. package/lib/types/client/ReasoningCard.d.ts +11 -0
  48. package/lib/types/client/ReasoningCard.d.ts.map +1 -0
  49. package/lib/types/client/ReasoningCard.js +322 -0
  50. package/lib/types/client/ReasoningCard.js.map +1 -0
  51. package/lib/types/client/SettingsSection.d.ts +37 -0
  52. package/lib/types/client/SettingsSection.d.ts.map +1 -0
  53. package/lib/types/client/SettingsSection.js +63 -0
  54. package/lib/types/client/SettingsSection.js.map +1 -0
  55. package/lib/types/client/StickyLane.d.ts +8 -0
  56. package/lib/types/client/StickyLane.d.ts.map +1 -0
  57. package/lib/types/client/StickyLane.js +39 -0
  58. package/lib/types/client/StickyLane.js.map +1 -0
  59. package/lib/types/client/TimelineRail.d.ts +10 -0
  60. package/lib/types/client/TimelineRail.d.ts.map +1 -0
  61. package/lib/types/client/TimelineRail.js +168 -0
  62. package/lib/types/client/TimelineRail.js.map +1 -0
  63. package/lib/types/client/ToolActivity.d.ts +17 -0
  64. package/lib/types/client/ToolActivity.d.ts.map +1 -0
  65. package/lib/types/client/ToolActivity.js +244 -0
  66. package/lib/types/client/ToolActivity.js.map +1 -0
  67. package/lib/types/client/TurnMetrics.d.ts +11 -0
  68. package/lib/types/client/TurnMetrics.d.ts.map +1 -0
  69. package/lib/types/client/TurnMetrics.js +44 -0
  70. package/lib/types/client/TurnMetrics.js.map +1 -0
  71. package/lib/types/client/WaitClock.d.ts +16 -0
  72. package/lib/types/client/WaitClock.d.ts.map +1 -0
  73. package/lib/types/client/WaitClock.js +29 -0
  74. package/lib/types/client/WaitClock.js.map +1 -0
  75. package/lib/types/client/WaitingClock.d.ts +15 -0
  76. package/lib/types/client/WaitingClock.d.ts.map +1 -0
  77. package/lib/types/client/WaitingClock.js +30 -0
  78. package/lib/types/client/WaitingClock.js.map +1 -0
  79. package/lib/types/client/WaitingStatus.d.ts +6 -0
  80. package/lib/types/client/WaitingStatus.d.ts.map +1 -0
  81. package/lib/types/client/WaitingStatus.js +9 -0
  82. package/lib/types/client/WaitingStatus.js.map +1 -0
  83. package/lib/types/client/conversation-scroll.d.ts +19 -0
  84. package/lib/types/client/conversation-scroll.d.ts.map +1 -0
  85. package/lib/types/client/conversation-scroll.js +25 -0
  86. package/lib/types/client/conversation-scroll.js.map +1 -0
  87. package/lib/types/client/deliverables.d.ts +24 -0
  88. package/lib/types/client/deliverables.d.ts.map +1 -0
  89. package/lib/types/client/deliverables.js +104 -0
  90. package/lib/types/client/deliverables.js.map +1 -0
  91. package/lib/types/client/entry-policy.d.ts +10 -0
  92. package/lib/types/client/entry-policy.d.ts.map +1 -0
  93. package/lib/types/client/entry-policy.js +24 -0
  94. package/lib/types/client/entry-policy.js.map +1 -0
  95. package/lib/types/client/entry.d.ts +4 -0
  96. package/lib/types/client/entry.d.ts.map +1 -0
  97. package/lib/types/client/entry.js +34 -0
  98. package/lib/types/client/entry.js.map +1 -0
  99. package/lib/types/client/fold-choreography.d.ts +40 -0
  100. package/lib/types/client/fold-choreography.d.ts.map +1 -0
  101. package/lib/types/client/fold-choreography.js +48 -0
  102. package/lib/types/client/fold-choreography.js.map +1 -0
  103. package/lib/types/client/fold-intensity.d.ts +11 -0
  104. package/lib/types/client/fold-intensity.d.ts.map +1 -0
  105. package/lib/types/client/fold-intensity.js +32 -0
  106. package/lib/types/client/fold-intensity.js.map +1 -0
  107. package/lib/types/client/index.d.ts +7 -0
  108. package/lib/types/client/index.d.ts.map +1 -0
  109. package/lib/types/client/index.js +195 -0
  110. package/lib/types/client/index.js.map +1 -0
  111. package/lib/types/client/live-turn.d.ts +58 -0
  112. package/lib/types/client/live-turn.d.ts.map +1 -0
  113. package/lib/types/client/live-turn.js +190 -0
  114. package/lib/types/client/live-turn.js.map +1 -0
  115. package/lib/types/client/markdown/MarkdownText.d.ts +41 -0
  116. package/lib/types/client/markdown/MarkdownText.d.ts.map +1 -0
  117. package/lib/types/client/markdown/MarkdownText.js +178 -0
  118. package/lib/types/client/markdown/MarkdownText.js.map +1 -0
  119. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts +9 -0
  120. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts.map +1 -0
  121. package/lib/types/client/markdown/cjkFriendlyStrong.js +73 -0
  122. package/lib/types/client/markdown/cjkFriendlyStrong.js.map +1 -0
  123. package/lib/types/client/markdown/incremental.d.ts +69 -0
  124. package/lib/types/client/markdown/incremental.d.ts.map +1 -0
  125. package/lib/types/client/markdown/incremental.js +108 -0
  126. package/lib/types/client/markdown/incremental.js.map +1 -0
  127. package/lib/types/client/markdown/katex.d.ts +27 -0
  128. package/lib/types/client/markdown/katex.d.ts.map +1 -0
  129. package/lib/types/client/markdown/katex.js +88 -0
  130. package/lib/types/client/markdown/katex.js.map +1 -0
  131. package/lib/types/client/markdown/mathCompatibility.d.ts +11 -0
  132. package/lib/types/client/markdown/mathCompatibility.d.ts.map +1 -0
  133. package/lib/types/client/markdown/mathCompatibility.js +293 -0
  134. package/lib/types/client/markdown/mathCompatibility.js.map +1 -0
  135. package/lib/types/client/markdown/parse.d.ts +25 -0
  136. package/lib/types/client/markdown/parse.d.ts.map +1 -0
  137. package/lib/types/client/markdown/parse.js +42 -0
  138. package/lib/types/client/markdown/parse.js.map +1 -0
  139. package/lib/types/client/markdown/render.d.ts +121 -0
  140. package/lib/types/client/markdown/render.d.ts.map +1 -0
  141. package/lib/types/client/markdown/render.js +452 -0
  142. package/lib/types/client/markdown/render.js.map +1 -0
  143. package/lib/types/client/mcp-app.d.ts +50 -0
  144. package/lib/types/client/mcp-app.d.ts.map +1 -0
  145. package/lib/types/client/mcp-app.js +328 -0
  146. package/lib/types/client/mcp-app.js.map +1 -0
  147. package/lib/types/client/message-chrome.d.ts +19 -0
  148. package/lib/types/client/message-chrome.d.ts.map +1 -0
  149. package/lib/types/client/message-chrome.js +42 -0
  150. package/lib/types/client/message-chrome.js.map +1 -0
  151. package/lib/types/client/motion.d.ts +38 -0
  152. package/lib/types/client/motion.d.ts.map +1 -0
  153. package/lib/types/client/motion.js +453 -0
  154. package/lib/types/client/motion.js.map +1 -0
  155. package/lib/types/client/native/ContextBody.d.ts +130 -0
  156. package/lib/types/client/native/ContextBody.d.ts.map +1 -0
  157. package/lib/types/client/native/ContextBody.js +398 -0
  158. package/lib/types/client/native/ContextBody.js.map +1 -0
  159. package/lib/types/client/native/ContextInjectionRow.d.ts +35 -0
  160. package/lib/types/client/native/ContextInjectionRow.d.ts.map +1 -0
  161. package/lib/types/client/native/ContextInjectionRow.js +42 -0
  162. package/lib/types/client/native/ContextInjectionRow.js.map +1 -0
  163. package/lib/types/client/native/ReferenceIcon.d.ts +16 -0
  164. package/lib/types/client/native/ReferenceIcon.d.ts.map +1 -0
  165. package/lib/types/client/native/ReferenceIcon.js +16 -0
  166. package/lib/types/client/native/ReferenceIcon.js.map +1 -0
  167. package/lib/types/client/native/tool-call-model.d.ts +58 -0
  168. package/lib/types/client/native/tool-call-model.d.ts.map +1 -0
  169. package/lib/types/client/native/tool-call-model.js +219 -0
  170. package/lib/types/client/native/tool-call-model.js.map +1 -0
  171. package/lib/types/client/native/tool-update.d.ts +23 -0
  172. package/lib/types/client/native/tool-update.d.ts.map +1 -0
  173. package/lib/types/client/native/tool-update.js +22 -0
  174. package/lib/types/client/native/tool-update.js.map +1 -0
  175. package/lib/types/client/official-slots.d.ts +71 -0
  176. package/lib/types/client/official-slots.d.ts.map +1 -0
  177. package/lib/types/client/official-slots.js +183 -0
  178. package/lib/types/client/official-slots.js.map +1 -0
  179. package/lib/types/client/open-file.d.ts +29 -0
  180. package/lib/types/client/open-file.d.ts.map +1 -0
  181. package/lib/types/client/open-file.js +71 -0
  182. package/lib/types/client/open-file.js.map +1 -0
  183. package/lib/types/client/pending-submission.d.ts +28 -0
  184. package/lib/types/client/pending-submission.d.ts.map +1 -0
  185. package/lib/types/client/pending-submission.js +28 -0
  186. package/lib/types/client/pending-submission.js.map +1 -0
  187. package/lib/types/client/platform-media.d.ts +6 -0
  188. package/lib/types/client/platform-media.d.ts.map +1 -0
  189. package/lib/types/client/platform-media.js +18 -0
  190. package/lib/types/client/platform-media.js.map +1 -0
  191. package/lib/types/client/primitive-labels.d.ts +10 -0
  192. package/lib/types/client/primitive-labels.d.ts.map +1 -0
  193. package/lib/types/client/primitive-labels.js +38 -0
  194. package/lib/types/client/primitive-labels.js.map +1 -0
  195. package/lib/types/client/projection.d.ts +41 -0
  196. package/lib/types/client/projection.d.ts.map +1 -0
  197. package/lib/types/client/projection.js +112 -0
  198. package/lib/types/client/projection.js.map +1 -0
  199. package/lib/types/client/reasoning-follow.d.ts +10 -0
  200. package/lib/types/client/reasoning-follow.d.ts.map +1 -0
  201. package/lib/types/client/reasoning-follow.js +21 -0
  202. package/lib/types/client/reasoning-follow.js.map +1 -0
  203. package/lib/types/client/resource-address.d.ts +3 -0
  204. package/lib/types/client/resource-address.d.ts.map +1 -0
  205. package/lib/types/client/resource-address.js +33 -0
  206. package/lib/types/client/resource-address.js.map +1 -0
  207. package/lib/types/client/settings-copy.d.ts +7 -0
  208. package/lib/types/client/settings-copy.d.ts.map +1 -0
  209. package/lib/types/client/settings-copy.js +53 -0
  210. package/lib/types/client/settings-copy.js.map +1 -0
  211. package/lib/types/client/settings-slots.d.ts +23 -0
  212. package/lib/types/client/settings-slots.d.ts.map +1 -0
  213. package/lib/types/client/settings-slots.js +2 -0
  214. package/lib/types/client/settings-slots.js.map +1 -0
  215. package/lib/types/client/settings.d.ts +4 -0
  216. package/lib/types/client/settings.d.ts.map +1 -0
  217. package/lib/types/client/settings.js +60 -0
  218. package/lib/types/client/settings.js.map +1 -0
  219. package/lib/types/client/skill-status.d.ts +25 -0
  220. package/lib/types/client/skill-status.d.ts.map +1 -0
  221. package/lib/types/client/skill-status.js +44 -0
  222. package/lib/types/client/skill-status.js.map +1 -0
  223. package/lib/types/client/store.d.ts +35 -0
  224. package/lib/types/client/store.d.ts.map +1 -0
  225. package/lib/types/client/store.js +37 -0
  226. package/lib/types/client/store.js.map +1 -0
  227. package/lib/types/client/stream-buffer.d.ts +37 -0
  228. package/lib/types/client/stream-buffer.d.ts.map +1 -0
  229. package/lib/types/client/stream-buffer.js +150 -0
  230. package/lib/types/client/stream-buffer.js.map +1 -0
  231. package/lib/types/client/streaming.d.ts +18 -0
  232. package/lib/types/client/streaming.d.ts.map +1 -0
  233. package/lib/types/client/streaming.js +84 -0
  234. package/lib/types/client/streaming.js.map +1 -0
  235. package/lib/types/client/timeline.d.ts +26 -0
  236. package/lib/types/client/timeline.d.ts.map +1 -0
  237. package/lib/types/client/timeline.js +48 -0
  238. package/lib/types/client/timeline.js.map +1 -0
  239. package/lib/types/client/tool-activity.d.ts +98 -0
  240. package/lib/types/client/tool-activity.d.ts.map +1 -0
  241. package/lib/types/client/tool-activity.js +301 -0
  242. package/lib/types/client/tool-activity.js.map +1 -0
  243. package/lib/types/client/types.d.ts +91 -0
  244. package/lib/types/client/types.d.ts.map +1 -0
  245. package/lib/types/client/types.js +2 -0
  246. package/lib/types/client/types.js.map +1 -0
  247. package/lib/types/client/waiting-clock.d.ts +49 -0
  248. package/lib/types/client/waiting-clock.d.ts.map +1 -0
  249. package/lib/types/client/waiting-clock.js +80 -0
  250. package/lib/types/client/waiting-clock.js.map +1 -0
  251. package/lib/types/client/word-motion.d.ts +16 -0
  252. package/lib/types/client/word-motion.d.ts.map +1 -0
  253. package/lib/types/client/word-motion.js +90 -0
  254. package/lib/types/client/word-motion.js.map +1 -0
  255. package/lib/types/client/word-timeline.d.ts +32 -0
  256. package/lib/types/client/word-timeline.d.ts.map +1 -0
  257. package/lib/types/client/word-timeline.js +119 -0
  258. package/lib/types/client/word-timeline.js.map +1 -0
  259. package/lib/types/dsh-better-display.d.ts +17 -0
  260. package/lib/types/dsh-better-display.d.ts.map +1 -0
  261. package/lib/types/dsh-better-display.js +93 -0
  262. package/lib/types/dsh-better-display.js.map +1 -0
  263. package/lib/types/skill-roots.d.ts +22 -0
  264. package/lib/types/skill-roots.d.ts.map +1 -0
  265. package/lib/types/skill-roots.js +126 -0
  266. package/lib/types/skill-roots.js.map +1 -0
  267. package/lib/types/skill-status.d.ts +36 -0
  268. package/lib/types/skill-status.d.ts.map +1 -0
  269. package/lib/types/skill-status.js +51 -0
  270. package/lib/types/skill-status.js.map +1 -0
  271. package/package.json +133 -0
  272. package/scripts/build-motion-fixture.mjs +26 -0
  273. package/scripts/check-harness-compat.mjs +71 -0
  274. package/scripts/link-harness-dependencies.mjs +54 -0
  275. package/scripts/verify-auto-fold.mjs +114 -0
  276. package/scripts/verify-official-bridge.mjs +121 -0
  277. package/scripts/verify-tool-shimmer.mjs +62 -0
  278. package/skills/generative-mcpapps/SKILL.md +47 -0
  279. package/skills/generative-mcpapps/examples/interactive_quiz.html +153 -0
  280. package/skills/generative-mcpapps/references/html_boilerplate.md +122 -0
  281. package/skills/generative-mcpapps/references/sep1865_protocol.md +54 -0
  282. package/src/client/Blocks.tsx +213 -0
  283. package/src/client/ChoreographedFlow.tsx +232 -0
  284. package/src/client/ClosedProcessSummary.tsx +23 -0
  285. package/src/client/DiffPanel.tsx +124 -0
  286. package/src/client/LiveFold.tsx +43 -0
  287. package/src/client/McpAppFrame.module.css +210 -0
  288. package/src/client/McpAppFrame.tsx +317 -0
  289. package/src/client/OfficialContent.tsx +69 -0
  290. package/src/client/Reader.module.css +692 -0
  291. package/src/client/Reader.tsx +878 -0
  292. package/src/client/ReasoningCard.tsx +306 -0
  293. package/src/client/SettingsSection.module.css +184 -0
  294. package/src/client/SettingsSection.tsx +194 -0
  295. package/src/client/StickyLane.tsx +34 -0
  296. package/src/client/TimelineRail.module.css +170 -0
  297. package/src/client/TimelineRail.tsx +262 -0
  298. package/src/client/ToolActivity.tsx +274 -0
  299. package/src/client/TurnMetrics.module.css +139 -0
  300. package/src/client/TurnMetrics.tsx +160 -0
  301. package/src/client/WaitClock.tsx +33 -0
  302. package/src/client/WaitingStatus.tsx +13 -0
  303. package/src/client/conversation-scroll.ts +28 -0
  304. package/src/client/deliverables.ts +122 -0
  305. package/src/client/entry-policy.ts +20 -0
  306. package/src/client/entry.tsx +40 -0
  307. package/src/client/fold-choreography.ts +55 -0
  308. package/src/client/fold-intensity.ts +36 -0
  309. package/src/client/index.tsx +222 -0
  310. package/src/client/live-turn.ts +198 -0
  311. package/src/client/markdown/MarkdownText.module.css +304 -0
  312. package/src/client/markdown/MarkdownText.tsx +195 -0
  313. package/src/client/markdown/cjkFriendlyStrong.ts +84 -0
  314. package/src/client/markdown/incremental.ts +131 -0
  315. package/src/client/markdown/katex.tsx +91 -0
  316. package/src/client/markdown/mathCompatibility.ts +350 -0
  317. package/src/client/markdown/parse.ts +45 -0
  318. package/src/client/markdown/render.tsx +647 -0
  319. package/src/client/markdown/upstream.json +14 -0
  320. package/src/client/mcp-app.ts +323 -0
  321. package/src/client/message-chrome.ts +47 -0
  322. package/src/client/motion.tsx +410 -0
  323. package/src/client/native/ContextBody.module.css +161 -0
  324. package/src/client/native/ContextBody.tsx +591 -0
  325. package/src/client/native/ContextInjectionRow.module.css +66 -0
  326. package/src/client/native/ContextInjectionRow.tsx +106 -0
  327. package/src/client/native/ReferenceIcon.tsx +35 -0
  328. package/src/client/native/tool-call-model.ts +248 -0
  329. package/src/client/native/tool-update.ts +32 -0
  330. package/src/client/native/upstream.json +41 -0
  331. package/src/client/official-slots.tsx +211 -0
  332. package/src/client/open-file.ts +94 -0
  333. package/src/client/pending-submission.ts +49 -0
  334. package/src/client/platform-media.ts +17 -0
  335. package/src/client/primitive-labels.ts +54 -0
  336. package/src/client/projection.ts +118 -0
  337. package/src/client/reasoning-follow.ts +28 -0
  338. package/src/client/settings-copy.ts +80 -0
  339. package/src/client/settings-slots.ts +20 -0
  340. package/src/client/settings.tsx +73 -0
  341. package/src/client/skill-status.ts +78 -0
  342. package/src/client/store.ts +75 -0
  343. package/src/client/stream-buffer.ts +136 -0
  344. package/src/client/streaming.tsx +70 -0
  345. package/src/client/style.d.ts +4 -0
  346. package/src/client/timeline.ts +77 -0
  347. package/src/client/tool-activity.ts +298 -0
  348. package/src/client/types.ts +89 -0
  349. package/src/client/waiting-clock.ts +83 -0
  350. package/src/client/word-motion.tsx +92 -0
  351. package/src/client/word-timeline.ts +113 -0
  352. package/src/dsh-better-display.ts +108 -0
  353. package/src/skill-roots.ts +138 -0
  354. package/src/skill-status.ts +81 -0
  355. package/tests/browser-auto-fold.tsx +64 -0
  356. package/tests/browser-closed-gap.tsx +20 -0
  357. package/tests/browser-motion.tsx +65 -0
  358. package/tests/browser-official-bridge.tsx +152 -0
  359. package/tests/browser-sticky-lanes.tsx +22 -0
  360. package/tests/browser-waiting-clock.tsx +14 -0
  361. package/tests/chat-flow-hook.test.ts +66 -0
  362. package/tests/cloud-gate.test.ts +34 -0
  363. package/tests/context-tool-update.test.ts +33 -0
  364. package/tests/conversation-scroll.test.ts +47 -0
  365. package/tests/deliverables.test.ts +128 -0
  366. package/tests/entry.test.ts +42 -0
  367. package/tests/fixtures/maid-composer-hide.html +31 -0
  368. package/tests/fold-choreography.test.ts +54 -0
  369. package/tests/fold-intensity.test.ts +94 -0
  370. package/tests/footer-precedence.test.ts +129 -0
  371. package/tests/history-word-regression.test.ts +16 -0
  372. package/tests/live-turn.test.ts +218 -0
  373. package/tests/mcp-apps.test.ts +157 -0
  374. package/tests/message-chrome.test.ts +29 -0
  375. package/tests/official-slots.test.ts +112 -0
  376. package/tests/open-file.test.ts +114 -0
  377. package/tests/pending-submission.test.ts +45 -0
  378. package/tests/platform-media.test.ts +23 -0
  379. package/tests/projection.test.ts +184 -0
  380. package/tests/reasoning-follow.test.ts +34 -0
  381. package/tests/settings-copy.test.ts +63 -0
  382. package/tests/skill-status.test.ts +137 -0
  383. package/tests/stock-install.test.ts +58 -0
  384. package/tests/stream-buffer.test.ts +102 -0
  385. package/tests/timeline.test.ts +59 -0
  386. package/tests/tool-diff.test.ts +57 -0
  387. package/tests/waiting-clock.test.ts +83 -0
  388. package/tests/word-timeline.test.ts +146 -0
  389. package/tsconfig.json +11 -0
  390. package/tsdown.config.ts +51 -0
@@ -0,0 +1,603 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { Fragment, memo, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
3
+ import { JsonBlock, MarkdownText } from '@deepseek-ai/dsh-client-ui-primitives';
4
+ import { BlockBoundary, Blocks, contentBlocks, CopyAnswer, UserMessageActions } from './Blocks.js';
5
+ import { ReasoningCard } from './ReasoningCard.js';
6
+ import { ToolActivity, ToolMedia } from './ToolActivity.js';
7
+ import { OfficialActions, OfficialNode, OfficialTail } from './OfficialContent.js';
8
+ import { preparingLabel, readerFlow } from './tool-activity.js';
9
+ import { Disclosure, ProcessFragment, RetiringContent, StatusText, useMotionAllowed, usePinnedSelection, useReadingScroll } from './motion.js';
10
+ import { StreamMotionContext } from './streaming.js';
11
+ import { assistantSegments, boundaryOf, forkAnchorSeq, groupNodes, hasProcessContent, hasVisibleBody, isEarlierNarration, processChoiceKey, processExpanded, terminalLabel } from './projection.js';
12
+ import { basename, createProducedFileMentions, dirname, getTurnDeliverables, showDeliverablesRow } from './deliverables.js';
13
+ import { deliverableOpenModeOf } from './open-file.js';
14
+ import { asReadonlyArray, pendingSubmissionImages } from './pending-submission.js';
15
+ import { WaitingStatus } from './WaitingStatus.js';
16
+ import { handsBackToModel, waitingAnchor } from './waiting-clock.js';
17
+ import { ContextInjectionRow } from './native/ContextInjectionRow.js';
18
+ import { TimelineRail } from './TimelineRail.js';
19
+ import { landTurn, scrollerOf } from './conversation-scroll.js';
20
+ import { mergeTimelineItems } from './timeline.js';
21
+ import { presentLiveTurn, segmentLiveTurn } from './live-turn.js';
22
+ import { bubblesOf, frostedGlassOf } from './fold-intensity.js';
23
+ import { ChoreographedFlow, useFlowChat } from './ChoreographedFlow.js';
24
+ import { ClosedProcessSummary } from './ClosedProcessSummary.js';
25
+ import { StickyLane } from './StickyLane.js';
26
+ import css from './Reader.module.css';
27
+ import { markdownLabels, truncatedJsonLabel } from './primitive-labels.js';
28
+ function isNode(node, kind) {
29
+ return node.kind === kind;
30
+ }
31
+ function cleanErrorMessage(raw) {
32
+ if (!raw)
33
+ return '模型服务暂时无响应或连接中断,请稍后重试。';
34
+ let str = raw.trim();
35
+ if (str.includes('"error"') || str.startsWith('{')) {
36
+ try {
37
+ const idx = str.indexOf('{');
38
+ const parsed = JSON.parse(str.slice(idx));
39
+ const msg = parsed?.error?.message || parsed?.message || parsed?.error;
40
+ if (typeof msg === 'string')
41
+ str = msg;
42
+ }
43
+ catch {
44
+ // keep
45
+ }
46
+ }
47
+ return str;
48
+ }
49
+ const CompactionDivider = memo(function CompactionDivider({ data }) {
50
+ const [open, setOpen] = useState(false);
51
+ if (!data)
52
+ return null;
53
+ const hasSummary = typeof data.summary === 'string' && data.summary.trim().length > 0;
54
+ const items = data.shadowedItemCount;
55
+ const tokens = data.shadowedTokenCount;
56
+ let label = '已压缩历史上下文';
57
+ if (items && tokens) {
58
+ const kTokens = tokens >= 1000 ? `${(tokens / 1000).toFixed(1)}k` : String(tokens);
59
+ label = `已压缩 ${items} 条上下文 · 释放约 ${kTokens} tokens`;
60
+ }
61
+ else if (items) {
62
+ label = `已压缩 ${items} 条上下文`;
63
+ }
64
+ else if (tokens) {
65
+ const kTokens = tokens >= 1000 ? `${(tokens / 1000).toFixed(1)}k` : String(tokens);
66
+ label = `已压缩上下文 · 释放约 ${kTokens} tokens`;
67
+ }
68
+ return (_jsxs("div", { className: css.compactionRow, "data-reader-compaction": true, children: [_jsx("div", { className: css.compactionLine, children: hasSummary ? (_jsxs("button", { type: "button", className: `${css.compactionPill} ${css.compactionButton}`, onClick: () => setOpen(v => !v), "aria-expanded": open, title: open ? '收起历史记忆摘要' : '展开查看此节点提炼的记忆摘要', children: [_jsxs("svg", { className: css.compactionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("path", { d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2z", strokeWidth: "1.2" }), _jsx("path", { d: "M8 5v3.2l2 1.8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })] }), _jsx("span", { children: label }), _jsx("span", { className: css.compactionToggle, children: open ? '收起备忘' : '查看备忘' })] })) : (_jsxs("span", { className: css.compactionPill, children: [_jsxs("svg", { className: css.compactionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("path", { d: "M8 2a6 6 0 1 0 0 12A6 6 0 0 0 8 2z", strokeWidth: "1.2" }), _jsx("path", { d: "M8 5v3.2l2 1.8", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })] }), _jsx("span", { children: label })] })) }), open && hasSummary && (_jsxs("div", { className: css.compactionSummaryBox, "data-reader-anchor": true, children: [_jsx("div", { className: css.compactionSummaryHeader, children: "\u524D\u671F\u5BF9\u8BDD\u8981\u70B9\u5907\u5FD8" }), _jsx(MarkdownText, { text: data.summary, labels: markdownLabels })] }))] }));
69
+ });
70
+ const ProcessNode = memo(function ProcessNode({ useChat, t, nodeKey, open, motion, onRead, returnFocusTo }) {
71
+ const node = useChat(snapshot => snapshot.nodes.get(nodeKey));
72
+ if (!node || node.visibility === 'hidden')
73
+ return null;
74
+ let content = null;
75
+ if (isNode(node, 'context'))
76
+ content = _jsx(ContextInjectionRow, { ...node.data, t: t });
77
+ else if (isNode(node, 'system-prompt'))
78
+ content = _jsxs("details", { className: css.detail, children: [_jsx("summary", { children: "\u7CFB\u7EDF\u63D0\u793A\u8BCD" }), _jsx("pre", { className: css.systemPrompt, children: node.data.text })] });
79
+ else if (isNode(node, 'model-retry'))
80
+ content = _jsx(JsonBlock, { label: "\u6A21\u578B\u91CD\u8BD5\u8BB0\u5F55", payload: node.data.attempts, truncatedLabel: truncatedJsonLabel });
81
+ else if (isNode(node, 'manual-compaction')) {
82
+ if (node.data.command.outcome?.kind === 'error') {
83
+ content = _jsxs("div", { className: css.error, role: "alert", children: [_jsxs("svg", { className: css.errorIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.5", strokeWidth: "1.2" }), _jsx("path", { d: "M8 5v3.5M8 11.2h.01", strokeWidth: "1.5", strokeLinecap: "round" })] }), _jsxs("div", { className: css.errorCopy, children: [_jsx("div", { className: css.errorTitle, children: _jsx("strong", { children: "\u4E0A\u4E0B\u6587\u538B\u7F29\u672A\u6210\u529F" }) }), _jsx("p", { className: css.errorMessage, children: node.data.command.outcome.text })] })] });
84
+ }
85
+ else {
86
+ content = node.data.compaction ? _jsx(CompactionDivider, { data: node.data.compaction }) : null;
87
+ }
88
+ }
89
+ else if (isNode(node, 'compaction'))
90
+ content = _jsx(CompactionDivider, { data: node.data });
91
+ else if (isNode(node, 'command'))
92
+ content = _jsx(JsonBlock, { label: "\u547D\u4EE4\u8BB0\u5F55", payload: node.data, truncatedLabel: truncatedJsonLabel });
93
+ return content && _jsx(ProcessFragment, { open: open, motion: motion, onRead: onRead, returnFocusTo: returnFocusTo, nodeKey: nodeKey, framed: true, children: content });
94
+ });
95
+ const AssistantNode = memo(function AssistantNode({ useChat, nodeKey, boundary, processOpen = false, pinned = false, folded = false, partStart, motion, onRead, returnFocusTo, ...render }) {
96
+ const node = useChat(snapshot => snapshot.nodes.get(nodeKey));
97
+ if (!node || node.visibility === 'hidden' || !isNode(node, 'assistant-step'))
98
+ return null;
99
+ const data = node.data;
100
+ const parts = assistantSegments(data.blocks);
101
+ const earlier = isEarlierNarration(data, boundary);
102
+ const hasToolCalls = data.blocks.some(block => block.kind === 'tool-call');
103
+ const isProcessStep = earlier || folded || hasToolCalls || (boundary.latestStep > 0 && data.step < boundary.latestStep);
104
+ const body = data.blocks.filter(block => block.kind !== 'reasoning' && block.kind !== 'tool-call');
105
+ const visible = partStart === undefined ? parts : parts.filter(part => part.start === partStart);
106
+ return _jsx(_Fragment, { children: visible.map(part => {
107
+ const index = parts.findIndex(item => item.start === part.start);
108
+ const last = index === parts.length - 1;
109
+ return part.kind === 'reasoning'
110
+ ? _jsx(ProcessFragment, { open: processOpen, motion: motion, onRead: onRead, returnFocusTo: returnFocusTo, nodeKey: nodeKey, framed: true, children: _jsx(ReasoningCard, { step: data.step, active: processOpen && boundary.status === 'open' && data.step === boundary.latestStep, motion: motion, selected: pinned, onRead: onRead, children: _jsx(Blocks, { ...render, blocks: part.blocks, streaming: data.status === 'running' && last && data.blocks.at(-1)?.kind === 'reasoning', holdFormatting: pinned, startedAt: data.time, interrupted: data.status === 'interrupted', liveText: true }) }) }, part.start)
111
+ : isProcessStep ? _jsx(ProcessFragment, { open: processOpen, motion: motion, onRead: onRead, returnFocusTo: returnFocusTo, nodeKey: nodeKey, children: _jsx("article", { className: css.processCommentary, children: _jsx(Blocks, { ...render, blocks: part.blocks, streaming: data.status === 'running', holdFormatting: pinned, startedAt: data.time, interrupted: data.status === 'interrupted', liveText: true }) }) }, part.start)
112
+ : hasVisibleBody(part.blocks) && _jsx(RetiringContent, { visible: pinned || processOpen || (!earlier && !folded), children: _jsxs("article", { className: css.answer, "data-reader-answer": true, "data-reader-anchor": true, "data-reader-key": nodeKey, "data-reader-source-start": part.start, "data-answer-status": data.status, "data-answer-phase": earlier || folded ? 'process' : 'body', children: [_jsx(Blocks, { ...render, blocks: part.blocks, streaming: data.status === 'running', holdFormatting: pinned, startedAt: data.time, interrupted: data.status === 'interrupted', liveText: true }), last && data.status === 'interrupted' && _jsx("span", { className: css.stopped, children: "\u5DF2\u505C\u6B62" }), last && !earlier && !folded && data.status !== 'running' && boundary.status === 'closed' && (_jsx(CopyAnswer, { blocks: body, onFork: (() => {
113
+ // The fork anchor must be the durable closing message seq (same as
114
+ // the official turn-tail branch). AssistantChatData carries no seq
115
+ // of its own; passing it would fork the whole session instead.
116
+ const anchor = forkAnchorSeq([data.finalNode, { seq: render.forkSeq }]);
117
+ return render.forkAt && anchor !== undefined ? () => render.forkAt(anchor) : undefined;
118
+ })(), metrics: render.metrics, extraActions: _jsx(OfficialActions, { official: render.official, messageId: data.finalNode?.messageId }) }))] }) }, part.start);
119
+ }) });
120
+ });
121
+ const MainNode = memo(function MainNode({ useChat, nodeKey, boundary, pinned, processOpen = false, ...render }) {
122
+ const node = useChat(snapshot => snapshot.nodes.get(nodeKey));
123
+ if (!node || node.visibility === 'hidden')
124
+ return null;
125
+ if (isNode(node, 'user') || isNode(node, 'steering')) {
126
+ const blocks = contentBlocks(node.data.content);
127
+ const imageBlocks = blocks.filter(b => b.kind === 'image');
128
+ const otherBlocks = blocks.filter(b => b.kind !== 'image');
129
+ const text = otherBlocks.filter((block) => block.kind === 'text').map(block => block.text).join('\n\n');
130
+ const time = node.data.time;
131
+ return _jsxs("div", { className: css.userCluster, "data-reader-anchor": true, "data-reader-key": nodeKey, children: [node.kind === 'steering' && _jsx("p", { className: css.meta, children: "\u8865\u5145\u6D88\u606F" }), imageBlocks.length > 0 && _jsx("div", { className: css.userImages, children: _jsx(Blocks, { ...render, blocks: imageBlocks, source: "user" }) }), otherBlocks.length > 0 && _jsx("div", { className: css.user, children: _jsx(Blocks, { ...render, blocks: otherBlocks, source: "user" }) }), _jsx(UserMessageActions, { text: text, time: time })] });
132
+ }
133
+ if (isNode(node, 'assistant-step'))
134
+ return null;
135
+ if (isNode(node, 'tool-call'))
136
+ return _jsx(ToolMedia, { ...render, block: node.data.root });
137
+ if (isNode(node, 'turn-error'))
138
+ return _jsxs("div", { className: css.error, role: "alert", "data-reader-anchor": true, children: [_jsxs("svg", { className: css.errorIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.5", strokeWidth: "1.2" }), _jsx("path", { d: "M8 5v3.5M8 11.2h.01", strokeWidth: "1.5", strokeLinecap: "round" })] }), _jsxs("div", { className: css.errorCopy, children: [_jsxs("div", { className: css.errorTitle, children: [_jsx("strong", { children: "\u672C\u8F6E\u8FD0\u884C\u5931\u8D25" }), node.data.code && _jsx("code", { className: css.errorCode, children: node.data.code })] }), _jsx("p", { className: css.errorMessage, children: cleanErrorMessage(node.data.message) })] })] });
139
+ if (isNode(node, 'turn-max-tokens'))
140
+ return _jsx("div", { className: css.notice, children: "\u5DF2\u5230\u8FBE\u8F93\u51FA\u957F\u5EA6\u9650\u5236\uFF0C\u56DE\u7B54\u5C1A\u672A\u5B8C\u6574\u3002" });
141
+ if (isNode(node, 'model-retry'))
142
+ return node.data.current.retryState === 'scheduled'
143
+ ? _jsx("div", { className: css.notice, role: "status", children: "\u6A21\u578B\u8BF7\u6C42\u672A\u6210\u529F\uFF0C\u6B63\u5728\u7B49\u5F85\u91CD\u8BD5\u3002\u8BE6\u60C5\u4FDD\u7559\u5728\u6267\u884C\u8FC7\u7A0B\u4E2D\u3002" }) : null;
144
+ if (isNode(node, 'command') && render.official)
145
+ return _jsx(OfficialNode, { ...render, node: node, fallback: _jsx(JsonBlock, { label: "\u547D\u4EE4\u8BB0\u5F55", payload: node.data, truncatedLabel: truncatedJsonLabel }) });
146
+ if (isNode(node, 'command')) {
147
+ if (node.data.outcome?.kind === 'error')
148
+ return _jsxs("div", { className: css.error, role: "alert", children: [_jsxs("svg", { className: css.errorIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("circle", { cx: "8", cy: "8", r: "6.5", strokeWidth: "1.2" }), _jsx("path", { d: "M8 5v3.5M8 11.2h.01", strokeWidth: "1.5", strokeLinecap: "round" })] }), _jsxs("div", { className: css.errorCopy, children: [_jsx("div", { className: css.errorTitle, children: _jsx("strong", { children: "\u547D\u4EE4\u6267\u884C\u672A\u6210\u529F" }) }), _jsx("p", { className: css.errorMessage, children: node.data.outcome.text ?? node.data.name ?? '查看原对话中的命令记录' })] })] });
149
+ return node.data.outcome?.text ? _jsx(MarkdownText, { text: node.data.outcome.text, labels: markdownLabels }) : null;
150
+ }
151
+ if (isNode(node, 'manual-compaction') || isNode(node, 'compaction'))
152
+ return null;
153
+ if (node.kind === 'context' || node.kind === 'turn-tail' || node.kind === 'system-prompt' || node.kind === 'turn-process')
154
+ return null;
155
+ // No 'command-input' branch: that string is not a chat node kind in any released
156
+ // host (it appears nowhere in the installed packages), so a slash command arrives
157
+ // as 'command' above and is rendered there. Keeping the branch only made the file
158
+ // look like it handled a case that cannot occur.
159
+ return _jsx(OfficialNode, { ...render, node: node, fallback: _jsxs("div", { className: css.unknown, "data-reader-anchor": true, children: [_jsxs("p", { children: ["\u6B64\u8BB0\u5F55\u7C7B\u578B\u6682\u672A\u63A5\u5165\u9605\u8BFB\u9875\uFF1A", node.kind] }), render.official && _jsx("button", { type: "button", className: css.textButton, onClick: () => render.official.openView('chat', node.key), children: "\u5728\u5BF9\u8BDD\u4E2D\u67E5\u770B" }), _jsx(JsonBlock, { label: "\u67E5\u770B\u539F\u59CB\u8BB0\u5F55", payload: node.data, truncatedLabel: truncatedJsonLabel })] }) });
160
+ });
161
+ /**
162
+ * Sub-agents this turn dispatched, read from the host's own Turn-process row.
163
+ *
164
+ * The host already derives this from the dispatch tree (`subagentCount` on
165
+ * `TurnProcessChatData`), so counting calls here would only risk disagreeing with
166
+ * it. The row is otherwise hidden by the reader, which is why this is the one place
167
+ * its counters are read.
168
+ */
169
+ function subagentCount(snapshot, keys) {
170
+ for (const key of keys) {
171
+ const node = snapshot.nodes.get(key);
172
+ if (!node || node.kind !== 'turn-process')
173
+ continue;
174
+ const value = node.data.subagentCount;
175
+ if (typeof value === 'number' && Number.isFinite(value) && value > 0)
176
+ return value;
177
+ }
178
+ return 0;
179
+ }
180
+ function GroupStatus({ group, sessionId, useChat, pending, motion }) {
181
+ const text = useChat(snapshot => {
182
+ const turn = group.turn === null ? undefined : snapshot.timeline.turns.get(group.turn);
183
+ if (turn?.status === 'closed') {
184
+ if (turn.end?.data.reason.kind !== 'completed')
185
+ return '执行过程';
186
+ const elapsed = turn.start && turn.end ? Math.max(0, Math.round((turn.end.time - turn.start.time) / 1000)) : null;
187
+ return elapsed === null ? '执行过程' : elapsed < 60 ? `用时 ${elapsed} 秒` : `用时 ${Math.floor(elapsed / 60)} 分 ${elapsed % 60} 秒`;
188
+ }
189
+ if (turn?.status !== 'open')
190
+ return '执行过程';
191
+ if (pending !== undefined)
192
+ return '等待你的操作';
193
+ const current = turn.steps.at(-1)?.data.get('assistant-step');
194
+ const last = current?.blocks.at(-1);
195
+ if (current?.status === 'running' && last?.kind === 'tool-call') {
196
+ const spawned = subagentCount(snapshot, group.keys);
197
+ return spawned ? `${preparingLabel(last.name)}·${spawned} 个子代理` : preparingLabel(last.name);
198
+ }
199
+ for (let index = group.keys.length - 1; index >= 0; index--) {
200
+ const node = snapshot.nodes.get(group.keys[index]);
201
+ if (!node)
202
+ continue;
203
+ if (isNode(node, 'tool-call') && !('kind' in node.data.root))
204
+ return '正在使用工具';
205
+ if (isNode(node, 'assistant-step') && node.data.status === 'running') {
206
+ const last = node.data.blocks.at(-1);
207
+ return last?.kind === 'reasoning' ? '正在思考' : last?.kind === 'text' ? '正在输出' : '正在准备回复';
208
+ }
209
+ }
210
+ return '正在处理';
211
+ });
212
+ const busy = useChat(snapshot => group.turn !== null && snapshot.timeline.turns.get(group.turn)?.status === 'open' && pending === undefined);
213
+ return _jsx(StatusText, { text: text, motion: motion, shimmer: busy });
214
+ }
215
+ const DeliverableChip = memo(function DeliverableChip({ path, openFile, revealFile, openMode }) {
216
+ const [status, setStatus] = useState('idle');
217
+ const timer = useRef();
218
+ const flash = (next) => {
219
+ setStatus(next);
220
+ clearTimeout(timer.current);
221
+ timer.current = setTimeout(() => setStatus('idle'), 1600);
222
+ };
223
+ const onOpen = (event) => {
224
+ event.stopPropagation();
225
+ try {
226
+ openFile?.(path);
227
+ flash('opened');
228
+ }
229
+ catch {
230
+ // fallback
231
+ }
232
+ };
233
+ const onReveal = (event) => {
234
+ event.stopPropagation();
235
+ try {
236
+ if (revealFile) {
237
+ revealFile(path);
238
+ }
239
+ else {
240
+ openFile?.(dirname(path));
241
+ }
242
+ flash('revealed');
243
+ }
244
+ catch {
245
+ // fallback
246
+ }
247
+ };
248
+ const onCopy = (event) => {
249
+ event.stopPropagation();
250
+ try {
251
+ void navigator.clipboard?.writeText(path);
252
+ flash('copied');
253
+ }
254
+ catch {
255
+ // fallback
256
+ }
257
+ };
258
+ const name = basename(path);
259
+ const folder = dirname(path);
260
+ return (_jsxs("div", { className: css.deliverableChip, "data-status": status, title: path, children: [_jsxs("button", { type: "button", className: css.chipMain, onClick: onOpen, onDoubleClick: onOpen, "aria-label": openMode === 'sidebar' ? `在内置面板中打开 ${path}` : `用系统应用打开 ${path}`, children: [status === 'opened' ? (_jsx("svg", { className: css.statusIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M3.5 8.5l3 3 6-7", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (_jsxs("svg", { className: css.deliverableIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("path", { d: "M4 2.5h5l3 3V13.5H4V2.5z", strokeWidth: "1.2", strokeLinejoin: "round" }), _jsx("path", { d: "M9 2.5v3h3", strokeWidth: "1.2", strokeLinejoin: "round" })] })), _jsx("span", { className: css.deliverableName, children: status === 'opened' ? (openMode === 'sidebar' ? '已在面板打开' : '已在外部打开') : name })] }), _jsxs("div", { className: css.chipActions, "aria-label": "\u6587\u4EF6\u64CD\u4F5C", children: [_jsx("button", { type: "button", className: css.chipActionBtn, title: `在访达中定位所在目录 (${folder})`, "aria-label": "\u5728\u8BBF\u8FBE\u4E2D\u663E\u793A\u6240\u5728\u76EE\u5F55", onClick: onReveal, children: status === 'revealed' ? (_jsx("svg", { className: css.actionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M3.5 8.5l3 3 6-7", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (_jsx("svg", { className: css.actionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M2 4.5h4l1.5 2H14v6.5H2V4.5z", strokeWidth: "1.2", strokeLinejoin: "round" }) })) }), _jsx("button", { type: "button", className: css.chipActionBtn, title: "\u590D\u5236\u76F8\u5BF9\u8DEF\u5F84", "aria-label": "\u590D\u5236\u76F8\u5BF9\u8DEF\u5F84", onClick: onCopy, children: status === 'copied' ? (_jsx("svg", { className: css.actionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M3.5 8.5l3 3 6-7", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (_jsxs("svg", { className: css.actionIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: [_jsx("rect", { x: "5.5", y: "5.5", width: "8", height: "8", rx: "1.5", strokeWidth: "1.2" }), _jsx("path", { d: "M4 10.5H3a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h6a1 1 0 0 1 1 1v1", strokeWidth: "1.2", strokeLinecap: "round" })] })) })] })] }));
261
+ });
262
+ function DeliverablesRow({ deliverables, openFile, revealFile, openMode }) {
263
+ const [folderStatus, setFolderStatus] = useState('idle');
264
+ const onOpenWorkspace = () => {
265
+ try {
266
+ openFile?.('.');
267
+ setFolderStatus('opened');
268
+ setTimeout(() => setFolderStatus('idle'), 1600);
269
+ }
270
+ catch {
271
+ // ignore
272
+ }
273
+ };
274
+ return (_jsxs("div", { className: css.deliverablesRoot, "data-reader-deliverables": true, children: [_jsx("span", { className: css.deliverablesLabel, children: "\u4EA7\u7269" }), _jsx("div", { className: css.deliverablesLane, children: _jsxs("div", { className: css.deliverablesRow, children: [deliverables.slice(0, 8).map(path => (_jsx(DeliverableChip, { path: path, openFile: openFile, revealFile: revealFile, openMode: openMode }, path))), deliverables.length > 8 && (_jsxs("span", { className: css.deliverablesMore, children: ["+ ", deliverables.length - 8, " \u4E2A\u6587\u4EF6"] })), deliverables.length > 1 && (_jsxs("button", { type: "button", className: css.deliverablesShowFolder, "data-status": folderStatus, onClick: onOpenWorkspace, title: "\u5728\u8BBF\u8FBE\u4E2D\u6253\u5F00\u6574\u4E2A\u5DE5\u4F5C\u533A\u76EE\u5F55", children: [folderStatus === 'opened' && (_jsx("svg", { className: css.statusIcon, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: _jsx("path", { d: "M3.5 8.5l3 3 6-7", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })), _jsx("span", { children: folderStatus === 'opened' ? '已打开访达' : '在文件夹中显示' })] }))] }) })] }));
275
+ }
276
+ const TurnGroup = memo(function TurnGroup({ group, motion, autoFold, pinnedKeys, selectedProcessKeys, isAwaitingModel = false, ...props }) {
277
+ const snapshot = props.useChat(snapshot => snapshot);
278
+ const nodes = snapshot.nodes;
279
+ const turn = group.turn === null ? undefined : snapshot.timeline.turns.get(group.turn);
280
+ const interaction = props.useSessionStatus(snapshot => snapshot.get(props.sessionId)?.pendingInteraction);
281
+ const sessionRunning = props.useSession(snapshot => snapshot.running);
282
+ const boundary = useMemo(() => boundaryOf(turn), [turn]);
283
+ const choiceKey = processChoiceKey(group.key, boundary);
284
+ const expansionChoice = props.useStore(state => state.expanded[choiceKey]);
285
+ const flowId = useId();
286
+ const processButton = useRef(null);
287
+ const setExpanded = useCallback((value) => props.actions.setExpanded(choiceKey, value), [props.actions, choiceKey]);
288
+ const pinProcess = useCallback(() => setExpanded(true), [setExpanded]);
289
+ const firstKind = props.useChat(snapshot => snapshot.nodes.get(group.keys[0])?.kind);
290
+ const startsWithUser = firstKind === 'user';
291
+ const mainKeys = startsWithUser ? group.keys.slice(1) : group.keys;
292
+ const flow = useMemo(() => readerFlow({ ...group, keys: mainKeys }, turn, key => nodes.get(key)), [nodes, group, mainKeys, turn]);
293
+ const steps = useMemo(() => segmentLiveTurn(flow, key => nodes.get(key)), [flow, nodes]);
294
+ const liveItems = useMemo(() => presentLiveTurn(steps, boundary, autoFold), [steps, boundary, autoFold]);
295
+ const openMode = deliverableOpenModeOf(useSyncExternalStore(props.openPrefs?.subscribe ?? ((fn) => { void fn; return () => { }; }), () => props.openPrefs?.getSnapshot()?.deliverableOpenMode, () => 'external'));
296
+ const hasProcess = flow.some(item => item.kind === 'tool' || hasProcessContent(nodes.get(item.nodeKey), boundary));
297
+ // Only a real, still-active text selection delays folding. Merely clicking,
298
+ // focusing or scrolling the live card does not create a permanent override.
299
+ const holdingSelection = selectedProcessKeys.some(key => flow.some(item => item.key === key)
300
+ || liveItems.some(item => item.kind === 'fold'
301
+ ? item.key === key || item.steps.some(step => step.key === key || ('nodeKey' in step && step.nodeKey === key))
302
+ : item.key === key || ('nodeKey' in item.step && item.step.nodeKey === key)));
303
+ const expanded = !autoFold || holdingSelection || processExpanded(expansionChoice, boundary);
304
+ const [foldOpenByKey, setFoldOpenByKey] = useState({});
305
+ useLayoutEffect(() => {
306
+ // Restoring automatic folding also releases live "prior steps" disclosures.
307
+ if (autoFold)
308
+ setFoldOpenByKey(current => Object.keys(current).length ? {} : current);
309
+ }, [autoFold]);
310
+ const deliverables = useMemo(() => getTurnDeliverables(turn, flow), [turn, flow]);
311
+ const tailData = useMemo(() => {
312
+ for (const key of group.keys) {
313
+ const n = nodes.get(key);
314
+ if (n && isNode(n, 'turn-tail'))
315
+ return n.data;
316
+ }
317
+ return undefined;
318
+ }, [group.keys, nodes]);
319
+ const tailOwner = useMemo(() => turn && tailData ? {
320
+ turn, seq: tailData.closing?.finalNode.seq ?? tailData.seq, openFile: props.openFile,
321
+ } : undefined, [turn, tailData, props.openFile]);
322
+ const fileMentions = useMemo(() => {
323
+ const official = tailOwner ? props.officialFileMentions(tailOwner) : undefined;
324
+ const reader = deliverables.length > 0 ? createProducedFileMentions(deliverables, props.openFile) : undefined;
325
+ return official || reader ? { resolve: (value) => official?.resolve(value) ?? reader?.resolve(value) } : undefined;
326
+ }, [tailOwner, props.officialFileMentions, deliverables, props.openFile]);
327
+ const official = useMemo(() => ({
328
+ renderSlot: props.renderSlot, renderSlotChain: props.renderSlotChain,
329
+ officialImageLoader: props.officialImageLoader, officialFileMentions: props.officialFileMentions,
330
+ officialPreviewFile: props.officialPreviewFile,
331
+ officialHost: props.officialHost, openView: props.openView,
332
+ }), [props.renderSlot, props.renderSlotChain, props.officialImageLoader, props.officialFileMentions, props.officialPreviewFile, props.officialHost, props.openView]);
333
+ const cwd = props.useSessions(state => state.byId[props.sessionId]?.cwd);
334
+ const runMs = turn?.start && turn?.end ? Math.max(0, turn.end.time - turn.start.time) : undefined;
335
+ const metrics = useMemo(() => ({
336
+ usage: tailData?.tokenUsage,
337
+ runMs,
338
+ tokensPerSecond: tailData?.tokensPerSecond,
339
+ ttftMs: tailData?.ttftMs,
340
+ endedAt: tailData?.closing?.time ?? turn?.end?.time,
341
+ }), [tailData, runMs, turn?.end?.time]);
342
+ const forkSeq = forkAnchorSeq([tailData?.closing?.finalNode]);
343
+ const presentation = useMemo(() => {
344
+ // ChatNodeStore exposes live keyed readers. Materialize this turn instead of
345
+ // retaining a live get() function and mistakenly calling it a frozen frame.
346
+ const captured = new Map(group.keys.flatMap(key => {
347
+ const node = nodes.get(key);
348
+ return node ? [[key, node]] : [];
349
+ }));
350
+ return { items: holdingSelection ? presentLiveTurn(steps, boundary, false) : liveItems,
351
+ snapshot: { ...snapshot, nodes: { ...nodes, get: (key) => captured.get(key), values: () => [...captured.values()] } } };
352
+ }, [snapshot, nodes, group, steps, boundary, liveItems, holdingSelection]);
353
+ const shared = {
354
+ useChat: useFlowChat,
355
+ renderSlotChain: props.renderSlotChain,
356
+ loadImage: props.loadImage,
357
+ fillComposer: props.fillComposer,
358
+ openFile: props.openFile,
359
+ revealFile: props.revealFile,
360
+ forkAt: props.forkAt,
361
+ forkSeq,
362
+ fileMentions,
363
+ metrics,
364
+ official,
365
+ cwd,
366
+ };
367
+ const terminal = terminalLabel(boundary.reason);
368
+ const hasTurnError = flow.some(item => item.kind === 'node' && nodes.get(item.nodeKey)?.kind === 'turn-error');
369
+ // A stopped turn normally stays quiet, but a stopped turn that produced no
370
+ // prose at all reads as if its answer vanished into the process fold. Say so.
371
+ const hasAnswerProse = steps.some(step => step.kind === 'body'
372
+ && step.blocks.some(block => block.kind === 'text' && block.text.trim() !== ''));
373
+ const stoppedWithoutAnswer = (boundary.reason === 'interrupted' || boundary.reason === 'aborted') && !hasAnswerProse;
374
+ const showTerminalNotice = terminal && !hasTurnError
375
+ && (stoppedWithoutAnswer || (boundary.reason !== 'interrupted' && boundary.reason !== 'aborted'));
376
+ const renderStep = (step, folded) => {
377
+ const processOpen = folded || expanded;
378
+ if (step.kind === 'reasoning' || step.kind === 'body')
379
+ return _jsx(BlockBoundary, { children: _jsx(AssistantNode, { ...shared, boundary: boundary, nodeKey: step.nodeKey, partStart: step.start, pinned: pinnedKeys.includes(step.nodeKey), processOpen: processOpen, folded: folded, motion: motion, onRead: pinProcess, returnFocusTo: processButton }) });
380
+ if (step.kind === 'tool')
381
+ return _jsx(BlockBoundary, { children: _jsxs(ProcessFragment, { open: processOpen, motion: motion, onRead: pinProcess, returnFocusTo: processButton, nodeKey: step.key, framed: true, children: [_jsx(ToolActivity, { ...shared, entry: step.entry, motion: motion, turnClosed: boundary.status === 'closed', onRead: pinProcess }), step.entry.block && _jsx(ToolMedia, { ...shared, block: step.entry.block })] }) });
382
+ if (step.kind === 'user')
383
+ return _jsx(BlockBoundary, { children: _jsx(MainNode, { ...shared, boundary: boundary, nodeKey: step.nodeKey }) });
384
+ return _jsxs(Fragment, { children: [_jsx(BlockBoundary, { children: _jsx(ProcessNode, { useChat: useFlowChat, t: props.t, nodeKey: step.nodeKey, open: processOpen, motion: motion, onRead: pinProcess, returnFocusTo: processButton }) }), _jsx(BlockBoundary, { children: _jsx(MainNode, { ...shared, boundary: boundary, nodeKey: step.nodeKey, pinned: pinnedKeys.includes(step.nodeKey), processOpen: processOpen }) })] });
385
+ };
386
+ return _jsxs("section", { className: css.turn, "data-reader-turn": group.turn ?? 'unresolved', "data-reader-turn-state": boundary.status, "data-reader-turn-result": boundary.reason ?? undefined, children: [startsWithUser && _jsx(BlockBoundary, { children: _jsx(MainNode, { ...shared, useChat: props.useChat, boundary: boundary, nodeKey: group.keys[0] }) }), hasProcess && !isAwaitingModel && _jsx(StickyLane, { kind: "status", className: css.turnProcessSticky, children: _jsx(Disclosure, { open: expanded, onChange: setExpanded, controls: flowId, buttonRef: processButton, label: _jsx(GroupStatus, { group: group, sessionId: props.sessionId, useChat: props.useChat, pending: interaction, motion: motion }) }) }), boundary.status === 'closed' && hasProcess && autoFold && _jsx(ClosedProcessSummary, { open: expanded, onChange: setExpanded, controls: flowId, steps: steps.filter(step => {
387
+ if (step.kind === 'user')
388
+ return false;
389
+ if (step.kind !== 'body')
390
+ return true;
391
+ const node = nodes.get(step.nodeKey);
392
+ return !!node && isNode(node, 'assistant-step') && (isEarlierNarration(node.data, boundary)
393
+ || node.data.blocks.some(block => block.kind === 'tool-call')
394
+ || (boundary.latestStep > 0 && node.data.step < boundary.latestStep));
395
+ }) }), _jsx(ChoreographedFlow, { id: flowId, frame: presentation, motion: motion, enabled: autoFold && boundary.status === 'open' && !holdingSelection, urgent: hasTurnError || interaction !== undefined || !sessionRunning, open: foldOpenByKey, processOpen: expanded, onOpenChange: (key, value) => { pinProcess(); setFoldOpenByKey(current => ({ ...current, [key]: value })); }, renderStep: renderStep }), !hasProcess && boundary.status === 'open' && !isAwaitingModel && _jsx("div", { className: css.disclosure, "data-reader-status-only": true, children: _jsx(GroupStatus, { group: group, sessionId: props.sessionId, useChat: props.useChat, pending: interaction, motion: motion }) }), showDeliverablesRow(boundary.status, deliverables) && _jsx(DeliverablesRow, { deliverables: deliverables, openFile: props.openFile, revealFile: props.revealFile, openMode: openMode }), boundary.status === 'closed' && _jsx(BlockBoundary, { children: _jsx(OfficialTail, { official: official, owner: tailOwner, produced: deliverables }) }), showTerminalNotice && _jsx("div", { className: css.notice, "data-reader-terminal": true, children: terminal })] });
396
+ });
397
+ export function Reader(props) {
398
+ const root = useRef(null);
399
+ const activatedAt = useRef(Date.now());
400
+ const order = props.useChat(snapshot => snapshot.order);
401
+ const nodes = props.useChat(snapshot => snapshot.nodes);
402
+ const timeline = props.useChat(snapshot => snapshot.timeline);
403
+ const running = props.useSession(snapshot => snapshot.running);
404
+ const pending = props.useSessionStatus(snapshot => snapshot.get(props.sessionId)?.pendingInteraction);
405
+ const openError = props.useSession(snapshot => snapshot.openError);
406
+ const loading = props.useSession(snapshot => snapshot.openState === 'loading');
407
+ const hasMore = props.useSession(snapshot => snapshot.hasMore);
408
+ const loadingOlder = props.useSession(snapshot => snapshot.loadingOlder);
409
+ const pendingSubmissions = props.useSession(snapshot => snapshot.pendingSubmissions);
410
+ const pendingList = asReadonlyArray(pendingSubmissions);
411
+ const waitAnchor = waitingAnchor(order, key => nodes.get(key), pendingList);
412
+ const motionPreference = props.useStore(state => state.motion);
413
+ const motion = useMotionAllowed(motionPreference);
414
+ const prefsSnap = useSyncExternalStore(props.openPrefs?.subscribe ?? ((fn) => { void fn; return () => { }; }), () => props.openPrefs?.getSnapshot?.(), () => undefined);
415
+ const storeAutoFold = props.useStore(state => state.autoFold);
416
+ const autoFold = prefsSnap?.autoFold ?? (prefsSnap?.foldIntensity !== undefined ? prefsSnap.foldIntensity !== 0 : undefined) ?? storeAutoFold ?? true;
417
+ const previousAutoFold = useRef(autoFold);
418
+ useLayoutEffect(() => {
419
+ const restored = autoFold && !previousAutoFold.current;
420
+ previousAutoFold.current = autoFold;
421
+ // Watch the effective preference so toolbar and Settings changes behave alike.
422
+ // Reading while folding is off must not pin completed process content forever.
423
+ if (restored)
424
+ props.actions.resetExpanded();
425
+ }, [autoFold, props.actions]);
426
+ const frostedGlass = frostedGlassOf(prefsSnap);
427
+ const bubbles = bubblesOf(prefsSnap);
428
+ const streamMotion = useMemo(() => ({ enabled: motion, activatedAt: activatedAt.current }), [motion]);
429
+ const groups = useMemo(() => groupNodes(order, key => nodes.get(key)), [order, nodes, timeline]);
430
+ const isAwaitingModel = useMemo(() => {
431
+ // 状态机铁律:「深度求索中」与「正在处理/思考」永远互斥。
432
+ // 1. 仅空闲发送(!running)的本地回显窗口:用户按下回车第 0 毫秒立即反馈。
433
+ // 忙碌时的 queued/steering 回显不算等待——模型本来就在工作。
434
+ if (!running && pendingList.length > 0)
435
+ return true;
436
+ const lastKey = order.at(-1);
437
+ const lastNode = lastKey ? nodes.get(lastKey) : undefined;
438
+ if (!lastKey || !lastNode)
439
+ return false;
440
+ // 2. 模型已经产出内容:等待结束,计时器必须立刻消失。
441
+ // 「产出」= assistant-step 已带 block(正文/思维链/工具调用都算)。
442
+ if (lastNode.kind === 'assistant-step') {
443
+ const data = lastNode.data;
444
+ const blocks = data.blocks ?? [];
445
+ // 空 block 且仍在跑 = 请求已发出、模型还没吐字,正是要计时的那一刻。
446
+ return blocks.length === 0 && data.status === 'running';
447
+ }
448
+ // 3. 球在模型脚下:用户刚发言,或工具已返回、上下文已注入、命令已执行。
449
+ // 这些时刻模型随时可能卡住,正是要计时的地方;工具执行期间不计时,
450
+ // 因为那时忙的是工具而不是模型。
451
+ // handsBackToModel 内部按 chat 层 kind 判定,并区分「工具已返回」与
452
+ // 「工具仍在跑」——后者不算等待。
453
+ const modelOwesResponse = handsBackToModel(lastNode);
454
+ if (!modelOwesResponse)
455
+ return false;
456
+ // 轮次已结束就没什么可等的。
457
+ const lastGroup = groups.at(-1);
458
+ const turn = lastGroup?.turn === null || lastGroup?.turn === undefined ? undefined : timeline.turns.get(lastGroup.turn);
459
+ return turn?.status !== 'closed';
460
+ }, [running, pendingList, order, nodes, groups, timeline]);
461
+ const scroll = useReadingScroll(root, motion);
462
+ const pinnedKeys = usePinnedSelection(root);
463
+ const selectedProcessKeys = usePinnedSelection(root, '[data-reader-process]');
464
+ const [historyError, setHistoryError] = useState(false);
465
+ // 1. Navigation items from Chat snapshot
466
+ const turnNavigationItems = props.useChat(snapshot => snapshot.navigation?.items ? snapshot.navigation.items() : undefined);
467
+ // 2. Whole-log turn outline projection
468
+ const turnOutline = props.useProjection?.('turnOutline');
469
+ // 3. Track turns with deliverables
470
+ const turnsWithDeliverables = useMemo(() => {
471
+ const set = new Set();
472
+ for (const [turnNum, loc] of timeline.turns) {
473
+ const deliv = loc.data?.get('deliverables');
474
+ if (Array.isArray(deliv?.produced) && deliv.produced.length > 0) {
475
+ set.add(turnNum);
476
+ }
477
+ }
478
+ return set;
479
+ }, [timeline]);
480
+ // 4. Merged timeline items for the rail
481
+ const timelineItems = useMemo(() => mergeTimelineItems(turnNavigationItems, turnOutline, turnsWithDeliverables), [turnNavigationItems, turnOutline, turnsWithDeliverables]);
482
+ // 5. Active & busy turn tracking
483
+ const [activeTurn, setActiveTurn] = useState(null);
484
+ const [busyTurn, setBusyTurn] = useState(null);
485
+ // Scroll spy to update activeTurn
486
+ useEffect(() => {
487
+ const el = root.current;
488
+ if (!el)
489
+ return;
490
+ const scroller = el.closest('[data-conversation-scroll]') ?? el;
491
+ let ticking = false;
492
+ const updateActive = () => {
493
+ if (ticking)
494
+ return;
495
+ ticking = true;
496
+ requestAnimationFrame(() => {
497
+ ticking = false;
498
+ const line = (scroller instanceof HTMLElement ? scroller.clientHeight : window.innerHeight) * 0.35;
499
+ const turnRows = el.querySelectorAll('[data-reader-turn]:not([data-reader-turn="unresolved"])');
500
+ let current = null;
501
+ for (const row of turnRows) {
502
+ const rect = row.getBoundingClientRect();
503
+ if (rect.top <= line) {
504
+ const num = Number(row.dataset.readerTurn);
505
+ if (Number.isSafeInteger(num))
506
+ current = num;
507
+ }
508
+ else {
509
+ break;
510
+ }
511
+ }
512
+ if (current !== null) {
513
+ setActiveTurn(current);
514
+ }
515
+ else if (turnRows.length > 0) {
516
+ const first = Number(turnRows[0].dataset.readerTurn);
517
+ if (Number.isSafeInteger(first))
518
+ setActiveTurn(first);
519
+ }
520
+ });
521
+ };
522
+ scroller.addEventListener('scroll', updateActive, { passive: true });
523
+ updateActive();
524
+ return () => scroller.removeEventListener('scroll', updateActive);
525
+ }, [groups]);
526
+ // Navigation handler (supports loaded jump & unloaded loadThrough).
527
+ // Land on the conversation scroller only — scrollIntoView also moves
528
+ // ancestor boxes and can lift the sticky composer after a top→bottom jump.
529
+ const onNavigateTurn = useCallback(async (item) => {
530
+ const el = root.current;
531
+ if (!el)
532
+ return;
533
+ const port = scrollerOf(el);
534
+ const reveal = (turn) => {
535
+ const targetRow = el.querySelector(`[data-reader-turn="${turn}"]`);
536
+ if (!targetRow)
537
+ return;
538
+ const last = timelineItems.at(-1);
539
+ if (last !== undefined && last.turn === turn) {
540
+ scroll.jump();
541
+ }
542
+ else {
543
+ scroll.release();
544
+ landTurn(targetRow, port);
545
+ }
546
+ setActiveTurn(turn);
547
+ };
548
+ if (item.anchor.kind === 'loaded') {
549
+ reveal(item.turn);
550
+ return;
551
+ }
552
+ setBusyTurn(item.turn);
553
+ try {
554
+ if (props.loadThrough) {
555
+ await props.loadThrough(item.anchor.seq);
556
+ }
557
+ else {
558
+ await props.loadOlder();
559
+ }
560
+ setTimeout(() => { reveal(item.turn); }, 50);
561
+ }
562
+ finally {
563
+ setBusyTurn(null);
564
+ }
565
+ }, [props.loadThrough, props.loadOlder, scroll.jump, scroll.release, timelineItems]);
566
+ const lastKey = order.at(-1);
567
+ const lastNode = lastKey ? nodes.get(lastKey) : undefined;
568
+ const lastSubmissionId = pendingList.length ? pendingList[pendingList.length - 1].requestId : null;
569
+ const lastOrderKeyRef = useRef(lastKey);
570
+ const lastSubmissionRef = useRef(lastSubmissionId);
571
+ useLayoutEffect(() => {
572
+ const appendedUser = lastKey !== lastOrderKeyRef.current && (lastNode?.kind === 'user' || lastNode?.kind === 'steering');
573
+ const appendedSubmission = lastSubmissionId !== null && lastSubmissionId !== lastSubmissionRef.current;
574
+ lastOrderKeyRef.current = lastKey;
575
+ lastSubmissionRef.current = lastSubmissionId;
576
+ if (appendedUser || appendedSubmission) {
577
+ scroll.jump();
578
+ }
579
+ }, [lastKey, lastNode?.kind, lastSubmissionId, scroll]);
580
+ const visibleSubmissions = useMemo(() => {
581
+ if (pendingList.length === 0)
582
+ return [];
583
+ return pendingList.filter(sub => sub.placement !== 'queued');
584
+ }, [pendingList]);
585
+ // ChatView publishes data-chat-flow="" on its column. Skins treat a
586
+ // scrollport without that hook as inspect-only and hide [data-composer-seat].
587
+ return _jsx(StreamMotionContext.Provider, { value: streamMotion, children: _jsxs("div", { ref: root, className: css.root, "data-reader-build": "0.3.3", "data-dsh-better-display": "0.3.3", "data-reader-wait-clock-version": "input-v1", "data-reader-wait-start": waitAnchor.time ?? undefined, "data-motion": motion ? 'on' : 'off', "data-reader-glass": frostedGlass || undefined, "data-reader-bubbles": bubbles ? 'on' : 'off', "data-reader-auto-fold": autoFold ? 'on' : 'off', children: [_jsx(TimelineRail, { items: timelineItems, activeTurn: activeTurn, busyTurn: busyTurn, onNavigate: onNavigateTurn }), _jsxs("div", { className: css.column, "data-chat-flow": "", children: [_jsx(StickyLane, { kind: "toolbar", className: css.toolbar, children: _jsx("button", { type: "button", className: css.textButton, "aria-pressed": autoFold, onClick: () => {
588
+ props.actions.setAutoFold(!autoFold);
589
+ props.openPrefs?.actions?.setAutoFold?.(!autoFold);
590
+ }, title: "\u65B0\u601D\u8003\u4EA7\u751F\u65F6\uFF0C\u662F\u5426\u81EA\u52A8\u5C06\u6B64\u524D\u6B65\u9AA4\u6536\u62E2\u4E3A\u4E00\u884C\u6C47\u603B\u3002\u5173\u95ED\u540E\u5B8C\u6574\u4FDD\u7559\u539F\u59CB\u8FC7\u7A0B\u4E0E\u6D41\u5F0F\u8F93\u51FA\u3002", children: `自动折叠${autoFold ? '开' : '关'}` }) }), hasMore && _jsx("button", { type: "button", className: css.historyButton, disabled: loadingOlder, onClick: async () => {
591
+ setHistoryError(false);
592
+ try {
593
+ await props.loadOlder();
594
+ }
595
+ catch {
596
+ setHistoryError(true);
597
+ }
598
+ }, children: loadingOlder ? '正在加载更早记录' : '加载更早记录' }), historyError && _jsx("div", { className: css.notice, children: "\u5386\u53F2\u8BB0\u5F55\u52A0\u8F7D\u5931\u8D25\uFF0C\u53EF\u518D\u6B21\u5C1D\u8BD5\uFF1B\u73B0\u6709\u5185\u5BB9\u672A\u6539\u53D8\u3002" }), openError && _jsxs("div", { className: css.error, role: "alert", children: ["\u4F1A\u8BDD\u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\uFF1A", openError.message] }), loading && groups.length === 0 && _jsx("p", { className: css.empty, role: "status", children: "\u6B63\u5728\u8BFB\u53D6\u4F1A\u8BDD\u2026" }), groups.map(group => _jsx(TurnGroup, { ...props, group: group, motion: motion, autoFold: autoFold, pinnedKeys: pinnedKeys, selectedProcessKeys: selectedProcessKeys, isAwaitingModel: isAwaitingModel && group.key === groups.at(-1)?.key }, group.key)), visibleSubmissions.map(submission => {
599
+ const images = pendingSubmissionImages(submission);
600
+ return (_jsxs("div", { className: css.userCluster, "data-reader-pending-submission": true, children: [images.length > 0 && (_jsx("div", { className: css.userImages, children: images.map((item, idx) => (_jsx("figure", { className: css.imageFigure, children: _jsx("div", { className: css.imageFrame, style: { aspectRatio: `${item.width || 4} / ${item.height || 3}` }, children: _jsx("img", { src: item.previewUrl, alt: item.name ?? '发送的图片', className: css.pendingImage }) }) }, idx))) })), submission.text ? (_jsx("div", { className: css.user, children: _jsx("div", { className: css.blocks, children: submission.text }) })) : null, _jsx(UserMessageActions, { text: submission.text ?? '', time: submission.time })] }, submission.requestId));
601
+ }), isAwaitingModel && _jsx(WaitingStatus, { anchor: waitAnchor, label: props.t ? props.t('chat.deepDiving') : '深度求索中...' }), pending !== undefined && _jsxs("div", { className: css.attention, role: "alert", "data-reader-attention": true, children: [_jsx("strong", { children: pending.kind === 'question' ? '需要你回答一个问题' : '需要你的确认' }), _jsx("span", { children: "\u8BF7\u5728\u4E0B\u65B9\u539F\u751F\u64CD\u4F5C\u533A\u5904\u7406\u3002\u6B64\u63D0\u793A\u4E0D\u4F1A\u6536\u8FDB\u6267\u884C\u8FC7\u7A0B\u3002" })] }), scroll.detached && _jsx("div", { className: css.jumpDock, children: _jsx("button", { type: "button", className: css.jump, "aria-label": "\u56DE\u5230\u5E95\u90E8", title: "\u56DE\u5230\u5E95\u90E8", onClick: scroll.jump, children: _jsx("svg", { viewBox: "0 0 14 14", width: "14", height: "14", "aria-hidden": "true", children: _jsx("path", { d: "M3 5.5 7 9.5 11 5.5", fill: "none", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }) }) }) })] })] }) });
602
+ }
603
+ //# sourceMappingURL=Reader.js.map