@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,81 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import type { InjectFace, PropsRenderSlots } from '@deepseek-ai/dsh-client-ui-slots'
|
|
3
|
+
import type { ChatNodeViewProps, PerformanceUsageInjected, TurnTailOwnerProps } from '../contract/slots.ts'
|
|
4
|
+
import { MessageIconActions } from './MessageIconActions.tsx'
|
|
5
|
+
import { TurnUsagePanel } from './TurnUsagePanel.tsx'
|
|
6
|
+
import { assistantText } from './turn-assistant.ts'
|
|
7
|
+
import { hasAssistantReplyContent } from '../contract/assistant-content.ts'
|
|
8
|
+
import type { ChatNode } from '../contract/chat-nodes.ts'
|
|
9
|
+
import type { ChatSnapshot } from '../contract/snapshot.ts'
|
|
10
|
+
import css from './TurnTailNodeView.module.css'
|
|
11
|
+
|
|
12
|
+
type TurnTailNodeViewProps = ChatNodeViewProps<'turn-tail'>
|
|
13
|
+
& PropsRenderSlots<'conversation.chat.turnTail' | 'conversation.chat.assistant-actions'>
|
|
14
|
+
& InjectFace<PerformanceUsageInjected>
|
|
15
|
+
|
|
16
|
+
function lastContent(snapshot: ChatSnapshot, turn: number, skipWarning: boolean): ChatNode | undefined {
|
|
17
|
+
const keys = snapshot.locations.getTurn(turn)
|
|
18
|
+
for (let index = keys.length - 1; index >= 0; index--) {
|
|
19
|
+
const node = snapshot.nodes.get(keys[index] as string) as ChatNode | undefined
|
|
20
|
+
if (node === undefined || node.kind === 'turn-tail' || node.kind === 'turn-process'
|
|
21
|
+
|| (skipWarning && node.kind === 'turn-max-tokens')) continue
|
|
22
|
+
return node
|
|
23
|
+
}
|
|
24
|
+
return undefined
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Turn-local actions and feature tail over the Location index, independent of Assistant placement. */
|
|
28
|
+
export const TurnTailNodeView = memo(function TurnTailNodeView({
|
|
29
|
+
node, openFile, forkAt, renderSlot, t, useAccess, useChat, usePerformanceUsage,
|
|
30
|
+
}: TurnTailNodeViewProps) {
|
|
31
|
+
const detailed = usePerformanceUsage(mode => mode) === 'detailed'
|
|
32
|
+
const forkAllowed = useAccess('session/fork')
|
|
33
|
+
const data = node.data
|
|
34
|
+
const hasLaterChatNode = useChat(snapshot =>
|
|
35
|
+
(lastContent(snapshot, data.turn, true)?.anchorSeq ?? -1) > (data.closing?.finalNode.seq ?? data.seq))
|
|
36
|
+
const endsWithResponse = useChat((snapshot) => {
|
|
37
|
+
if (snapshot.timeline.turnOrder.at(-1) !== data.turn) return false
|
|
38
|
+
const last = lastContent(snapshot, data.turn, false)
|
|
39
|
+
const block = last?.kind === 'assistant-step' ? last.data.blocks.findLast(candidate =>
|
|
40
|
+
(candidate.kind !== 'text' && candidate.kind !== 'reasoning') || candidate.text.trim() !== '') : undefined
|
|
41
|
+
return block !== undefined && hasAssistantReplyContent([block])
|
|
42
|
+
})
|
|
43
|
+
const turn = node.location.kind === 'turn' || node.location.kind === 'step'
|
|
44
|
+
? node.location.turn
|
|
45
|
+
: undefined
|
|
46
|
+
if (turn === undefined) return null
|
|
47
|
+
const closing = data.closing
|
|
48
|
+
const owner: TurnTailOwnerProps = { turn, seq: closing?.finalNode.seq ?? data.seq, openFile }
|
|
49
|
+
const tail = renderSlot('conversation.chat.turnTail', owner)
|
|
50
|
+
if (closing === null) return tail === null ? null : <div className={css.root} data-turn-tail={data.turn}>{tail}</div>
|
|
51
|
+
// Interruption-frozen partials carry no messageId, so they address no
|
|
52
|
+
// durable message and contribute no per-message actions.
|
|
53
|
+
const messageId = closing.finalNode.messageId
|
|
54
|
+
const assistantActions = messageId === undefined
|
|
55
|
+
? null
|
|
56
|
+
: renderSlot('conversation.chat.assistant-actions', { messageId })
|
|
57
|
+
return (
|
|
58
|
+
<div
|
|
59
|
+
className={css.root}
|
|
60
|
+
data-turn-tail={data.turn}
|
|
61
|
+
data-actions-reveal={endsWithResponse ? 'always' : 'hover'}
|
|
62
|
+
>
|
|
63
|
+
{tail}
|
|
64
|
+
<MessageIconActions
|
|
65
|
+
text={assistantText(closing.blocks)}
|
|
66
|
+
time={closing.time}
|
|
67
|
+
clock="end"
|
|
68
|
+
// The branch action owns boundary resolution: it sends the real
|
|
69
|
+
// turn/end seq it already has, and the Host cuts exactly there.
|
|
70
|
+
onBranch={forkAllowed ? () => { forkAt(data.seq) } : undefined}
|
|
71
|
+
branchUnavailable={data.branchUnavailable || hasLaterChatNode}
|
|
72
|
+
className={css.actions}
|
|
73
|
+
extraActions={assistantActions}
|
|
74
|
+
usageAction={detailed && data.tokenUsage !== undefined
|
|
75
|
+
? <TurnUsagePanel usage={data.tokenUsage} t={t} />
|
|
76
|
+
: null}
|
|
77
|
+
t={t}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
min-width: 0;
|
|
3
|
+
border: 0.5px solid var(--dsw-alias-border-l1);
|
|
4
|
+
border-radius: var(--dsw-radius-xl);
|
|
5
|
+
background: var(--dsw-alias-turn-trigger-bg, var(--dsw-alias-markdown-code-block));
|
|
6
|
+
transition: background-color 100ms ease;
|
|
7
|
+
}
|
|
8
|
+
@media (hover: hover) {
|
|
9
|
+
.root:hover { background: var(--dsw-alias-turn-trigger-bg-hover, var(--dsw-alias-interactive-bg-hover)); }
|
|
10
|
+
}
|
|
11
|
+
.header {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
gap: 10px;
|
|
15
|
+
width: 100%;
|
|
16
|
+
padding: 12px 16px;
|
|
17
|
+
border: 0;
|
|
18
|
+
background: none;
|
|
19
|
+
color: var(--dsw-alias-label-tertiary);
|
|
20
|
+
transition: color 100ms ease;
|
|
21
|
+
font: inherit;
|
|
22
|
+
text-align: left;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
}
|
|
25
|
+
@media (hover: hover) {
|
|
26
|
+
.header:hover { color: var(--dsw-alias-label-secondary); }
|
|
27
|
+
}
|
|
28
|
+
.icon { display: inline-flex; flex: none; color: inherit; }
|
|
29
|
+
.continuation {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 6px;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
padding: 2px 0;
|
|
35
|
+
color: var(--dsw-alias-label-tertiary);
|
|
36
|
+
font-size: var(--dsh-content-font-size-secondary, 13px);
|
|
37
|
+
line-height: calc(20px + var(--dsh-content-font-delta-secondary, 0px));
|
|
38
|
+
overflow-wrap: anywhere;
|
|
39
|
+
}
|
|
40
|
+
.title { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: var(--dsh-content-font-size, 14px); }
|
|
41
|
+
.time { flex: none; margin-left: auto; color: inherit; font: var(--dsw-font-xxs-12); }
|
|
42
|
+
.chevron, .openChevron { flex: none; color: inherit; }
|
|
43
|
+
.openChevron { transform: rotate(180deg); }
|
|
44
|
+
.body { padding: 0 16px 12px 40px; }
|
|
45
|
+
.explanation { margin: 8px 0; color: var(--dsw-alias-label-secondary); font: var(--dsw-font-xxs-12); }
|
|
46
|
+
.content { max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: var(--dsw-font-xxs-12); }
|
|
47
|
+
|
|
48
|
+
@media (prefers-reduced-motion: reduce) {
|
|
49
|
+
.root, .header { transition: none; }
|
|
50
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** Recorded Turn triggers and compact manual-continuation receipts. */
|
|
2
|
+
import { useId, useState, type ComponentType } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
IconAgentPresetOutlineRegular, IconClockOutlineRegular, IconBranchOutlineRegular,
|
|
5
|
+
IconChevronDownOutlineRegular, IconContextInjectionOutlineRegular, IconCordisPluginOutlineRegular,
|
|
6
|
+
IconGoalOutlineRegular, IconGlobeOutlineRegular, IconPaperPlaneOutlineRegular, IconQueueOutlineRegular,
|
|
7
|
+
IconUsersOutlineRegular, IconPlayOutlineRegular, type IconProps,
|
|
8
|
+
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
9
|
+
import type { ChatNodeViewProps } from '../contract/slots.ts'
|
|
10
|
+
import { formatMessageClock } from './message-chrome.ts'
|
|
11
|
+
import { NoticeBody } from './ContextBody.tsx'
|
|
12
|
+
import { turnTriggerDetails, type TurnTriggerIcon } from './turn-trigger.ts'
|
|
13
|
+
import css from './TurnTriggerNodeView.module.css'
|
|
14
|
+
|
|
15
|
+
const TRIGGER_ICONS: Record<TurnTriggerIcon, ComponentType<IconProps>> = {
|
|
16
|
+
continue: IconPlayOutlineRegular,
|
|
17
|
+
request: IconContextInjectionOutlineRegular,
|
|
18
|
+
goal: IconGoalOutlineRegular,
|
|
19
|
+
agent: IconPaperPlaneOutlineRegular,
|
|
20
|
+
team: IconAgentPresetOutlineRegular,
|
|
21
|
+
subagent: IconUsersOutlineRegular,
|
|
22
|
+
github: IconBranchOutlineRegular,
|
|
23
|
+
webhook: IconGlobeOutlineRegular,
|
|
24
|
+
schedule: IconClockOutlineRegular,
|
|
25
|
+
job: IconQueueOutlineRegular,
|
|
26
|
+
plugin: IconCordisPluginOutlineRegular,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Render recorded trigger attribution above the whole-Turn disclosure. */
|
|
30
|
+
export function TurnTriggerNodeView({ node, t }: Pick<ChatNodeViewProps<'turn-trigger'>, 'node' | 't'>) {
|
|
31
|
+
const [open, setOpen] = useState(false)
|
|
32
|
+
const bodyId = useId()
|
|
33
|
+
const details = turnTriggerDetails(node.data)
|
|
34
|
+
const TriggerIcon = TRIGGER_ICONS[details.icon]
|
|
35
|
+
if (details.compact) return (
|
|
36
|
+
<div className={css.continuation} data-generation-continuation>
|
|
37
|
+
<span className={css.icon} aria-hidden><TriggerIcon size={14} /></span>
|
|
38
|
+
<span>{t(details.title)}</span>
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
const date = new Date(node.data.time)
|
|
42
|
+
const time = formatMessageClock(node.data.time, t)
|
|
43
|
+
return (
|
|
44
|
+
<section className={css.root} data-turn-trigger>
|
|
45
|
+
<button className={css.header} type="button" aria-expanded={open} aria-controls={bodyId} onClick={() => { setOpen(!open) }}>
|
|
46
|
+
<span className={css.icon} aria-hidden><TriggerIcon size={14} /></span>
|
|
47
|
+
<span className={css.title}>{t(details.title)}</span>
|
|
48
|
+
<time className={css.time} dateTime={date.toISOString()}>{time}</time>
|
|
49
|
+
<IconChevronDownOutlineRegular size={12} className={open ? css.openChevron : css.chevron} />
|
|
50
|
+
</button>
|
|
51
|
+
{open && <div id={bodyId} className={css.body}>
|
|
52
|
+
<p className={css.explanation}>{t('message.trigger.explanation')}</p>
|
|
53
|
+
<div className={css.content}><NoticeBody content={node.data.content} source={node.data.source} t={t} /></div>
|
|
54
|
+
</div>}
|
|
55
|
+
</section>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* Icon-row Turn-usage pill (data icon + turn total); its click-open dialog
|
|
2
|
+
wears the shared stat-dialog.module.css skin. */
|
|
3
|
+
|
|
4
|
+
.root {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
min-width: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Adjacent stat pills (usage then time) rebate part of their combined internal
|
|
10
|
+
padding so the pair reads as one cluster inside the row's 8px flex gap,
|
|
11
|
+
while keeping 2px clear between their hover backgrounds. */
|
|
12
|
+
.root + .root {
|
|
13
|
+
margin-left: -6px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* The information pills use the action icons' resting color. */
|
|
17
|
+
.trigger {
|
|
18
|
+
display: inline-flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: 4px;
|
|
21
|
+
min-width: 0;
|
|
22
|
+
height: calc(28px + var(--dsh-content-font-delta, 0px));
|
|
23
|
+
padding: 6px 8px;
|
|
24
|
+
border: none;
|
|
25
|
+
border-radius: var(--dsw-radius-sm);
|
|
26
|
+
background: transparent;
|
|
27
|
+
color: var(--dsw-alias-label-tertiary);
|
|
28
|
+
font-size: calc(var(--dsh-content-font-size-secondary, 13px) - 1px);
|
|
29
|
+
font-variant-numeric: tabular-nums;
|
|
30
|
+
line-height: calc(24px + var(--dsh-content-font-delta, 0px));
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* A narrow column trims the label to an ellipsis instead of overflowing the
|
|
36
|
+
pill; the data glyph never shrinks. */
|
|
37
|
+
.label {
|
|
38
|
+
min-width: 0;
|
|
39
|
+
overflow: hidden;
|
|
40
|
+
text-overflow: ellipsis;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.trigger svg {
|
|
44
|
+
width: calc(15px + var(--dsh-content-font-delta, 0px));
|
|
45
|
+
height: calc(15px + var(--dsh-content-font-delta, 0px));
|
|
46
|
+
flex: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.trigger[aria-expanded='true'] {
|
|
50
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
51
|
+
color: var(--dsw-alias-label-tertiary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@media (hover: hover) {
|
|
55
|
+
.trigger:hover {
|
|
56
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
57
|
+
color: var(--dsw-alias-label-tertiary);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Narrow viewport: the pills collapse to bare icons with the sibling
|
|
62
|
+
`.action` geometry (28px circle, 6px padding, centered glyph); the
|
|
63
|
+
label-padding rebate no longer applies, so the pair keeps the row's plain
|
|
64
|
+
8px rhythm. The dialogs keep the words. */
|
|
65
|
+
@media (max-width: 480px) {
|
|
66
|
+
.trigger {
|
|
67
|
+
justify-content: center;
|
|
68
|
+
width: calc(28px + var(--dsh-content-font-delta, 0px));
|
|
69
|
+
padding: 6px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.trigger .label {
|
|
73
|
+
display: none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.root + .root {
|
|
77
|
+
margin-left: 0;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Completed-Turn token usage action and its accounting details dialog. */
|
|
2
|
+
|
|
3
|
+
import { createPortal } from 'react-dom'
|
|
4
|
+
import { IconDatabaseOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
+
import type { TurnTokenUsage } from '../contract/chat-nodes.ts'
|
|
6
|
+
import type { ChatViewSlotProps } from '../contract/slots.ts'
|
|
7
|
+
import { formatCacheHitPercent, formatExactTokens, formatTokens } from './token-format.ts'
|
|
8
|
+
import { useStatDialog } from './stat-dialog.ts'
|
|
9
|
+
import css from './TurnUsagePanel.module.css'
|
|
10
|
+
import dialogCss from './stat-dialog.module.css'
|
|
11
|
+
|
|
12
|
+
export interface TurnUsagePanelProps {
|
|
13
|
+
usage: TurnTokenUsage
|
|
14
|
+
/** The owning view's locale seat, passed down as a plain prop. */
|
|
15
|
+
t: ChatViewSlotProps['t']
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function formatCompactCount(value: number, t: ChatViewSlotProps['t']): string {
|
|
19
|
+
return t('message.turnUsage.count', { count: formatTokens(value, t) })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function formatExactCount(value: number, t: ChatViewSlotProps['t']): string {
|
|
23
|
+
return t('message.turnUsage.count', { count: formatExactTokens(value, t) })
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Turn-usage IconActions pill with a click-open Turn-usage details dialog.
|
|
28
|
+
* @param props - Turn usage buckets and locale seat.
|
|
29
|
+
* @returns The trigger and, while open, its portaled dialog anchored above the trigger.
|
|
30
|
+
*/
|
|
31
|
+
export function TurnUsagePanel({ usage, t }: TurnUsagePanelProps) {
|
|
32
|
+
const { open, setOpen, rootRef, panelRef, anchorName } = useStatDialog()
|
|
33
|
+
|
|
34
|
+
const cacheHit = usage.cacheReadTokens === undefined
|
|
35
|
+
? null
|
|
36
|
+
: formatCacheHitPercent(usage.cacheReadTokens, usage.totalTokens - usage.outputTokens, 1)
|
|
37
|
+
const total = formatCompactCount(usage.totalTokens, t)
|
|
38
|
+
const routes = usage.routes?.map(route => `${route.provider}/${route.model}`).join(', ') ?? ''
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<span ref={rootRef} style={{ anchorName }} className={css.root}>
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
className={css.trigger}
|
|
45
|
+
aria-haspopup="dialog"
|
|
46
|
+
aria-expanded={open}
|
|
47
|
+
onClick={() => { setOpen(!open) }}
|
|
48
|
+
>
|
|
49
|
+
<IconDatabaseOutlineRegular />
|
|
50
|
+
<span className={css.label}>{t('message.turnUsage.consumed', { total })}</span>
|
|
51
|
+
</button>
|
|
52
|
+
{open && createPortal(
|
|
53
|
+
<div
|
|
54
|
+
ref={panelRef}
|
|
55
|
+
className={dialogCss.panel}
|
|
56
|
+
role="dialog"
|
|
57
|
+
aria-label={t('message.turnUsage.title')}
|
|
58
|
+
style={{ positionAnchor: anchorName }}
|
|
59
|
+
>
|
|
60
|
+
<div className={dialogCss.title}>
|
|
61
|
+
<span className={dialogCss.titleLabel}>
|
|
62
|
+
<IconDatabaseOutlineRegular />
|
|
63
|
+
{t('message.turnUsage.title')}
|
|
64
|
+
</span>
|
|
65
|
+
<span className={dialogCss.titleValue}>{formatExactCount(usage.totalTokens, t)}</span>
|
|
66
|
+
</div>
|
|
67
|
+
<div className={dialogCss.titleRule} aria-hidden />
|
|
68
|
+
<dl className={dialogCss.details} data-turn-usage-details>
|
|
69
|
+
{routes !== '' && (
|
|
70
|
+
<>
|
|
71
|
+
<dt>{t('message.turnUsage.model')}</dt>
|
|
72
|
+
<dd className={dialogCss.route}>{routes}</dd>
|
|
73
|
+
</>
|
|
74
|
+
)}
|
|
75
|
+
{cacheHit !== null && (
|
|
76
|
+
<>
|
|
77
|
+
<dt>{t('message.turnUsage.cacheHit')}</dt>
|
|
78
|
+
<dd>{`${cacheHit}%`}</dd>
|
|
79
|
+
</>
|
|
80
|
+
)}
|
|
81
|
+
<dt>{t('message.turnUsage.input')}</dt>
|
|
82
|
+
<dd>{formatExactCount(usage.uncachedInputTokens, t)}</dd>
|
|
83
|
+
{usage.cacheReadTokens !== undefined && (
|
|
84
|
+
<>
|
|
85
|
+
<dt>{t('message.turnUsage.cacheRead')}</dt>
|
|
86
|
+
<dd>{formatExactCount(usage.cacheReadTokens, t)}</dd>
|
|
87
|
+
</>
|
|
88
|
+
)}
|
|
89
|
+
{usage.cacheWriteTokens !== undefined && (
|
|
90
|
+
<>
|
|
91
|
+
<dt>{t('message.turnUsage.cacheWrite')}</dt>
|
|
92
|
+
<dd>{formatExactCount(usage.cacheWriteTokens, t)}</dd>
|
|
93
|
+
</>
|
|
94
|
+
)}
|
|
95
|
+
<dt>{t('message.turnUsage.output')}</dt>
|
|
96
|
+
<dd>
|
|
97
|
+
{formatExactCount(usage.outputTokens, t)}
|
|
98
|
+
{usage.reasoningTokens !== undefined && (
|
|
99
|
+
<span className={dialogCss.reasoning}>
|
|
100
|
+
{t('message.turnUsage.reasoning', { tokens: formatExactCount(usage.reasoningTokens, t) })}
|
|
101
|
+
</span>
|
|
102
|
+
)}
|
|
103
|
+
</dd>
|
|
104
|
+
</dl>
|
|
105
|
+
</div>,
|
|
106
|
+
document.body,
|
|
107
|
+
)}
|
|
108
|
+
</span>
|
|
109
|
+
)
|
|
110
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** Reusable user contents inside a caller-owned message row. */
|
|
2
|
+
import { Fragment } from 'react'
|
|
3
|
+
import type { FactoryComponentPropsOf } from '@deepseek-ai/dsh-client-ui-slots'
|
|
4
|
+
import { fileExtension, FileTypeIcon, fileSizeText, JsonBlock, UserMessageBubble } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
+
import css from './MessageItem.module.css'
|
|
6
|
+
|
|
7
|
+
const EMPTY_LABELS: readonly string[] = []
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Render prepared text, ordered attachments, and references without message chrome.
|
|
11
|
+
* The caller owns row identity, pending/echo state, time, and message actions.
|
|
12
|
+
* @param props - prepared content, facts, authorized image loader, and framework Factory/locale seats.
|
|
13
|
+
* @returns the content stack using the existing user-message layout.
|
|
14
|
+
*/
|
|
15
|
+
export function UserContent({ content, loadImage, facts, interactive = false, ellipsis = false, renderSlot, renderFactorySlot, t }:
|
|
16
|
+
FactoryComponentPropsOf<'conversation.chat.user.content'>) {
|
|
17
|
+
const { text, attachments, extraBlocks, referenceLabels = EMPTY_LABELS } = content
|
|
18
|
+
const compactImages = attachments.length > 1
|
|
19
|
+
const truncated = (total: number): string => t('json.truncated', { total })
|
|
20
|
+
const showBubble = text !== '' || extraBlocks.length > 0
|
|
21
|
+
return (
|
|
22
|
+
<div className={css.userStack}>
|
|
23
|
+
{attachments.length > 0 && (
|
|
24
|
+
<div className={css.attachmentRow} data-message-attachments>
|
|
25
|
+
{attachments.map((attachment, index) => attachment.type === 'image'
|
|
26
|
+
? (
|
|
27
|
+
<Fragment key={`image:${index}`}>
|
|
28
|
+
{renderSlot('conversation.chat.user.images', {
|
|
29
|
+
images: [attachment.image], loadImage, align: 'end', compact: compactImages,
|
|
30
|
+
})}
|
|
31
|
+
</Fragment>
|
|
32
|
+
)
|
|
33
|
+
: (
|
|
34
|
+
<span key={`file:${index}`} className={css.fileCard} title={attachment.file.name}>
|
|
35
|
+
<FileTypeIcon path={attachment.file.name} className={css.fileIcon} />
|
|
36
|
+
<span className={css.fileContent}>
|
|
37
|
+
<span className={css.fileName}>{attachment.file.name}</span>
|
|
38
|
+
<span className={css.fileMeta}>
|
|
39
|
+
{[fileExtension(attachment.file.name).toUpperCase().slice(0, 8), fileSizeText(attachment.file.bytes)]
|
|
40
|
+
.filter(Boolean).join(' ')}
|
|
41
|
+
</span>
|
|
42
|
+
</span>
|
|
43
|
+
</span>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
)}
|
|
47
|
+
{showBubble && <UserMessageBubble data-message-bubble="" data-text-interaction-source="">
|
|
48
|
+
{renderFactorySlot('conversation.user.text', { text, facts, interactive, ellipsis })}
|
|
49
|
+
{extraBlocks.map((block, index) => (
|
|
50
|
+
<JsonBlock key={index} label={t('message.extraBlock')} payload={block} truncatedLabel={truncated} />
|
|
51
|
+
))}
|
|
52
|
+
</UserMessageBubble>}
|
|
53
|
+
{referenceLabels.length > 0 && (
|
|
54
|
+
<div className={css.referenceSummary}>
|
|
55
|
+
{t('message.referenceSummary', { labels: referenceLabels.join(t('message.referenceSeparator')) })}
|
|
56
|
+
</div>
|
|
57
|
+
)}
|
|
58
|
+
</div>
|
|
59
|
+
)
|
|
60
|
+
}
|