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,130 @@
|
|
|
1
|
+
import { defineStore } from '@deepseek-ai/dsh-client-store';
|
|
2
|
+
import type { EngineStoreHandle } from '@deepseek-ai/dsh-client-store';
|
|
3
|
+
import {
|
|
4
|
+
FOLD_INTENSITY_DEFAULT,
|
|
5
|
+
autoFoldFromIntensity,
|
|
6
|
+
processOnlyFromIntensity,
|
|
7
|
+
type FoldIntensity,
|
|
8
|
+
} from './fold-intensity.js';
|
|
9
|
+
import type { DeliverableOpenMode } from './open-file.js';
|
|
10
|
+
|
|
11
|
+
export interface ReaderState {
|
|
12
|
+
expanded: Record<string, boolean>;
|
|
13
|
+
motion: boolean;
|
|
14
|
+
/** Derived from foldIntensity; kept so older persisted snapshots still read. */
|
|
15
|
+
autoFold: boolean;
|
|
16
|
+
/** Default stays the system app. `sidebar` is opt-in. */
|
|
17
|
+
deliverableOpenMode: DeliverableOpenMode;
|
|
18
|
+
/**
|
|
19
|
+
* 0 = no auto-fold, 1 = current-main fold-on-next-reasoning (default),
|
|
20
|
+
* 2 = process-summary mode from community PR #14.
|
|
21
|
+
*/
|
|
22
|
+
foldIntensity: FoldIntensity;
|
|
23
|
+
/** Translucent frosted chrome. Default off so opaque main chrome stays. */
|
|
24
|
+
frostedGlass: boolean;
|
|
25
|
+
/** Rounded answer bubbles. Default on; off lays answers flat on the page. */
|
|
26
|
+
bubbles: boolean;
|
|
27
|
+
/** Derived from foldIntensity === 2; kept for older #14 snapshots. */
|
|
28
|
+
processOnly: boolean;
|
|
29
|
+
/** Canvas message rail (ported from dsh-tidychat). */
|
|
30
|
+
railEnabled: boolean;
|
|
31
|
+
railSide: 'left' | 'right';
|
|
32
|
+
railStyle: 'bar' | 'dot';
|
|
33
|
+
/** White sheen beneath current/hover marks. */
|
|
34
|
+
railRing: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Hide the official TurnNavigator via the takeover attribute. The official
|
|
37
|
+
* rail still mounts even under the reader, so this stays a user-facing
|
|
38
|
+
* switch (default on) — the merge did drop it once and the official rail
|
|
39
|
+
* resurfaced next to ours.
|
|
40
|
+
*/
|
|
41
|
+
hideOfficialNav: boolean;
|
|
42
|
+
/** Rail palette (ported from dsh-tidychat): auto / hue×lightness / custom. */
|
|
43
|
+
railColor: string;
|
|
44
|
+
railColorCustom: string;
|
|
45
|
+
railColorLight: string;
|
|
46
|
+
railAccent: string;
|
|
47
|
+
railAccentCustom: string;
|
|
48
|
+
railAccentLight: string;
|
|
49
|
+
}
|
|
50
|
+
type ReaderActions = {
|
|
51
|
+
setExpanded: (draft: ReaderState, key: string, value: boolean) => void;
|
|
52
|
+
resetExpanded: (draft: ReaderState) => void;
|
|
53
|
+
setMotion: (draft: ReaderState, value: boolean) => void;
|
|
54
|
+
setAutoFold: (draft: ReaderState, value: boolean) => void;
|
|
55
|
+
setDeliverableOpenMode: (draft: ReaderState, value: DeliverableOpenMode) => void;
|
|
56
|
+
setFoldIntensity: (draft: ReaderState, value: FoldIntensity) => void;
|
|
57
|
+
setFrostedGlass: (draft: ReaderState, value: boolean) => void;
|
|
58
|
+
setBubbles: (draft: ReaderState, value: boolean) => void;
|
|
59
|
+
setRailEnabled: (draft: ReaderState, value: boolean) => void;
|
|
60
|
+
setRailSide: (draft: ReaderState, value: 'left' | 'right') => void;
|
|
61
|
+
setRailStyle: (draft: ReaderState, value: 'bar' | 'dot') => void;
|
|
62
|
+
setRailRing: (draft: ReaderState, value: boolean) => void;
|
|
63
|
+
setHideOfficialNav: (draft: ReaderState, value: boolean) => void;
|
|
64
|
+
setRailColor: (draft: ReaderState, value: string) => void;
|
|
65
|
+
setRailColorCustom: (draft: ReaderState, value: string) => void;
|
|
66
|
+
setRailColorLight: (draft: ReaderState, value: string) => void;
|
|
67
|
+
setRailAccent: (draft: ReaderState, value: string) => void;
|
|
68
|
+
setRailAccentCustom: (draft: ReaderState, value: string) => void;
|
|
69
|
+
setRailAccentLight: (draft: ReaderState, value: string) => void;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function applyFoldIntensity(draft: ReaderState, value: FoldIntensity): void {
|
|
73
|
+
draft.foldIntensity = value;
|
|
74
|
+
draft.autoFold = autoFoldFromIntensity(value);
|
|
75
|
+
draft.processOnly = processOnlyFromIntensity(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function createReaderStore(): EngineStoreHandle<ReaderState, ReaderActions> {
|
|
79
|
+
return defineStore({
|
|
80
|
+
init: (): ReaderState => ({
|
|
81
|
+
expanded: {},
|
|
82
|
+
motion: true,
|
|
83
|
+
autoFold: true,
|
|
84
|
+
deliverableOpenMode: 'external',
|
|
85
|
+
foldIntensity: FOLD_INTENSITY_DEFAULT,
|
|
86
|
+
frostedGlass: false,
|
|
87
|
+
bubbles: true,
|
|
88
|
+
processOnly: false,
|
|
89
|
+
railEnabled: true,
|
|
90
|
+
railSide: 'left',
|
|
91
|
+
railStyle: 'bar',
|
|
92
|
+
// Default on: the sheen is the rail's wallpaper-legibility guarantee
|
|
93
|
+
// (the user-facing requirement was "selectable AND visible").
|
|
94
|
+
railRing: true,
|
|
95
|
+
hideOfficialNav: true,
|
|
96
|
+
railColor: 'auto',
|
|
97
|
+
railColorCustom: '',
|
|
98
|
+
railColorLight: 'l3',
|
|
99
|
+
railAccent: 'auto',
|
|
100
|
+
railAccentCustom: '',
|
|
101
|
+
railAccentLight: 'l3',
|
|
102
|
+
}),
|
|
103
|
+
persist: 'dsh.reader.v1',
|
|
104
|
+
actions: {
|
|
105
|
+
setExpanded: (draft, key: string, value: boolean) => { draft.expanded[key] = value; },
|
|
106
|
+
resetExpanded: draft => { draft.expanded = {}; },
|
|
107
|
+
setMotion: (draft, value: boolean) => { draft.motion = value; },
|
|
108
|
+
setAutoFold: (draft, value: boolean) => {
|
|
109
|
+
applyFoldIntensity(draft, value
|
|
110
|
+
? (draft.foldIntensity === 2 ? 2 : 1)
|
|
111
|
+
: 0);
|
|
112
|
+
},
|
|
113
|
+
setDeliverableOpenMode: (draft, value: DeliverableOpenMode) => { draft.deliverableOpenMode = value; },
|
|
114
|
+
setFoldIntensity: (draft, value: FoldIntensity) => { applyFoldIntensity(draft, value); },
|
|
115
|
+
setFrostedGlass: (draft, value: boolean) => { draft.frostedGlass = value; },
|
|
116
|
+
setBubbles: (draft, value: boolean) => { draft.bubbles = value; },
|
|
117
|
+
setRailEnabled: (draft, value: boolean) => { draft.railEnabled = value; },
|
|
118
|
+
setRailSide: (draft, value: 'left' | 'right') => { draft.railSide = value; },
|
|
119
|
+
setRailStyle: (draft, value: 'bar' | 'dot') => { draft.railStyle = value; },
|
|
120
|
+
setRailRing: (draft, value: boolean) => { draft.railRing = value; },
|
|
121
|
+
setHideOfficialNav: (draft, value: boolean) => { draft.hideOfficialNav = value; },
|
|
122
|
+
setRailColor: (draft, value: string) => { draft.railColor = value; },
|
|
123
|
+
setRailColorCustom: (draft, value: string) => { draft.railColorCustom = value; },
|
|
124
|
+
setRailColorLight: (draft, value: string) => { draft.railColorLight = value; },
|
|
125
|
+
setRailAccent: (draft, value: string) => { draft.railAccent = value; },
|
|
126
|
+
setRailAccentCustom: (draft, value: string) => { draft.railAccentCustom = value; },
|
|
127
|
+
setRailAccentLight: (draft, value: string) => { draft.railAccentLight = value; },
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/** Presentation only. The original session string remains the source of truth. */
|
|
2
|
+
// The reveal runs at the rate the source is actually producing (feed-forward)
|
|
3
|
+
// plus a proportional term that closes whatever backlog jitter left behind.
|
|
4
|
+
// A proportional-only controller drains exactly one window per window, so the
|
|
5
|
+
// display trails live output by catchUpMs forever — unreadable-but-smooth at
|
|
6
|
+
// 75 chars/s, permanently behind at 1000. The feed-forward term is what makes
|
|
7
|
+
// the pace adapt to the model instead of to a fixed constant.
|
|
8
|
+
export const STREAM_TIMING = {
|
|
9
|
+
catchUpMs: 520,
|
|
10
|
+
maxQueuedMs: 600,
|
|
11
|
+
finishMs: 96,
|
|
12
|
+
revealMs: 350,
|
|
13
|
+
minimumRate: 260,
|
|
14
|
+
/** Weight of the newest arrival sample in the smoothed source rate. */
|
|
15
|
+
rateWeight: 0.35,
|
|
16
|
+
/** A longer gap is a pause between runs, not a slow model: keep the estimate. */
|
|
17
|
+
rateGapMs: 250,
|
|
18
|
+
} as const;
|
|
19
|
+
const graphemes = new Intl.Segmenter(undefined, { granularity: 'grapheme' });
|
|
20
|
+
|
|
21
|
+
function atOrAfter(values: readonly number[], target: number): number {
|
|
22
|
+
let low = 0;
|
|
23
|
+
let high = values.length - 1;
|
|
24
|
+
while (low < high) {
|
|
25
|
+
const middle = (low + high) >>> 1;
|
|
26
|
+
if (values[middle]! < target) low = middle + 1;
|
|
27
|
+
else high = middle;
|
|
28
|
+
}
|
|
29
|
+
return low;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class StreamBuffer {
|
|
33
|
+
target: string;
|
|
34
|
+
visible: string;
|
|
35
|
+
revision = 0;
|
|
36
|
+
private boundaries = [0];
|
|
37
|
+
private arrivals: { end: number; at: number }[] = [];
|
|
38
|
+
private lastAt: number | null = null;
|
|
39
|
+
private credit = 0;
|
|
40
|
+
private finishAt: number | null = null;
|
|
41
|
+
private rateEwma = 0;
|
|
42
|
+
private lastArrival: number | null = null;
|
|
43
|
+
|
|
44
|
+
constructor(initial = '') {
|
|
45
|
+
this.target = initial;
|
|
46
|
+
this.visible = initial;
|
|
47
|
+
this.segment(0);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
get pending(): boolean { return this.visible.length < this.target.length; }
|
|
51
|
+
|
|
52
|
+
private segment(from: number): void {
|
|
53
|
+
const index = atOrAfter(this.boundaries, from);
|
|
54
|
+
this.boundaries.length = index;
|
|
55
|
+
for (const part of graphemes.segment(this.target.slice(from))) this.boundaries.push(from + part.index);
|
|
56
|
+
if (this.boundaries.at(-1) !== this.target.length) this.boundaries.push(this.target.length);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Non-append updates, cancellations and hidden/reduced views never replay. */
|
|
60
|
+
update(text: string, now: number, options: { immediate?: boolean; finished?: boolean } = {}): void {
|
|
61
|
+
if (options.immediate || !text.startsWith(this.target)) {
|
|
62
|
+
if (text !== this.target) this.revision++;
|
|
63
|
+
this.target = text;
|
|
64
|
+
this.flush();
|
|
65
|
+
this.boundaries = [0];
|
|
66
|
+
this.segment(0);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (text !== this.target) {
|
|
70
|
+
const wasPending = this.pending;
|
|
71
|
+
const grew = text.length - this.target.length;
|
|
72
|
+
const from = this.boundaries.at(-2) ?? 0;
|
|
73
|
+
this.observe(grew, now);
|
|
74
|
+
this.target = text;
|
|
75
|
+
// Re-segment the previous last cluster: an emoji/combining sequence can
|
|
76
|
+
// itself span transport chunks. Frozen source prefixes are not scanned.
|
|
77
|
+
this.segment(from);
|
|
78
|
+
this.arrivals.push({ end: text.length, at: now });
|
|
79
|
+
if (!wasPending) { this.lastAt = now; this.credit = 0; }
|
|
80
|
+
}
|
|
81
|
+
if (options.finished && this.finishAt === null) this.finishAt = now + STREAM_TIMING.finishMs;
|
|
82
|
+
if (!options.finished) this.finishAt = null;
|
|
83
|
+
if (this.target.length - this.visible.length > 8192) { this.revision++; this.flush(); }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Smoothed source rate, so one jittery transport chunk cannot set the pace. */
|
|
87
|
+
private observe(grew: number, now: number): void {
|
|
88
|
+
const previous = this.lastArrival;
|
|
89
|
+
this.lastArrival = now;
|
|
90
|
+
if (previous === null || grew <= 0) return;
|
|
91
|
+
const elapsed = now - previous;
|
|
92
|
+
if (elapsed <= 0 || elapsed > STREAM_TIMING.rateGapMs) return;
|
|
93
|
+
const sample = grew * 1000 / elapsed;
|
|
94
|
+
this.rateEwma = this.rateEwma === 0
|
|
95
|
+
? sample
|
|
96
|
+
: this.rateEwma * (1 - STREAM_TIMING.rateWeight) + sample * STREAM_TIMING.rateWeight;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
flush(): void {
|
|
100
|
+
this.visible = this.target;
|
|
101
|
+
this.arrivals = [];
|
|
102
|
+
this.credit = 0;
|
|
103
|
+
this.lastAt = null;
|
|
104
|
+
this.lastArrival = null;
|
|
105
|
+
this.finishAt = null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
advance(now: number): boolean {
|
|
109
|
+
if (!this.pending) return false;
|
|
110
|
+
const before = this.visible.length;
|
|
111
|
+
const index = atOrAfter(this.boundaries, before);
|
|
112
|
+
const remaining = this.boundaries.length - index - 1;
|
|
113
|
+
const delta = Math.max(0, now - (this.lastAt ?? now));
|
|
114
|
+
this.lastAt = now;
|
|
115
|
+
const windowMs = this.finishAt === null ? STREAM_TIMING.catchUpMs : Math.max(16, Math.min(STREAM_TIMING.catchUpMs, this.finishAt - now));
|
|
116
|
+
// Feed-forward keeps pace with the source; the proportional term then drains
|
|
117
|
+
// whatever backlog is left, so lag decays instead of settling at one window.
|
|
118
|
+
const rate = Math.max(STREAM_TIMING.minimumRate, this.rateEwma + remaining * 1000 / windowMs);
|
|
119
|
+
this.credit += rate * delta / 1000;
|
|
120
|
+
const count = Math.floor(this.credit);
|
|
121
|
+
this.credit -= count;
|
|
122
|
+
let end = this.boundaries[Math.min(this.boundaries.length - 1, index + count)]!;
|
|
123
|
+
for (const item of this.arrivals) {
|
|
124
|
+
if (now - item.at < STREAM_TIMING.maxQueuedMs) break;
|
|
125
|
+
end = Math.max(end, this.boundaries[atOrAfter(this.boundaries, item.end)]!);
|
|
126
|
+
}
|
|
127
|
+
if (this.finishAt !== null && now >= this.finishAt) end = this.target.length;
|
|
128
|
+
// Never expose half of a surrogate pair while the source can still grow.
|
|
129
|
+
if (end && /[\uD800-\uDBFF]/.test(this.target[end - 1]!) && this.finishAt === null) end--;
|
|
130
|
+
end = Math.max(before, end);
|
|
131
|
+
this.visible = this.target.slice(0, end);
|
|
132
|
+
this.arrivals = this.arrivals.filter(item => item.end > end);
|
|
133
|
+
if (!this.pending) { this.credit = 0; this.lastAt = null; }
|
|
134
|
+
return end !== before;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { StreamBuffer } from './stream-buffer.js';
|
|
3
|
+
import { WORD_MOTION } from './word-timeline.js';
|
|
4
|
+
|
|
5
|
+
export const StreamMotionContext = createContext<{ enabled: boolean; activatedAt: number; paused?: boolean; resumed?: boolean }>({ enabled: false, activatedAt: 0 });
|
|
6
|
+
|
|
7
|
+
export function useStreamingText(source: string, streaming: boolean, options: { startedAt?: number; interrupted: boolean; selected: boolean }) {
|
|
8
|
+
const { enabled, activatedAt, paused = false, resumed = false } = useContext(StreamMotionContext);
|
|
9
|
+
const fresh = resumed || (options.startedAt ?? 0) >= activatedAt;
|
|
10
|
+
const buffer = useRef<StreamBuffer>();
|
|
11
|
+
// Only newly mounted content after a fold uses the catch-up path. History and
|
|
12
|
+
// user-opened drawers stay immediate; already mounted prefixes never replay.
|
|
13
|
+
if (!buffer.current) buffer.current = new StreamBuffer(enabled && (streaming || resumed) && fresh ? '' : source);
|
|
14
|
+
const [display, setDisplay] = useState(() => ({ text: buffer.current!.visible, revision: 0 }));
|
|
15
|
+
const [finalizing, setFinalizing] = useState(streaming);
|
|
16
|
+
const frame = useRef(0);
|
|
17
|
+
const immediate = !enabled || options.interrupted || options.selected;
|
|
18
|
+
const publish = () => {
|
|
19
|
+
const current = buffer.current!;
|
|
20
|
+
setDisplay(previous => previous.text === current.visible && previous.revision === current.revision ? previous : { text: current.visible, revision: current.revision });
|
|
21
|
+
};
|
|
22
|
+
const handoff = useRef(resumed);
|
|
23
|
+
const presentationClock = useRef(performance.now());
|
|
24
|
+
useLayoutEffect(() => {
|
|
25
|
+
cancelAnimationFrame(frame.current);
|
|
26
|
+
const current = buffer.current!;
|
|
27
|
+
// While the choreography holds the reveal, keep the buffer absorbing the
|
|
28
|
+
// source instead of returning early: the target must never lag behind what
|
|
29
|
+
// arrived, or the text would keep catching up long after the fold settled.
|
|
30
|
+
// Dropping the frame loop is what pauses the reveal; the target still tracks.
|
|
31
|
+
if (paused && !immediate && !document.hidden) {
|
|
32
|
+
current.update(source, performance.now(), { immediate: false, finished: !streaming });
|
|
33
|
+
publish();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
let previous = performance.now();
|
|
37
|
+
current.update(source, handoff.current ? presentationClock.current : previous, { immediate: immediate || document.hidden, finished: !streaming && !resumed });
|
|
38
|
+
publish();
|
|
39
|
+
const tick = (now: number) => {
|
|
40
|
+
// A delayed browser frame must not dump the whole buffered response at
|
|
41
|
+
// first paint. Bound catch-up by visible frame time for this handoff only.
|
|
42
|
+
presentationClock.current += Math.min(32, Math.max(0, now - previous));
|
|
43
|
+
previous = now;
|
|
44
|
+
if (document.hidden) current.flush();
|
|
45
|
+
else current.advance(handoff.current ? presentationClock.current : now);
|
|
46
|
+
publish();
|
|
47
|
+
if (current.pending) frame.current = requestAnimationFrame(tick);
|
|
48
|
+
else handoff.current = false;
|
|
49
|
+
};
|
|
50
|
+
if (current.pending) frame.current = requestAnimationFrame(tick);
|
|
51
|
+
return () => cancelAnimationFrame(frame.current);
|
|
52
|
+
}, [source, streaming, immediate, paused, resumed]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const hidden = () => {
|
|
55
|
+
if (!document.hidden) return;
|
|
56
|
+
cancelAnimationFrame(frame.current);
|
|
57
|
+
buffer.current!.flush(); publish(); setFinalizing(false);
|
|
58
|
+
};
|
|
59
|
+
document.addEventListener('visibilitychange', hidden);
|
|
60
|
+
return () => document.removeEventListener('visibilitychange', hidden);
|
|
61
|
+
}, []);
|
|
62
|
+
const pending = display.text !== source;
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (streaming || pending) { setFinalizing(true); return; }
|
|
65
|
+
if (immediate || document.hidden) { setFinalizing(false); return; }
|
|
66
|
+
const timer = setTimeout(() => setFinalizing(false), WORD_MOTION.duration + WORD_MOTION.maxDelay);
|
|
67
|
+
return () => clearTimeout(timer);
|
|
68
|
+
}, [streaming, pending, immediate]);
|
|
69
|
+
return { text: immediate ? source : display.text, pending: !immediate && pending, revision: display.revision, formatStreaming: streaming || (!immediate && (pending || finalizing)), reveal: enabled && !options.interrupted && !options.selected };
|
|
70
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export interface TimelineItem {
|
|
2
|
+
readonly turn: number;
|
|
3
|
+
readonly prompt: string;
|
|
4
|
+
readonly response: string;
|
|
5
|
+
readonly hasDeliverables: boolean;
|
|
6
|
+
readonly anchor:
|
|
7
|
+
| { readonly kind: 'loaded'; readonly key: string }
|
|
8
|
+
| { readonly kind: 'unloaded'; readonly seq: number };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface RawOutlineEntry {
|
|
12
|
+
readonly turn?: unknown;
|
|
13
|
+
readonly seq?: unknown;
|
|
14
|
+
readonly prompt?: unknown;
|
|
15
|
+
readonly response?: unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface LoadedTurnNavigationItem {
|
|
19
|
+
readonly turn: number;
|
|
20
|
+
readonly anchorKey: string;
|
|
21
|
+
readonly prompt: string;
|
|
22
|
+
readonly response: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Merge host turn outline with loaded navigation items and turn deliverables.
|
|
27
|
+
* Guarantees strictly ascending turn order and dedupes entries.
|
|
28
|
+
*/
|
|
29
|
+
export function mergeTimelineItems(
|
|
30
|
+
loaded: readonly LoadedTurnNavigationItem[] | undefined,
|
|
31
|
+
outline: unknown,
|
|
32
|
+
turnsWithDeliverables?: ReadonlySet<number>,
|
|
33
|
+
): readonly TimelineItem[] {
|
|
34
|
+
const byTurn = new Map<number, TimelineItem>();
|
|
35
|
+
|
|
36
|
+
// 1. Process host whole-log outline (if available)
|
|
37
|
+
if (Array.isArray(outline)) {
|
|
38
|
+
for (const raw of outline) {
|
|
39
|
+
if (typeof raw !== 'object' || raw === null) continue;
|
|
40
|
+
const entry = raw as RawOutlineEntry;
|
|
41
|
+
if (typeof entry.turn !== 'number' || !Number.isSafeInteger(entry.turn) || entry.turn < 0) continue;
|
|
42
|
+
if (typeof entry.seq !== 'number' || !Number.isSafeInteger(entry.seq) || entry.seq < 0) continue;
|
|
43
|
+
|
|
44
|
+
byTurn.set(entry.turn, {
|
|
45
|
+
turn: entry.turn,
|
|
46
|
+
prompt: typeof entry.prompt === 'string' ? entry.prompt.trim() : '',
|
|
47
|
+
response: typeof entry.response === 'string' ? entry.response.trim() : '',
|
|
48
|
+
hasDeliverables: turnsWithDeliverables?.has(entry.turn) ?? false,
|
|
49
|
+
anchor: { kind: 'unloaded', seq: entry.seq },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 2. Overlay loaded items (taking loaded anchor, preferring freshest previews)
|
|
55
|
+
if (Array.isArray(loaded)) {
|
|
56
|
+
for (const item of loaded) {
|
|
57
|
+
if (typeof item.turn !== 'number') continue;
|
|
58
|
+
const preview = byTurn.get(item.turn);
|
|
59
|
+
const prompt = item.prompt?.trim() || preview?.prompt || '';
|
|
60
|
+
const response = item.response?.trim() || preview?.response || '';
|
|
61
|
+
const hasDeliverables = turnsWithDeliverables?.has(item.turn) ?? preview?.hasDeliverables ?? false;
|
|
62
|
+
|
|
63
|
+
byTurn.set(item.turn, {
|
|
64
|
+
turn: item.turn,
|
|
65
|
+
prompt,
|
|
66
|
+
response,
|
|
67
|
+
hasDeliverables,
|
|
68
|
+
anchor: { kind: 'loaded', key: item.anchorKey },
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (byTurn.size === 0) return [];
|
|
74
|
+
return [...byTurn.values()].sort((a, b) => a.turn - b.turn);
|
|
75
|
+
}
|