dsh-tidy-display 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +270 -0
- package/DESIGN.md +72 -0
- package/LICENSE +24 -0
- package/README.en.md +118 -0
- package/README.md +118 -0
- package/THIRD_PARTY_NOTICES.md +65 -0
- package/compat/harness-rc2.json +99 -0
- package/cordis.patch.yml +5 -0
- package/cordis.yml +4 -0
- package/docs/official-rendering-bridge.md +65 -0
- package/docs/plans/2026-09-28-merge/checklist.md +21 -0
- package/docs/plans/2026-09-28-merge/findings.md +24 -0
- package/docs/plans/2026-09-28-merge/spec.md +61 -0
- package/docs/plans/2026-09-28-merge/tasks.md +34 -0
- package/dshx.yml +5 -0
- package/lib/client.js +50207 -0
- package/lib/client.js.map +1 -0
- package/lib/dsh-tidy-display.js +254 -0
- package/lib/types/client/Blocks.d.ts +49 -0
- package/lib/types/client/Blocks.d.ts.map +1 -0
- package/lib/types/client/Blocks.js +143 -0
- package/lib/types/client/Blocks.js.map +1 -0
- package/lib/types/client/ChoreographedFlow.d.ts +22 -0
- package/lib/types/client/ChoreographedFlow.d.ts.map +1 -0
- package/lib/types/client/ChoreographedFlow.js +218 -0
- package/lib/types/client/ChoreographedFlow.js.map +1 -0
- package/lib/types/client/ClosedProcessSummary.d.ts +9 -0
- package/lib/types/client/ClosedProcessSummary.d.ts.map +1 -0
- package/lib/types/client/ClosedProcessSummary.js +16 -0
- package/lib/types/client/ClosedProcessSummary.js.map +1 -0
- package/lib/types/client/DiffPanel.d.ts +13 -0
- package/lib/types/client/DiffPanel.d.ts.map +1 -0
- package/lib/types/client/DiffPanel.js +115 -0
- package/lib/types/client/DiffPanel.js.map +1 -0
- package/lib/types/client/LiveFold.d.ts +10 -0
- package/lib/types/client/LiveFold.d.ts.map +1 -0
- package/lib/types/client/LiveFold.js +39 -0
- package/lib/types/client/LiveFold.js.map +1 -0
- package/lib/types/client/McpAppFrame.d.ts +32 -0
- package/lib/types/client/McpAppFrame.d.ts.map +1 -0
- package/lib/types/client/McpAppFrame.js +193 -0
- package/lib/types/client/McpAppFrame.js.map +1 -0
- package/lib/types/client/OfficialContent.d.ts +25 -0
- package/lib/types/client/OfficialContent.d.ts.map +1 -0
- package/lib/types/client/OfficialContent.js +53 -0
- package/lib/types/client/OfficialContent.js.map +1 -0
- package/lib/types/client/Reader.d.ts +3 -0
- package/lib/types/client/Reader.d.ts.map +1 -0
- package/lib/types/client/Reader.js +508 -0
- package/lib/types/client/Reader.js.map +1 -0
- package/lib/types/client/ReasoningCard.d.ts +11 -0
- package/lib/types/client/ReasoningCard.d.ts.map +1 -0
- package/lib/types/client/ReasoningCard.js +322 -0
- package/lib/types/client/ReasoningCard.js.map +1 -0
- package/lib/types/client/SettingsSection.d.ts +59 -0
- package/lib/types/client/SettingsSection.d.ts.map +1 -0
- package/lib/types/client/SettingsSection.js +93 -0
- package/lib/types/client/SettingsSection.js.map +1 -0
- package/lib/types/client/StickyLane.d.ts +8 -0
- package/lib/types/client/StickyLane.d.ts.map +1 -0
- package/lib/types/client/StickyLane.js +39 -0
- package/lib/types/client/StickyLane.js.map +1 -0
- package/lib/types/client/TimelineRail.d.ts +10 -0
- package/lib/types/client/TimelineRail.d.ts.map +1 -0
- package/lib/types/client/TimelineRail.js +168 -0
- package/lib/types/client/TimelineRail.js.map +1 -0
- package/lib/types/client/ToolActivity.d.ts +17 -0
- package/lib/types/client/ToolActivity.d.ts.map +1 -0
- package/lib/types/client/ToolActivity.js +244 -0
- package/lib/types/client/ToolActivity.js.map +1 -0
- package/lib/types/client/TurnMetrics.d.ts +11 -0
- package/lib/types/client/TurnMetrics.d.ts.map +1 -0
- package/lib/types/client/TurnMetrics.js +44 -0
- package/lib/types/client/TurnMetrics.js.map +1 -0
- package/lib/types/client/WaitClock.d.ts +16 -0
- package/lib/types/client/WaitClock.d.ts.map +1 -0
- package/lib/types/client/WaitClock.js +29 -0
- package/lib/types/client/WaitClock.js.map +1 -0
- package/lib/types/client/WaitingClock.d.ts +15 -0
- package/lib/types/client/WaitingClock.d.ts.map +1 -0
- package/lib/types/client/WaitingClock.js +30 -0
- package/lib/types/client/WaitingClock.js.map +1 -0
- package/lib/types/client/WaitingStatus.d.ts +6 -0
- package/lib/types/client/WaitingStatus.d.ts.map +1 -0
- package/lib/types/client/WaitingStatus.js +9 -0
- package/lib/types/client/WaitingStatus.js.map +1 -0
- package/lib/types/client/conversation-scroll.d.ts +19 -0
- package/lib/types/client/conversation-scroll.d.ts.map +1 -0
- package/lib/types/client/conversation-scroll.js +25 -0
- package/lib/types/client/conversation-scroll.js.map +1 -0
- package/lib/types/client/deliverables.d.ts +24 -0
- package/lib/types/client/deliverables.d.ts.map +1 -0
- package/lib/types/client/deliverables.js +104 -0
- package/lib/types/client/deliverables.js.map +1 -0
- package/lib/types/client/entry-policy.d.ts +10 -0
- package/lib/types/client/entry-policy.d.ts.map +1 -0
- package/lib/types/client/entry-policy.js +24 -0
- package/lib/types/client/entry-policy.js.map +1 -0
- package/lib/types/client/entry.d.ts +4 -0
- package/lib/types/client/entry.d.ts.map +1 -0
- package/lib/types/client/entry.js +34 -0
- package/lib/types/client/entry.js.map +1 -0
- package/lib/types/client/fold-choreography.d.ts +40 -0
- package/lib/types/client/fold-choreography.d.ts.map +1 -0
- package/lib/types/client/fold-choreography.js +48 -0
- package/lib/types/client/fold-choreography.js.map +1 -0
- package/lib/types/client/fold-intensity.d.ts +11 -0
- package/lib/types/client/fold-intensity.d.ts.map +1 -0
- package/lib/types/client/fold-intensity.js +32 -0
- package/lib/types/client/fold-intensity.js.map +1 -0
- package/lib/types/client/index.d.ts +7 -0
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js +234 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/live-turn.d.ts +58 -0
- package/lib/types/client/live-turn.d.ts.map +1 -0
- package/lib/types/client/live-turn.js +144 -0
- package/lib/types/client/live-turn.js.map +1 -0
- package/lib/types/client/markdown/MarkdownText.d.ts +41 -0
- package/lib/types/client/markdown/MarkdownText.d.ts.map +1 -0
- package/lib/types/client/markdown/MarkdownText.js +178 -0
- package/lib/types/client/markdown/MarkdownText.js.map +1 -0
- package/lib/types/client/markdown/cjkFriendlyStrong.d.ts +9 -0
- package/lib/types/client/markdown/cjkFriendlyStrong.d.ts.map +1 -0
- package/lib/types/client/markdown/cjkFriendlyStrong.js +73 -0
- package/lib/types/client/markdown/cjkFriendlyStrong.js.map +1 -0
- package/lib/types/client/markdown/incremental.d.ts +69 -0
- package/lib/types/client/markdown/incremental.d.ts.map +1 -0
- package/lib/types/client/markdown/incremental.js +108 -0
- package/lib/types/client/markdown/incremental.js.map +1 -0
- package/lib/types/client/markdown/katex.d.ts +27 -0
- package/lib/types/client/markdown/katex.d.ts.map +1 -0
- package/lib/types/client/markdown/katex.js +88 -0
- package/lib/types/client/markdown/katex.js.map +1 -0
- package/lib/types/client/markdown/mathCompatibility.d.ts +11 -0
- package/lib/types/client/markdown/mathCompatibility.d.ts.map +1 -0
- package/lib/types/client/markdown/mathCompatibility.js +295 -0
- package/lib/types/client/markdown/mathCompatibility.js.map +1 -0
- package/lib/types/client/markdown/parse.d.ts +25 -0
- package/lib/types/client/markdown/parse.d.ts.map +1 -0
- package/lib/types/client/markdown/parse.js +42 -0
- package/lib/types/client/markdown/parse.js.map +1 -0
- package/lib/types/client/markdown/render.d.ts +121 -0
- package/lib/types/client/markdown/render.d.ts.map +1 -0
- package/lib/types/client/markdown/render.js +452 -0
- package/lib/types/client/markdown/render.js.map +1 -0
- package/lib/types/client/mcp-app.d.ts +50 -0
- package/lib/types/client/mcp-app.d.ts.map +1 -0
- package/lib/types/client/mcp-app.js +328 -0
- package/lib/types/client/mcp-app.js.map +1 -0
- package/lib/types/client/message-chrome.d.ts +19 -0
- package/lib/types/client/message-chrome.d.ts.map +1 -0
- package/lib/types/client/message-chrome.js +42 -0
- package/lib/types/client/message-chrome.js.map +1 -0
- package/lib/types/client/motion.d.ts +38 -0
- package/lib/types/client/motion.d.ts.map +1 -0
- package/lib/types/client/motion.js +453 -0
- package/lib/types/client/motion.js.map +1 -0
- package/lib/types/client/native/ContextBody.d.ts +130 -0
- package/lib/types/client/native/ContextBody.d.ts.map +1 -0
- package/lib/types/client/native/ContextBody.js +398 -0
- package/lib/types/client/native/ContextBody.js.map +1 -0
- package/lib/types/client/native/ContextInjectionRow.d.ts +35 -0
- package/lib/types/client/native/ContextInjectionRow.d.ts.map +1 -0
- package/lib/types/client/native/ContextInjectionRow.js +42 -0
- package/lib/types/client/native/ContextInjectionRow.js.map +1 -0
- package/lib/types/client/native/ReferenceIcon.d.ts +16 -0
- package/lib/types/client/native/ReferenceIcon.d.ts.map +1 -0
- package/lib/types/client/native/ReferenceIcon.js +16 -0
- package/lib/types/client/native/ReferenceIcon.js.map +1 -0
- package/lib/types/client/native/tool-call-model.d.ts +58 -0
- package/lib/types/client/native/tool-call-model.d.ts.map +1 -0
- package/lib/types/client/native/tool-call-model.js +219 -0
- package/lib/types/client/native/tool-call-model.js.map +1 -0
- package/lib/types/client/native/tool-update.d.ts +23 -0
- package/lib/types/client/native/tool-update.d.ts.map +1 -0
- package/lib/types/client/native/tool-update.js +22 -0
- package/lib/types/client/native/tool-update.js.map +1 -0
- package/lib/types/client/official-slots.d.ts +71 -0
- package/lib/types/client/official-slots.d.ts.map +1 -0
- package/lib/types/client/official-slots.js +183 -0
- package/lib/types/client/official-slots.js.map +1 -0
- package/lib/types/client/open-file.d.ts +29 -0
- package/lib/types/client/open-file.d.ts.map +1 -0
- package/lib/types/client/open-file.js +71 -0
- package/lib/types/client/open-file.js.map +1 -0
- package/lib/types/client/pending-submission.d.ts +28 -0
- package/lib/types/client/pending-submission.d.ts.map +1 -0
- package/lib/types/client/pending-submission.js +28 -0
- package/lib/types/client/pending-submission.js.map +1 -0
- package/lib/types/client/platform-media.d.ts +6 -0
- package/lib/types/client/platform-media.d.ts.map +1 -0
- package/lib/types/client/platform-media.js +18 -0
- package/lib/types/client/platform-media.js.map +1 -0
- package/lib/types/client/primitive-labels.d.ts +10 -0
- package/lib/types/client/primitive-labels.d.ts.map +1 -0
- package/lib/types/client/primitive-labels.js +38 -0
- package/lib/types/client/primitive-labels.js.map +1 -0
- package/lib/types/client/projection.d.ts +41 -0
- package/lib/types/client/projection.d.ts.map +1 -0
- package/lib/types/client/projection.js +112 -0
- package/lib/types/client/projection.js.map +1 -0
- package/lib/types/client/rail/RailView.d.ts +24 -0
- package/lib/types/client/rail/RailView.d.ts.map +1 -0
- package/lib/types/client/rail/RailView.js +540 -0
- package/lib/types/client/rail/RailView.js.map +1 -0
- package/lib/types/client/rail/colors.d.ts +43 -0
- package/lib/types/client/rail/colors.d.ts.map +1 -0
- package/lib/types/client/rail/colors.js +223 -0
- package/lib/types/client/rail/colors.js.map +1 -0
- package/lib/types/client/reasoning-follow.d.ts +10 -0
- package/lib/types/client/reasoning-follow.d.ts.map +1 -0
- package/lib/types/client/reasoning-follow.js +21 -0
- package/lib/types/client/reasoning-follow.js.map +1 -0
- package/lib/types/client/resource-address.d.ts +3 -0
- package/lib/types/client/resource-address.d.ts.map +1 -0
- package/lib/types/client/resource-address.js +33 -0
- package/lib/types/client/resource-address.js.map +1 -0
- package/lib/types/client/settings-copy.d.ts +7 -0
- package/lib/types/client/settings-copy.d.ts.map +1 -0
- package/lib/types/client/settings-copy.js +85 -0
- package/lib/types/client/settings-copy.js.map +1 -0
- package/lib/types/client/settings-slots.d.ts +34 -0
- package/lib/types/client/settings-slots.d.ts.map +1 -0
- package/lib/types/client/settings-slots.js +2 -0
- package/lib/types/client/settings-slots.js.map +1 -0
- package/lib/types/client/settings.d.ts +4 -0
- package/lib/types/client/settings.d.ts.map +1 -0
- package/lib/types/client/settings.js +60 -0
- package/lib/types/client/settings.js.map +1 -0
- package/lib/types/client/skill-status.d.ts +25 -0
- package/lib/types/client/skill-status.d.ts.map +1 -0
- package/lib/types/client/skill-status.js +44 -0
- package/lib/types/client/skill-status.js.map +1 -0
- package/lib/types/client/store.d.ts +66 -0
- package/lib/types/client/store.d.ts.map +1 -0
- package/lib/types/client/store.js +61 -0
- package/lib/types/client/store.js.map +1 -0
- package/lib/types/client/stream-buffer.d.ts +37 -0
- package/lib/types/client/stream-buffer.d.ts.map +1 -0
- package/lib/types/client/stream-buffer.js +150 -0
- package/lib/types/client/stream-buffer.js.map +1 -0
- package/lib/types/client/streaming.d.ts +18 -0
- package/lib/types/client/streaming.d.ts.map +1 -0
- package/lib/types/client/streaming.js +84 -0
- package/lib/types/client/streaming.js.map +1 -0
- package/lib/types/client/timeline.d.ts +26 -0
- package/lib/types/client/timeline.d.ts.map +1 -0
- package/lib/types/client/timeline.js +48 -0
- package/lib/types/client/timeline.js.map +1 -0
- package/lib/types/client/tool-activity.d.ts +98 -0
- package/lib/types/client/tool-activity.d.ts.map +1 -0
- package/lib/types/client/tool-activity.js +301 -0
- package/lib/types/client/tool-activity.js.map +1 -0
- package/lib/types/client/types.d.ts +91 -0
- package/lib/types/client/types.d.ts.map +1 -0
- package/lib/types/client/types.js +2 -0
- package/lib/types/client/types.js.map +1 -0
- package/lib/types/client/waiting-clock.d.ts +49 -0
- package/lib/types/client/waiting-clock.d.ts.map +1 -0
- package/lib/types/client/waiting-clock.js +80 -0
- package/lib/types/client/waiting-clock.js.map +1 -0
- package/lib/types/client/word-motion.d.ts +16 -0
- package/lib/types/client/word-motion.d.ts.map +1 -0
- package/lib/types/client/word-motion.js +90 -0
- package/lib/types/client/word-motion.js.map +1 -0
- package/lib/types/client/word-timeline.d.ts +32 -0
- package/lib/types/client/word-timeline.d.ts.map +1 -0
- package/lib/types/client/word-timeline.js +119 -0
- package/lib/types/client/word-timeline.js.map +1 -0
- package/lib/types/dsh-tidy-display.d.ts +17 -0
- package/lib/types/dsh-tidy-display.d.ts.map +1 -0
- package/lib/types/dsh-tidy-display.js +97 -0
- package/lib/types/dsh-tidy-display.js.map +1 -0
- package/lib/types/skill-roots.d.ts +22 -0
- package/lib/types/skill-roots.d.ts.map +1 -0
- package/lib/types/skill-roots.js +126 -0
- package/lib/types/skill-roots.js.map +1 -0
- package/lib/types/skill-status.d.ts +36 -0
- package/lib/types/skill-status.d.ts.map +1 -0
- package/lib/types/skill-status.js +51 -0
- package/lib/types/skill-status.js.map +1 -0
- package/package.json +141 -0
- package/scripts/build-motion-fixture.mjs +26 -0
- package/scripts/check-harness-compat.mjs +75 -0
- package/scripts/link-harness-dependencies.mjs +54 -0
- package/scripts/verify-auto-fold.mjs +114 -0
- package/scripts/verify-official-bridge.mjs +121 -0
- package/scripts/verify-tool-shimmer.mjs +62 -0
- package/skills/generative-mcpapps/SKILL.md +47 -0
- package/skills/generative-mcpapps/examples/interactive_quiz.html +153 -0
- package/skills/generative-mcpapps/references/html_boilerplate.md +122 -0
- package/skills/generative-mcpapps/references/sep1865_protocol.md +54 -0
- package/src/client/Blocks.tsx +213 -0
- package/src/client/ChoreographedFlow.tsx +232 -0
- package/src/client/ClosedProcessSummary.tsx +23 -0
- package/src/client/DiffPanel.tsx +124 -0
- package/src/client/LiveFold.tsx +43 -0
- package/src/client/McpAppFrame.module.css +210 -0
- package/src/client/McpAppFrame.tsx +317 -0
- package/src/client/OfficialContent.tsx +69 -0
- package/src/client/Reader.module.css +714 -0
- package/src/client/Reader.tsx +783 -0
- package/src/client/ReasoningCard.tsx +306 -0
- package/src/client/SettingsSection.module.css +184 -0
- package/src/client/SettingsSection.tsx +391 -0
- package/src/client/StickyLane.tsx +34 -0
- package/src/client/ToolActivity.tsx +274 -0
- package/src/client/TurnMetrics.module.css +139 -0
- package/src/client/TurnMetrics.tsx +160 -0
- package/src/client/WaitClock.tsx +33 -0
- package/src/client/WaitingStatus.tsx +13 -0
- package/src/client/conversation-scroll.ts +28 -0
- package/src/client/deliverables.ts +122 -0
- package/src/client/entry-policy.ts +20 -0
- package/src/client/entry.tsx +40 -0
- package/src/client/fold-choreography.ts +55 -0
- package/src/client/fold-intensity.ts +36 -0
- package/src/client/index.tsx +268 -0
- package/src/client/live-turn.ts +155 -0
- package/src/client/markdown/MarkdownText.module.css +304 -0
- package/src/client/markdown/MarkdownText.tsx +195 -0
- package/src/client/markdown/cjkFriendlyStrong.ts +84 -0
- package/src/client/markdown/incremental.ts +131 -0
- package/src/client/markdown/katex.tsx +91 -0
- package/src/client/markdown/mathCompatibility.ts +352 -0
- package/src/client/markdown/parse.ts +45 -0
- package/src/client/markdown/render.tsx +647 -0
- package/src/client/markdown/upstream.json +14 -0
- package/src/client/mcp-app.ts +323 -0
- package/src/client/message-chrome.ts +47 -0
- package/src/client/motion.tsx +410 -0
- package/src/client/native/ContextBody.module.css +161 -0
- package/src/client/native/ContextBody.tsx +591 -0
- package/src/client/native/ContextInjectionRow.module.css +66 -0
- package/src/client/native/ContextInjectionRow.tsx +106 -0
- package/src/client/native/ReferenceIcon.tsx +35 -0
- package/src/client/native/tool-call-model.ts +248 -0
- package/src/client/native/tool-update.ts +32 -0
- package/src/client/native/upstream.json +41 -0
- package/src/client/official-slots.tsx +211 -0
- package/src/client/open-file.ts +94 -0
- package/src/client/pending-submission.ts +49 -0
- package/src/client/platform-media.ts +17 -0
- package/src/client/primitive-labels.ts +54 -0
- package/src/client/projection.ts +118 -0
- package/src/client/rail/RailView.tsx +508 -0
- package/src/client/rail/colors.ts +212 -0
- package/src/client/reasoning-follow.ts +28 -0
- package/src/client/settings-copy.ts +128 -0
- package/src/client/settings-slots.ts +27 -0
- package/src/client/settings.tsx +73 -0
- package/src/client/skill-status.ts +78 -0
- package/src/client/store.ts +130 -0
- package/src/client/stream-buffer.ts +136 -0
- package/src/client/streaming.tsx +70 -0
- package/src/client/style.d.ts +4 -0
- package/src/client/timeline.ts +75 -0
- package/src/client/tool-activity.ts +298 -0
- package/src/client/types.ts +89 -0
- package/src/client/waiting-clock.ts +83 -0
- package/src/client/word-motion.tsx +92 -0
- package/src/client/word-timeline.ts +113 -0
- package/src/dsh-tidy-display.ts +112 -0
- package/src/skill-roots.ts +138 -0
- package/src/skill-status.ts +81 -0
- package/tests/browser-auto-fold.tsx +64 -0
- package/tests/browser-closed-gap.tsx +20 -0
- package/tests/browser-motion.tsx +65 -0
- package/tests/browser-official-bridge.tsx +152 -0
- package/tests/browser-sticky-lanes.tsx +22 -0
- package/tests/browser-waiting-clock.tsx +14 -0
- package/tests/chat-flow-hook.test.ts +66 -0
- package/tests/cloud-gate.test.ts +34 -0
- package/tests/context-tool-update.test.ts +33 -0
- package/tests/conversation-scroll.test.ts +47 -0
- package/tests/deliverables.test.ts +128 -0
- package/tests/entry.test.ts +42 -0
- package/tests/fixtures/maid-composer-hide.html +31 -0
- package/tests/fold-choreography.test.ts +54 -0
- package/tests/fold-intensity.test.ts +93 -0
- package/tests/footer-precedence.test.ts +129 -0
- package/tests/history-word-regression.test.ts +16 -0
- package/tests/live-turn.test.ts +218 -0
- package/tests/mcp-apps.test.ts +157 -0
- package/tests/message-chrome.test.ts +29 -0
- package/tests/official-slots.test.ts +112 -0
- package/tests/open-file.test.ts +114 -0
- package/tests/pending-submission.test.ts +45 -0
- package/tests/platform-media.test.ts +23 -0
- package/tests/projection.test.ts +184 -0
- package/tests/reasoning-follow.test.ts +34 -0
- package/tests/settings-copy.test.ts +63 -0
- package/tests/skill-status.test.ts +140 -0
- package/tests/stock-install.test.ts +58 -0
- package/tests/stream-buffer.test.ts +102 -0
- package/tests/timeline.test.ts +59 -0
- package/tests/tool-diff.test.ts +57 -0
- package/tests/waiting-clock.test.ts +83 -0
- package/tests/word-timeline.test.ts +146 -0
- package/tsconfig.json +11 -0
- package/tsdown.config.ts +51 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { readFileSync } from 'node:fs';
|
|
4
|
+
import { dirname, resolve } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import {
|
|
7
|
+
FOLD_INTENSITY_DEFAULT,
|
|
8
|
+
autoFoldFromIntensity,
|
|
9
|
+
foldIntensityOf,
|
|
10
|
+
frostedGlassOf,
|
|
11
|
+
processOnlyFromIntensity,
|
|
12
|
+
} from '../src/client/fold-intensity.ts';
|
|
13
|
+
import { presentLiveTurn } from '../src/client/live-turn.ts';
|
|
14
|
+
import type { LiveStep } from '../src/client/live-turn.ts';
|
|
15
|
+
import { en, zh } from '../src/client/settings-copy.ts';
|
|
16
|
+
|
|
17
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
18
|
+
const reasoning = (n: number): LiveStep => ({ kind: 'reasoning', key: `r${n}`, nodeKey: `n${n}`, start: 0, blocks: [], step: n });
|
|
19
|
+
const body: LiveStep = { kind: 'body', key: 'b1', nodeKey: 'n1', start: 1, blocks: [{ kind: 'text', text: 'answer' }], step: 1 };
|
|
20
|
+
const tool: LiveStep = {
|
|
21
|
+
kind: 'tool',
|
|
22
|
+
key: 't1',
|
|
23
|
+
entry: {
|
|
24
|
+
kind: 'tool',
|
|
25
|
+
key: 't1',
|
|
26
|
+
callId: 'c1',
|
|
27
|
+
step: 0,
|
|
28
|
+
order: 0,
|
|
29
|
+
draft: { kind: 'tool-call', callId: 'c1', name: 'read', argsRaw: '{"path":"Reader.tsx"}' },
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
const open = { status: 'open' } as const;
|
|
33
|
+
|
|
34
|
+
test('fold intensity defaults to standard (1) and glass defaults off', () => {
|
|
35
|
+
assert.equal(FOLD_INTENSITY_DEFAULT, 1);
|
|
36
|
+
assert.equal(foldIntensityOf(undefined), 1);
|
|
37
|
+
assert.equal(foldIntensityOf({}), 1);
|
|
38
|
+
assert.equal(frostedGlassOf(undefined), false);
|
|
39
|
+
assert.equal(frostedGlassOf({}), false);
|
|
40
|
+
assert.equal(frostedGlassOf({ frostedGlass: false }), false);
|
|
41
|
+
assert.equal(frostedGlassOf({ frostedGlass: true }), true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('fold slider maps 0/1/2 and migrates older persist flags', () => {
|
|
45
|
+
assert.equal(foldIntensityOf({ foldIntensity: 0 }), 0);
|
|
46
|
+
assert.equal(foldIntensityOf({ foldIntensity: 1 }), 1);
|
|
47
|
+
assert.equal(foldIntensityOf({ foldIntensity: 2 }), 2);
|
|
48
|
+
assert.equal(foldIntensityOf({ autoFold: false }), 0);
|
|
49
|
+
assert.equal(foldIntensityOf({ processOnly: true }), 2);
|
|
50
|
+
assert.equal(foldIntensityOf({ autoFold: true, processOnly: false }), 1);
|
|
51
|
+
assert.equal(autoFoldFromIntensity(0), false);
|
|
52
|
+
assert.equal(autoFoldFromIntensity(1), true);
|
|
53
|
+
assert.equal(autoFoldFromIntensity(2), true);
|
|
54
|
+
assert.equal(processOnlyFromIntensity(0), false);
|
|
55
|
+
assert.equal(processOnlyFromIntensity(1), false);
|
|
56
|
+
assert.equal(processOnlyFromIntensity(2), true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('autoFold false keeps every step open; autoFold true is current-main fold-on-next-reasoning', () => {
|
|
60
|
+
const steps = [reasoning(1), body, tool, reasoning(2)];
|
|
61
|
+
const none = presentLiveTurn(steps, open, false);
|
|
62
|
+
assert.equal(none.some(item => item.kind === 'fold'), false);
|
|
63
|
+
assert.deepEqual(none.map(item => item.key), ['r1', 'b1', 't1', 'r2']);
|
|
64
|
+
|
|
65
|
+
const standard = presentLiveTurn(steps, open, true);
|
|
66
|
+
assert.equal(standard[0]?.kind, 'fold');
|
|
67
|
+
if (standard[0]?.kind !== 'fold') throw new Error('expected standard fold');
|
|
68
|
+
assert.deepEqual(standard[0].steps.map(step => step.key), ['r1', 'b1', 't1']);
|
|
69
|
+
assert.deepEqual(standard.filter(item => item.kind === 'open').map(item => item.key), ['r2']);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test('root reader store persists glass off and standard fold on dsh.reader.v1', () => {
|
|
73
|
+
const store = readFileSync(resolve(root, 'src/client/store.ts'), 'utf8');
|
|
74
|
+
assert.match(store, /persist:\s*'dsh\.reader\.v1'/);
|
|
75
|
+
assert.match(store, /frostedGlass:\s*false/);
|
|
76
|
+
assert.match(store, /foldIntensity:\s*FOLD_INTENSITY_DEFAULT/);
|
|
77
|
+
assert.match(store, /deliverableOpenMode:\s*'external'/);
|
|
78
|
+
assert.match(store, /setFrostedGlass/);
|
|
79
|
+
assert.match(store, /setFoldIntensity/);
|
|
80
|
+
assert.match(store, /setDeliverableOpenMode/);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('settings copy names fold switch and glass without leaking home paths', () => {
|
|
84
|
+
for (const copy of [en, zh]) {
|
|
85
|
+
assert.match(copy.glassTitle, /毛玻璃|Frosted glass/i);
|
|
86
|
+
assert.match(copy.foldTitle, /折叠|fold/i);
|
|
87
|
+
assert.doesNotMatch(Object.values(copy).join('\n'), /\/Users\/|\$HOME\b/);
|
|
88
|
+
}
|
|
89
|
+
const reader = readFileSync(resolve(root, 'src/client/Reader.tsx'), 'utf8');
|
|
90
|
+
assert.match(reader, /data-reader-glass=\{frostedGlass/);
|
|
91
|
+
assert.match(reader, /data-reader-auto-fold=\{autoFold/);
|
|
92
|
+
assert.doesNotMatch(reader, /setProcessOnly/);
|
|
93
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, resolve } from 'node:path';
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
8
|
+
const css = readFileSync(resolve(root, 'src/client/Reader.module.css'), 'utf8');
|
|
9
|
+
const bundle = readFileSync(resolve(root, 'lib/client.js'), 'utf8');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Host ConversationRoot owns the footer band: `.composerSeat` is `position:
|
|
13
|
+
* sticky; bottom: 0; z-index: 7`, its own markdown code banner is 6 and the
|
|
14
|
+
* floating controls are 8. A scrolling reader clamps every turn-level sticky
|
|
15
|
+
* lane down into that band (the lane stops at its containing block's bottom,
|
|
16
|
+
* which passes behind the input card), so a lane at 7 or above paints the
|
|
17
|
+
* reader's own opaque plate over the composer. Everything the reader pins
|
|
18
|
+
* inside the transcript therefore has to stay strictly below 7.
|
|
19
|
+
*/
|
|
20
|
+
const HOST_FOOTER_Z = 7;
|
|
21
|
+
|
|
22
|
+
/** Lanes a scroll can clamp into the footer band. */
|
|
23
|
+
const CLAMPED_LANES = [
|
|
24
|
+
'.turnProcessSticky',
|
|
25
|
+
'.liveFoldContainer',
|
|
26
|
+
'.flowCell[data-flow-summary]',
|
|
27
|
+
'.closedProcessSummary',
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
/** The one lane allowed at 7: it pins to the scrollport's first lane and can never reach the band. */
|
|
31
|
+
const TOP_LANE = '.toolbar';
|
|
32
|
+
|
|
33
|
+
function mergedDeclarations(source: string, selector: string, { hashed = false } = {}): Map<string, string> {
|
|
34
|
+
const declarations = new Map<string, string>();
|
|
35
|
+
const body = source.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
36
|
+
const rule = /([^{}]+)\{([^{}]*)\}/g;
|
|
37
|
+
let match: RegExpExecArray | null;
|
|
38
|
+
while ((match = rule.exec(body)) !== null) {
|
|
39
|
+
const selectors = match[1]!.split(',').map(part => part.trim());
|
|
40
|
+
const wanted = hashed
|
|
41
|
+
? selectors.some(part => part.endsWith(selector) || part.endsWith(selector.replace(/^\./, '')))
|
|
42
|
+
: selectors.includes(selector);
|
|
43
|
+
if (!wanted) continue;
|
|
44
|
+
for (const declaration of match[2]!.split(';')) {
|
|
45
|
+
const separator = declaration.indexOf(':');
|
|
46
|
+
if (separator < 0) continue;
|
|
47
|
+
const property = declaration.slice(0, separator).trim();
|
|
48
|
+
const value = declaration.slice(separator + 1).trim();
|
|
49
|
+
if (property) declarations.set(property, value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return declarations;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Minified CSS inside the committed bundle keeps the hashed prefix on each class. */
|
|
56
|
+
function bundledDeclarations(className: string): Map<string, string> {
|
|
57
|
+
const declarations = new Map<string, string>();
|
|
58
|
+
const rule = new RegExp(`(?:^|[.,}])[.#]?[\\w-]*${className}\\{([^{}]*)\\}`, 'g');
|
|
59
|
+
let match: RegExpExecArray | null;
|
|
60
|
+
while ((match = rule.exec(bundle)) !== null) {
|
|
61
|
+
for (const declaration of match[1]!.split(';')) {
|
|
62
|
+
const separator = declaration.indexOf(':');
|
|
63
|
+
if (separator < 0) continue;
|
|
64
|
+
declarations.set(declaration.slice(0, separator).trim(), declaration.slice(separator + 1).trim());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return declarations;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
test('clamped reader lanes stay strictly below the host footer band', () => {
|
|
71
|
+
for (const lane of CLAMPED_LANES) {
|
|
72
|
+
const declarations = mergedDeclarations(css, lane);
|
|
73
|
+
const zIndex = declarations.get('z-index');
|
|
74
|
+
assert.ok(zIndex, `${lane} still declares its lane z-index`);
|
|
75
|
+
assert.ok(
|
|
76
|
+
Number(zIndex) < HOST_FOOTER_Z,
|
|
77
|
+
`${lane} must stay below the host composer seat (z-index ${HOST_FOOTER_Z}), got ${zIndex}`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('the top toolbar lane stays at 7 and pins to the scrollport top', () => {
|
|
83
|
+
const declarations = mergedDeclarations(css, TOP_LANE);
|
|
84
|
+
assert.equal(declarations.get('z-index'), String(HOST_FOOTER_Z));
|
|
85
|
+
assert.equal(declarations.get('top'), '0');
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
test('the live status lane pins below the toolbar lane instead of over it', () => {
|
|
89
|
+
const declarations = mergedDeclarations(css, '.turnProcessSticky');
|
|
90
|
+
assert.match(
|
|
91
|
+
declarations.get('top') ?? '',
|
|
92
|
+
/var\(--reader-toolbar-height/,
|
|
93
|
+
'the status lane shares the measured lane below the toolbar',
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('the closed summary lane shares that same measured lane', () => {
|
|
98
|
+
const declarations = mergedDeclarations(css, '.flowCell[data-flow-summary]');
|
|
99
|
+
assert.match(declarations.get('top') ?? '', /var\(--reader-toolbar-height/);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test('skin mode does not reintroduce a lane above the footer band', () => {
|
|
103
|
+
for (const lane of CLAMPED_LANES) {
|
|
104
|
+
const zIndex = mergedDeclarations(css, `.root[data-reader-glass] ${lane}`).get('z-index');
|
|
105
|
+
if (zIndex === undefined || zIndex === 'auto') continue;
|
|
106
|
+
assert.ok(
|
|
107
|
+
Number(zIndex) < HOST_FOOTER_Z,
|
|
108
|
+
`glass override for ${lane} must not lift above ${HOST_FOOTER_Z}, got ${zIndex}`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
assert.equal(
|
|
112
|
+
mergedDeclarations(css, '.root[data-reader-glass] .toolbar').get('z-index'),
|
|
113
|
+
undefined,
|
|
114
|
+
'the toolbar keeps its single ladder value in both modes',
|
|
115
|
+
);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('the committed client bundle carries the same lane ladder', () => {
|
|
119
|
+
for (const lane of ['turnProcessSticky', 'liveFoldContainer']) {
|
|
120
|
+
const bundled = bundledDeclarations(lane);
|
|
121
|
+
const zIndex = bundled.get('z-index');
|
|
122
|
+
assert.ok(zIndex, `${lane} is present in the built bundle`);
|
|
123
|
+
assert.ok(
|
|
124
|
+
Number(zIndex) < HOST_FOOTER_Z,
|
|
125
|
+
`${lane} in lib/client.js must stay below ${HOST_FOOTER_Z}, got ${zIndex}`,
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
assert.equal(bundledDeclarations('toolbar').get('z-index'), String(HOST_FOOTER_Z));
|
|
129
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { WordTimeline } from '../src/client/word-timeline.js';
|
|
4
|
+
|
|
5
|
+
test('opening a long existing answer does not animate every historical word', () => {
|
|
6
|
+
const timeline = new WordTimeline();
|
|
7
|
+
const history = '已经接收的历史文字。'.repeat(20000);
|
|
8
|
+
timeline.begin(history, true, 0, 100);
|
|
9
|
+
assert.equal(timeline.hasLiveText, false, 'history must bypass per-word components');
|
|
10
|
+
|
|
11
|
+
timeline.begin(history + '新内容', true, 0, 200);
|
|
12
|
+
assert.equal(timeline.hasLiveText, true);
|
|
13
|
+
const words = timeline.words(history + '新内容', 0);
|
|
14
|
+
assert.ok(words.length < 10, `historical prefix expanded into ${words.length} words`);
|
|
15
|
+
assert.equal(words.map(word => word.text).join(''), history + '新内容');
|
|
16
|
+
});
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import type { AssistantChatData, ChatConversationViewNode } from '@deepseek-ai/dsh-client-ui-chat/client';
|
|
4
|
+
import type { AssistantBlock, TurnLocation } from '@deepseek-ai/dsh-client-ui-conversation/client';
|
|
5
|
+
import { assistantSegments, processExpanded } from '../src/client/projection.ts';
|
|
6
|
+
import type { TurnBoundary } from '../src/client/projection.ts';
|
|
7
|
+
import { foldSummary, presentLiveTurn, segmentLiveTurn, splitChain } from '../src/client/live-turn.ts';
|
|
8
|
+
import type { LiveStep } from '../src/client/live-turn.ts';
|
|
9
|
+
import { readerFlow } from '../src/client/tool-activity.ts';
|
|
10
|
+
|
|
11
|
+
const open: TurnBoundary = { status: 'open', reason: null, latestStep: 4, closingStep: null };
|
|
12
|
+
const completed: TurnBoundary = { status: 'closed', reason: 'completed', latestStep: 4, closingStep: 4 };
|
|
13
|
+
|
|
14
|
+
function reasoning(id: string, text = `思考 ${id}`): LiveStep {
|
|
15
|
+
return { kind: 'reasoning', key: id, nodeKey: id, start: 0, blocks: [{ kind: 'reasoning', text }], step: Number(id.replace(/\D/g, '') || 0) };
|
|
16
|
+
}
|
|
17
|
+
function body(id: string, text = `输出 ${id}`): LiveStep {
|
|
18
|
+
return { kind: 'body', key: id, nodeKey: id, start: 1, blocks: [{ kind: 'text', text }], step: 0 };
|
|
19
|
+
}
|
|
20
|
+
function tool(id: string): LiveStep {
|
|
21
|
+
return { kind: 'tool', key: id, entry: { kind: 'tool', key: id, callId: id, step: 0, order: 0, draft: { kind: 'tool-call', callId: id, name: 'bash', argsRaw: '{}' } } };
|
|
22
|
+
}
|
|
23
|
+
function user(id: string): LiveStep {
|
|
24
|
+
return { kind: 'user', key: id, nodeKey: id };
|
|
25
|
+
}
|
|
26
|
+
function other(id: string): LiveStep {
|
|
27
|
+
return { kind: 'other', key: id, nodeKey: id };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function kinds(items: ReturnType<typeof presentLiveTurn>) {
|
|
31
|
+
return items.map(item => item.kind === 'fold' ? ['fold', item.summary, item.steps.map(step => step.key)] : [item.kind, item.key]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
test('body or tool alone never folds, including after the first reasoning', () => {
|
|
35
|
+
assert.equal(splitChain([reasoning('1')]).fold, null);
|
|
36
|
+
assert.equal(splitChain([reasoning('1'), body('2')]).fold, null);
|
|
37
|
+
assert.equal(splitChain([reasoning('1'), body('2'), tool('3')]).fold, null);
|
|
38
|
+
assert.equal(splitChain([body('2'), tool('3')]).fold, null);
|
|
39
|
+
assert.equal(splitChain([other('ctx'), reasoning('1'), body('2')]).fold, null);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('a second reasoning folds every prior step into one box, then a third folds everything before it', () => {
|
|
43
|
+
const first = splitChain([reasoning('1'), body('2'), tool('3')]);
|
|
44
|
+
assert.equal(first.fold, null);
|
|
45
|
+
assert.deepEqual(first.open.map(step => step.key), ['1', '2', '3']);
|
|
46
|
+
|
|
47
|
+
const second = splitChain([reasoning('1'), body('2'), tool('3'), reasoning('4')]);
|
|
48
|
+
assert.deepEqual(second.fold?.map(step => step.key), ['1', '2', '3']);
|
|
49
|
+
assert.deepEqual(second.open.map(step => step.key), ['4']);
|
|
50
|
+
assert.equal(foldSummary(second.fold!), '思考×1 · 输出×1 · 工具×1');
|
|
51
|
+
if (second.fold?.[0]?.kind !== 'reasoning') throw new Error('folded reasoning missing');
|
|
52
|
+
assert.equal(second.fold[0].blocks[0]?.kind === 'reasoning' && second.fold[0].blocks[0].text, '思考 1');
|
|
53
|
+
assert.equal(foldSummary(second.fold).includes('思考 1'), false);
|
|
54
|
+
|
|
55
|
+
const withTool = splitChain([reasoning('1'), body('2'), tool('3'), reasoning('4'), tool('5')]);
|
|
56
|
+
assert.deepEqual(withTool.fold?.map(step => step.key), ['1', '2', '3']);
|
|
57
|
+
assert.deepEqual(withTool.open.map(step => step.key), ['4', '5']);
|
|
58
|
+
|
|
59
|
+
const third = splitChain([reasoning('1'), body('2'), tool('3'), reasoning('4'), tool('5'), reasoning('6')]);
|
|
60
|
+
assert.deepEqual(third.fold?.map(step => step.key), ['1', '2', '3', '4', '5']);
|
|
61
|
+
assert.deepEqual(third.open.map(step => step.key), ['6']);
|
|
62
|
+
assert.equal(foldSummary(third.fold!), '思考×2 · 输出×1 · 工具×2');
|
|
63
|
+
|
|
64
|
+
const latest = splitChain([reasoning('1'), body('2'), tool('3'), reasoning('4'), tool('5'), reasoning('6'), body('7')]);
|
|
65
|
+
assert.deepEqual(latest.fold?.map(step => step.key), ['1', '2', '3', '4', '5']);
|
|
66
|
+
assert.deepEqual(latest.open.map(step => step.key), ['6', '7']);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('fold presentation keeps prior step keys so the reader can collapse the same process fragments in place', () => {
|
|
70
|
+
const chain = [reasoning('1'), body('2'), tool('3')];
|
|
71
|
+
const before = presentLiveTurn(chain, open);
|
|
72
|
+
assert.deepEqual(before.map(item => item.key), ['1', '2', '3']);
|
|
73
|
+
|
|
74
|
+
const second = presentLiveTurn([...chain, reasoning('4')], open);
|
|
75
|
+
assert.equal(second[0]?.kind, 'fold');
|
|
76
|
+
if (second[0]?.kind !== 'fold') throw new Error('missing fold');
|
|
77
|
+
assert.equal(second[0].key, 'live-fold:1');
|
|
78
|
+
assert.deepEqual(second[0].steps.map(step => step.key), before.map(item => item.key));
|
|
79
|
+
assert.deepEqual(second.filter(item => item.kind === 'open').map(item => item.key), ['4']);
|
|
80
|
+
|
|
81
|
+
const third = presentLiveTurn([...chain, reasoning('4'), tool('5'), reasoning('6')], open);
|
|
82
|
+
if (third[0]?.kind !== 'fold') throw new Error('missing grown fold');
|
|
83
|
+
assert.equal(third[0].key, 'live-fold:1');
|
|
84
|
+
assert.deepEqual(third[0].steps.map(step => step.key), ['1', '2', '3', '4', '5']);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('presentLiveTurn keeps a single prior box rather than one fold per step', () => {
|
|
88
|
+
const items = presentLiveTurn([reasoning('1'), body('2'), tool('3'), reasoning('4'), tool('5'), reasoning('6'), body('7')], open);
|
|
89
|
+
const folds = items.filter(item => item.kind === 'fold');
|
|
90
|
+
assert.equal(folds.length, 1);
|
|
91
|
+
if (folds[0]?.kind !== 'fold') throw new Error('missing fold');
|
|
92
|
+
assert.equal(folds[0].steps.length, 5);
|
|
93
|
+
assert.deepEqual(items.filter(item => item.kind === 'open').map(item => item.key), ['6', '7']);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('mid-turn user insert resets the chain; only the next reasoning folds post-insert priors', () => {
|
|
97
|
+
const before = presentLiveTurn([reasoning('1'), body('2'), tool('3'), user('insert'), body('4'), tool('5')], open);
|
|
98
|
+
assert.deepEqual(kinds(before), [
|
|
99
|
+
['open', '1'], ['open', '2'], ['open', '3'],
|
|
100
|
+
['user', 'insert'],
|
|
101
|
+
['open', '4'], ['open', '5'],
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
const after = presentLiveTurn([reasoning('1'), body('2'), tool('3'), user('insert'), body('4'), tool('5'), reasoning('6')], open);
|
|
105
|
+
assert.deepEqual(kinds(after), [
|
|
106
|
+
['open', '1'], ['open', '2'], ['open', '3'],
|
|
107
|
+
['user', 'insert'],
|
|
108
|
+
['fold', '输出×1 · 工具×1', ['4', '5']],
|
|
109
|
+
['open', '6'],
|
|
110
|
+
]);
|
|
111
|
+
const folds = after.filter(item => item.kind === 'fold');
|
|
112
|
+
assert.equal(folds.length, 1);
|
|
113
|
+
if (folds[0]?.kind !== 'fold') throw new Error('missing insert fold');
|
|
114
|
+
assert.ok(!folds[0].steps.some(step => ['1', '2', '3', 'insert'].includes(step.key)));
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('each chain has at most one fold box; a later chain does not split priors into per-step folds', () => {
|
|
118
|
+
const items = presentLiveTurn([
|
|
119
|
+
reasoning('1'), body('2'), tool('3'), reasoning('4'),
|
|
120
|
+
user('insert'),
|
|
121
|
+
body('5'), tool('6'), reasoning('7'),
|
|
122
|
+
], open);
|
|
123
|
+
const folds = items.filter(item => item.kind === 'fold');
|
|
124
|
+
assert.equal(folds.length, 2);
|
|
125
|
+
if (folds[0]?.kind !== 'fold' || folds[1]?.kind !== 'fold') throw new Error('expected one box per chain');
|
|
126
|
+
assert.deepEqual(folds[0].steps.map(step => step.key), ['1', '2', '3']);
|
|
127
|
+
assert.deepEqual(folds[1].steps.map(step => step.key), ['5', '6']);
|
|
128
|
+
assert.equal(folds[0].summary, '思考×1 · 输出×1 · 工具×1');
|
|
129
|
+
assert.equal(folds[1].summary, '输出×1 · 工具×1');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
test('successful turn close disables live fold so the existing final-answer rules still apply', () => {
|
|
133
|
+
const items = presentLiveTurn([reasoning('1'), body('2'), tool('3'), reasoning('4'), body('final')], completed);
|
|
134
|
+
assert.equal(items.some(item => item.kind === 'fold'), false);
|
|
135
|
+
assert.deepEqual(items.map(item => item.kind), ['open', 'open', 'open', 'open', 'open']);
|
|
136
|
+
assert.equal(processExpanded(undefined, completed), false);
|
|
137
|
+
assert.equal(processExpanded(undefined, { ...completed, reason: 'error' }), true);
|
|
138
|
+
assert.equal(processExpanded(undefined, { ...completed, reason: 'interrupted' }), true);
|
|
139
|
+
assert.equal(processExpanded(undefined, { ...completed, reason: 'blocked' }), true);
|
|
140
|
+
assert.equal(processExpanded(undefined, { status: 'unknown', reason: null, latestStep: -1, closingStep: null }), true);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
test('error, interrupt, approval-blocked and unknown terminals do not live-fold away the transcript', () => {
|
|
144
|
+
const steps = [reasoning('1'), body('2'), tool('3'), reasoning('4')];
|
|
145
|
+
for (const reason of ['error', 'interrupted', 'aborted', 'blocked', 'max-tokens', 'future-terminal']) {
|
|
146
|
+
const items = presentLiveTurn(steps, { status: 'closed', reason, latestStep: 4, closingStep: 4 });
|
|
147
|
+
assert.equal(items.some(item => item.kind === 'fold'), false, reason);
|
|
148
|
+
assert.equal(processExpanded(undefined, { status: 'closed', reason, latestStep: 4, closingStep: 4 }), true, reason);
|
|
149
|
+
}
|
|
150
|
+
assert.equal(presentLiveTurn(steps, { status: 'unknown', reason: null, latestStep: -1, closingStep: null }).some(item => item.kind === 'fold'), false);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('segmentation uses existing assistantSegments and tool boundaries and does not invent empty reasoning', () => {
|
|
154
|
+
const think: AssistantBlock = { kind: 'reasoning', text: '第一段思考' };
|
|
155
|
+
const moreThink: AssistantBlock = { kind: 'reasoning', text: '同一思考步骤' };
|
|
156
|
+
const text: AssistantBlock = { kind: 'text', text: '中途说明' };
|
|
157
|
+
const call: AssistantBlock = { kind: 'tool-call', callId: 'c1', name: 'bash', argsRaw: '{"command":"ls"}' };
|
|
158
|
+
const empty: AssistantBlock = { kind: 'reasoning', text: ' ' };
|
|
159
|
+
assert.deepEqual(assistantSegments([think, moreThink, text, call, empty]).map(part => [part.kind, part.start]), [
|
|
160
|
+
['reasoning', 0], ['body', 2], ['reasoning', 4],
|
|
161
|
+
]);
|
|
162
|
+
|
|
163
|
+
const data: AssistantChatData = { status: 'running', turn: 1, step: 0, blocks: [think, moreThink, text, call], time: 1 };
|
|
164
|
+
const node = {
|
|
165
|
+
key: 'a', id: 'a', kind: 'assistant-step', target: 'chat', data, anchorSeq: 10, visibility: 'visible',
|
|
166
|
+
location: { kind: 'step', step: { step: 0 } },
|
|
167
|
+
} as unknown as ChatConversationViewNode;
|
|
168
|
+
const turn = { turn: 1, steps: [{ step: 0, start: { seq: 10 }, data: { get: () => data } }] } as unknown as TurnLocation;
|
|
169
|
+
const flow = readerFlow({ key: 'turn:1', turn: 1, keys: ['a'] }, turn, key => key === 'a' ? node : undefined);
|
|
170
|
+
const steps = segmentLiveTurn(flow, key => key === 'a' ? node : undefined);
|
|
171
|
+
assert.deepEqual(steps.map(step => step.kind), ['reasoning', 'body', 'tool']);
|
|
172
|
+
assert.equal(steps[0]?.kind === 'reasoning' && steps[0].blocks.length, 2);
|
|
173
|
+
if (steps[0]?.kind !== 'reasoning') throw new Error('missing reasoning');
|
|
174
|
+
assert.equal(steps[0].blocks[0], think);
|
|
175
|
+
assert.equal(steps[0].blocks[1], moreThink);
|
|
176
|
+
|
|
177
|
+
const blankData: AssistantChatData = { ...data, blocks: [empty, text] };
|
|
178
|
+
const blank = { ...node, data: blankData } as unknown as ChatConversationViewNode;
|
|
179
|
+
const blankTurn = { turn: 1, steps: [{ step: 0, start: { seq: 10 }, data: { get: () => blankData } }] } as unknown as TurnLocation;
|
|
180
|
+
const blankFlow = readerFlow({ key: 'turn:1', turn: 1, keys: ['a'] }, blankTurn, () => blank);
|
|
181
|
+
assert.deepEqual(segmentLiveTurn(blankFlow, () => blank).map(step => step.kind), ['body']);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('steering in the flow is a chain reset, same as a mid-turn user message', () => {
|
|
185
|
+
const think: AssistantBlock = { kind: 'reasoning', text: '先想' };
|
|
186
|
+
const text: AssistantBlock = { kind: 'text', text: '先说' };
|
|
187
|
+
const later: AssistantBlock = { kind: 'reasoning', text: '插入后再想' };
|
|
188
|
+
const first: AssistantChatData = { status: 'settled', turn: 1, step: 0, blocks: [think, text], time: 1 };
|
|
189
|
+
const second: AssistantChatData = { status: 'running', turn: 1, step: 1, blocks: [later], time: 2 };
|
|
190
|
+
const assistant = (key: string, seq: number, data: AssistantChatData) => ({
|
|
191
|
+
key, id: key, kind: 'assistant-step', target: 'chat', data, anchorSeq: seq, visibility: 'visible',
|
|
192
|
+
location: { kind: 'step', step: { step: data.step } },
|
|
193
|
+
}) as unknown as ChatConversationViewNode;
|
|
194
|
+
const steer = {
|
|
195
|
+
key: 'steer', id: 'steer', kind: 'steering', target: 'chat', data: { content: [{ type: 'text', text: '请改方向' }] },
|
|
196
|
+
anchorSeq: 15, visibility: 'visible', location: { kind: 'turn', turn: { turn: 1 } },
|
|
197
|
+
} as unknown as ChatConversationViewNode;
|
|
198
|
+
const nodes = new Map<string, ChatConversationViewNode>([
|
|
199
|
+
['a', assistant('a', 10, first)],
|
|
200
|
+
['steer', steer],
|
|
201
|
+
['b', assistant('b', 20, second)],
|
|
202
|
+
]);
|
|
203
|
+
const flow = readerFlow({ key: 'turn:1', turn: 1, keys: ['a', 'steer', 'b'] }, undefined, key => nodes.get(key));
|
|
204
|
+
const items = presentLiveTurn(segmentLiveTurn(flow, key => nodes.get(key)), open);
|
|
205
|
+
assert.deepEqual(kinds(items), [
|
|
206
|
+
['open', 'a:reasoning:0'], ['open', 'a:body:1'],
|
|
207
|
+
['user', 'steer'],
|
|
208
|
+
['open', 'b:reasoning:0'],
|
|
209
|
+
]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('disabling auto-fold keeps all steps open as plain streaming steps', () => {
|
|
213
|
+
const steps = [reasoning('1'), body('2'), tool('3'), reasoning('4'), tool('5'), reasoning('6')];
|
|
214
|
+
const items = presentLiveTurn(steps, open, false);
|
|
215
|
+
assert.equal(items.some(item => item.kind === 'fold'), false);
|
|
216
|
+
assert.deepEqual(items.map(item => item.key), ['1', '2', '3', '4', '5', '6']);
|
|
217
|
+
assert.deepEqual(items.map(item => item.kind), ['open', 'open', 'open', 'open', 'open', 'open']);
|
|
218
|
+
});
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import type { Code } from 'mdast';
|
|
4
|
+
import {
|
|
5
|
+
isMcpAppCodeBlock,
|
|
6
|
+
extractMcpAppTitle,
|
|
7
|
+
extractMcpAppHeight,
|
|
8
|
+
ensureHtmlDocument,
|
|
9
|
+
extractHtmlTitle,
|
|
10
|
+
formatReceiptPrompt,
|
|
11
|
+
findComposerTextarea,
|
|
12
|
+
fillComposerDom,
|
|
13
|
+
} from '../src/client/mcp-app.js';
|
|
14
|
+
import { parseGfmWithMath } from '../src/client/markdown/parse.js';
|
|
15
|
+
|
|
16
|
+
test('isMcpAppCodeBlock detects all valid MCP App code block formats', () => {
|
|
17
|
+
// Direct lang tags
|
|
18
|
+
assert.equal(isMcpAppCodeBlock('mcp-app', null, '<div>test</div>'), true);
|
|
19
|
+
assert.equal(isMcpAppCodeBlock('mcpapp', null, '<div>test</div>'), true);
|
|
20
|
+
assert.equal(isMcpAppCodeBlock('mcp-ui', null, '<div>test</div>'), true);
|
|
21
|
+
assert.equal(isMcpAppCodeBlock('mcp', null, '<div>test</div>'), true);
|
|
22
|
+
assert.equal(isMcpAppCodeBlock('mcp-app:html', null, '<div>test</div>'), true);
|
|
23
|
+
assert.equal(isMcpAppCodeBlock('html:mcp-app', null, '<div>test</div>'), true);
|
|
24
|
+
|
|
25
|
+
// Meta indicators
|
|
26
|
+
assert.equal(isMcpAppCodeBlock('html', 'mcp-app title="测试"', '<div>test</div>'), true);
|
|
27
|
+
assert.equal(isMcpAppCodeBlock(null, 'sep-1865', '<div>test</div>'), true);
|
|
28
|
+
|
|
29
|
+
// Content heuristic for SEP-1865 JSON-RPC
|
|
30
|
+
const quizSnippet = `
|
|
31
|
+
window.parent.postMessage({
|
|
32
|
+
jsonrpc: "2.0",
|
|
33
|
+
method: "ui/submit",
|
|
34
|
+
params: { choice: "A" }
|
|
35
|
+
}, "*");
|
|
36
|
+
`;
|
|
37
|
+
assert.equal(isMcpAppCodeBlock('html', null, quizSnippet), true);
|
|
38
|
+
|
|
39
|
+
// Negative cases
|
|
40
|
+
assert.equal(isMcpAppCodeBlock('typescript', null, 'const x = 1;'), false);
|
|
41
|
+
assert.equal(isMcpAppCodeBlock('json', null, '{"a": 1}'), false);
|
|
42
|
+
assert.equal(isMcpAppCodeBlock('html', null, '<h1>Hello World</h1>'), false);
|
|
43
|
+
assert.equal(isMcpAppCodeBlock(null, null, ''), false);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('extractMcpAppTitle extracts title from meta or html content', () => {
|
|
47
|
+
assert.equal(extractMcpAppTitle('title="双盲方案盲选评测器"', '<div>test</div>'), '双盲方案盲选评测器');
|
|
48
|
+
assert.equal(extractMcpAppTitle("title='架构方案对比'", '<div>test</div>'), '架构方案对比');
|
|
49
|
+
assert.equal(extractMcpAppTitle(null, '<!DOCTYPE html><html><head><title>网页标题评测</title></head></html>'), '网页标题评测');
|
|
50
|
+
assert.equal(extractMcpAppTitle(null, '<div>无标题内容</div>'), undefined);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('extractMcpAppHeight parses explicit height budget from meta', () => {
|
|
54
|
+
assert.equal(extractMcpAppHeight('title="看板" height=600'), 600);
|
|
55
|
+
assert.equal(extractMcpAppHeight('height="550px"'), 550);
|
|
56
|
+
assert.equal(extractMcpAppHeight('height=50'), undefined); // too small
|
|
57
|
+
assert.equal(extractMcpAppHeight('title="普通"'), undefined);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('extractHtmlTitle extracts document title accurately', () => {
|
|
61
|
+
assert.equal(extractHtmlTitle('<title>我的测试 App</title>'), '我的测试 App');
|
|
62
|
+
assert.equal(extractHtmlTitle('<title class="main" > 性能看板 </title>'), '性能看板');
|
|
63
|
+
assert.equal(extractHtmlTitle('<div>没有标题</div>'), undefined);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('ensureHtmlDocument wraps bare fragments and preserves complete documents with theme bridge', () => {
|
|
67
|
+
const completeHtml = '<!DOCTYPE html>\n<html><head><title>Test</title></head><body>Content</body></html>';
|
|
68
|
+
const processed = ensureHtmlDocument(completeHtml, 'dark');
|
|
69
|
+
assert.ok(processed.includes('<title>Test</title>'));
|
|
70
|
+
assert.ok(processed.includes('<body>Content</body>'));
|
|
71
|
+
assert.ok(processed.includes('applyTheme'));
|
|
72
|
+
|
|
73
|
+
const fragment = '<div class="quiz"><h2>Question</h2></div>';
|
|
74
|
+
const wrapped = ensureHtmlDocument(fragment, 'dark');
|
|
75
|
+
assert.ok(wrapped.startsWith('<!DOCTYPE html>'));
|
|
76
|
+
assert.ok(wrapped.includes('<html lang="zh-CN" data-theme="dark" class="dark"'));
|
|
77
|
+
assert.ok(wrapped.includes(fragment));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('markdown parsing correctly extracts MCP App code fence and prepares for McpAppFrame mounting', () => {
|
|
81
|
+
const markdown = `
|
|
82
|
+
这里是为您生成的方案评测器,请在下方直接点击交互:
|
|
83
|
+
|
|
84
|
+
\`\`\`mcp-app title="双盲方案盲选评测器"
|
|
85
|
+
<!DOCTYPE html>
|
|
86
|
+
<html lang="zh-CN">
|
|
87
|
+
<head>
|
|
88
|
+
<meta charset="UTF-8">
|
|
89
|
+
<title>双盲方案盲选评测器</title>
|
|
90
|
+
</head>
|
|
91
|
+
<body>
|
|
92
|
+
<div class="quiz-card">
|
|
93
|
+
<h3>题目</h3>
|
|
94
|
+
<button onclick="submitChoice('B')">B: 延迟消息队列</button>
|
|
95
|
+
</div>
|
|
96
|
+
</body>
|
|
97
|
+
</html>
|
|
98
|
+
\`\`\`
|
|
99
|
+
|
|
100
|
+
如有其他疑问,请随时告诉我。
|
|
101
|
+
`.trim();
|
|
102
|
+
|
|
103
|
+
const root = parseGfmWithMath(markdown);
|
|
104
|
+
const codeNode = root.children.find((child): child is Code => child.type === 'code');
|
|
105
|
+
assert.ok(codeNode, 'Must contain a code block node');
|
|
106
|
+
assert.equal(codeNode.lang, 'mcp-app');
|
|
107
|
+
assert.equal(codeNode.meta, 'title="双盲方案盲选评测器"');
|
|
108
|
+
assert.equal(isMcpAppCodeBlock(codeNode.lang, codeNode.meta, codeNode.value), true);
|
|
109
|
+
assert.equal(extractMcpAppTitle(codeNode.meta, codeNode.value), '双盲方案盲选评测器');
|
|
110
|
+
assert.ok(ensureHtmlDocument(codeNode.value).includes('延迟消息队列'));
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('formatReceiptPrompt formats clean, natural conversational text without extra whitespace or raw JSON dump', () => {
|
|
114
|
+
const quizParams = {
|
|
115
|
+
task: 'architecture_quiz_completed',
|
|
116
|
+
choice: 'B',
|
|
117
|
+
desc: '延迟消息队列',
|
|
118
|
+
};
|
|
119
|
+
const prompt = formatReceiptPrompt(quizParams, '双盲方案盲选评测器');
|
|
120
|
+
assert.equal(prompt, '我在「双盲方案盲选评测器」中选择了:B(延迟消息队列)。请根据我的选择继续。');
|
|
121
|
+
assert.ok(!prompt.includes('\n'), 'Must not contain multiline newlines');
|
|
122
|
+
assert.ok(!prompt.includes('{'), 'Must not dump raw JSON braces');
|
|
123
|
+
|
|
124
|
+
const variantParams = {
|
|
125
|
+
selectedVariant: 'Skill_v2',
|
|
126
|
+
score: 95,
|
|
127
|
+
};
|
|
128
|
+
assert.equal(formatReceiptPrompt(variantParams), '我在方案评测中选择了:Skill_v2,得分:95。请根据该方案继续分析。');
|
|
129
|
+
|
|
130
|
+
const actionParams = {
|
|
131
|
+
action: 'reset_counter',
|
|
132
|
+
payload: { count: 0 },
|
|
133
|
+
};
|
|
134
|
+
assert.equal(formatReceiptPrompt(actionParams, '计数器'), '[计数器] 已完成 reset_counter: {"count":0}');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('ensureHtmlDocument injects theme bridge and auto-height reporter into complete documents', () => {
|
|
138
|
+
const completeHtml = '<!DOCTYPE html>\n<html><head><title>Demo</title></head><body><div class="box">hi</div></body></html>';
|
|
139
|
+
const processed = ensureHtmlDocument(completeHtml, 'dark');
|
|
140
|
+
assert.ok(processed.includes('<title>Demo</title>'));
|
|
141
|
+
assert.ok(processed.includes('<body><div class="box">hi</div></body>'));
|
|
142
|
+
// Theme bridge must apply the initial theme and listen for live host updates
|
|
143
|
+
// (host pushes ui/initialize result / host-context-changed carrying hostContext.theme).
|
|
144
|
+
assert.ok(processed.includes('applyTheme("dark")'));
|
|
145
|
+
assert.ok(processed.includes('hostContext'));
|
|
146
|
+
// Auto-height reporter must observe the body and emit SEP-1865 resize events.
|
|
147
|
+
assert.ok(processed.includes('ResizeObserver'));
|
|
148
|
+
assert.ok(processed.includes('ui/resize'));
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test('findComposerTextarea is importable and null-safe without a DOM', () => {
|
|
152
|
+
assert.equal(findComposerTextarea(undefined as unknown as Document), null);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test('fillComposerDom refuses without a DOM instead of throwing', () => {
|
|
156
|
+
assert.equal(fillComposerDom('hello'), false);
|
|
157
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { formatMessageClock, formatRanFor, formatRunDuration } from '../src/client/message-chrome.ts';
|
|
4
|
+
|
|
5
|
+
test('run duration matches official Chat labels', () => {
|
|
6
|
+
assert.equal(formatRunDuration(0), '0秒');
|
|
7
|
+
assert.equal(formatRunDuration(19_000), '19秒');
|
|
8
|
+
assert.equal(formatRunDuration(118_000), '1分58秒');
|
|
9
|
+
assert.equal(formatRunDuration(65_000), '1分05秒');
|
|
10
|
+
assert.equal(formatRanFor(118_000), '用时 1分58秒');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('same calendar day is HH:mm', () => {
|
|
14
|
+
const now = new Date(2026, 8, 11, 16, 40).getTime();
|
|
15
|
+
const time = new Date(2026, 8, 11, 16, 36).getTime();
|
|
16
|
+
assert.equal(formatMessageClock(time, now), '16:36');
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('earlier this year includes month and day', () => {
|
|
20
|
+
const now = new Date(2026, 8, 11, 16, 40).getTime();
|
|
21
|
+
const time = new Date(2026, 7, 3, 9, 5).getTime();
|
|
22
|
+
assert.equal(formatMessageClock(time, now), '8月3日 09:05');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('other years include the year', () => {
|
|
26
|
+
const now = new Date(2026, 8, 11, 16, 40).getTime();
|
|
27
|
+
const time = new Date(2025, 11, 31, 23, 4).getTime();
|
|
28
|
+
assert.equal(formatMessageClock(time, now), '2025年12月31日 23:04');
|
|
29
|
+
});
|