dsh-better-display 0.1.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 (300) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/DESIGN.md +72 -0
  3. package/LICENSE +24 -0
  4. package/README.en.md +41 -0
  5. package/README.md +41 -0
  6. package/THIRD_PARTY_NOTICES.md +65 -0
  7. package/cordis.patch.yml +5 -0
  8. package/cordis.yml +4 -0
  9. package/dshx.yml +5 -0
  10. package/lib/client.js +49923 -0
  11. package/lib/client.js.map +1 -0
  12. package/lib/dsh-better-display.js +256 -0
  13. package/lib/types/client/Blocks.d.ts +45 -0
  14. package/lib/types/client/Blocks.d.ts.map +1 -0
  15. package/lib/types/client/Blocks.js +136 -0
  16. package/lib/types/client/Blocks.js.map +1 -0
  17. package/lib/types/client/ChoreographedFlow.d.ts +22 -0
  18. package/lib/types/client/ChoreographedFlow.d.ts.map +1 -0
  19. package/lib/types/client/ChoreographedFlow.js +170 -0
  20. package/lib/types/client/ChoreographedFlow.js.map +1 -0
  21. package/lib/types/client/ClosedProcessSummary.d.ts +9 -0
  22. package/lib/types/client/ClosedProcessSummary.d.ts.map +1 -0
  23. package/lib/types/client/ClosedProcessSummary.js +15 -0
  24. package/lib/types/client/ClosedProcessSummary.js.map +1 -0
  25. package/lib/types/client/LiveFold.d.ts +10 -0
  26. package/lib/types/client/LiveFold.d.ts.map +1 -0
  27. package/lib/types/client/LiveFold.js +39 -0
  28. package/lib/types/client/LiveFold.js.map +1 -0
  29. package/lib/types/client/McpAppFrame.d.ts +32 -0
  30. package/lib/types/client/McpAppFrame.d.ts.map +1 -0
  31. package/lib/types/client/McpAppFrame.js +193 -0
  32. package/lib/types/client/McpAppFrame.js.map +1 -0
  33. package/lib/types/client/Reader.d.ts +3 -0
  34. package/lib/types/client/Reader.d.ts.map +1 -0
  35. package/lib/types/client/Reader.js +537 -0
  36. package/lib/types/client/Reader.js.map +1 -0
  37. package/lib/types/client/ReasoningCard.d.ts +11 -0
  38. package/lib/types/client/ReasoningCard.d.ts.map +1 -0
  39. package/lib/types/client/ReasoningCard.js +301 -0
  40. package/lib/types/client/ReasoningCard.js.map +1 -0
  41. package/lib/types/client/StickyLane.d.ts +8 -0
  42. package/lib/types/client/StickyLane.d.ts.map +1 -0
  43. package/lib/types/client/StickyLane.js +28 -0
  44. package/lib/types/client/StickyLane.js.map +1 -0
  45. package/lib/types/client/TimelineRail.d.ts +10 -0
  46. package/lib/types/client/TimelineRail.d.ts.map +1 -0
  47. package/lib/types/client/TimelineRail.js +168 -0
  48. package/lib/types/client/TimelineRail.js.map +1 -0
  49. package/lib/types/client/ToolActivity.d.ts +17 -0
  50. package/lib/types/client/ToolActivity.d.ts.map +1 -0
  51. package/lib/types/client/ToolActivity.js +192 -0
  52. package/lib/types/client/ToolActivity.js.map +1 -0
  53. package/lib/types/client/TurnMetrics.d.ts +11 -0
  54. package/lib/types/client/TurnMetrics.d.ts.map +1 -0
  55. package/lib/types/client/TurnMetrics.js +44 -0
  56. package/lib/types/client/TurnMetrics.js.map +1 -0
  57. package/lib/types/client/WaitingStatus.d.ts +6 -0
  58. package/lib/types/client/WaitingStatus.d.ts.map +1 -0
  59. package/lib/types/client/WaitingStatus.js +19 -0
  60. package/lib/types/client/WaitingStatus.js.map +1 -0
  61. package/lib/types/client/conversation-scroll.d.ts +19 -0
  62. package/lib/types/client/conversation-scroll.d.ts.map +1 -0
  63. package/lib/types/client/conversation-scroll.js +25 -0
  64. package/lib/types/client/conversation-scroll.js.map +1 -0
  65. package/lib/types/client/deliverables.d.ts +24 -0
  66. package/lib/types/client/deliverables.d.ts.map +1 -0
  67. package/lib/types/client/deliverables.js +104 -0
  68. package/lib/types/client/deliverables.js.map +1 -0
  69. package/lib/types/client/entry-policy.d.ts +10 -0
  70. package/lib/types/client/entry-policy.d.ts.map +1 -0
  71. package/lib/types/client/entry-policy.js +24 -0
  72. package/lib/types/client/entry-policy.js.map +1 -0
  73. package/lib/types/client/entry.d.ts +4 -0
  74. package/lib/types/client/entry.d.ts.map +1 -0
  75. package/lib/types/client/entry.js +34 -0
  76. package/lib/types/client/entry.js.map +1 -0
  77. package/lib/types/client/fold-choreography.d.ts +28 -0
  78. package/lib/types/client/fold-choreography.d.ts.map +1 -0
  79. package/lib/types/client/fold-choreography.js +31 -0
  80. package/lib/types/client/fold-choreography.js.map +1 -0
  81. package/lib/types/client/index.d.ts +7 -0
  82. package/lib/types/client/index.d.ts.map +1 -0
  83. package/lib/types/client/index.js +153 -0
  84. package/lib/types/client/index.js.map +1 -0
  85. package/lib/types/client/live-turn.d.ts +58 -0
  86. package/lib/types/client/live-turn.d.ts.map +1 -0
  87. package/lib/types/client/live-turn.js +144 -0
  88. package/lib/types/client/live-turn.js.map +1 -0
  89. package/lib/types/client/markdown/MarkdownText.d.ts +39 -0
  90. package/lib/types/client/markdown/MarkdownText.d.ts.map +1 -0
  91. package/lib/types/client/markdown/MarkdownText.js +171 -0
  92. package/lib/types/client/markdown/MarkdownText.js.map +1 -0
  93. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts +9 -0
  94. package/lib/types/client/markdown/cjkFriendlyStrong.d.ts.map +1 -0
  95. package/lib/types/client/markdown/cjkFriendlyStrong.js +73 -0
  96. package/lib/types/client/markdown/cjkFriendlyStrong.js.map +1 -0
  97. package/lib/types/client/markdown/incremental.d.ts +69 -0
  98. package/lib/types/client/markdown/incremental.d.ts.map +1 -0
  99. package/lib/types/client/markdown/incremental.js +108 -0
  100. package/lib/types/client/markdown/incremental.js.map +1 -0
  101. package/lib/types/client/markdown/katex.d.ts +27 -0
  102. package/lib/types/client/markdown/katex.d.ts.map +1 -0
  103. package/lib/types/client/markdown/katex.js +88 -0
  104. package/lib/types/client/markdown/katex.js.map +1 -0
  105. package/lib/types/client/markdown/mathCompatibility.d.ts +11 -0
  106. package/lib/types/client/markdown/mathCompatibility.d.ts.map +1 -0
  107. package/lib/types/client/markdown/mathCompatibility.js +293 -0
  108. package/lib/types/client/markdown/mathCompatibility.js.map +1 -0
  109. package/lib/types/client/markdown/parse.d.ts +25 -0
  110. package/lib/types/client/markdown/parse.d.ts.map +1 -0
  111. package/lib/types/client/markdown/parse.js +42 -0
  112. package/lib/types/client/markdown/parse.js.map +1 -0
  113. package/lib/types/client/markdown/render.d.ts +119 -0
  114. package/lib/types/client/markdown/render.d.ts.map +1 -0
  115. package/lib/types/client/markdown/render.js +435 -0
  116. package/lib/types/client/markdown/render.js.map +1 -0
  117. package/lib/types/client/mcp-app.d.ts +50 -0
  118. package/lib/types/client/mcp-app.d.ts.map +1 -0
  119. package/lib/types/client/mcp-app.js +328 -0
  120. package/lib/types/client/mcp-app.js.map +1 -0
  121. package/lib/types/client/message-chrome.d.ts +19 -0
  122. package/lib/types/client/message-chrome.d.ts.map +1 -0
  123. package/lib/types/client/message-chrome.js +42 -0
  124. package/lib/types/client/message-chrome.js.map +1 -0
  125. package/lib/types/client/motion.d.ts +38 -0
  126. package/lib/types/client/motion.d.ts.map +1 -0
  127. package/lib/types/client/motion.js +367 -0
  128. package/lib/types/client/motion.js.map +1 -0
  129. package/lib/types/client/native/ContextBody.d.ts +130 -0
  130. package/lib/types/client/native/ContextBody.d.ts.map +1 -0
  131. package/lib/types/client/native/ContextBody.js +398 -0
  132. package/lib/types/client/native/ContextBody.js.map +1 -0
  133. package/lib/types/client/native/ContextInjectionRow.d.ts +26 -0
  134. package/lib/types/client/native/ContextInjectionRow.d.ts.map +1 -0
  135. package/lib/types/client/native/ContextInjectionRow.js +27 -0
  136. package/lib/types/client/native/ContextInjectionRow.js.map +1 -0
  137. package/lib/types/client/native/ReferenceIcon.d.ts +16 -0
  138. package/lib/types/client/native/ReferenceIcon.d.ts.map +1 -0
  139. package/lib/types/client/native/ReferenceIcon.js +16 -0
  140. package/lib/types/client/native/ReferenceIcon.js.map +1 -0
  141. package/lib/types/client/native/tool-call-model.d.ts +58 -0
  142. package/lib/types/client/native/tool-call-model.d.ts.map +1 -0
  143. package/lib/types/client/native/tool-call-model.js +219 -0
  144. package/lib/types/client/native/tool-call-model.js.map +1 -0
  145. package/lib/types/client/open-file.d.ts +24 -0
  146. package/lib/types/client/primitive-labels.d.ts +10 -0
  147. package/lib/types/client/primitive-labels.d.ts.map +1 -0
  148. package/lib/types/client/primitive-labels.js +37 -0
  149. package/lib/types/client/primitive-labels.js.map +1 -0
  150. package/lib/types/client/projection.d.ts +41 -0
  151. package/lib/types/client/projection.d.ts.map +1 -0
  152. package/lib/types/client/projection.js +112 -0
  153. package/lib/types/client/projection.js.map +1 -0
  154. package/lib/types/client/reasoning-follow.d.ts +6 -0
  155. package/lib/types/client/reasoning-follow.d.ts.map +1 -0
  156. package/lib/types/client/reasoning-follow.js +12 -0
  157. package/lib/types/client/reasoning-follow.js.map +1 -0
  158. package/lib/types/client/settings-copy.d.ts +6 -0
  159. package/lib/types/client/settings-slots.d.ts +16 -0
  160. package/lib/types/client/store.d.ts +17 -0
  161. package/lib/types/client/store.d.ts.map +1 -0
  162. package/lib/types/client/store.js +13 -0
  163. package/lib/types/client/store.js.map +1 -0
  164. package/lib/types/client/stream-buffer.d.ts +29 -0
  165. package/lib/types/client/stream-buffer.d.ts.map +1 -0
  166. package/lib/types/client/stream-buffer.js +113 -0
  167. package/lib/types/client/stream-buffer.js.map +1 -0
  168. package/lib/types/client/streaming.d.ts +18 -0
  169. package/lib/types/client/streaming.d.ts.map +1 -0
  170. package/lib/types/client/streaming.js +77 -0
  171. package/lib/types/client/streaming.js.map +1 -0
  172. package/lib/types/client/timeline.d.ts +26 -0
  173. package/lib/types/client/timeline.d.ts.map +1 -0
  174. package/lib/types/client/timeline.js +48 -0
  175. package/lib/types/client/timeline.js.map +1 -0
  176. package/lib/types/client/tool-activity.d.ts +52 -0
  177. package/lib/types/client/tool-activity.d.ts.map +1 -0
  178. package/lib/types/client/tool-activity.js +178 -0
  179. package/lib/types/client/tool-activity.js.map +1 -0
  180. package/lib/types/client/types.d.ts +66 -0
  181. package/lib/types/client/types.d.ts.map +1 -0
  182. package/lib/types/client/types.js +2 -0
  183. package/lib/types/client/types.js.map +1 -0
  184. package/lib/types/client/waiting-clock.d.ts +17 -0
  185. package/lib/types/client/waiting-clock.d.ts.map +1 -0
  186. package/lib/types/client/waiting-clock.js +24 -0
  187. package/lib/types/client/waiting-clock.js.map +1 -0
  188. package/lib/types/client/word-motion.d.ts +16 -0
  189. package/lib/types/client/word-motion.d.ts.map +1 -0
  190. package/lib/types/client/word-motion.js +89 -0
  191. package/lib/types/client/word-motion.js.map +1 -0
  192. package/lib/types/client/word-timeline.d.ts +28 -0
  193. package/lib/types/client/word-timeline.d.ts.map +1 -0
  194. package/lib/types/client/word-timeline.js +100 -0
  195. package/lib/types/client/word-timeline.js.map +1 -0
  196. package/lib/types/dsh-better-display.d.ts +17 -0
  197. package/lib/types/dsh-better-display.d.ts.map +1 -0
  198. package/lib/types/dsh-better-display.js +53 -0
  199. package/lib/types/dsh-better-display.js.map +1 -0
  200. package/package.json +121 -0
  201. package/scripts/build-motion-fixture.mjs +26 -0
  202. package/scripts/link-harness-dependencies.mjs +51 -0
  203. package/skills/generative-mcpapps/SKILL.md +47 -0
  204. package/skills/generative-mcpapps/examples/interactive_quiz.html +153 -0
  205. package/skills/generative-mcpapps/references/html_boilerplate.md +122 -0
  206. package/skills/generative-mcpapps/references/sep1865_protocol.md +54 -0
  207. package/src/client/Blocks.tsx +205 -0
  208. package/src/client/ChoreographedFlow.tsx +182 -0
  209. package/src/client/ClosedProcessSummary.tsx +19 -0
  210. package/src/client/LiveFold.tsx +43 -0
  211. package/src/client/McpAppFrame.module.css +210 -0
  212. package/src/client/McpAppFrame.tsx +317 -0
  213. package/src/client/Reader.module.css +329 -0
  214. package/src/client/Reader.tsx +814 -0
  215. package/src/client/ReasoningCard.tsx +285 -0
  216. package/src/client/SettingsSection.module.css +147 -0
  217. package/src/client/SettingsSection.tsx +117 -0
  218. package/src/client/StickyLane.tsx +24 -0
  219. package/src/client/TimelineRail.module.css +170 -0
  220. package/src/client/TimelineRail.tsx +262 -0
  221. package/src/client/ToolActivity.tsx +214 -0
  222. package/src/client/TurnMetrics.module.css +139 -0
  223. package/src/client/TurnMetrics.tsx +160 -0
  224. package/src/client/WaitingStatus.tsx +22 -0
  225. package/src/client/conversation-scroll.ts +28 -0
  226. package/src/client/deliverables.ts +122 -0
  227. package/src/client/entry-policy.ts +20 -0
  228. package/src/client/entry.tsx +40 -0
  229. package/src/client/fold-choreography.ts +38 -0
  230. package/src/client/index.tsx +198 -0
  231. package/src/client/live-turn.ts +155 -0
  232. package/src/client/markdown/MarkdownText.module.css +304 -0
  233. package/src/client/markdown/MarkdownText.tsx +187 -0
  234. package/src/client/markdown/cjkFriendlyStrong.ts +84 -0
  235. package/src/client/markdown/incremental.ts +131 -0
  236. package/src/client/markdown/katex.tsx +91 -0
  237. package/src/client/markdown/mathCompatibility.ts +350 -0
  238. package/src/client/markdown/parse.ts +45 -0
  239. package/src/client/markdown/render.tsx +630 -0
  240. package/src/client/markdown/upstream.json +14 -0
  241. package/src/client/mcp-app.ts +323 -0
  242. package/src/client/message-chrome.ts +47 -0
  243. package/src/client/motion.tsx +338 -0
  244. package/src/client/native/ContextBody.module.css +161 -0
  245. package/src/client/native/ContextBody.tsx +591 -0
  246. package/src/client/native/ContextInjectionRow.module.css +62 -0
  247. package/src/client/native/ContextInjectionRow.tsx +72 -0
  248. package/src/client/native/ReferenceIcon.tsx +35 -0
  249. package/src/client/native/tool-call-model.ts +248 -0
  250. package/src/client/native/upstream.json +41 -0
  251. package/src/client/open-file.ts +94 -0
  252. package/src/client/pending-submission.ts +49 -0
  253. package/src/client/primitive-labels.ts +53 -0
  254. package/src/client/projection.ts +118 -0
  255. package/src/client/reasoning-follow.ts +12 -0
  256. package/src/client/settings-copy.ts +53 -0
  257. package/src/client/settings-slots.ts +20 -0
  258. package/src/client/settings.tsx +73 -0
  259. package/src/client/skill-status.ts +78 -0
  260. package/src/client/store.ts +30 -0
  261. package/src/client/stream-buffer.ts +100 -0
  262. package/src/client/streaming.tsx +62 -0
  263. package/src/client/style.d.ts +4 -0
  264. package/src/client/timeline.ts +77 -0
  265. package/src/client/tool-activity.ts +152 -0
  266. package/src/client/types.ts +66 -0
  267. package/src/client/waiting-clock.ts +25 -0
  268. package/src/client/word-motion.tsx +91 -0
  269. package/src/client/word-timeline.ts +96 -0
  270. package/src/dsh-better-display.ts +108 -0
  271. package/src/skill-roots.ts +138 -0
  272. package/src/skill-status.ts +81 -0
  273. package/tests/browser-closed-gap.tsx +20 -0
  274. package/tests/browser-motion.tsx +65 -0
  275. package/tests/browser-sticky-lanes.tsx +22 -0
  276. package/tests/browser-waiting-clock.tsx +14 -0
  277. package/tests/chat-flow-hook.test.ts +66 -0
  278. package/tests/cloud-gate.test.ts +34 -0
  279. package/tests/conversation-scroll.test.ts +47 -0
  280. package/tests/deliverables.test.ts +128 -0
  281. package/tests/entry.test.ts +42 -0
  282. package/tests/fixtures/maid-composer-hide.html +31 -0
  283. package/tests/fold-choreography.test.ts +38 -0
  284. package/tests/history-word-regression.test.ts +16 -0
  285. package/tests/live-turn.test.ts +218 -0
  286. package/tests/mcp-apps.test.ts +157 -0
  287. package/tests/message-chrome.test.ts +29 -0
  288. package/tests/open-file.test.ts +103 -0
  289. package/tests/pending-submission.test.ts +45 -0
  290. package/tests/projection.test.ts +184 -0
  291. package/tests/reasoning-follow.test.ts +34 -0
  292. package/tests/settings-copy.test.ts +63 -0
  293. package/tests/skill-status.test.ts +137 -0
  294. package/tests/stock-install.test.ts +50 -0
  295. package/tests/stream-buffer.test.ts +97 -0
  296. package/tests/timeline.test.ts +59 -0
  297. package/tests/waiting-clock.test.ts +24 -0
  298. package/tests/word-timeline.test.ts +136 -0
  299. package/tsconfig.json +11 -0
  300. package/tsdown.config.ts +49 -0
