@deepseek-ai/dsh-client-ui-chat 0.2.2-alpha.3 → 0.2.2-rc.2
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/README.i18n.yaml +16 -16
- package/README.md +17 -5
- package/README.zh.md +17 -5
- package/lib/client.js +18 -15587
- package/lib/client.js.map +1 -0
- package/lib/types/chat-settings.d.ts.map +1 -0
- package/lib/types/chat-settings.js.map +1 -0
- package/lib/types/client/apply.d.ts.map +1 -0
- package/lib/types/client/apply.js.map +1 -0
- package/lib/types/client/chat/ApprovalCommand.d.ts +4 -3
- package/lib/types/client/chat/ApprovalCommand.d.ts.map +1 -0
- package/lib/types/client/chat/ApprovalCommand.js.map +1 -0
- package/lib/types/client/chat/AssistantMarkdown.d.ts.map +1 -0
- package/lib/types/client/chat/AssistantMarkdown.js.map +1 -0
- package/lib/types/client/chat/AssistantNodeView.d.ts.map +1 -0
- package/lib/types/client/chat/AssistantNodeView.js.map +1 -0
- package/lib/types/client/chat/ChatFlow.d.ts.map +1 -0
- package/lib/types/client/chat/ChatFlow.js.map +1 -0
- package/lib/types/client/chat/ChatGroupSeat.d.ts.map +1 -0
- package/lib/types/client/chat/ChatGroupSeat.js.map +1 -0
- package/lib/types/client/chat/ChatNodeSeat.d.ts.map +1 -0
- package/lib/types/client/chat/ChatNodeSeat.js.map +1 -0
- package/lib/types/client/chat/ChatView.d.ts +1 -1
- package/lib/types/client/chat/ChatView.d.ts.map +1 -0
- package/lib/types/client/chat/ChatView.js.map +1 -0
- package/lib/types/client/chat/CommandNodeView.d.ts.map +1 -0
- package/lib/types/client/chat/CommandNodeView.js.map +1 -0
- package/lib/types/client/chat/CompactionCommandCard.d.ts.map +1 -0
- package/lib/types/client/chat/CompactionCommandCard.js.map +1 -0
- package/lib/types/client/chat/CompactionItem.d.ts.map +1 -0
- package/lib/types/client/chat/CompactionItem.js.map +1 -0
- package/lib/types/client/chat/ContextBody.d.ts.map +1 -0
- package/lib/types/client/chat/ContextBody.js.map +1 -0
- package/lib/types/client/chat/ContextInjectionRow.d.ts.map +1 -0
- package/lib/types/client/chat/ContextInjectionRow.js.map +1 -0
- package/lib/types/client/chat/GenericCommandCard.d.ts.map +1 -0
- package/lib/types/client/chat/GenericCommandCard.js.map +1 -0
- package/lib/types/client/chat/MessageIconActions.d.ts.map +1 -0
- package/lib/types/client/chat/MessageIconActions.js.map +1 -0
- package/lib/types/client/chat/MessageItem.d.ts.map +1 -0
- package/lib/types/client/chat/MessageItem.js.map +1 -0
- package/lib/types/client/chat/QuotaNoticeHost.d.ts.map +1 -0
- package/lib/types/client/chat/QuotaNoticeHost.js.map +1 -0
- package/lib/types/client/chat/ReasoningContent.d.ts.map +1 -0
- package/lib/types/client/chat/ReasoningContent.js.map +1 -0
- package/lib/types/client/chat/ReasoningRow.d.ts.map +1 -0
- package/lib/types/client/chat/ReasoningRow.js.map +1 -0
- package/lib/types/client/chat/RunningStatus.d.ts.map +1 -0
- package/lib/types/client/chat/RunningStatus.js.map +1 -0
- package/lib/types/client/chat/RunningWhaleTail.d.ts.map +1 -0
- package/lib/types/client/chat/RunningWhaleTail.js.map +1 -0
- package/lib/types/client/chat/StatsPills.d.ts.map +1 -0
- package/lib/types/client/chat/StatsPills.js.map +1 -0
- package/lib/types/client/chat/SystemPromptRow.d.ts.map +1 -0
- package/lib/types/client/chat/SystemPromptRow.js.map +1 -0
- package/lib/types/client/chat/TurnNavigator.d.ts.map +1 -0
- package/lib/types/client/chat/TurnNavigator.js.map +1 -0
- package/lib/types/client/chat/TurnProcessNodeView.d.ts.map +1 -0
- package/lib/types/client/chat/TurnProcessNodeView.js.map +1 -0
- package/lib/types/client/chat/TurnTailNodeView.d.ts.map +1 -0
- package/lib/types/client/chat/TurnTailNodeView.js.map +1 -0
- package/lib/types/client/chat/TurnTriggerNodeView.d.ts.map +1 -0
- package/lib/types/client/chat/TurnTriggerNodeView.js.map +1 -0
- package/lib/types/client/chat/TurnUsagePanel.d.ts.map +1 -0
- package/lib/types/client/chat/TurnUsagePanel.js.map +1 -0
- package/lib/types/client/chat/UserContent.d.ts.map +1 -0
- package/lib/types/client/chat/UserContent.js.map +1 -0
- package/lib/types/client/chat/flow-motion.d.ts +2 -0
- package/lib/types/client/chat/flow-motion.d.ts.map +1 -0
- package/lib/types/client/chat/flow-motion.js.map +1 -0
- package/lib/types/client/chat/message-chrome.d.ts.map +1 -0
- package/lib/types/client/chat/message-chrome.js.map +1 -0
- package/lib/types/client/chat/register-node-renderers.d.ts.map +1 -0
- package/lib/types/client/chat/register-node-renderers.js.map +1 -0
- package/lib/types/client/chat/render-entry.d.ts.map +1 -0
- package/lib/types/client/chat/render-entry.js.map +1 -0
- package/lib/types/client/chat/searchable-hidden.d.ts.map +1 -0
- package/lib/types/client/chat/searchable-hidden.js.map +1 -0
- package/lib/types/client/chat/stat-dialog.d.ts +5 -10
- package/lib/types/client/chat/stat-dialog.d.ts.map +1 -0
- package/lib/types/client/chat/stat-dialog.js.map +1 -0
- package/lib/types/client/chat/step-process.d.ts.map +1 -0
- package/lib/types/client/chat/step-process.js.map +1 -0
- package/lib/types/client/chat/text-interaction.d.ts.map +1 -0
- package/lib/types/client/chat/text-interaction.js.map +1 -0
- package/lib/types/client/chat/text-selection.d.ts.map +1 -0
- package/lib/types/client/chat/text-selection.js.map +1 -0
- package/lib/types/client/chat/token-format.d.ts.map +1 -0
- package/lib/types/client/chat/token-format.js.map +1 -0
- package/lib/types/client/chat/turn-assistant.d.ts.map +1 -0
- package/lib/types/client/chat/turn-assistant.js.map +1 -0
- package/lib/types/client/chat/turn-rail-items.d.ts.map +1 -0
- package/lib/types/client/chat/turn-rail-items.js.map +1 -0
- package/lib/types/client/chat/turn-trigger.d.ts +3 -2
- package/lib/types/client/chat/turn-trigger.d.ts.map +1 -0
- package/lib/types/client/chat/turn-trigger.js.map +1 -0
- package/lib/types/client/chat/use-calendar-day.d.ts.map +1 -0
- package/lib/types/client/chat/use-calendar-day.js.map +1 -0
- package/lib/types/client/chat/use-chat-navigation.d.ts +21 -5
- package/lib/types/client/chat/use-chat-navigation.d.ts.map +1 -0
- package/lib/types/client/chat/use-chat-navigation.js.map +1 -0
- package/lib/types/client/chat/use-chat-reading.d.ts.map +1 -0
- package/lib/types/client/chat/use-chat-reading.js.map +1 -0
- package/lib/types/client/chat/use-chat-scroll.d.ts +5 -2
- package/lib/types/client/chat/use-chat-scroll.d.ts.map +1 -0
- package/lib/types/client/chat/use-chat-scroll.js.map +1 -0
- package/lib/types/client/chat/use-chat-viewport.d.ts +53 -0
- package/lib/types/client/chat/use-chat-viewport.d.ts.map +1 -0
- package/lib/types/client/chat/use-chat-viewport.js.map +1 -0
- package/lib/types/client/chat/use-disclosure.d.ts.map +1 -0
- package/lib/types/client/chat/use-disclosure.js.map +1 -0
- package/lib/types/client/chat/use-process-scroll.d.ts.map +1 -0
- package/lib/types/client/chat/use-process-scroll.js.map +1 -0
- package/lib/types/client/chat/use-scroll-follow.d.ts.map +1 -0
- package/lib/types/client/chat/use-scroll-follow.js.map +1 -0
- package/lib/types/client/chat/use-turn-data.d.ts.map +1 -0
- package/lib/types/client/chat/use-turn-data.js.map +1 -0
- package/lib/types/client/contract/assistant-content.d.ts.map +1 -0
- package/lib/types/client/contract/assistant-content.js.map +1 -0
- package/lib/types/client/contract/chat-nodes.d.ts.map +1 -0
- package/lib/types/client/contract/chat-nodes.js.map +1 -0
- package/lib/types/client/contract/chat-visibility.d.ts +2 -2
- package/lib/types/client/contract/chat-visibility.d.ts.map +1 -0
- package/lib/types/client/contract/chat-visibility.js.map +1 -0
- package/lib/types/client/contract/group-tree.d.ts.map +1 -0
- package/lib/types/client/contract/group-tree.js.map +1 -0
- package/lib/types/client/contract/process-groups.d.ts +6 -3
- package/lib/types/client/contract/process-groups.d.ts.map +1 -0
- package/lib/types/client/contract/process-groups.js.map +1 -0
- package/lib/types/client/contract/slots.d.ts +11 -2
- package/lib/types/client/contract/slots.d.ts.map +1 -0
- package/lib/types/client/contract/slots.js.map +1 -0
- package/lib/types/client/contract/snapshot.d.ts.map +1 -0
- package/lib/types/client/contract/snapshot.js.map +1 -0
- package/lib/types/client/contract/store.d.ts.map +1 -0
- package/lib/types/client/contract/store.js.map +1 -0
- package/lib/types/client/contract/turn-metrics.d.ts.map +1 -0
- package/lib/types/client/contract/turn-metrics.js.map +1 -0
- package/lib/types/client/contract/turn-process.d.ts.map +1 -0
- package/lib/types/client/contract/turn-process.js.map +1 -0
- package/lib/types/client/conversation-nodes/assistant.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/assistant.js.map +1 -0
- package/lib/types/client/conversation-nodes/chat-snapshot-builder.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/chat-snapshot-builder.js.map +1 -0
- package/lib/types/client/conversation-nodes/command.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/command.js.map +1 -0
- package/lib/types/client/conversation-nodes/common.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/common.js.map +1 -0
- package/lib/types/client/conversation-nodes/compaction.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/compaction.js.map +1 -0
- package/lib/types/client/conversation-nodes/event-projection.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/event-projection.js.map +1 -0
- package/lib/types/client/conversation-nodes/fallback.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/fallback.js.map +1 -0
- package/lib/types/client/conversation-nodes/group-tree-segments.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/group-tree-segments.js.map +1 -0
- package/lib/types/client/conversation-nodes/inbox.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/inbox.js.map +1 -0
- package/lib/types/client/conversation-nodes/message.d.ts +1 -1
- package/lib/types/client/conversation-nodes/message.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/message.js.map +1 -0
- package/lib/types/client/conversation-nodes/process-activity.d.ts +1 -0
- package/lib/types/client/conversation-nodes/process-activity.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/process-activity.js.map +1 -0
- package/lib/types/client/conversation-nodes/process-groups.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/process-groups.js.map +1 -0
- package/lib/types/client/conversation-nodes/register.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/register.js.map +1 -0
- package/lib/types/client/conversation-nodes/request-prompt.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/request-prompt.js.map +1 -0
- package/lib/types/client/conversation-nodes/retry.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/retry.js.map +1 -0
- package/lib/types/client/conversation-nodes/tool.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/tool.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-error.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-error.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-max-tokens.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-max-tokens.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-navigation.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-navigation.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-process-presentation.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-process-presentation.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-process.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-process.js.map +1 -0
- package/lib/types/client/conversation-nodes/turn-tail.d.ts.map +1 -0
- package/lib/types/client/conversation-nodes/turn-tail.js.map +1 -0
- package/lib/types/client/fence/FenceLayers.d.ts +21 -0
- package/lib/types/client/fence/FenceLayers.d.ts.map +1 -0
- package/lib/types/client/fence/FenceLayers.js.map +1 -0
- package/lib/types/client/fence/register.d.ts +10 -0
- package/lib/types/client/fence/register.d.ts.map +1 -0
- package/lib/types/client/fence/register.js.map +1 -0
- package/lib/types/client/file-path.d.ts.map +1 -0
- package/lib/types/client/file-path.js.map +1 -0
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.d.ts.map +1 -0
- package/lib/types/client/index.js.map +1 -0
- package/lib/types/client/locale.d.ts +96 -0
- package/lib/types/client/locale.d.ts.map +1 -0
- package/lib/types/client/locale.js.map +1 -0
- package/lib/types/client/markdown-labels.d.ts.map +1 -0
- package/lib/types/client/markdown-labels.js.map +1 -0
- package/lib/types/client/model/conversation-context.d.ts.map +1 -0
- package/lib/types/client/model/conversation-context.js.map +1 -0
- package/lib/types/client/model/steering-history.d.ts.map +1 -0
- package/lib/types/client/model/steering-history.js.map +1 -0
- package/lib/types/client/model/tool-call-tree.d.ts.map +1 -0
- package/lib/types/client/model/tool-call-tree.js.map +1 -0
- package/lib/types/client/performance-usage.d.ts.map +1 -0
- package/lib/types/client/performance-usage.js.map +1 -0
- package/lib/types/client/presentation-policy.d.ts.map +1 -0
- package/lib/types/client/presentation-policy.js.map +1 -0
- package/lib/types/client/reasoning-text.d.ts.map +1 -0
- package/lib/types/client/reasoning-text.js.map +1 -0
- package/lib/types/client/settings/LinkOpeningRow.d.ts.map +1 -0
- package/lib/types/client/settings/LinkOpeningRow.js.map +1 -0
- package/lib/types/client/settings/PerformanceUsageRow.d.ts.map +1 -0
- package/lib/types/client/settings/PerformanceUsageRow.js.map +1 -0
- package/lib/types/client/settings/PreferenceRow.d.ts.map +1 -0
- package/lib/types/client/settings/PreferenceRow.js.map +1 -0
- package/lib/types/client/settings/TranscriptViewRow.d.ts.map +1 -0
- package/lib/types/client/settings/TranscriptViewRow.js.map +1 -0
- package/lib/types/client/stores.d.ts.map +1 -0
- package/lib/types/client/stores.js.map +1 -0
- package/lib/types/client/transcript-view.d.ts.map +1 -0
- package/lib/types/client/transcript-view.js.map +1 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/package.json +47 -44
- package/src/chat-settings.ts +98 -0
- package/src/client/apply.ts +355 -0
- package/src/client/assets/running-whale@2x.png +0 -0
- package/src/client/chat/ApprovalCommand.tsx +42 -0
- package/src/client/chat/AssistantMarkdown.module.css +88 -0
- package/src/client/chat/AssistantMarkdown.tsx +170 -0
- package/src/client/chat/AssistantNodeView.tsx +67 -0
- package/src/client/chat/ChatFlow.tsx +100 -0
- package/src/client/chat/ChatGroupSeat.module.css +166 -0
- package/src/client/chat/ChatGroupSeat.tsx +208 -0
- package/src/client/chat/ChatNodeSeat.tsx +179 -0
- package/src/client/chat/ChatView.module.css +426 -0
- package/src/client/chat/ChatView.tsx +351 -0
- package/src/client/chat/CommandNodeView.tsx +40 -0
- package/src/client/chat/CompactionCommandCard.tsx +26 -0
- package/src/client/chat/CompactionItem.tsx +76 -0
- package/src/client/chat/ContextBody.module.css +161 -0
- package/src/client/chat/ContextBody.tsx +592 -0
- package/src/client/chat/ContextInjectionRow.module.css +68 -0
- package/src/client/chat/ContextInjectionRow.tsx +94 -0
- package/src/client/chat/GenericCommandCard.module.css +49 -0
- package/src/client/chat/GenericCommandCard.tsx +75 -0
- package/src/client/chat/MessageIconActions.module.css +116 -0
- package/src/client/chat/MessageIconActions.tsx +90 -0
- package/src/client/chat/MessageItem.module.css +360 -0
- package/src/client/chat/MessageItem.tsx +410 -0
- package/src/client/chat/QuotaNoticeHost.tsx +27 -0
- package/src/client/chat/ReasoningContent.tsx +26 -0
- package/src/client/chat/ReasoningRow.module.css +77 -0
- package/src/client/chat/ReasoningRow.tsx +112 -0
- package/src/client/chat/RunningStatus.tsx +48 -0
- package/src/client/chat/RunningWhaleTail.tsx +19 -0
- package/src/client/chat/StatsPills.module.css +63 -0
- package/src/client/chat/StatsPills.tsx +348 -0
- package/src/client/chat/SystemPromptRow.tsx +50 -0
- package/src/client/chat/TurnNavigator.module.css +223 -0
- package/src/client/chat/TurnNavigator.tsx +295 -0
- package/src/client/chat/TurnProcessNodeView.module.css +62 -0
- package/src/client/chat/TurnProcessNodeView.tsx +62 -0
- package/src/client/chat/TurnTailNodeView.module.css +12 -0
- package/src/client/chat/TurnTailNodeView.tsx +81 -0
- package/src/client/chat/TurnTriggerNodeView.module.css +50 -0
- package/src/client/chat/TurnTriggerNodeView.tsx +57 -0
- package/src/client/chat/TurnUsagePanel.module.css +79 -0
- package/src/client/chat/TurnUsagePanel.tsx +110 -0
- package/src/client/chat/UserContent.tsx +60 -0
- package/src/client/chat/accessibility.module.css +8 -0
- package/src/client/chat/flow-motion.ts +556 -0
- package/src/client/chat/message-chrome.ts +100 -0
- package/src/client/chat/register-node-renderers.ts +100 -0
- package/src/client/chat/render-entry.ts +16 -0
- package/src/client/chat/searchable-hidden.ts +45 -0
- package/src/client/chat/stat-dialog.module.css +149 -0
- package/src/client/chat/stat-dialog.ts +55 -0
- package/src/client/chat/step-process.ts +28 -0
- package/src/client/chat/text-interaction.ts +298 -0
- package/src/client/chat/text-selection.ts +180 -0
- package/src/client/chat/token-format.ts +98 -0
- package/src/client/chat/turn-assistant.ts +10 -0
- package/src/client/chat/turn-rail-items.ts +89 -0
- package/src/client/chat/turn-trigger.ts +88 -0
- package/src/client/chat/use-calendar-day.ts +25 -0
- package/src/client/chat/use-chat-navigation.ts +309 -0
- package/src/client/chat/use-chat-reading.ts +283 -0
- package/src/client/chat/use-chat-scroll.ts +209 -0
- package/src/client/chat/use-chat-viewport.ts +1130 -0
- package/src/client/chat/use-disclosure.ts +35 -0
- package/src/client/chat/use-process-scroll.ts +88 -0
- package/src/client/chat/use-scroll-follow.ts +182 -0
- package/src/client/chat/use-turn-data.ts +23 -0
- package/src/client/contract/assistant-content.ts +15 -0
- package/src/client/contract/chat-nodes.ts +135 -0
- package/src/client/contract/chat-visibility.ts +20 -0
- package/src/client/contract/group-tree.ts +37 -0
- package/src/client/contract/process-groups.ts +30 -0
- package/src/client/contract/slots.ts +508 -0
- package/src/client/contract/snapshot.ts +171 -0
- package/src/client/contract/store.ts +17 -0
- package/src/client/contract/turn-metrics.ts +43 -0
- package/src/client/contract/turn-process.ts +58 -0
- package/src/client/conversation-nodes/README.i18n.yaml +64 -0
- package/src/client/conversation-nodes/README.md +338 -0
- package/src/client/conversation-nodes/README.zh.md +338 -0
- package/src/client/conversation-nodes/assistant.ts +384 -0
- package/src/client/conversation-nodes/chat-snapshot-builder.ts +1244 -0
- package/src/client/conversation-nodes/command.ts +227 -0
- package/src/client/conversation-nodes/common.ts +83 -0
- package/src/client/conversation-nodes/compaction.ts +65 -0
- package/src/client/conversation-nodes/event-projection.ts +179 -0
- package/src/client/conversation-nodes/fallback.ts +41 -0
- package/src/client/conversation-nodes/group-tree-segments.ts +91 -0
- package/src/client/conversation-nodes/inbox.ts +148 -0
- package/src/client/conversation-nodes/message.ts +182 -0
- package/src/client/conversation-nodes/process-activity.ts +170 -0
- package/src/client/conversation-nodes/process-groups.ts +303 -0
- package/src/client/conversation-nodes/register.ts +38 -0
- package/src/client/conversation-nodes/request-prompt.ts +169 -0
- package/src/client/conversation-nodes/retry.ts +97 -0
- package/src/client/conversation-nodes/tool.ts +371 -0
- package/src/client/conversation-nodes/turn-error.ts +120 -0
- package/src/client/conversation-nodes/turn-max-tokens.ts +82 -0
- package/src/client/conversation-nodes/turn-navigation.ts +97 -0
- package/src/client/conversation-nodes/turn-process-presentation.ts +149 -0
- package/src/client/conversation-nodes/turn-process.ts +374 -0
- package/src/client/conversation-nodes/turn-tail.ts +164 -0
- package/src/client/fence/FenceLayers.tsx +33 -0
- package/src/client/fence/register.ts +22 -0
- package/src/client/file-path.ts +19 -0
- package/src/client/index.ts +69 -0
- package/src/client/locale.ts +1695 -0
- package/src/client/markdown-labels.ts +16 -0
- package/src/client/model/conversation-context.ts +24 -0
- package/src/client/model/steering-history.ts +64 -0
- package/src/client/model/tool-call-tree.ts +204 -0
- package/src/client/performance-usage.ts +34 -0
- package/src/client/presentation-policy.ts +109 -0
- package/src/client/reasoning-text.ts +25 -0
- package/src/client/settings/LinkOpeningRow.tsx +47 -0
- package/src/client/settings/PerformanceUsageRow.tsx +46 -0
- package/src/client/settings/PreferenceRow.module.css +66 -0
- package/src/client/settings/PreferenceRow.tsx +59 -0
- package/src/client/settings/TranscriptViewRow.tsx +93 -0
- package/src/client/stores.ts +62 -0
- package/src/client/transcript-view.ts +81 -0
- package/src/css-modules.d.ts +6 -0
- package/src/index.ts +45 -0
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/* The rail is a sibling of the clipped transcript, not its descendant. */
|
|
2
|
+
.slot {
|
|
3
|
+
position: absolute;
|
|
4
|
+
top: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
/* Above transcript CodeBlock banners (z-index 6). The rail band excludes
|
|
8
|
+
the composer, so its preview never needs to cross the footer. */
|
|
9
|
+
z-index: 7;
|
|
10
|
+
height: 0;
|
|
11
|
+
/* Query the transcript's usable width while keeping the rail full-bleed. */
|
|
12
|
+
padding-inline: calc(var(--dsh-composer-side-clearance) + 16px);
|
|
13
|
+
container-type: inline-size;
|
|
14
|
+
pointer-events: none;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:global([data-conversation-scroll]) .slot {
|
|
18
|
+
position: sticky;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.frame {
|
|
22
|
+
/* The band a reader actually sees: the scrollport minus the sticky composer
|
|
23
|
+
stack covering its floor. ConversationRoot publishes both measurements on
|
|
24
|
+
the scrollport; the fallbacks carry the first paint before its observer
|
|
25
|
+
fires. */
|
|
26
|
+
--turn-rail-band: calc(
|
|
27
|
+
var(--dsh-conversation-viewport-height, 100dvh) - var(--dsh-composer-height, 152px)
|
|
28
|
+
);
|
|
29
|
+
--turn-preview-height: 100px;
|
|
30
|
+
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: calc(var(--turn-rail-band) / 2);
|
|
33
|
+
right: 12px;
|
|
34
|
+
width: 28px;
|
|
35
|
+
/* Fixed-pitch marks never compress: a ladder taller than the band scrolls
|
|
36
|
+
inside this frame instead of pushing marks under the composer or above
|
|
37
|
+
the scrollport. */
|
|
38
|
+
max-height: min(
|
|
39
|
+
max(0px, calc(var(--turn-rail-band) - 64px)),
|
|
40
|
+
420px
|
|
41
|
+
);
|
|
42
|
+
contain: layout;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
pointer-events: auto;
|
|
45
|
+
transform: translateY(-50%);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* The frame's inner scroller: no visible scrollbar, no scroll chaining into
|
|
49
|
+
the transcript, and gradient fades over the ends that can still scroll. */
|
|
50
|
+
.scroller {
|
|
51
|
+
position: relative;
|
|
52
|
+
max-height: inherit;
|
|
53
|
+
overflow-y: auto;
|
|
54
|
+
overscroll-behavior: contain;
|
|
55
|
+
scrollbar-width: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.scroller::-webkit-scrollbar {
|
|
59
|
+
display: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.fadeTop {
|
|
63
|
+
mask-image: linear-gradient(to bottom, transparent 0, #000 24px, #000 100%);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.fadeBottom {
|
|
67
|
+
mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 24px), transparent 100%);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.fadeTop.fadeBottom {
|
|
71
|
+
mask-image: linear-gradient(
|
|
72
|
+
to bottom,
|
|
73
|
+
transparent 0,
|
|
74
|
+
#000 24px,
|
|
75
|
+
#000 calc(100% - 24px),
|
|
76
|
+
transparent 100%
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.marks {
|
|
81
|
+
position: relative;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.mark {
|
|
85
|
+
position: absolute;
|
|
86
|
+
top: 0;
|
|
87
|
+
right: 0;
|
|
88
|
+
left: 0;
|
|
89
|
+
height: 10px;
|
|
90
|
+
padding: 0;
|
|
91
|
+
border: 0;
|
|
92
|
+
border-radius: 8px;
|
|
93
|
+
background: transparent;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.mark::before {
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 50%;
|
|
100
|
+
right: 0;
|
|
101
|
+
width: 20px;
|
|
102
|
+
height: 2px;
|
|
103
|
+
border-radius: 2px;
|
|
104
|
+
background: var(--dsw-alias-border-l4);
|
|
105
|
+
content: '';
|
|
106
|
+
transform: translateY(-50%) scaleX(0.6);
|
|
107
|
+
transform-origin: right center;
|
|
108
|
+
transition: transform 140ms ease, background-color 140ms ease;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Ordered before hover/active so those states keep their stronger tick. */
|
|
112
|
+
.markUnloaded::before {
|
|
113
|
+
transform: translateY(-50%) scaleX(0.4);
|
|
114
|
+
opacity: 0.6;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.markPreview::before {
|
|
118
|
+
transform: translateY(-50%) scaleX(0.9);
|
|
119
|
+
background: var(--dsw-alias-label-tertiary);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.markBusy::before {
|
|
123
|
+
animation: dsh-turn-mark-busy 1s ease-in-out infinite;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.markActive::before {
|
|
127
|
+
transform: translateY(-50%) scaleX(1);
|
|
128
|
+
background: var(--dsw-alias-label-primary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/* Keyboard focus outranks both resting states: the tick takes the brand color
|
|
132
|
+
the rest of the rail never uses, and a hairline ring keeps it legible
|
|
133
|
+
against a busy transcript. */
|
|
134
|
+
.mark:focus-visible::before {
|
|
135
|
+
transform: translateY(-50%) scaleX(1);
|
|
136
|
+
background: var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.mark:focus-visible {
|
|
140
|
+
outline: none;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.mark:focus-visible::after {
|
|
144
|
+
position: absolute;
|
|
145
|
+
inset: 0 0 0 auto;
|
|
146
|
+
width: 20px;
|
|
147
|
+
border-radius: inherit;
|
|
148
|
+
outline: 1px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
|
149
|
+
/* The scroller clips the right edge; keep the marker's ring inside it. */
|
|
150
|
+
outline-offset: -1px;
|
|
151
|
+
content: '';
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.preview {
|
|
155
|
+
position: absolute;
|
|
156
|
+
top: clamp(
|
|
157
|
+
0px,
|
|
158
|
+
calc(var(--turn-preview-center) - var(--turn-preview-height) / 2),
|
|
159
|
+
calc(100% - var(--turn-preview-height))
|
|
160
|
+
);
|
|
161
|
+
right: calc(100% + 10px);
|
|
162
|
+
box-sizing: border-box;
|
|
163
|
+
width: min(300px, calc(100cqw - 120px));
|
|
164
|
+
max-height: var(--turn-preview-height);
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
padding: 10px 12px;
|
|
167
|
+
border: 0;
|
|
168
|
+
border-radius: var(--dsw-radius-lg);
|
|
169
|
+
color: var(--dsw-alias-label-primary);
|
|
170
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
171
|
+
box-shadow: var(--dsw-elevation-panel);
|
|
172
|
+
pointer-events: none;
|
|
173
|
+
animation: dsh-turn-preview-enter 120ms ease-out;
|
|
174
|
+
transition: top 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.previewPrompt,
|
|
178
|
+
.previewResponse {
|
|
179
|
+
display: -webkit-box;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
-webkit-box-orient: vertical;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.previewPrompt {
|
|
185
|
+
font: var(--dsw-font-xs-strong-13);
|
|
186
|
+
-webkit-line-clamp: 1;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.previewResponse {
|
|
190
|
+
margin-top: 4px;
|
|
191
|
+
color: var(--dsw-alias-label-caption);
|
|
192
|
+
font: var(--dsw-font-xxs-12);
|
|
193
|
+
-webkit-line-clamp: 3;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
@keyframes dsh-turn-preview-enter {
|
|
197
|
+
from { opacity: 0; transform: translateX(4px); }
|
|
198
|
+
to { opacity: 1; transform: translateX(0); }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
@keyframes dsh-turn-mark-busy {
|
|
202
|
+
0%,
|
|
203
|
+
100% { opacity: 1; }
|
|
204
|
+
50% { opacity: 0.35; }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
@container (max-width: 900px) {
|
|
208
|
+
.frame {
|
|
209
|
+
display: none;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
@media (prefers-reduced-motion: reduce) {
|
|
214
|
+
.frame,
|
|
215
|
+
.scroller,
|
|
216
|
+
.mark::before,
|
|
217
|
+
.markBusy::before,
|
|
218
|
+
.preview {
|
|
219
|
+
transition: none;
|
|
220
|
+
animation: none;
|
|
221
|
+
scroll-behavior: auto;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/** Fixed-pitch virtual turn rail with independent activation and scroll controls. */
|
|
2
|
+
import {
|
|
3
|
+
forwardRef, memo, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState,
|
|
4
|
+
type CSSProperties, type ForwardedRef,
|
|
5
|
+
} from 'react'
|
|
6
|
+
import { defaultRangeExtractor, elementScroll, observeElementOffset, useVirtualizer, type Range } from '@tanstack/react-virtual'
|
|
7
|
+
import type { ChatViewSlotProps } from '../contract/slots.ts'
|
|
8
|
+
import type { TurnRailItem } from './turn-rail-items.ts'
|
|
9
|
+
import css from './TurnNavigator.module.css'
|
|
10
|
+
|
|
11
|
+
interface TurnNavigatorProps {
|
|
12
|
+
readonly items: readonly TurnRailItem[]
|
|
13
|
+
readonly activeTurn: number | null
|
|
14
|
+
/** Turn whose jump is still paging history in; its mark pulses. */
|
|
15
|
+
readonly busyTurn: number | null
|
|
16
|
+
readonly onNavigate: (item: TurnRailItem) => void
|
|
17
|
+
readonly t: ChatViewSlotProps['t']
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Imperative controls for known turns; unknown turn numbers are ignored. */
|
|
21
|
+
export interface TurnNavigatorHandle {
|
|
22
|
+
/** @param turn - turn to activate through the navigation callback. */
|
|
23
|
+
activateTurn(turn: number): void
|
|
24
|
+
/** @param turn - turn to center in the rail without navigating the transcript. */
|
|
25
|
+
scrollToTurn(turn: number): void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Fixed pitch between neighbouring marks; overflow scrolls inside the frame. */
|
|
29
|
+
const TURN_SPACING_PX = 10
|
|
30
|
+
/** Rail padding above the first mark and below the last one, per end. */
|
|
31
|
+
const RAIL_INSET_PX = 6
|
|
32
|
+
/** Fade band the mask reserves at a scrollable end. */
|
|
33
|
+
const FADE_PX = 24
|
|
34
|
+
|
|
35
|
+
function preferredScrollBehavior(): 'auto' | 'smooth' {
|
|
36
|
+
return typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
37
|
+
? 'auto'
|
|
38
|
+
: 'smooth'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface TurnMarkProps extends Pick<TurnNavigatorProps, 'onNavigate' | 't'> {
|
|
42
|
+
readonly item: TurnRailItem
|
|
43
|
+
readonly index: number
|
|
44
|
+
readonly active: boolean
|
|
45
|
+
readonly busy: boolean
|
|
46
|
+
readonly previewId: string | undefined
|
|
47
|
+
readonly registerElement: (element: HTMLButtonElement | null) => void
|
|
48
|
+
readonly onPreview: (turn: number | null) => void
|
|
49
|
+
readonly onFocusChange: (turn: number | null) => void
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const TurnMark = memo(function TurnMark({
|
|
53
|
+
item, index, active, busy, previewId, registerElement, onNavigate, onPreview, onFocusChange, t,
|
|
54
|
+
}: TurnMarkProps) {
|
|
55
|
+
const classes = [css.mark]
|
|
56
|
+
if (item.anchor.kind === 'unloaded') classes.push(css.markUnloaded)
|
|
57
|
+
if (active) classes.push(css.markActive)
|
|
58
|
+
else if (previewId !== undefined) classes.push(css.markPreview)
|
|
59
|
+
if (busy) classes.push(css.markBusy)
|
|
60
|
+
return (
|
|
61
|
+
<button
|
|
62
|
+
ref={registerElement}
|
|
63
|
+
data-index={index}
|
|
64
|
+
type="button"
|
|
65
|
+
className={classes.join(' ')}
|
|
66
|
+
aria-label={t(
|
|
67
|
+
item.anchor.kind === 'loaded' ? 'chat.turnNavigation.jump' : 'chat.turnNavigation.jumpLoad',
|
|
68
|
+
{ turn: item.turn },
|
|
69
|
+
)}
|
|
70
|
+
aria-current={active ? 'true' : undefined}
|
|
71
|
+
aria-busy={busy ? 'true' : undefined}
|
|
72
|
+
aria-describedby={previewId}
|
|
73
|
+
onPointerMove={() => { onPreview(item.turn) }}
|
|
74
|
+
onClick={() => { onNavigate(item) }}
|
|
75
|
+
onFocus={() => { onFocusChange(item.turn) }}
|
|
76
|
+
onBlur={() => { onFocusChange(null) }}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
function TurnNavigatorRail(
|
|
82
|
+
{ items, activeTurn, busyTurn, onNavigate, t }: TurnNavigatorProps,
|
|
83
|
+
ref: ForwardedRef<TurnNavigatorHandle>,
|
|
84
|
+
) {
|
|
85
|
+
const [previewTurn, setPreviewTurn] = useState<number | null>(null)
|
|
86
|
+
const [focusedTurn, setFocusedTurn] = useState<number | null>(null)
|
|
87
|
+
const scrollerRef = useRef<HTMLDivElement | null>(null)
|
|
88
|
+
const initialization = useRef({
|
|
89
|
+
placed: false,
|
|
90
|
+
index: 0,
|
|
91
|
+
follow: null as { index: number; count: number; height: number } | null,
|
|
92
|
+
publishOffset: null as ((offset: number, scrolling: boolean) => void) | null,
|
|
93
|
+
})
|
|
94
|
+
/** While the pointer works the rail, follow must not move it under the hand. */
|
|
95
|
+
const pointerInsideRef = useRef(false)
|
|
96
|
+
const previewId = useId()
|
|
97
|
+
const turnIndexes = useMemo(() => {
|
|
98
|
+
const indexes = new Map<number, number>()
|
|
99
|
+
items.forEach((item, index) => { indexes.set(item.turn, index) })
|
|
100
|
+
return indexes
|
|
101
|
+
}, [items])
|
|
102
|
+
const activeIndex = activeTurn === null ? undefined : turnIndexes.get(activeTurn)
|
|
103
|
+
useLayoutEffect(() => { initialization.current.index = activeIndex ?? 0 }, [activeIndex])
|
|
104
|
+
const focusedIndex = focusedTurn === null ? undefined : turnIndexes.get(focusedTurn)
|
|
105
|
+
const previewIndex = previewTurn === null ? undefined : turnIndexes.get(previewTurn)
|
|
106
|
+
const onFocusChange = useCallback((turn: number | null) => {
|
|
107
|
+
setFocusedTurn(turn)
|
|
108
|
+
setPreviewTurn(turn)
|
|
109
|
+
}, [])
|
|
110
|
+
const virtualizer = useVirtualizer<HTMLDivElement, HTMLButtonElement>({
|
|
111
|
+
count: items.length,
|
|
112
|
+
enabled: items.length >= 2,
|
|
113
|
+
directDomUpdates: true,
|
|
114
|
+
directDomUpdatesMode: 'transform',
|
|
115
|
+
useScrollendEvent: true,
|
|
116
|
+
getScrollElement: useCallback(() => scrollerRef.current, []),
|
|
117
|
+
getItemKey: useCallback((index: number) => items[index]?.turn ?? index, [items]),
|
|
118
|
+
estimateSize: () => TURN_SPACING_PX,
|
|
119
|
+
measureElement: () => TURN_SPACING_PX,
|
|
120
|
+
initialRect: { width: 0, height: 0 },
|
|
121
|
+
initialOffset: 0,
|
|
122
|
+
scrollToFn: (offset, options, instance) => {
|
|
123
|
+
if (initialization.current.placed) elementScroll(offset, options, instance)
|
|
124
|
+
},
|
|
125
|
+
observeElementOffset: (instance, notify) => {
|
|
126
|
+
initialization.current.publishOffset = notify
|
|
127
|
+
const dispose = observeElementOffset(instance, notify)
|
|
128
|
+
return () => {
|
|
129
|
+
dispose?.()
|
|
130
|
+
initialization.current.placed = false
|
|
131
|
+
initialization.current.follow = null
|
|
132
|
+
initialization.current.publishOffset = null
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
observeElementRect: (instance, notify) => {
|
|
136
|
+
const element = instance.scrollElement
|
|
137
|
+
const Observer = instance.targetWindow?.ResizeObserver
|
|
138
|
+
if (element === null || Observer === undefined) return
|
|
139
|
+
const observer = new Observer(([entry]) => {
|
|
140
|
+
if (entry === undefined) return
|
|
141
|
+
const box = entry.borderBoxSize[0]
|
|
142
|
+
const rect = {
|
|
143
|
+
width: Math.round(box?.inlineSize ?? entry.contentRect.width),
|
|
144
|
+
height: Math.round(box?.blockSize ?? entry.contentRect.height),
|
|
145
|
+
}
|
|
146
|
+
const initial = initialization.current
|
|
147
|
+
if (!initial.placed && rect.height > 0) {
|
|
148
|
+
const max = Math.max(0, instance.getTotalSize() - rect.height)
|
|
149
|
+
const center = initial.index * TURN_SPACING_PX + RAIL_INSET_PX
|
|
150
|
+
const target = Math.max(0, Math.min(max, center - rect.height / 2))
|
|
151
|
+
initial.placed = true
|
|
152
|
+
initial.follow = { index: initial.index, count: instance.options.count, height: rect.height }
|
|
153
|
+
element.scrollTop = target
|
|
154
|
+
initial.publishOffset?.(target, false)
|
|
155
|
+
}
|
|
156
|
+
notify(rect)
|
|
157
|
+
})
|
|
158
|
+
observer.observe(element, { box: 'border-box' })
|
|
159
|
+
return () => { observer.disconnect() }
|
|
160
|
+
},
|
|
161
|
+
paddingStart: RAIL_INSET_PX - TURN_SPACING_PX / 2,
|
|
162
|
+
paddingEnd: RAIL_INSET_PX - TURN_SPACING_PX / 2,
|
|
163
|
+
scrollPaddingStart: FADE_PX,
|
|
164
|
+
scrollPaddingEnd: FADE_PX,
|
|
165
|
+
overscan: 3,
|
|
166
|
+
rangeExtractor: useCallback((range: Range) => {
|
|
167
|
+
const indexes = defaultRangeExtractor(range)
|
|
168
|
+
if (focusedIndex !== undefined) {
|
|
169
|
+
const last = Math.min(range.count - 1, focusedIndex + 1)
|
|
170
|
+
for (let index = Math.max(0, focusedIndex - 1); index <= last; index++) {
|
|
171
|
+
if (!indexes.includes(index)) indexes.push(index)
|
|
172
|
+
}
|
|
173
|
+
indexes.sort((left, right) => left - right)
|
|
174
|
+
}
|
|
175
|
+
return indexes
|
|
176
|
+
}, [focusedIndex]),
|
|
177
|
+
})
|
|
178
|
+
const scrollTop = virtualizer.scrollOffset ?? 0
|
|
179
|
+
const viewHeight = virtualizer.scrollRect?.height ?? 0
|
|
180
|
+
const virtualItems = virtualizer.getVirtualItems()
|
|
181
|
+
|
|
182
|
+
const scrollToIndex = useCallback((
|
|
183
|
+
index: number, reveal: 'if-needed' | 'always', behavior: 'auto' | 'smooth' | 'instant' = preferredScrollBehavior(),
|
|
184
|
+
): void => {
|
|
185
|
+
const item = virtualizer.measurementsCache[index]
|
|
186
|
+
const height = virtualizer.scrollRect?.height ?? 0
|
|
187
|
+
if (item === undefined || height <= 0) return
|
|
188
|
+
const current = virtualizer.scrollOffset ?? 0
|
|
189
|
+
const center = item.start + item.size / 2
|
|
190
|
+
if (reveal === 'if-needed') {
|
|
191
|
+
const { scrollPaddingStart, scrollPaddingEnd } = virtualizer.options
|
|
192
|
+
if (center >= current + scrollPaddingStart && center <= current + height - scrollPaddingEnd) return
|
|
193
|
+
}
|
|
194
|
+
const target = center - height / 2
|
|
195
|
+
const max = Math.max(0, virtualizer.getTotalSize() - height)
|
|
196
|
+
const delta = Math.max(0, Math.min(max, target)) - current
|
|
197
|
+
if (delta !== 0) virtualizer.scrollBy(delta, { behavior })
|
|
198
|
+
}, [virtualizer])
|
|
199
|
+
|
|
200
|
+
useImperativeHandle(ref, (): TurnNavigatorHandle => ({
|
|
201
|
+
activateTurn(turn) {
|
|
202
|
+
const index = turnIndexes.get(turn)
|
|
203
|
+
const item = index === undefined ? undefined : items[index]
|
|
204
|
+
if (item !== undefined) onNavigate(item)
|
|
205
|
+
},
|
|
206
|
+
scrollToTurn(turn) {
|
|
207
|
+
const index = turnIndexes.get(turn)
|
|
208
|
+
if (index !== undefined) scrollToIndex(index, 'always')
|
|
209
|
+
},
|
|
210
|
+
}), [items, turnIndexes, onNavigate, scrollToIndex])
|
|
211
|
+
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
if (viewHeight <= 0) {
|
|
214
|
+
initialization.current.follow = null
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
if (activeIndex === undefined || pointerInsideRef.current) return
|
|
218
|
+
const previous = initialization.current.follow
|
|
219
|
+
if (previous?.index === activeIndex && previous.count === items.length && previous.height === viewHeight) return
|
|
220
|
+
initialization.current.follow = { index: activeIndex, count: items.length, height: viewHeight }
|
|
221
|
+
const behavior = previous?.count === items.length && previous.height === viewHeight
|
|
222
|
+
? preferredScrollBehavior()
|
|
223
|
+
: 'instant'
|
|
224
|
+
scrollToIndex(activeIndex, 'if-needed', behavior)
|
|
225
|
+
}, [activeIndex, items.length, viewHeight, scrollToIndex])
|
|
226
|
+
|
|
227
|
+
if (items.length < 2) return null
|
|
228
|
+
const preview = previewIndex === undefined ? undefined : items[previewIndex]
|
|
229
|
+
const previewPosition = virtualItems.find(item => item.index === previewIndex)
|
|
230
|
+
const fadeClasses = [css.scroller]
|
|
231
|
+
if (scrollTop > 1) fadeClasses.push(css.fadeTop)
|
|
232
|
+
if (scrollTop < virtualizer.getTotalSize() - viewHeight - 1) fadeClasses.push(css.fadeBottom)
|
|
233
|
+
return (
|
|
234
|
+
<div className={css.slot}>
|
|
235
|
+
<nav
|
|
236
|
+
className={css.frame}
|
|
237
|
+
aria-label={t('chat.turnNavigation.label')}
|
|
238
|
+
onPointerEnter={() => { pointerInsideRef.current = true }}
|
|
239
|
+
onPointerLeave={() => {
|
|
240
|
+
pointerInsideRef.current = false
|
|
241
|
+
setPreviewTurn(null)
|
|
242
|
+
}}
|
|
243
|
+
>
|
|
244
|
+
<div ref={scrollerRef} className={fadeClasses.join(' ')}>
|
|
245
|
+
<div ref={virtualizer.containerRef} className={css.marks}>
|
|
246
|
+
{virtualItems.map(({ index, key }) => {
|
|
247
|
+
const item = items[index]
|
|
248
|
+
if (item === undefined) return null
|
|
249
|
+
return (
|
|
250
|
+
<TurnMark
|
|
251
|
+
key={key}
|
|
252
|
+
item={item}
|
|
253
|
+
index={index}
|
|
254
|
+
active={item.turn === activeTurn}
|
|
255
|
+
busy={item.turn === busyTurn}
|
|
256
|
+
previewId={item.turn === previewTurn ? previewId : undefined}
|
|
257
|
+
registerElement={virtualizer.measureElement}
|
|
258
|
+
onNavigate={onNavigate}
|
|
259
|
+
onPreview={setPreviewTurn}
|
|
260
|
+
onFocusChange={onFocusChange}
|
|
261
|
+
t={t}
|
|
262
|
+
/>
|
|
263
|
+
)
|
|
264
|
+
})}
|
|
265
|
+
</div>
|
|
266
|
+
</div>
|
|
267
|
+
{preview !== undefined && previewPosition !== undefined && (
|
|
268
|
+
<div
|
|
269
|
+
id={previewId}
|
|
270
|
+
role="tooltip"
|
|
271
|
+
className={css.preview}
|
|
272
|
+
style={{
|
|
273
|
+
'--turn-preview-center': `${String(previewPosition.start + previewPosition.size / 2 - scrollTop)}px`,
|
|
274
|
+
} as CSSProperties}
|
|
275
|
+
>
|
|
276
|
+
<div className={css.previewPrompt}>
|
|
277
|
+
{preview.prompt || t('chat.turnNavigation.turn', { turn: preview.turn })}
|
|
278
|
+
</div>
|
|
279
|
+
{preview.response !== '' && <div className={css.previewResponse}>{preview.response}</div>}
|
|
280
|
+
</div>
|
|
281
|
+
)}
|
|
282
|
+
</nav>
|
|
283
|
+
</div>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Fixed-pitch rail of every known Turn — loaded marks scroll, unloaded marks
|
|
289
|
+
* page history in first — with hover and focus previews. Overflow scrolls
|
|
290
|
+
* inside the frame, gradient fades marking each scrollable end, and the
|
|
291
|
+
* active mark centers only outside the fade-free band while the pointer is
|
|
292
|
+
* elsewhere. Previews follow pointer movement or focus, not scrolling under
|
|
293
|
+
* a stationary pointer.
|
|
294
|
+
*/
|
|
295
|
+
export const TurnNavigator = memo(forwardRef(TurnNavigatorRail))
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
width: 100%;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
height: calc(33px + var(--dsh-content-font-delta, 0px));
|
|
8
|
+
padding: 0 0 8px;
|
|
9
|
+
border: none;
|
|
10
|
+
border-bottom: 0.5px solid var(--dsw-alias-border-l2);
|
|
11
|
+
background: none;
|
|
12
|
+
color: var(--dsw-alias-label-tertiary);
|
|
13
|
+
font: inherit;
|
|
14
|
+
font-size: var(--dsh-content-font-size, 14px);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
text-align: left;
|
|
17
|
+
transition: color 100ms ease;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.root:disabled {
|
|
21
|
+
cursor: default;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@media (hover: hover) {
|
|
25
|
+
.root:hover:not(:disabled) {
|
|
26
|
+
color: var(--dsw-alias-label-secondary);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.chevron {
|
|
31
|
+
flex: none;
|
|
32
|
+
width: 14px;
|
|
33
|
+
height: 14px;
|
|
34
|
+
margin-left: 4px;
|
|
35
|
+
color: inherit;
|
|
36
|
+
transition: transform 100ms ease;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.root[data-open] .chevron {
|
|
40
|
+
transform: rotate(180deg);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.label {
|
|
44
|
+
min-width: 0;
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
font-size: inherit;
|
|
47
|
+
line-height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
48
|
+
text-overflow: ellipsis;
|
|
49
|
+
white-space: nowrap;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.durationNumber {
|
|
53
|
+
font-family: var(--ds-font-family-code);
|
|
54
|
+
font-variant-numeric: tabular-nums;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@media (prefers-reduced-motion: reduce) {
|
|
58
|
+
.root,
|
|
59
|
+
.chevron {
|
|
60
|
+
transition: none;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import { IconChevronDownOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
3
|
+
import type { ChatNodeViewProps } from '../contract/slots.ts'
|
|
4
|
+
import { turnProcessAlwaysOpen } from '../contract/turn-process.ts'
|
|
5
|
+
import { formatRunDuration } from './message-chrome.ts'
|
|
6
|
+
import a11yCss from './accessibility.module.css'
|
|
7
|
+
import css from './TurnProcessNodeView.module.css'
|
|
8
|
+
|
|
9
|
+
/** Settled Turn duration and process disclosure above its content. */
|
|
10
|
+
export const TurnProcessNodeView = memo(function TurnProcessNodeView({
|
|
11
|
+
node, turnProcess, t,
|
|
12
|
+
}: ChatNodeViewProps<'turn-process'>) {
|
|
13
|
+
if (turnProcess === undefined) throw new Error('turn-process node requires Turn process owner state')
|
|
14
|
+
const open = !turnProcess.foldable || turnProcess.open
|
|
15
|
+
const turn = node.location.kind === 'turn' || node.location.kind === 'step'
|
|
16
|
+
? node.location.turn
|
|
17
|
+
: undefined
|
|
18
|
+
if (turn?.status !== 'closed') return null
|
|
19
|
+
const canCollapse = turnProcess.foldable && turnProcess.hasContent && !turnProcessAlwaysOpen(node)
|
|
20
|
+
const reason = turn.end?.data.reason.kind
|
|
21
|
+
const stopped = reason === 'aborted' || reason === 'interrupted'
|
|
22
|
+
const elapsedMs = turn.start === undefined || turn.end === undefined ? undefined
|
|
23
|
+
: Math.max(1000, turn.end.time - turn.start.time)
|
|
24
|
+
const duration = elapsedMs === undefined || stopped || reason === 'error' ? undefined
|
|
25
|
+
: formatRunDuration(elapsedMs, t)
|
|
26
|
+
// Other end reasons retain elapsed time; only stops and failure replace it.
|
|
27
|
+
const label = stopped ? t('message.stopped')
|
|
28
|
+
: reason === 'error' ? t('message.turnProcess.failed')
|
|
29
|
+
: duration === undefined ? t('message.turnProcess.worked')
|
|
30
|
+
: t('message.turnProcess.took')
|
|
31
|
+
const announcement = stopped ? t('message.stopped')
|
|
32
|
+
: reason === 'error' ? t('message.turnProcess.failed')
|
|
33
|
+
: t('message.turnProcess.worked')
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<span className={a11yCss.visuallyHidden} role="status" aria-live="polite" aria-atomic="true">{announcement}</span>
|
|
37
|
+
<button
|
|
38
|
+
type="button"
|
|
39
|
+
className={css.root}
|
|
40
|
+
data-open={open || undefined}
|
|
41
|
+
data-turn-process={node.data.turn}
|
|
42
|
+
data-turn-process-messages={node.data.messageCount}
|
|
43
|
+
data-turn-process-tool-calls={node.data.toolCallCount}
|
|
44
|
+
data-turn-process-subagents={node.data.subagentCount}
|
|
45
|
+
disabled={!canCollapse}
|
|
46
|
+
aria-expanded={turnProcess.hasContent ? open : undefined}
|
|
47
|
+
onClick={(event) => {
|
|
48
|
+
event.currentTarget.focus()
|
|
49
|
+
turnProcess.setOpen(!open)
|
|
50
|
+
}}
|
|
51
|
+
>
|
|
52
|
+
<span className={css.label}>
|
|
53
|
+
{label}
|
|
54
|
+
{duration?.map((part, index) => (
|
|
55
|
+
<span key={index} className={part.numeric ? css.durationNumber : undefined}>{part.text}</span>
|
|
56
|
+
))}
|
|
57
|
+
</span>
|
|
58
|
+
{canCollapse && <IconChevronDownOutlineRegular className={css.chevron} />}
|
|
59
|
+
</button>
|
|
60
|
+
</>
|
|
61
|
+
)
|
|
62
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: 16px;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.actions {
|
|
8
|
+
/* With tail content, this adds to the root gap; without it, the Chat flow's
|
|
9
|
+
preceding-item offset supplies the other 16px. */
|
|
10
|
+
margin-top: 4px;
|
|
11
|
+
margin-left: -6px;
|
|
12
|
+
}
|