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,112 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { SlotCore } from '@deepseek-ai/dsh-client-ui-slots';
|
|
5
|
+
import { mirrorOfficialSlot, readerTailMatch, type CompositionRegistry } from '../src/client/official-slots.js';
|
|
6
|
+
|
|
7
|
+
function registry(kind: 'keyed' | 'chain' | 'list' = 'keyed') {
|
|
8
|
+
const core = new SlotCore();
|
|
9
|
+
const register = (options: object, component: unknown) => (core.register as (...args: unknown[]) => unknown)(options, component) as () => void;
|
|
10
|
+
register({ name: 'root', children: {
|
|
11
|
+
source: { kind, scope: 'session' },
|
|
12
|
+
reader: { kind, scope: 'session' },
|
|
13
|
+
} }, () => null);
|
|
14
|
+
const slots: CompositionRegistry = {
|
|
15
|
+
register,
|
|
16
|
+
spec: key => core.spec(key as never),
|
|
17
|
+
entriesOfSlot: key => core.entriesOfSlot(key),
|
|
18
|
+
subscribe: (key, fn) => core.subscribe(key, fn),
|
|
19
|
+
inject: () => { throw new Error('not used by the subtree test'); },
|
|
20
|
+
};
|
|
21
|
+
return { core, slots, register };
|
|
22
|
+
}
|
|
23
|
+
const changed = () => new Promise(resolve => queueMicrotask(resolve));
|
|
24
|
+
|
|
25
|
+
test('official present cards retain their data while the existing Reader produced row stays unique', () => {
|
|
26
|
+
const original = Object.freeze({ produced: Object.freeze(['/work/code.ts']), presented: Object.freeze([{ path: '/work/report.pdf', seq: 42 }]), future: 'retained' });
|
|
27
|
+
assert.deepEqual(readerTailMatch(original, ['/work/code.ts']), { produced: [], presented: original.presented, future: 'retained' });
|
|
28
|
+
assert.equal(readerTailMatch(original), original);
|
|
29
|
+
assert.deepEqual(readerTailMatch({ produced: ['/work/code.ts', '/work/new.ts'], presented: [] }, ['/work/code.ts']), { produced: ['/work/new.ts'], presented: [] });
|
|
30
|
+
assert.deepEqual(original.produced, ['/work/code.ts']);
|
|
31
|
+
const future = { artifacts: ['/work/report.pdf'] };
|
|
32
|
+
assert.equal(readerTailMatch(future), future);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test('official memo components retain injection, store, locale and selector metadata', () => {
|
|
36
|
+
const { core, slots, register } = registry('chain');
|
|
37
|
+
const component = memo(() => null);
|
|
38
|
+
const inject = () => ({ hooks: { status: { getSnapshot: () => 1, subscribe: () => () => {} } } });
|
|
39
|
+
const select = (owner: unknown) => owner;
|
|
40
|
+
const store = { create: () => ({}) };
|
|
41
|
+
register({ name: 'source', select, inject, store, locale: 'feedback', priority: -7 }, component);
|
|
42
|
+
const before = core.entriesOfSlot('source')[0];
|
|
43
|
+
const stop = mirrorOfficialSlot(slots, 'source', 'reader', 'reader.children');
|
|
44
|
+
const mirrored = core.entriesOfSlot('reader')[0];
|
|
45
|
+
assert.equal(mirrored.component, component);
|
|
46
|
+
assert.equal(mirrored.inject, inject);
|
|
47
|
+
assert.equal(mirrored.select, select);
|
|
48
|
+
assert.equal(mirrored.store, store);
|
|
49
|
+
assert.equal(mirrored.locale, 'feedback');
|
|
50
|
+
assert.equal(mirrored.options.priority, -7);
|
|
51
|
+
assert.equal(core.entriesOfSlot('source')[0], before);
|
|
52
|
+
stop();
|
|
53
|
+
assert.equal(core.entriesOfSlot('reader').length, 0);
|
|
54
|
+
assert.equal(core.entriesOfSlot('source')[0], before);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('nested declarations use distinct seats and are disposed without touching the source', () => {
|
|
58
|
+
const { core, slots, register } = registry();
|
|
59
|
+
const hookContext = { hooks: { turnData: () => () => 'live' } };
|
|
60
|
+
register({ name: 'source', key: 'read-image', children: { images: { kind: 'single', scope: 'session', inject: hookContext } } }, () => null);
|
|
61
|
+
const child = memo(() => null);
|
|
62
|
+
register({ name: 'images', locale: 'images' }, child);
|
|
63
|
+
const before = core.snapshot('source');
|
|
64
|
+
const stop = mirrorOfficialSlot(slots, 'source', 'reader', 'reader.children');
|
|
65
|
+
assert.equal(core.entriesOfSlot('reader.children/images')[0].component, child);
|
|
66
|
+
assert.equal(slots.spec('reader.children/images')?.inject, hookContext);
|
|
67
|
+
assert.deepEqual(core.snapshot('source'), before);
|
|
68
|
+
stop();
|
|
69
|
+
assert.equal(slots.spec('reader.children/images'), undefined);
|
|
70
|
+
assert.equal(core.entriesOfSlot('images')[0].component, child);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('new registrations do not remount existing cards; winner changes and unload reconcile', async () => {
|
|
74
|
+
const { core, slots, register } = registry();
|
|
75
|
+
const first = memo(() => null);
|
|
76
|
+
const second = memo(() => null);
|
|
77
|
+
const fallback = memo(() => null);
|
|
78
|
+
register({ name: 'source', key: 'read' }, first);
|
|
79
|
+
const stop = mirrorOfficialSlot(slots, 'source', 'reader', 'reader.children');
|
|
80
|
+
const originalSeat = core.entriesOfSlot('reader')[0];
|
|
81
|
+
const removeNew = register({ name: 'source', key: 'new-official-tool' }, second);
|
|
82
|
+
await changed();
|
|
83
|
+
assert.equal(core.entriesOfSlot('reader').find(e => e.options.key === 'read'), originalSeat);
|
|
84
|
+
assert.equal(core.entriesOfSlot('reader').length, 2);
|
|
85
|
+
const restore = register({ name: 'source', key: 'read', priority: -1 }, fallback);
|
|
86
|
+
await changed();
|
|
87
|
+
assert.equal(core.entriesOfSlot('reader').find(e => e.options.key === 'read')?.component, fallback);
|
|
88
|
+
restore();
|
|
89
|
+
removeNew();
|
|
90
|
+
await changed();
|
|
91
|
+
assert.equal(core.entriesOfSlot('reader').length, 1);
|
|
92
|
+
assert.equal(core.entriesOfSlot('reader')[0].component, first);
|
|
93
|
+
stop();
|
|
94
|
+
register({ name: 'source', key: 'after-reader-unload' }, second);
|
|
95
|
+
await changed();
|
|
96
|
+
assert.equal(core.entriesOfSlot('reader').length, 0);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('partial setup rolls back its own registrations on a nested contract failure', () => {
|
|
100
|
+
const { core, slots, register } = registry();
|
|
101
|
+
register({ name: 'source', key: 'nested', children: { detail: { kind: 'single', scope: 'session' } } }, () => null);
|
|
102
|
+
register({ name: 'detail' }, () => null);
|
|
103
|
+
const failing = { ...slots, register(options: Parameters<CompositionRegistry['register']>[0], component: unknown) {
|
|
104
|
+
if (options.name === 'reader.children/detail') throw new Error('fixture failure');
|
|
105
|
+
return slots.register(options, component);
|
|
106
|
+
} };
|
|
107
|
+
assert.throws(() => mirrorOfficialSlot(failing, 'source', 'reader', 'reader.children'), /fixture failure/);
|
|
108
|
+
assert.equal(core.entriesOfSlot('reader').length, 0);
|
|
109
|
+
assert.equal(slots.spec('reader.children/detail'), undefined);
|
|
110
|
+
assert.equal(core.entriesOfSlot('source').length, 1);
|
|
111
|
+
assert.equal(core.entriesOfSlot('detail').length, 1);
|
|
112
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
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
|
+
deliverableOpenModeOf,
|
|
8
|
+
fileAddressFor,
|
|
9
|
+
isFolderOpenPath,
|
|
10
|
+
modeFromSnapshot,
|
|
11
|
+
openDeliverableFile,
|
|
12
|
+
resolveOpenWorkspacePath,
|
|
13
|
+
} from '../src/client/open-file.ts';
|
|
14
|
+
|
|
15
|
+
test('index still routes opens through #13 open-mode, not a forced sidebar', () => {
|
|
16
|
+
const index = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../src/client/index.tsx'), 'utf8');
|
|
17
|
+
assert.match(index, /modeFromSnapshot\(prefs\)/);
|
|
18
|
+
assert.match(index, /openDeliverableFile/);
|
|
19
|
+
assert.doesNotMatch(index, /openOnDesktop/);
|
|
20
|
+
assert.doesNotMatch(index, /sidebarRight\.openResource!\(address\)/);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('deliverable open mode defaults to external', () => {
|
|
24
|
+
assert.equal(deliverableOpenModeOf(undefined), 'external');
|
|
25
|
+
assert.equal(deliverableOpenModeOf('external'), 'external');
|
|
26
|
+
assert.equal(deliverableOpenModeOf('sidebar'), 'sidebar');
|
|
27
|
+
assert.equal(deliverableOpenModeOf('other'), 'external');
|
|
28
|
+
assert.equal(modeFromSnapshot(undefined), 'external');
|
|
29
|
+
assert.equal(modeFromSnapshot({ getSnapshot: () => ({}) }), 'external');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('folder affordances stay on the OS path', () => {
|
|
33
|
+
assert.equal(isFolderOpenPath('.'), true);
|
|
34
|
+
assert.equal(isFolderOpenPath(''), true);
|
|
35
|
+
assert.equal(isFolderOpenPath('src/a.ts'), false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('fileAddressFor matches official session-scoped grammar', () => {
|
|
39
|
+
assert.equal(
|
|
40
|
+
fileAddressFor('s1', '/repo', 'src/client/Reader.tsx'),
|
|
41
|
+
'dsh-resource://file/session/s1/src/client/Reader.tsx',
|
|
42
|
+
);
|
|
43
|
+
assert.equal(
|
|
44
|
+
fileAddressFor('s1', '/repo', '/repo/src/a.ts'),
|
|
45
|
+
'dsh-resource://file/session/s1/src/a.ts',
|
|
46
|
+
);
|
|
47
|
+
assert.equal(
|
|
48
|
+
fileAddressFor('id with space', undefined, 'notes and more.md'),
|
|
49
|
+
'dsh-resource://file/session/id%20with%20space/notes%20and%20more.md',
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('sidebar mode opens the right-panel address; external uses the system opener', async () => {
|
|
54
|
+
const opened: string[] = [];
|
|
55
|
+
const sidebar: string[] = [];
|
|
56
|
+
const resolve = (cwd: string | undefined, path: string) => `${cwd ?? ''}/${path}`;
|
|
57
|
+
|
|
58
|
+
assert.equal(await openDeliverableFile({
|
|
59
|
+
path: 'a.ts',
|
|
60
|
+
mode: 'external',
|
|
61
|
+
sessionId: 's1',
|
|
62
|
+
cwd: '/repo',
|
|
63
|
+
resolveWorkspacePath: resolve,
|
|
64
|
+
openExternal: async (path) => { opened.push(path); },
|
|
65
|
+
openSidebar: (address) => { sidebar.push(address); },
|
|
66
|
+
}), 'external');
|
|
67
|
+
assert.deepEqual(opened, ['/repo/a.ts']);
|
|
68
|
+
assert.deepEqual(sidebar, []);
|
|
69
|
+
|
|
70
|
+
assert.equal(await openDeliverableFile({
|
|
71
|
+
path: 'a.ts',
|
|
72
|
+
mode: 'sidebar',
|
|
73
|
+
sessionId: 's1',
|
|
74
|
+
cwd: '/repo',
|
|
75
|
+
resolveWorkspacePath: resolve,
|
|
76
|
+
openExternal: async (path) => { opened.push(path); },
|
|
77
|
+
openSidebar: (address) => { sidebar.push(address); },
|
|
78
|
+
}), 'sidebar');
|
|
79
|
+
assert.deepEqual(sidebar, ['dsh-resource://file/session/s1/a.ts']);
|
|
80
|
+
assert.deepEqual(opened, ['/repo/a.ts']);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('missing Sidebar API warns and falls back to the system opener', async () => {
|
|
84
|
+
const warnings: string[] = [];
|
|
85
|
+
const opened: string[] = [];
|
|
86
|
+
assert.equal(await openDeliverableFile({
|
|
87
|
+
path: 'a.ts',
|
|
88
|
+
mode: 'sidebar',
|
|
89
|
+
sessionId: 's1',
|
|
90
|
+
cwd: '/repo',
|
|
91
|
+
resolveWorkspacePath: (_cwd, path) => path,
|
|
92
|
+
openExternal: async (path) => { opened.push(path); },
|
|
93
|
+
warn: (message) => { warnings.push(message); },
|
|
94
|
+
}), 'external');
|
|
95
|
+
assert.deepEqual(opened, ['a.ts']);
|
|
96
|
+
assert.match(warnings[0] ?? '', /sidebarRight.openResource is not available/);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test('workspace folder clicks stay external even when sidebar mode is on', async () => {
|
|
100
|
+
const sidebar: string[] = [];
|
|
101
|
+
const opened: string[] = [];
|
|
102
|
+
assert.equal(await openDeliverableFile({
|
|
103
|
+
path: '.',
|
|
104
|
+
mode: 'sidebar',
|
|
105
|
+
sessionId: 's1',
|
|
106
|
+
cwd: '/repo',
|
|
107
|
+
resolveWorkspacePath: (cwd, path) => `${cwd}/${path}`,
|
|
108
|
+
openExternal: async (path) => { opened.push(path); },
|
|
109
|
+
openSidebar: (address) => { sidebar.push(address); },
|
|
110
|
+
}), 'external');
|
|
111
|
+
assert.deepEqual(opened, ['/repo']);
|
|
112
|
+
assert.deepEqual(sidebar, []);
|
|
113
|
+
assert.equal(resolveOpenWorkspacePath('/repo', '.', (cwd, path) => `${cwd}/${path}`), '/repo');
|
|
114
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { asReadonlyArray, pendingSubmissionImages } from '../src/client/pending-submission.ts';
|
|
7
|
+
|
|
8
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
9
|
+
|
|
10
|
+
test('text-only pending submission does not throw on missing images', () => {
|
|
11
|
+
const echo = { requestId: 'r1', text: 'hello', time: 1 };
|
|
12
|
+
assert.doesNotThrow(() => pendingSubmissionImages(echo).length);
|
|
13
|
+
assert.deepEqual(pendingSubmissionImages(echo), []);
|
|
14
|
+
assert.deepEqual(pendingSubmissionImages({ images: undefined }), []);
|
|
15
|
+
assert.deepEqual(pendingSubmissionImages({ attachments: undefined }), []);
|
|
16
|
+
assert.deepEqual(pendingSubmissionImages(undefined), []);
|
|
17
|
+
assert.deepEqual(pendingSubmissionImages(null), []);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('official images and legacy attachments both resolve', () => {
|
|
21
|
+
assert.deepEqual(
|
|
22
|
+
pendingSubmissionImages({ images: [{ previewUrl: 'blob:a', width: 4, height: 3, name: 'a.png' }] }),
|
|
23
|
+
[{ previewUrl: 'blob:a', width: 4, height: 3, name: 'a.png' }],
|
|
24
|
+
);
|
|
25
|
+
assert.deepEqual(
|
|
26
|
+
pendingSubmissionImages({ attachments: [{ type: 'image', value: { previewUrl: 'blob:b' } }, { type: 'file' }] }),
|
|
27
|
+
[{ previewUrl: 'blob:b' }],
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test('pendingSubmissions that is not an array is treated as empty', () => {
|
|
32
|
+
assert.deepEqual(asReadonlyArray(undefined), []);
|
|
33
|
+
assert.deepEqual(asReadonlyArray(null), []);
|
|
34
|
+
assert.deepEqual(asReadonlyArray({ length: 2 }), []);
|
|
35
|
+
assert.deepEqual(asReadonlyArray([{ requestId: 'a' }]), [{ requestId: 'a' }]);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('Reader and committed client bundle do not read unguarded submission.images.length', () => {
|
|
39
|
+
const source = readFileSync(resolve(root, 'src/client/Reader.tsx'), 'utf8');
|
|
40
|
+
assert.match(source, /pendingSubmissionImages/);
|
|
41
|
+
assert.doesNotMatch(source, /submission\.images\.length/);
|
|
42
|
+
const client = readFileSync(resolve(root, 'lib/client.js'), 'utf8');
|
|
43
|
+
assert.doesNotMatch(client, /submission\.images\.length/);
|
|
44
|
+
assert.match(client, /pendingSubmissionImages|function pendingSubmissionImages/);
|
|
45
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import test from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { localPathMediaUrl } from '../src/client/platform-media.js';
|
|
4
|
+
|
|
5
|
+
test('absolute local image paths use the authenticated Host file API without losing authored bytes', () => {
|
|
6
|
+
for (const path of ['/tmp/a.png', '/tmp/中文 图 #1.png', '/tmp/a%20b.png', '/tmp/a?x=1&y=2.png']) {
|
|
7
|
+
const url = localPathMediaUrl('http:', 'http://127.0.0.1:43127', path)!;
|
|
8
|
+
assert.equal(new URL(url).pathname, '/api/file');
|
|
9
|
+
assert.equal(new URL(url).searchParams.get('path'), path);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
test('relative, protocol-relative and non-HTTP page paths are not sent to the Host file API', () => {
|
|
13
|
+
for (const path of ['', 'relative.png', '//host/image.png', 'https://host/image.png', 'data:image/png,x', 'javascript:alert(1)']) {
|
|
14
|
+
assert.equal(localPathMediaUrl('http:', 'http://local', path), undefined);
|
|
15
|
+
}
|
|
16
|
+
assert.equal(localPathMediaUrl('file:', 'null', '/tmp/image.png'), undefined);
|
|
17
|
+
assert.equal(localPathMediaUrl('dsh-app:', 'dsh-app://other', '/tmp/image.png'), undefined);
|
|
18
|
+
});
|
|
19
|
+
test('Desktop file routes use the application file API', () => {
|
|
20
|
+
const url = localPathMediaUrl('dsh-app:', 'dsh-app://app', '/tmp/a.png')!;
|
|
21
|
+
assert.equal(url.startsWith('dsh-app://app/api/file?'), true);
|
|
22
|
+
assert.equal(new URL(url).searchParams.get('path'), '/tmp/a.png');
|
|
23
|
+
});
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { test } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import type { AssistantBlock, ToolCallBlock, TurnLocation } from '@deepseek-ai/dsh-client-ui-conversation/client';
|
|
4
|
+
import type { AssistantChatData, ChatConversationViewNode } from '@deepseek-ai/dsh-client-ui-chat/client';
|
|
5
|
+
import { assistantSegments, boundaryOf, forkAnchorSeq, groupNodes, hasProcessContent, hasVisibleBody, isEarlierNarration, processChoiceKey, processExpanded, terminalLabel, toolFailed } from '../src/client/projection.ts';
|
|
6
|
+
import type { TurnBoundary } from '../src/client/projection.ts';
|
|
7
|
+
import { activityPhase, activitySummary, inputFields, readerFlow } from '../src/client/tool-activity.ts';
|
|
8
|
+
|
|
9
|
+
const text: AssistantBlock = { kind: 'text', text: '前序说明或回答:不能靠关键词判断。' };
|
|
10
|
+
function assistant(values: Partial<AssistantChatData> = {}): AssistantChatData {
|
|
11
|
+
return { status: 'settled', turn: 1, step: 0, blocks: [text], time: 1, ...values };
|
|
12
|
+
}
|
|
13
|
+
const active: TurnBoundary = { status: 'open', reason: null, latestStep: 2, closingStep: null };
|
|
14
|
+
const completed: TurnBoundary = { ...active, status: 'closed', reason: 'completed', closingStep: 2 };
|
|
15
|
+
|
|
16
|
+
test('RC1 system prompts belong to process details', () => {
|
|
17
|
+
assert.equal(hasProcessContent({ kind: 'system-prompt', visibility: 'visible', data: { text: 'system' } } as ChatConversationViewNode, completed), true);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('canonical cancellation is interrupted while genuine failures stay failed', () => {
|
|
21
|
+
const cancelled = { kind: 'tool-result', isError: true, error: { code: 'ABORTED', name: 'AbortError' }, content: [{ type: 'text', text: 'Error: tool call aborted' }], subCalls: [] } as unknown as ToolCallBlock;
|
|
22
|
+
assert.equal(activityPhase({ block: cancelled }), 'interrupted');
|
|
23
|
+
assert.equal(toolFailed(cancelled), false);
|
|
24
|
+
const failure = { ...cancelled, error: { code: 'OTHER' }, content: [{ type: 'text', text: 'failure' }], meta: { exitCode: 7 } } as ToolCallBlock;
|
|
25
|
+
assert.equal(activityPhase({ block: failure }, true), 'failed');
|
|
26
|
+
assert.equal(toolFailed(failure), true);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('reasoning and body retain original order, content and identities across streaming appends', () => {
|
|
30
|
+
const first: AssistantBlock = { kind: 'reasoning', text: '**原始标点**\n 原始空格\n' };
|
|
31
|
+
const later: AssistantBlock = { kind: 'reasoning', text: '正文之后的思考' };
|
|
32
|
+
const segments = assistantSegments([first, text, later]);
|
|
33
|
+
assert.deepEqual(segments.map(part => [part.kind, part.start]), [['reasoning', 0], ['body', 1], ['reasoning', 2]]);
|
|
34
|
+
assert.deepEqual(segments.flatMap(part => part.blocks), [first, text, later]);
|
|
35
|
+
assert.equal(segments[0].blocks[0], first);
|
|
36
|
+
const append = assistantSegments([first, text, later, { kind: 'text', text: '最终正文' }]);
|
|
37
|
+
assert.deepEqual(append.slice(0, 3), segments);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('a settled step alone never means final or disposable', () => {
|
|
41
|
+
assert.equal(isEarlierNarration(assistant(), { ...active, latestStep: 0 }), false);
|
|
42
|
+
assert.equal(isEarlierNarration(assistant(), { ...active, status: 'unknown' }), false);
|
|
43
|
+
assert.equal(isEarlierNarration(assistant({ status: 'running' }), active), false);
|
|
44
|
+
assert.equal(isEarlierNarration(assistant(), active), false);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test('process stays open through body output and later steps until successful turn completion', () => {
|
|
48
|
+
assert.equal(processExpanded(undefined, active), true);
|
|
49
|
+
assert.equal(processExpanded(undefined, { ...active, latestStep: 7 }), true);
|
|
50
|
+
assert.equal(processExpanded(undefined, completed), false);
|
|
51
|
+
assert.equal(processExpanded(undefined, { ...active, status: 'unknown' }), true);
|
|
52
|
+
for (const reason of ['error', 'aborted', 'interrupted', 'blocked', 'max-tokens', 'future-terminal']) {
|
|
53
|
+
assert.equal(processExpanded(undefined, { ...completed, reason }), true, reason);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
test('deliberate process expansion or collapse overrides the automatic lifecycle', () => {
|
|
58
|
+
assert.equal(processExpanded(true, completed), true);
|
|
59
|
+
assert.equal(processExpanded(false, active), false);
|
|
60
|
+
assert.equal(processExpanded(false, { ...completed, reason: 'error' }), false);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('reading during a run does not keep the completed process open; reopening after completion is deliberate', () => {
|
|
64
|
+
const choices: Record<string, boolean> = {};
|
|
65
|
+
choices[processChoiceKey('turn:1', active)] = true;
|
|
66
|
+
assert.equal(processExpanded(choices[processChoiceKey('turn:1', completed)], completed), false);
|
|
67
|
+
assert.equal(processChoiceKey('turn:1', active), processChoiceKey('turn:1', { ...active, latestStep: 9 }));
|
|
68
|
+
choices[processChoiceKey('turn:1', completed)] = true;
|
|
69
|
+
assert.equal(processExpanded(choices[processChoiceKey('turn:1', completed)], completed), true);
|
|
70
|
+
assert.equal(processExpanded(choices[processChoiceKey('turn:2', completed)], completed), false);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('body-only steps do not advertise empty thinking, while real reasoning and earlier progress remain accessible', () => {
|
|
74
|
+
const node = (data: AssistantChatData) => ({ kind: 'assistant-step', visibility: 'visible', data }) as ChatConversationViewNode;
|
|
75
|
+
const closing = node(assistant({ step: 2 }));
|
|
76
|
+
assert.equal(hasProcessContent(closing, active), false);
|
|
77
|
+
assert.equal(hasProcessContent(closing, completed), false);
|
|
78
|
+
assert.equal(hasProcessContent(node(assistant({ step: 2, blocks: [{ kind: 'reasoning', text: '' }, text] })), completed), false);
|
|
79
|
+
assert.equal(hasProcessContent(node(assistant({ step: 2, blocks: [{ kind: 'reasoning', text: '真实思考' }, text] })), active), true);
|
|
80
|
+
assert.equal(hasProcessContent(node(assistant({ step: 1 })), completed), true);
|
|
81
|
+
assert.equal(hasProcessContent({ ...closing, visibility: 'hidden' }, completed), false);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('completed turns preserve the public closing message, even with a later nontext step', () => {
|
|
85
|
+
assert.equal(isEarlierNarration(assistant({ step: 2 }), completed), false);
|
|
86
|
+
assert.equal(isEarlierNarration(assistant({ step: 1 }), { ...completed, closingStep: 1 }), false);
|
|
87
|
+
assert.equal(isEarlierNarration(assistant({ step: 0 }), { ...completed, closingStep: 1 }), true);
|
|
88
|
+
assert.equal(isEarlierNarration(assistant(), { ...completed, closingStep: null }), false);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test('all abnormal and unknown terminal states preserve generated prefixes', () => {
|
|
92
|
+
for (const reason of ['error', 'aborted', 'interrupted', 'blocked', 'max-tokens', 'future-terminal']) {
|
|
93
|
+
assert.equal(isEarlierNarration(assistant(), { ...completed, reason }), false, reason);
|
|
94
|
+
assert.ok(terminalLabel(reason), reason);
|
|
95
|
+
}
|
|
96
|
+
assert.equal(isEarlierNarration(assistant({ status: 'interrupted' }), completed), false);
|
|
97
|
+
assert.equal(terminalLabel('completed'), null);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('images, future modalities, and mixed body blocks never disappear into process', () => {
|
|
101
|
+
const unknown: AssistantBlock = { kind: 'other', block: { type: 'mcp-app', html: '<script>window.bad=true</script>' } };
|
|
102
|
+
const image: AssistantBlock = { kind: 'image', attachment: { attachmentId: 'test-attachment' as never, width: 100, height: 100, mediaType: 'image/png', bytes: 10 } };
|
|
103
|
+
for (const blocks of [[unknown], [text, unknown], [image], [text, image]]) {
|
|
104
|
+
assert.equal(isEarlierNarration(assistant({ blocks }), completed), false);
|
|
105
|
+
assert.equal(hasVisibleBody(blocks), true);
|
|
106
|
+
}
|
|
107
|
+
assert.equal(hasVisibleBody([{ kind: 'reasoning', text: 'private display trace' }]), false);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('classification never inspects wording', () => {
|
|
111
|
+
for (const value of ['Final answer:', '正在处理', '请你确认再继续', 'All done', 'Think']) {
|
|
112
|
+
assert.equal(isEarlierNarration(assistant({ step: 2, blocks: [{ kind: 'text', text: value }] }), completed), false);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('structural grouping retains keys and source order and excludes host-hidden rows', () => {
|
|
117
|
+
const turn = { turn: 1, status: 'open', steps: [] } as unknown as TurnLocation;
|
|
118
|
+
const node = (key: string, kind: string, location: ChatConversationViewNode['location'], visibility: 'visible' | 'hidden' = 'visible'): ChatConversationViewNode => ({ key, id: key, kind, target: 'chat', data: {}, anchorSeq: Number(key), visibility, location });
|
|
119
|
+
const nodes = [node('1', 'user', { kind: 'unresolved' }), node('2', 'assistant-step', { kind: 'turn', turn }), node('3', 'tool-call', { kind: 'turn', turn }), node('4', 'context', { kind: 'turn', turn }, 'hidden'), node('5', 'custom', { kind: 'unresolved' })];
|
|
120
|
+
const byKey = new Map(nodes.map(row => [row.key, row]));
|
|
121
|
+
const result = groupNodes(nodes.map(row => row.key), key => byKey.get(key));
|
|
122
|
+
assert.deepEqual(result.map(group => group.keys), [['1'], ['2', '3'], ['5']]);
|
|
123
|
+
assert.deepEqual(result.flatMap(group => group.keys), ['1', '2', '3', '5']);
|
|
124
|
+
assert.equal(result[1]?.key, groupNodes([...nodes.map(row => row.key), 'missing'], key => byKey.get(key))[1]?.key);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('missing historical boundaries remain explicit uncertainty', () => {
|
|
128
|
+
const boundary = boundaryOf(undefined);
|
|
129
|
+
assert.deepEqual(boundary, { status: 'unknown', reason: null, latestStep: -1, closingStep: null });
|
|
130
|
+
assert.equal(isEarlierNarration(assistant(), boundary), false);
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('a failed child tool is not hidden by a successful parent summary', () => {
|
|
134
|
+
const failed = { kind: 'tool-result', isError: true, content: [], subCalls: [] } as unknown as ToolCallBlock;
|
|
135
|
+
const parent = { kind: 'tool-result', isError: false, content: [], subCalls: [failed] } as unknown as ToolCallBlock;
|
|
136
|
+
assert.equal(toolFailed(parent), true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test('tool input is visible before execution, including native-hidden tool-only steps', () => {
|
|
140
|
+
const draft = { kind: 'tool-call' as const, callId: 'draft-call', name: 'write', argsRaw: '{"file_path":"/work/view.html","content":"<html>\\n' };
|
|
141
|
+
const data = assistant({ status: 'running', blocks: [draft] });
|
|
142
|
+
const turn = { turn: 1, steps: [{ step: 0, start: { seq: 1 }, data: { get: () => data } }] } as unknown as TurnLocation;
|
|
143
|
+
const group = { key: 'turn:1', turn: 1, keys: [] };
|
|
144
|
+
const pending = readerFlow(group, turn, () => undefined);
|
|
145
|
+
assert.equal(pending.length, 1);
|
|
146
|
+
assert.equal(pending[0]?.kind, 'tool');
|
|
147
|
+
if (pending[0]?.kind !== 'tool') throw new Error('missing tool');
|
|
148
|
+
assert.equal(activityPhase(pending[0]), 'preparing');
|
|
149
|
+
assert.equal(activitySummary(pending[0]).title, '写入 view.html');
|
|
150
|
+
assert.equal(activitySummary(pending[0]).content, '<html>\n');
|
|
151
|
+
const block = { callId: draft.callId, name: 'write', argsRaw: draft.argsRaw, subCalls: [] } as unknown as ToolCallBlock;
|
|
152
|
+
const node = { key: 'tool-native', kind: 'tool-call', visibility: 'visible', anchorSeq: 10, data: { root: block }, location: { kind: 'step', step: { step: 0 } } } as unknown as ChatConversationViewNode;
|
|
153
|
+
const running = readerFlow({ ...group, keys: [node.key] }, turn, () => node);
|
|
154
|
+
assert.equal(running.length, 1);
|
|
155
|
+
assert.equal(running[0]?.key, pending[0].key, 'one call keeps the same React key at execution');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
test('partial argument parsing respects JSON nesting, escapes and unfinished unicode', () => {
|
|
159
|
+
const source = JSON.stringify({ file_path: '/work/真实.html', content: '"file_path":"fake"\n你好😀', nested: { file_path: 'also fake' } });
|
|
160
|
+
for (let cut = source.indexOf('content') + 10; cut <= source.length; cut++) {
|
|
161
|
+
const fields = inputFields(source.slice(0, cut));
|
|
162
|
+
assert.equal(fields.file_path, '/work/真实.html');
|
|
163
|
+
if (typeof fields.content === 'string') assert.ok('"file_path":"fake"\n你好😀'.startsWith(fields.content));
|
|
164
|
+
}
|
|
165
|
+
assert.equal(inputFields('{"content":"start\\u4f').content, 'start');
|
|
166
|
+
assert.equal(inputFields('{"content":"slash\\\\').content, 'slash\\');
|
|
167
|
+
assert.equal(inputFields('{"nested":{"file_path":"fake"},"file_path":"real').file_path, 'real');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test('a nonzero terminal exit is a failure even when the tool transport is non-error', () => {
|
|
171
|
+
const block = { kind: 'tool-result', isError: false, content: [], meta: { exitCode: 7 }, subCalls: [] } as unknown as ToolCallBlock;
|
|
172
|
+
assert.equal(toolFailed(block), true);
|
|
173
|
+
assert.equal(activityPhase({ block }), 'failed');
|
|
174
|
+
assert.equal(activityPhase({ block: { ...block, meta: null } as ToolCallBlock }), 'returned');
|
|
175
|
+
assert.equal(activityPhase({}, true), 'interrupted');
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('fork anchor prefers the durable closing seq and never yields a missing anchor', () => {
|
|
179
|
+
assert.equal(forkAnchorSeq([{ seq: 42 }]), 42);
|
|
180
|
+
assert.equal(forkAnchorSeq([null, undefined, {}, { seq: '42' as unknown as number }, { seq: 7 }]), 7);
|
|
181
|
+
assert.equal(forkAnchorSeq([{ seq: NaN }, { seq: Infinity }, { seq: 100.5 }]), 100.5);
|
|
182
|
+
assert.equal(forkAnchorSeq([]), undefined);
|
|
183
|
+
assert.equal(forkAnchorSeq([null, {}, { seq: undefined }]), undefined);
|
|
184
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import { test } from 'node:test';
|
|
3
|
+
import { reasoningTarget } from '../src/client/reasoning-follow.js';
|
|
4
|
+
|
|
5
|
+
test('reasoning follows ordinary growth in two-line steps without passing the tail', () => {
|
|
6
|
+
assert.equal(reasoningTarget(0, 284, 224, 24), 48);
|
|
7
|
+
assert.equal(reasoningTarget(48, 284, 224, 24), 60);
|
|
8
|
+
assert.equal(reasoningTarget(0, 100, 224, 24), 0);
|
|
9
|
+
assert.equal(reasoningTarget(999, 284, 224, 24), 60);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('a large reasoning burst still advances exactly two lines without skipping the middle', () => {
|
|
13
|
+
let top = 0;
|
|
14
|
+
for (const content of [400, 1200, 1500, 1500]) {
|
|
15
|
+
const target = reasoningTarget(top, content, 224, 24);
|
|
16
|
+
assert.equal(target - top, 48, 'a transport burst must not change the reference step distance');
|
|
17
|
+
assert.ok(target <= content - 224);
|
|
18
|
+
top = target;
|
|
19
|
+
}
|
|
20
|
+
while (top < 1500 - 224) {
|
|
21
|
+
const target = reasoningTarget(top, 1500, 224, 24);
|
|
22
|
+
assert.ok(target > top && target - top <= 48);
|
|
23
|
+
top = target;
|
|
24
|
+
}
|
|
25
|
+
assert.equal(top, 1500 - 224);
|
|
26
|
+
assert.equal(reasoningTarget(top, 1500, 224, 24), top, 'reaching the end must not replay the transcript');
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('two-line movement follows actual typography and clamps a resized viewport', () => {
|
|
30
|
+
assert.equal(reasoningTarget(28, 900, 192, 30), 88);
|
|
31
|
+
assert.equal(reasoningTarget(-50, 900, 192, 30), 60);
|
|
32
|
+
assert.equal(reasoningTarget(708, 900, 400, 30), 500);
|
|
33
|
+
assert.equal(reasoningTarget(0, 900, 192, 0), 2);
|
|
34
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
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 { en, zh } from '../src/client/settings-copy.ts';
|
|
7
|
+
import { CONVENTIONAL_SKILL_ROOTS, GENERATIVE_MCPAPPS_SKILL } from '../src/skill-status.ts';
|
|
8
|
+
import { shortestInstallCommand } from '../src/client/skill-status.ts';
|
|
9
|
+
|
|
10
|
+
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
11
|
+
|
|
12
|
+
/** User-facing surfaces must never print home/profile absolutes. */
|
|
13
|
+
const LEAKED_ABSOLUTE_PATH = /\/Users\/|[A-Za-z]:\\|(?:^|[\s"'`])\/home\/|\$HOME\b|\$DSH_HOME\b|~\//;
|
|
14
|
+
|
|
15
|
+
function installGuidanceSurface(): string {
|
|
16
|
+
return [
|
|
17
|
+
...Object.values(en),
|
|
18
|
+
...Object.values(zh),
|
|
19
|
+
shortestInstallCommand({
|
|
20
|
+
packPath: '/Users/cola/plugin/skills/generative-mcpapps',
|
|
21
|
+
roots: [
|
|
22
|
+
{ source: 'user-dsh', path: '/Users/cola/.dsh/skills' },
|
|
23
|
+
{ source: 'user-agents', path: 'C:\\Users\\cola\\.agents\\skills' },
|
|
24
|
+
],
|
|
25
|
+
}),
|
|
26
|
+
...CONVENTIONAL_SKILL_ROOTS,
|
|
27
|
+
].join('\n');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
test('install guidance names only relative skill roots', () => {
|
|
31
|
+
const surface = installGuidanceSurface();
|
|
32
|
+
assert.match(surface, /\.dsh\/skills/);
|
|
33
|
+
assert.match(surface, /\.agents\/skills/);
|
|
34
|
+
assert.match(surface, new RegExp(GENERATIVE_MCPAPPS_SKILL));
|
|
35
|
+
assert.doesNotMatch(surface, LEAKED_ABSOLUTE_PATH);
|
|
36
|
+
assert.doesNotMatch(surface, /\/Users\//);
|
|
37
|
+
assert.doesNotMatch(surface, /C:\\/);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('Settings dictionaries mention conventional roots and the skill folder', () => {
|
|
41
|
+
for (const copy of [en, zh]) {
|
|
42
|
+
const blob = `${copy.skillInstall}\n${copy.skillUnavailable}`;
|
|
43
|
+
assert.match(blob, /\.dsh\/skills/);
|
|
44
|
+
assert.match(blob, /\.agents\/skills/);
|
|
45
|
+
assert.match(blob, /generative-mcpapps/);
|
|
46
|
+
assert.doesNotMatch(blob, LEAKED_ABSOLUTE_PATH);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('committed Settings UI copy and command stay relative', () => {
|
|
51
|
+
const client = readFileSync(resolve(root, 'lib/client.js'), 'utf8');
|
|
52
|
+
const section = readFileSync(resolve(root, 'src/client/SettingsSection.tsx'), 'utf8');
|
|
53
|
+
assert.match(section, /CONVENTIONAL_SKILL_ROOTS/);
|
|
54
|
+
assert.doesNotMatch(section, /root\.path/);
|
|
55
|
+
assert.doesNotMatch(section, /shortestInstallCommand\(skill\)/);
|
|
56
|
+
assert.match(client, /\.dsh\/skills/);
|
|
57
|
+
assert.match(client, /\.agents\/skills/);
|
|
58
|
+
assert.doesNotMatch(client, /mkdir -p "\$DSH_HOME\/skills"/);
|
|
59
|
+
assert.doesNotMatch(client, /status\.packPath \?\?/);
|
|
60
|
+
assert.doesNotMatch(client, /root\.source, ": ", root\.path/);
|
|
61
|
+
assert.doesNotMatch(client, /\/Users\//);
|
|
62
|
+
assert.doesNotMatch(client, /C:\\\\/);
|
|
63
|
+
});
|