@@ -0,0 +1,317 @@
1
+ import { createContext, memo, useCallback, useContext, useEffect, useId, useMemo, useRef, useState } from 'react';
2
+ import {
3
+ getHostTheme,
4
+ getCssTokens,
5
+ extractHtmlTitle,
6
+ ensureHtmlDocument,
7
+ formatReceiptPrompt,
8
+ fillComposerDom,
9
+ } from './mcp-app.js';
10
+ import css from './McpAppFrame.module.css';
11
+
12
+ /**
13
+ * Composer fill channel shared by every McpAppFrame in one Reader tree.
14
+ * Provided by Blocks from the session-scoped Reader face (sanctioned
15
+ * conversation input API); absent outside a Reader, where the DOM fallback
16
+ * applies. React context avoids threading the callback through the whole
17
+ * markdown pipeline (MarkdownText -> render context -> code fence).
18
+ */
19
+ export type ComposerFill = (text: string) => boolean;
20
+ export const ComposerFillContext = createContext<ComposerFill | undefined>(undefined);
21
+ export function useComposerFill(): ComposerFill | undefined {
22
+ return useContext(ComposerFillContext);
23
+ }
24
+
25
+ export interface McpAppFrameProps {
26
+ html: string;
27
+ title?: string;
28
+ initialHeight?: number;
29
+ /** Session-scoped composer writer; falls back to context, then DOM. */
30
+ fillComposer?: ComposerFill;
31
+ }
32
+
33
+ export const McpAppFrame = memo(function McpAppFrame({
34
+ html,
35
+ title: initialTitle,
36
+ initialHeight = 240,
37
+ fillComposer: fillComposerProp,
38
+ }: McpAppFrameProps) {
39
+ const fillComposerFromContext = useComposerFill();
40
+ const writeComposer = useMemo<ComposerFill>(
41
+ () => fillComposerProp ?? fillComposerFromContext ?? fillComposerDom,
42
+ [fillComposerProp, fillComposerFromContext],
43
+ );
44
+ const iframeRef = useRef<HTMLIFrameElement>(null);
45
+ const lastParamsRef = useRef<Record<string, unknown>>({});
46
+ const [height, setHeight] = useState(() => Math.max(60, Math.min(2400, initialHeight)));
47
+ const [ready, setReady] = useState(false);
48
+ const [receipt, setReceipt] = useState<string | null>(null);
49
+ const [lastPrompt, setLastPrompt] = useState<string | null>(null);
50
+ const [reloadNonce, setReloadNonce] = useState(0);
51
+ const frameId = useId();
52
+
53
+ const title = useMemo(() => {
54
+ return initialTitle || extractHtmlTitle(html) || '交互式 MCP App';
55
+ }, [initialTitle, html]);
56
+
57
+ // Capture the host theme ONCE for the initial srcDoc. Live theme switches
58
+ // are delivered via postMessage (broadcastTheme), so the srcDoc identity
59
+ // stays stable and the iframe never reloads (which would wipe user state
60
+ // such as checked boxes or selected tabs).
61
+ const [initialTheme] = useState(getHostTheme);
62
+ const preparedHtml = useMemo(() => ensureHtmlDocument(html, initialTheme), [html, initialTheme]);
63
+
64
+ const fillComposer = useCallback((params: Record<string, unknown>) => {
65
+ const prompt = formatReceiptPrompt(params, title);
66
+ setLastPrompt(prompt);
67
+ try {
68
+ if (writeComposer(prompt)) return true;
69
+ // Composer refused: leave the prompt visible in the receipt bar and
70
+ // stash a clipboard copy as a fallback.
71
+ try {
72
+ void navigator.clipboard?.writeText(prompt);
73
+ } catch {
74
+ // Clipboard unavailable; the visible receipt text remains copyable.
75
+ }
76
+ } catch {
77
+ // Ignore DOM query errors in non-browser environments
78
+ }
79
+ return false;
80
+ }, [title, writeComposer]);
81
+
82
+ const handleUserSubmit = useCallback((params: Record<string, unknown>) => {
83
+ lastParamsRef.current = params;
84
+ let summary = '';
85
+ if (typeof params.choice === 'string') {
86
+ const desc = typeof params.desc === 'string' ? ` (${params.desc})` : '';
87
+ summary = `选择: ${params.choice}${desc}`;
88
+ } else if (typeof params.action === 'string') {
89
+ summary = `操作: ${params.action}${params.payload ? ` (${JSON.stringify(params.payload)})` : ''}`;
90
+ } else if (typeof params.selectedVariant === 'string') {
91
+ summary = `方案: ${params.selectedVariant}`;
92
+ } else {
93
+ summary = JSON.stringify(params);
94
+ }
95
+ setReceipt(summary);
96
+
97
+ // Populate DSH composer with natural prompt and trigger React input state
98
+ fillComposer(params);
99
+ }, [fillComposer]);
100
+
101
+ useEffect(() => {
102
+ const handleMessage = (event: MessageEvent) => {
103
+ const iframe = iframeRef.current;
104
+ if (!iframe || event.source !== iframe.contentWindow) return;
105
+
106
+ const data = event.data;
107
+ if (!data || typeof data !== 'object') return;
108
+
109
+ // Protocol SEP-1865 JSON-RPC 2.0
110
+ const currentTheme = getHostTheme();
111
+ const cssTokens = getCssTokens(currentTheme);
112
+
113
+ // 1. ui/initialize (View -> Host)
114
+ if (data.method === 'ui/initialize') {
115
+ const response = {
116
+ jsonrpc: '2.0',
117
+ id: data.id,
118
+ result: {
119
+ protocolVersion: '2026-01-26',
120
+ hostContext: {
121
+ theme: currentTheme,
122
+ locale: 'zh-CN',
123
+ styles: {
124
+ variables: cssTokens,
125
+ },
126
+ },
127
+ },
128
+ };
129
+ iframe.contentWindow?.postMessage(response, '*');
130
+ setReady(true);
131
+ return;
132
+ }
133
+
134
+ // 2. ui/ready or initialized notification
135
+ if (data.method === 'ui/ready' || data.method === 'ui/notifications/initialized') {
136
+ setReady(true);
137
+ return;
138
+ }
139
+
140
+ // 3. ui/resize
141
+ if (data.method === 'ui/resize' && data.params?.height) {
142
+ const h = Number(data.params.height);
143
+ if (Number.isFinite(h) && h > 0) {
144
+ setHeight(Math.max(60, Math.min(2400, Math.round(h))));
145
+ }
146
+ return;
147
+ }
148
+
149
+ // 4. ui/submit or ui/update-model-context
150
+ if (data.method === 'ui/submit' || data.method === 'ui/update-model-context') {
151
+ const params = (data.params as Record<string, unknown>) || {};
152
+ handleUserSubmit(params);
153
+ return;
154
+ }
155
+ };
156
+
157
+ window.addEventListener('message', handleMessage);
158
+
159
+ // Broadcast live theme changes to running iframe
160
+ const broadcastTheme = () => {
161
+ const newTheme = getHostTheme();
162
+ const tokens = getCssTokens(newTheme);
163
+ iframeRef.current?.contentWindow?.postMessage({
164
+ jsonrpc: '2.0',
165
+ method: 'ui/notifications/host-context-changed',
166
+ params: {
167
+ theme: newTheme,
168
+ styles: { variables: tokens },
169
+ },
170
+ }, '*');
171
+ };
172
+
173
+ let observer: MutationObserver | null = null;
174
+ if (typeof MutationObserver !== 'undefined' && typeof document !== 'undefined') {
175
+ observer = new MutationObserver(broadcastTheme);
176
+ if (document.body) {
177
+ observer.observe(document.body, { attributes: true, attributeFilter: ['data-ds-dark-theme', 'class', 'style', 'data-theme'] });
178
+ }
179
+ if (document.documentElement) {
180
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'class', 'style'] });
181
+ }
182
+ }
183
+
184
+ const media = typeof window !== 'undefined' && window.matchMedia ? window.matchMedia('(prefers-color-scheme: dark)') : null;
185
+ media?.addEventListener?.('change', broadcastTheme);
186
+
187
+ return () => {
188
+ window.removeEventListener('message', handleMessage);
189
+ observer?.disconnect();
190
+ media?.removeEventListener?.('change', broadcastTheme);
191
+ };
192
+ }, [handleUserSubmit]);
193
+
194
+ const handleFrameLoad = useCallback(() => {
195
+ const iframe = iframeRef.current;
196
+ if (!iframe) return;
197
+
198
+ // Proactive Host -> View initialize notification for boilerplate compatibility
199
+ const currentTheme = getHostTheme();
200
+ const cssTokens = getCssTokens(currentTheme);
201
+ iframe.contentWindow?.postMessage({
202
+ jsonrpc: '2.0',
203
+ method: 'ui/initialize',
204
+ params: {
205
+ theme: currentTheme,
206
+ locale: 'zh-CN',
207
+ styles: {
208
+ variables: cssTokens,
209
+ },
210
+ },
211
+ }, '*');
212
+
213
+ setReady(true);
214
+ }, []);
215
+
216
+ const handleReload = useCallback(() => {
217
+ setReloadNonce(n => n + 1);
218
+ setReady(false);
219
+ setReceipt(null);
220
+ }, []);
221
+
222
+ return (
223
+ <div className={css.card} data-mcp-app-card data-testid="mcp-app-card">
224
+ <div className={css.header}>
225
+ <div className={css.titleArea}>
226
+ <span className={css.icon} aria-hidden="true">
227
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
228
+ <rect width="18" height="18" x="3" y="3" rx="2" />
229
+ <path d="M3 9h18" />
230
+ <path d="M9 21V9" />
231
+ </svg>
232
+ </span>
233
+ <span className={css.title} title={title}>{title}</span>
234
+ </div>
235
+ <div className={css.actions}>
236
+ <button
237
+ type="button"
238
+ className={css.iconBtn}
239
+ onClick={handleReload}
240
+ title="重置组件状态"
241
+ aria-label="重置组件状态"
242
+ >
243
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
244
+ <path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
245
+ <path d="M3 3v5h5" />
246
+ <path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16" />
247
+ <path d="M16 16h5v5" />
248
+ </svg>
249
+ </button>
250
+ </div>
251
+ </div>
252
+
253
+ <div className={css.iframeWrapper} style={{ height: `${height}px` }}>
254
+ <iframe
255
+ key={`${frameId}-${reloadNonce}`}
256
+ ref={iframeRef}
257
+ className={css.iframe}
258
+ title={title}
259
+ srcDoc={preparedHtml}
260
+ sandbox="allow-scripts allow-forms"
261
+ referrerPolicy="no-referrer"
262
+ onLoad={handleFrameLoad}
263
+ />
264
+ </div>
265
+
266
+ {receipt && (
267
+ <div className={css.receipt} data-testid="mcp-app-receipt">
268
+ <span className={css.receiptSummary}>
269
+ <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
270
+ <polyline points="20 6 9 17 4 12" />
271
+ </svg>
272
+ <span>已就绪:{receipt}</span>
273
+ </span>
274
+ {lastPrompt && (
275
+ <div className={css.receiptPrompt} title={lastPrompt}>
276
+ {lastPrompt}
277
+ </div>
278
+ )}
279
+ <div className={css.receiptHint}>
280
+ <button
281
+ type="button"
282
+ className={css.sendKbd}
283
+ title="把这条结果重新填入输入框,然后回车发送"
284
+ onClick={() => {
285
+ fillComposer(lastParamsRef.current);
286
+ }}
287
+ >
288
+ <span>填入输入框</span>
289
+ <kbd>↵</kbd>
290
+ </button>
291
+ </div>
292
+ </div>
293
+ )}
294
+ </div>
295
+ );
296
+ });
297
+
298
+ /**
299
+ * Markdown code-fence mount point: picks the session composer writer from
300
+ * React context (provided by Blocks) without changing the markdown
301
+ * pipeline's signatures.
302
+ */
303
+ export function McpAppCodeBlock({ html, title, initialHeight }: {
304
+ html: string; title?: string; initialHeight?: number;
305
+ }) {
306
+ const fillComposer = useComposerFill();
307
+ return <McpAppFrame html={html} title={title} initialHeight={initialHeight} fillComposer={fillComposer} />;
308
+ }
309
+
310
+ export function StreamingMcpAppPlaceholder({ title }: { title?: string }) {
311
+ return (
312
+ <div className={css.streamingPlaceholder}>
313
+ <span className={css.pulseDot} aria-hidden="true" />
314
+ <span>正在生成交互组件{title ? `(${title})` : ''}...</span>
315
+ </div>
316
+ );
317
+ }
@@ -0,0 +1,329 @@
1
+ .root {
2
+ color: var(--dsw-alias-label-primary);
3
+ font-family: inherit;
4
+ font-size: 16px;
5
+ line-height: 28px;
6
+ padding: 16px calc(var(--dsh-composer-side-clearance, 16px) + 16px) 24px;
7
+ min-width: 0;
8
+ flex: 0 0 auto;
9
+ overflow-anchor: auto;
10
+ container-type: inline-size;
11
+ }
12
+ .column { max-width: var(--dsh-chat-content-width, 748px); width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; min-width: 0; }
13
+ .toolbar { position: sticky; top: 0; z-index: 9; display: flex; justify-content: flex-end; align-items: center; min-height: 32px; padding: 0; color: var(--dsw-alias-label-tertiary); font-size: 12px; background: var(--dsw-alias-bg-base); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
14
+ /* 吸顶带第一车道:左「正在处理」+ 右「自动折叠」共享同一 32px 水平基线 */
15
+ .turnProcessSticky { position: sticky; top: 0; z-index: 8; background: var(--dsw-alias-bg-base); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); min-height: 32px; display: flex; align-items: center; }
16
+ .turnProcessSticky .disclosureButton { min-height: 32px; }
17
+ /* 第二车道:折叠胶囊吸附在第一车道正下方,互不重叠 */
18
+ .textButton, .historyButton, .iconButton, .jump, .disclosureButton, .imageOpen, .dialogClose { font: inherit; cursor: pointer; }
19
+ .textButton { border: 0; background: transparent; color: var(--dsw-alias-label-secondary); padding: 2px 6px; border-radius: 6px; white-space: nowrap; }
20
+ .textButton:hover, .iconButton:hover, .disclosureButton:hover { background: var(--dsw-alias-interactive-bg-hover); }
21
+ .root button:focus-visible, .root summary:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: 3px; }
22
+ .turn { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
23
+ .turn + .turn { margin-top: 12px; }
24
+ .userCluster { display: flex; flex-direction: column; align-self: flex-end; align-items: flex-end; max-width: min(525px, 82%); gap: 8px; min-width: 0; margin-bottom: 4px; }
25
+ .userImages { display: flex; flex-direction: column; align-items: flex-end; max-width: 100%; min-width: 0; }
26
+ .userImages .imageFigure { align-self: flex-end; }
27
+ .user { align-self: flex-end; max-width: 100%; padding: 10px 16px; border-radius: 22px; background: var(--dsw-specific-bubble); color: var(--dsw-alias-label-primary); line-height: 24px; overflow-wrap: anywhere; box-sizing: border-box; }
28
+ .user .blocks { gap: 10px; }
29
+ .answer { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
30
+ .readingText { min-width: 0; }
31
+ .reasonPlain { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; color: inherit; }
32
+ .readingText button { min-width: 24px; min-height: 24px; }
33
+ .streamWord { display: inline-block; }
34
+ .streamInlineWord { display: inline; }
35
+ .streamWord, .streamInlineWord, .streamAtom { opacity: 1; filter: none; }
36
+ .streamAtom { min-width: 0; }
37
+ @media (prefers-reduced-motion: reduce) { .streamWord, .streamInlineWord, .streamAtom { opacity: 1 !important; filter: none !important; } }
38
+ .retiringContent { min-width: 0; }
39
+ .retiringContent[data-reader-retiring=retiring] { overflow: hidden; }
40
+ .mainFlow, .blocks { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
41
+ .mainFlow:empty, .blocks:empty { display: none; }
42
+ .blocks > :first-child { margin-top: 0; }
43
+ .blocks > :last-child { margin-bottom: 0; }
44
+ .blocks :global(.md-table-wide) { max-width: 100%; }
45
+ .disclosure { min-width: 0; }
46
+ .disclosureButton { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; border: 0; background: transparent; border-radius: 7px; color: var(--dsw-alias-label-tertiary); font-size: 14px; line-height: 24px; font-weight: 400; padding: 4px 6px; margin-left: -6px; text-align: left; }
47
+ .disclosure[data-reader-status-only] { display: flex; align-items: center; min-height: 32px; }
48
+ .statusText { display: inline-flex; min-width: 0; max-width: 100%; font-size: 14px; line-height: 24px; font-weight: 400; color: var(--dsw-alias-label-secondary); }
49
+ .srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
50
+ /* Transitions.dev — Thinking states, supplied by the user. Native DSH colors;
51
+ the hidden sizer shares this font and the short phases share a left edge. */
52
+ .think {
53
+ --think-swap: 150ms;
54
+ --think-gap: 50ms;
55
+ --think-distance: 8px;
56
+ --think-blur: 2px;
57
+ --think-shimmer: 2000ms;
58
+ --think-base: var(--dsw-alias-label-secondary);
59
+ --think-highlight: var(--dsw-alias-label-primary);
60
+ --think-ease: ease-in-out;
61
+ position: relative; display: inline-block; max-width: 100%; text-align: left;
62
+ }
63
+ .thinkSizer { display: block; visibility: hidden; white-space: nowrap; }
64
+ .thinkText {
65
+ position: absolute; top: 0; left: 0; right: 0; display: block;
66
+ color: var(--think-base); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
67
+ transform: translateY(0); filter: blur(0); opacity: 1;
68
+ transition: transform var(--think-swap) var(--think-ease), filter var(--think-swap) var(--think-ease), opacity var(--think-swap) var(--think-ease);
69
+ }
70
+ .think[data-reader-status-phase=running] .thinkText[data-reader-status-copy=current] { transition-delay: var(--think-gap); }
71
+ .think:not([data-reader-status-phase=idle]) .thinkText { will-change: transform, filter, opacity; }
72
+ @supports (background-clip: text) or (-webkit-background-clip: text) {
73
+ .think[data-active=true] .thinkText::before {
74
+ content: attr(data-text); position: absolute; inset: 0; pointer-events: none;
75
+ background-image: linear-gradient(90deg, transparent 0%, transparent 40%, var(--think-highlight) 50%, transparent 60%, transparent 100%);
76
+ background-size: 400% 100%; background-repeat: no-repeat;
77
+ -webkit-background-clip: text; background-clip: text;
78
+ color: transparent; -webkit-text-fill-color: transparent;
79
+ animation: thinkShimmer var(--think-shimmer) linear infinite;
80
+ }
81
+ }
82
+ @keyframes thinkShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0% 0; } }
83
+ .thinkText.isExit { transform: translateY(calc(var(--think-distance) * -1)); filter: blur(var(--think-blur)); opacity: 0; }
84
+ .thinkText.isEnterStart { transition: none; transform: translateY(var(--think-distance)); filter: blur(var(--think-blur)); opacity: 0; }
85
+ [data-motion=off] .thinkText { transition: none !important; transform: none !important; filter: none !important; opacity: 1 !important; }
86
+ [data-motion=off] .thinkText[data-reader-status-copy=outgoing] { display: none !important; }
87
+ [data-motion=off] .thinkText::before { display: none !important; }
88
+ @media (prefers-reduced-motion: reduce), (forced-colors: active) {
89
+ .thinkText { transition: none !important; transform: none !important; filter: none !important; opacity: 1 !important; }
90
+ .thinkText[data-reader-status-copy=outgoing] { display: none !important; }
91
+ .thinkText::before { display: none !important; }
92
+ }
93
+ .processMeta { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 260ms cubic-bezier(.22,1,.36,1), opacity 160ms ease-out; }
94
+ .processMeta[data-open=true] { grid-template-rows: 1fr; opacity: 1; }
95
+ .processMetaInner { min-height: 0; overflow: hidden; }
96
+ .processMetaLine { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; padding: 8px 0 0 16px; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
97
+ .processMetaLine .meta { color: inherit; }
98
+ .chevron { flex: none; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; transition: transform 260ms cubic-bezier(.22,1,.36,1); }
99
+ .chevron[data-open=true] { transform: rotate(90deg); }
100
+ .disclosureBody { overflow: hidden; height: 0; transform-origin: top center; will-change: height, opacity, transform; }
101
+ .processContents { display: flow-root; border-left: 1px solid var(--dsw-alias-border-l2); padding: 3px 0 2px 17px; margin: 0 0 0 6px; color: var(--dsw-alias-label-secondary); font-size: 14px; line-height: 24px; }
102
+ .processContents > :last-child { margin-bottom: 0; }
103
+ .processCommentary { color: var(--dsw-alias-label-secondary); font-size: 14px; line-height: 24px; margin: 4px 0 8px 6px; padding-left: 12px; border-left: 2px solid var(--dsw-alias-border-l2); }
104
+ .processFrame { min-width: 0; }
105
+ .toolActivity { min-width: 0; color: var(--dsw-alias-label-secondary); }
106
+ .nativeToolRow { min-width: 0; }
107
+ .rowSeparator { flex: none; width: 2px; height: 2px; margin: 0 8px; border-radius: 1px; background: var(--dsw-alias-label-caption); }
108
+ .nativeToolSummary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-tertiary); font-size: 14px; line-height: 24px; }
109
+ .nativeToolRow:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: 3px; border-radius: 4px; }
110
+ .toolHeading { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: start; gap: 10px; width: 100%; padding: 10px 14px 4px; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 11px; }
111
+ .toolHeading:hover { background: var(--dsw-alias-interactive-bg-hover); }
112
+ .toolHeading:focus-visible { outline-offset: -3px !important; }
113
+ .toolGlyph { display: flex; align-items: center; justify-content: center; height: 22px; color: var(--dsw-alias-label-secondary); }
114
+ .toolHeadingCopy { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
115
+ .toolTitle { font-size: 13px; line-height: 22px; font-weight: 500; overflow-wrap: anywhere; }
116
+ .toolTarget { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 19px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
117
+ .toolHeadingState { display: flex; align-items: center; gap: 7px; min-height: 22px; color: var(--dsw-alias-label-secondary); }
118
+ .toolState { flex: none; font-size: 11px; line-height: 18px; white-space: nowrap; margin-left: 8px; }
119
+ .toolState[data-phase=preparing], .toolState[data-phase=running] { color: var(--dsw-alias-state-business-primary); }
120
+ .toolState[data-phase=failed] { color: var(--dsw-alias-state-error-primary); }
121
+ .toolState[data-phase=interrupted] { color: inherit; opacity: .7; }
122
+ .toolLedger { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px 0; color: var(--dsw-alias-label-secondary); font-size: 11px; line-height: 18px; font-variant-numeric: tabular-nums; }
123
+ .toolEngine { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
124
+ .toolDetails { margin: 6px 0 0 22px; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; min-width: 0; overflow: hidden; }
125
+ .toolTabs { display: flex; align-items: center; gap: 15px; padding: 0 14px; }
126
+ .toolTabs > button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 10px 1px 8px; font: inherit; font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-secondary); cursor: pointer; }
127
+ .toolTabs > button[aria-selected=true] { color: var(--dsw-alias-label-primary); border-bottom-color: var(--dsw-alias-state-business-primary); }
128
+ .toolPanel { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; font-size: 13px; line-height: 22px; }
129
+ .toolPanel:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: -3px; }
130
+ .toolDetailNote { margin: 0 0 9px; font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
131
+ .toolRawLabel { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 12px; font-weight: 500; }
132
+ .toolRaw { margin: 0; max-height: 400px; padding: 12px; overflow: auto; border-radius: 8px; background: var(--dsw-alias-bg-module-platform); color: var(--dsw-alias-label-primary); font: 12px/20px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
133
+ .systemPrompt { margin: 0; max-height: 320px; padding: 12px; overflow: auto; border-radius: 8px; background: var(--dsw-alias-bg-module-platform); color: var(--dsw-alias-label-primary); font: 12px/20px ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
134
+ .commandInput { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
135
+ .toolReceipt .blocks, .toolDocument .blocks { font-size: 13px; line-height: 22px; }
136
+ .toolChildren { margin: 0 14px 12px 24px; padding-left: 12px; border-left: 1px solid var(--dsw-alias-border-l2); display: flex; flex-direction: column; gap: 9px; }
137
+ @container (max-width: 420px) { .toolHeading { gap: 7px; padding: 11px 10px 6px; grid-template-columns: 16px minmax(0, 1fr) auto; } .toolHeadingState { gap: 4px; } .toolLedger { padding-left: 33px; padding-right: 10px; } .toolPanel { padding: 10px; } .toolChildren { margin-left: 12px; padding-left: 8px; } }
138
+ @media (pointer: coarse) { .toolTabs > button { min-height: 44px; } }
139
+ /* Transitions.dev — Reasoning stream (user-supplied). Transform the one real
140
+ transcript; hand the painted offset to native scrolling for manual reading. */
141
+ .reasonCard {
142
+ --reason-preview-height: 224px;
143
+ --reason-hold: 840ms;
144
+ --reason-step: 500ms;
145
+ --reason-lines: 2;
146
+ --reason-fade: 28px;
147
+ --reason-ease: cubic-bezier(0.22, 1, 0.36, 1);
148
+ position: relative;
149
+ min-width: 0;
150
+ overflow: hidden;
151
+ border: 1px solid var(--dsw-alias-border-l2);
152
+ border-radius: 12px;
153
+ background: var(--dsw-alias-bg-module-platform);
154
+ scroll-margin-block: 16px calc(var(--dsh-composer-height, 152px) + 16px);
155
+ }
156
+ .reasonHeading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 16px 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; }
157
+ .reasonCard[data-overflow=false][data-expanded=false] { border-color: transparent; border-radius: 0; background: transparent; }
158
+ .reasonCard[data-overflow=false][data-expanded=false] .reasonHeading { padding: 0; }
159
+ .reasonCard[data-overflow=false][data-expanded=false] .reasonText { padding: 4px 0 0 22px; }
160
+ .reasonLabel { font-weight: 500; }
161
+ .reasonViewport {
162
+ position: relative;
163
+ max-height: var(--reason-preview-height);
164
+ overflow: auto;
165
+ scroll-behavior: auto;
166
+ overflow-anchor: none;
167
+ overscroll-behavior-y: contain;
168
+ scrollbar-width: thin;
169
+ scrollbar-color: var(--dsw-alias-border-l1) transparent;
170
+ }
171
+ .reasonCard[data-expanded=true] .reasonViewport { max-height: min(60vh, 560px, var(--reason-reading-height, 560px)); }
172
+ .reasonViewport[data-edges=both], .reasonCard[data-following=true][data-overflow=true] .reasonViewport {
173
+ -webkit-mask-image: linear-gradient(transparent 0, black var(--reason-fade), black calc(100% - var(--reason-fade)), transparent 100%);
174
+ mask-image: linear-gradient(transparent 0, black var(--reason-fade), black calc(100% - var(--reason-fade)), transparent 100%);
175
+ }
176
+ .reasonViewport[data-edges=top] {
177
+ -webkit-mask-image: linear-gradient(transparent 0, black var(--reason-fade), black 100%);
178
+ mask-image: linear-gradient(transparent 0, black var(--reason-fade), black 100%);
179
+ }
180
+ .reasonViewport[data-edges=bottom] {
181
+ -webkit-mask-image: linear-gradient(black 0, black calc(100% - var(--reason-fade)), transparent 100%);
182
+ mask-image: linear-gradient(black 0, black calc(100% - var(--reason-fade)), transparent 100%);
183
+ }
184
+ .reasonCard[data-expanded=true] .reasonViewport { -webkit-mask-image: none; mask-image: none; }
185
+ .reasonViewport:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary); outline-offset: -3px; }
186
+ .reasonTrack { position: relative; transform: translateY(0); }
187
+ .reasonCard[data-following=true] .reasonTrack { will-change: transform; }
188
+ .reasonText { padding: 8px 16px 16px; font-size: 14px; line-height: 24px; color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; }
189
+ .reasonText .readingText > div { font-size: inherit; line-height: inherit; color: inherit; }
190
+ .reasonFooter { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 10px 8px; font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
191
+ .reasonAction { display: inline-flex; justify-content: center; align-items: center; gap: 5px; min-height: 28px; padding: 4px 6px; border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; white-space: nowrap; }
192
+ .reasonAction:hover { background: var(--dsw-alias-interactive-bg-hover); }
193
+ .reasonAction:disabled { cursor: default; opacity: .65; }
194
+ .reasonAction svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
195
+ .reasonCaption { padding-left: 6px; }
196
+ @container (max-width: 480px) { .reasonCard { --reason-preview-height: 192px; } }
197
+ @media (pointer: coarse) { .reasonAction { min-height: 44px; } }
198
+ @media (prefers-reduced-motion: reduce) { .reasonTrack { transition: none !important; transform: none !important; will-change: auto !important; } }
199
+ @media (forced-colors: active) { .reasonViewport { -webkit-mask-image: none !important; mask-image: none !important; } }
200
+ .processItem, .tool { margin: 0 0 18px; min-width: 0; }
201
+ .processLabel { display: flex; align-items: baseline; gap: 12px; margin: 0 0 6px; color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 20px; }
202
+ .processFootnote { color: var(--dsw-alias-label-tertiary); margin: 14px 0 0; font-size: 12px; line-height: 20px; }
203
+ .detail { font-size: 13px; line-height: 22px; color: var(--dsw-alias-label-secondary); }
204
+ .detail > summary { cursor: pointer; padding: 3px 0; }
205
+ .detail[open] > summary { margin-bottom: 8px; }
206
+ .tool > .tool { margin: 10px 0 0 12px; }
207
+ .meta { font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-tertiary); }
208
+ .stopped { align-self: flex-start; border-radius: 6px; padding: 0 6px; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 18px; margin-top: 12px; }
209
+ .compactionRow { display: flex; flex-direction: column; align-items: center; margin: 16px 0; width: 100%; box-sizing: border-box; }
210
+ .compactionLine { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 18px; user-select: none; }
211
+ .compactionLine::before, .compactionLine::after { content: ''; flex: 1; height: 1px; background: var(--dsw-alias-border-l1); opacity: .7; }
212
+ .compactionPill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l1); color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 18px; font-family: inherit; }
213
+ .compactionButton { cursor: pointer; transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease; }
214
+ .compactionButton:hover { color: var(--dsw-alias-label-primary); border-color: var(--dsw-alias-border-l2); background: var(--dsw-alias-interactive-bg-hover); }
215
+ .compactionIcon { width: 12px; height: 12px; flex: none; opacity: .7; }
216
+ .compactionToggle { font-size: 10px; opacity: .8; margin-left: 2px; }
217
+ .compactionSummaryBox { margin-top: 10px; width: 100%; max-width: 680px; padding: 12px 16px; border-radius: 8px; background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l2); font-size: 12px; line-height: 20px; color: var(--dsw-alias-label-secondary); box-sizing: border-box; }
218
+ .compactionSummaryHeader { font-size: 11px; font-weight: 500; color: var(--dsw-alias-label-tertiary); margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px dashed var(--dsw-alias-border-l1); }
219
+ .notice, .error, .attention { border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
220
+ .notice { background: var(--dsw-alias-bg-module-platform); color: var(--dsw-alias-label-secondary); border: 1px solid var(--dsw-alias-border-l2); }
221
+ .error { display: flex; align-items: flex-start; gap: 10px; background: rgba(239, 68, 68, 0.06); border: 1px solid rgba(239, 68, 68, 0.22); color: var(--dsw-alias-label-primary); }
222
+ .errorIcon { width: 16px; height: 16px; flex: none; margin-top: 2px; color: #ef4444; }
223
+ .errorCopy { flex: 1; min-width: 0; }
224
+ .errorTitle { display: flex; align-items: center; gap: 8px; color: #dc2626; font-weight: 500; margin-bottom: 2px; }
225
+ .errorMessage { margin: 0; color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 18px; word-break: break-word; }
226
+ .errorCode { font-size: 11px; padding: 1px 5px; border-radius: 4px; background: rgba(239, 68, 68, 0.12); color: #dc2626; font-family: inherit; }
227
+ .attention { display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--dsw-alias-state-business-primary); color: var(--dsw-alias-label-primary); background: var(--dsw-alias-bg-base); }
228
+ .attention span { color: var(--dsw-alias-label-secondary); }
229
+ .unknown { background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l2); border-radius: 10px; padding: 12px 14px; font-size: 13px; line-height: 22px; }
230
+ .unknown p { margin: 0 0 6px; }
231
+ .historyButton { align-self: center; background: transparent; border: 1px solid var(--dsw-alias-border-l2); border-radius: 8px; padding: 4px 12px; font-size: 12px; color: var(--dsw-alias-label-secondary); }
232
+ .historyButton:disabled { opacity: .55; cursor: default; }
233
+ .empty { padding: 40px 0; color: var(--dsw-alias-label-tertiary); text-align: center; }
234
+ .answerActions { display: flex; align-items: center; gap: 8px; margin: 13px 0 0 -6px; min-height: 28px; }
235
+ .userActions { display: flex; align-items: center; gap: 8px; min-height: 28px; }
236
+ .messageClock { font-size: 13px; line-height: 24px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; font-variant-numeric: tabular-nums; }
237
+ .iconButton { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; padding: 6px; background: transparent; color: var(--dsw-alias-label-tertiary); }
238
+ .iconButton svg { fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
239
+ .imageFigure { margin: 0; max-width: 100%; width: min(100%, 360px); box-sizing: border-box; align-self: flex-start; }
240
+ .imageFrame { position: relative; border-radius: 12px; background: var(--dsw-alias-bg-module-platform); border: 1px solid var(--dsw-alias-border-l2); overflow: hidden; max-height: 440px; min-height: 96px; max-width: 100%; box-sizing: border-box; }
241
+ .imageOpen { border: 0; padding: 0; position: absolute; inset: 0; background: transparent; display: flex; width: 100%; height: 100%; }
242
+ .imageOpen img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity 200ms cubic-bezier(.4,0,.2,1); }
243
+ .imageOpen img[data-ready=true] { opacity: 1; }
244
+ .pendingImage { display: block; width: 100%; height: 100%; max-width: 100%; object-fit: contain; }
245
+ .imagePlaceholder { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 8px; color: var(--dsw-alias-label-tertiary); font-size: 13px; pointer-events: none; }
246
+ .imagePlaceholder button { pointer-events: auto; }
247
+ .imageFigure figcaption { color: var(--dsw-alias-label-tertiary); font-size: 12px; line-height: 20px; margin-top: 6px; overflow-wrap: anywhere; }
248
+ .imageDialog { border: 1px solid var(--dsw-alias-border-l2); padding: 38px 20px 20px; border-radius: 16px; background: var(--dsw-alias-bg-base); color: var(--dsw-alias-label-primary); max-width: 90vw; max-height: 90vh; }
249
+ .imageDialog::backdrop { background: var(--dsw-alias-bg-mask-photo); }
250
+ .imageDialog img { max-width: 82vw; max-height: 75vh; display: block; object-fit: contain; }
251
+ .dialogClose { position: absolute; right: 8px; top: 4px; border: 0; background: transparent; color: inherit; width: 32px; height: 32px; border-radius: 8px; font-size: 24px; }
252
+ .jumpDock { position: sticky; bottom: calc(var(--dsh-composer-height, 152px) + 16px); height: 0; z-index: 8; display: flex; justify-content: flex-end; pointer-events: none; }
253
+ .deliverablesRoot { display: grid; grid-template-columns: max-content minmax(0, 1fr); align-items: start; column-gap: 10px; margin-top: 14px; font-size: 13px; line-height: 22px; }
254
+ .deliverablesLabel { grid-column: 1; grid-row: 1; color: var(--dsw-alias-label-tertiary); font-size: 12px; padding-top: 2px; font-weight: 500; }
255
+ .deliverablesLane { grid-column: 2; grid-row: 1; min-width: 0; }
256
+ .deliverablesRow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
257
+ .deliverableChip { box-sizing: border-box; display: inline-flex; align-items: center; border: 1px solid var(--dsw-alias-border-l2); border-radius: 6px; background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease; overflow: hidden; }
258
+ .deliverableChip:hover { border-color: var(--dsw-alias-border-l3); background: var(--dsw-alias-bg-module-platform); box-shadow: 0 1px 4px var(--dsw-alias-border-l1); }
259
+ .deliverableChip[data-status=opened] { border-color: #10b981; background: rgba(16, 185, 129, 0.12); color: #059669; }
260
+ .chipMain { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; padding: 3px 6px 3px 8px; border: none; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left; }
261
+ .chipMain:hover { color: var(--dsw-alias-label-primary); }
262
+ .deliverableIcon, .statusIcon { width: 13px; height: 13px; flex: none; opacity: .8; }
263
+ .statusIcon { color: #10b981; }
264
+ .deliverableName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
265
+ .chipActions { display: inline-flex; align-items: center; gap: 2px; padding-right: 4px; border-left: 1px solid transparent; opacity: .65; transition: opacity 150ms ease, border-left-color 150ms ease; }
266
+ .deliverableChip:hover .chipActions { opacity: 1; border-left-color: var(--dsw-alias-border-l2); }
267
+ .chipActionBtn { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: none; border-radius: 4px; background: transparent; color: var(--dsw-alias-label-tertiary); cursor: pointer; transition: color 120ms ease, background-color 120ms ease; }
268
+ .chipActionBtn:hover { color: var(--dsw-alias-label-primary); background: var(--dsw-alias-interactive-bg-hover); }
269
+ .actionIcon { width: 12px; height: 12px; }
270
+ .deliverablesMore { font-size: 12px; color: var(--dsw-alias-label-tertiary); white-space: nowrap; }
271
+ .deliverablesShowFolder { border: 1px solid transparent; background: transparent; color: var(--dsw-alias-label-tertiary); font: inherit; font-size: 12px; cursor: pointer; padding: 2px 7px; border-radius: 5px; display: inline-flex; align-items: center; gap: 4px; transition: all 150ms ease; }
272
+ .deliverablesShowFolder:hover { color: var(--dsw-alias-state-business-primary); background: var(--dsw-alias-interactive-bg-hover); border-color: var(--dsw-alias-border-l2); }
273
+ .deliverablesShowFolder[data-status=opened] { color: #10b981; border-color: rgba(16, 185, 129, 0.3); background: rgba(16, 185, 129, 0.08); }
274
+ .morphCluster { display: flex; flex-direction: column; width: 100%; min-width: 0; }
275
+ .morphDrawer { overflow: hidden; height: 0; transform-origin: top center; will-change: height, opacity, transform; }
276
+ .liveFoldImpact { animation: liveFoldElastic 180ms cubic-bezier(0.2, 0, 0, 1) both; }
277
+ @keyframes liveFoldElastic { 0% { transform: scale(1); } 50% { transform: scale(1.015); } 100% { transform: scale(1); } }
278
+ .liveFoldContainer { position: sticky; top: 32px; z-index: 8; background: var(--dsw-alias-bg-base); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 4px 0; margin-bottom: 6px; animation: liveFoldPulse 320ms cubic-bezier(0.16, 1, 0.3, 1) both; transform-origin: left center; will-change: transform, opacity; }
279
+ @keyframes liveFoldPulse { 0% { transform: translateY(-4px) scale(0.98); opacity: 0.8; } 50% { transform: translateY(0) scale(1.02); opacity: 1; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
280
+ [data-motion=off] .liveFoldContainer { animation: none !important; }
281
+ @media (prefers-reduced-motion: reduce) { .liveFoldContainer { animation: none !important; } }
282
+ .priorFoldDrawer { display: flex; flex-direction: column; gap: 14px; min-width: 0; width: 100%; }
283
+ .jump { margin-top: -34px; flex: none; width: 34px; height: 34px; display: flex; justify-content: center; align-items: center; padding: 0; border: 0; border-radius: 100px; color: var(--dsw-alias-label-primary); background: var(--dsw-alias-button-floating-fill, var(--dsw-alias-bg-base)); box-shadow: var(--dsw-elevation-panel, 0 2px 8px var(--dsw-alias-border-l1)); pointer-events: auto; }
284
+ .jump:hover { background: var(--dsw-alias-button-floating-hover, var(--dsw-alias-interactive-bg-hover)); }
285
+ .foldSummary { display: inline-flex; align-items: baseline; white-space: nowrap !important; max-width: 100%; }
286
+ .foldSummaryPart { display: inline-flex; align-items: baseline; white-space: nowrap !important; }
287
+ .numberRollRoot { display: inline-flex; position: relative; overflow: hidden; vertical-align: baseline; line-height: inherit; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap !important; flex-shrink: 0; min-width: 1.45em; justify-content: center; text-align: center; }
288
+ .numberRollSizer { visibility: hidden; user-select: none; pointer-events: none; line-height: inherit; white-space: nowrap; }
289
+ .numberRollDigit { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; line-height: inherit; white-space: nowrap; }
290
+ .numberRollExit { animation: numberRollOut 240ms cubic-bezier(0.16, 1, 0.3, 1) forwards; }
291
+ .numberRollEnter { animation: numberRollIn 240ms cubic-bezier(0.16, 1, 0.3, 1) forwards; }
292
+ @keyframes numberRollOut { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-100%); opacity: 0; } }
293
+ @keyframes numberRollIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
294
+ [data-motion=off] .chevron, [data-motion=off] .imageOpen img, [data-motion=off] .processMeta, [data-motion=off] .numberRollDigit { transition: none !important; animation: none !important; }
295
+ @media (prefers-reduced-motion: reduce) { .chevron, .imageOpen img, .processMeta, .numberRollDigit { transition: none !important; animation: none !important; } }
296
+ .turnStatus { align-self: flex-start; flex: none; display: inline-flex; align-items: center; height: 26px; font-size: 14px; line-height: 22px; white-space: nowrap; margin: 4px 0 12px; padding: 0 4px; }
297
+ .turnStatusLabel { font-weight: 500; background: linear-gradient(90deg, var(--dsw-static-deepseek-500, #4d6bfe) 0%, var(--dsw-static-deepseek-500, #4d6bfe) 40%, var(--dsw-static-deepseek-200, #a8c7fa) 50%, var(--dsw-static-deepseek-500, #4d6bfe) 60%, var(--dsw-static-deepseek-500, #4d6bfe) 100%); background-position: 100% 0; background-size: 250% 100%; background-clip: text; color: transparent; -webkit-background-clip: text; -webkit-text-fill-color: transparent; animation: dsh-turn-status-shimmer 1.8s linear infinite; }
298
+ .turnStatusClock { margin-left: 8px; font-size: 13px; font-weight: 400; font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; color: var(--dsw-alias-label-caption, #86868b); -webkit-text-fill-color: var(--dsw-alias-label-caption, #86868b); }
299
+ @keyframes dsh-turn-status-shimmer { to { background-position: 0 0; } }
300
+ [data-motion=off] .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; }
301
+ @media (prefers-reduced-motion: reduce) { .turnStatusLabel { animation: none !important; color: var(--dsw-static-deepseek-500, #4d6bfe) !important; -webkit-text-fill-color: var(--dsw-static-deepseek-500, #4d6bfe) !important; } }
302
+ @media (pointer: coarse) { .disclosureButton { min-height: 44px; } }
303
+ @media (max-width: 600px) { .root { padding-inline: 20px; } .column { gap: 18px; } .toolbar { font-size: 11px; } .user { max-width: 90%; } }
304
+
305
+ /* Measured flow owns geometry; steps never change React parents when folded. */
306
+ .choreographedFlow { display: flex; flex-direction: column; min-width: 0; overflow-anchor: none; }
307
+ .flowCell { min-width: 0; overflow: clip; display: flow-root; }
308
+ .flowCell[hidden] { display: none; }
309
+ .flowCellInner { display: flex; flex-direction: column; min-width: 0; padding-bottom: 16px; }
310
+ /* A null-rendered ProcessFragment must contribute no cumulative row spacing. */
311
+ .flowCellInner:empty { padding-bottom: 0; }
312
+ .choreographedFlow[data-reader-transition=collapse] .flowCell * { animation-play-state: paused !important; }
313
+ .numberRollExit, .numberRollEnter { animation-duration: 160ms; }
314
+ .foldSummary { flex-wrap: wrap; white-space: normal !important; }
315
+ /* A flex item's intrinsic width must include its real label and chevron.
316
+ The previous shrink-to-fit + max-width chain clipped even four CJK glyphs. */
317
+ .toolbar { width: 100%; max-width: 100%; align-self: stretch; box-sizing: border-box; min-height: 40px; z-index: 7; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
318
+ .turnProcessSticky { box-sizing: border-box; width: calc(100% - var(--reader-control-width, 100px)); min-height: 40px; padding-right: 0; z-index: 8; border-bottom: 1px solid transparent; background-clip: padding-box; backdrop-filter: none; -webkit-backdrop-filter: none; }
319
+ /* The same summary row stays in flow until it reaches the measured top lane. */
320
+ .flowCell[data-flow-summary], .closedProcessSummary { position: sticky; top: max(var(--reader-toolbar-height, 40px), var(--reader-status-height, 40px)); z-index: 6; overflow: visible; box-sizing: border-box; min-height: 40px; padding-block: 4px; background: var(--dsw-alias-bg-base); border-bottom: 0; }
321
+ .flowCell[data-flow-summary] > .flowCellInner { padding-bottom: 0; }
322
+ .flowCell[data-flow-summary] .disclosureButton, .closedProcessSummary .disclosureButton { width: auto; max-width: 100%; }
323
+ .flowCell[data-flow-summary] .foldSummary, .closedProcessSummary .foldSummary { min-width: 0; }
324
+ .turnProcessSticky > .disclosure { flex: 1 1 auto; min-width: 0; }
325
+ .disclosureButton { width: max-content; max-width: calc(100% + 6px); }
326
+ .statusText { flex: 0 1 auto; }
327
+ .think { width: max-content; min-width: 0; }
328
+ .thinkSizer { white-space: normal; overflow-wrap: anywhere; }
329
+ .thinkText { white-space: normal; overflow-wrap: anywhere; overflow: visible; text-overflow: clip; }