@wzrhine/agent 0.0.0-stage → 0.2.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 +40 -0
- package/LICENSE +21 -0
- package/README.md +29 -3
- package/dist/agent.css +16 -0
- package/dist/components/artifact/ArtifactCard.d.ts +59 -0
- package/dist/components/artifact/ArtifactCard.d.ts.map +1 -0
- package/dist/components/artifact/ArtifactCard.js +79 -0
- package/dist/components/artifact/ArtifactCard.js.map +1 -0
- package/dist/components/artifact/FilePreview.d.ts +121 -0
- package/dist/components/artifact/FilePreview.d.ts.map +1 -0
- package/dist/components/artifact/FilePreview.js +213 -0
- package/dist/components/artifact/FilePreview.js.map +1 -0
- package/dist/components/artifact/FilePreviewTabs.d.ts +51 -0
- package/dist/components/artifact/FilePreviewTabs.d.ts.map +1 -0
- package/dist/components/artifact/FilePreviewTabs.js +150 -0
- package/dist/components/artifact/FilePreviewTabs.js.map +1 -0
- package/dist/components/composer/AttachmentList.d.ts +33 -0
- package/dist/components/composer/AttachmentList.d.ts.map +1 -0
- package/dist/components/composer/AttachmentList.js +60 -0
- package/dist/components/composer/AttachmentList.js.map +1 -0
- package/dist/components/composer/Composer.d.ts +119 -0
- package/dist/components/composer/Composer.d.ts.map +1 -0
- package/dist/components/composer/Composer.js +336 -0
- package/dist/components/composer/Composer.js.map +1 -0
- package/dist/components/composer/ComposerInput.d.ts +103 -0
- package/dist/components/composer/ComposerInput.d.ts.map +1 -0
- package/dist/components/composer/ComposerInput.js +301 -0
- package/dist/components/composer/ComposerInput.js.map +1 -0
- package/dist/components/composer/ComposerNotice.d.ts +38 -0
- package/dist/components/composer/ComposerNotice.d.ts.map +1 -0
- package/dist/components/composer/ComposerNotice.js +16 -0
- package/dist/components/composer/ComposerNotice.js.map +1 -0
- package/dist/components/composer/MentionMenu.d.ts +37 -0
- package/dist/components/composer/MentionMenu.d.ts.map +1 -0
- package/dist/components/composer/MentionMenu.js +56 -0
- package/dist/components/composer/MentionMenu.js.map +1 -0
- package/dist/components/composer/MenuPanel.d.ts +49 -0
- package/dist/components/composer/MenuPanel.d.ts.map +1 -0
- package/dist/components/composer/MenuPanel.js +50 -0
- package/dist/components/composer/MenuPanel.js.map +1 -0
- package/dist/components/composer/ModelPicker.d.ts +53 -0
- package/dist/components/composer/ModelPicker.d.ts.map +1 -0
- package/dist/components/composer/ModelPicker.js +126 -0
- package/dist/components/composer/ModelPicker.js.map +1 -0
- package/dist/components/composer/PermissionPicker.d.ts +35 -0
- package/dist/components/composer/PermissionPicker.d.ts.map +1 -0
- package/dist/components/composer/PermissionPicker.js +51 -0
- package/dist/components/composer/PermissionPicker.js.map +1 -0
- package/dist/components/composer/ReferencePicker.d.ts +31 -0
- package/dist/components/composer/ReferencePicker.d.ts.map +1 -0
- package/dist/components/composer/ReferencePicker.js +50 -0
- package/dist/components/composer/ReferencePicker.js.map +1 -0
- package/dist/components/composer/SendStopButton.d.ts +73 -0
- package/dist/components/composer/SendStopButton.d.ts.map +1 -0
- package/dist/components/composer/SendStopButton.js +88 -0
- package/dist/components/composer/SendStopButton.js.map +1 -0
- package/dist/components/composer/SkillPicker.d.ts +26 -0
- package/dist/components/composer/SkillPicker.d.ts.map +1 -0
- package/dist/components/composer/SkillPicker.js +26 -0
- package/dist/components/composer/SkillPicker.js.map +1 -0
- package/dist/components/composer/SlashCommandMenu.d.ts +33 -0
- package/dist/components/composer/SlashCommandMenu.d.ts.map +1 -0
- package/dist/components/composer/SlashCommandMenu.js +43 -0
- package/dist/components/composer/SlashCommandMenu.js.map +1 -0
- package/dist/components/composer/composer-text.d.ts +10 -0
- package/dist/components/composer/composer-text.d.ts.map +1 -0
- package/dist/components/composer/composer-text.js +26 -0
- package/dist/components/composer/composer-text.js.map +1 -0
- package/dist/components/composer/composer-utils.d.ts +74 -0
- package/dist/components/composer/composer-utils.d.ts.map +1 -0
- package/dist/components/composer/composer-utils.js +133 -0
- package/dist/components/composer/composer-utils.js.map +1 -0
- package/dist/components/conversation/ConversationList.d.ts +94 -0
- package/dist/components/conversation/ConversationList.d.ts.map +1 -0
- package/dist/components/conversation/ConversationList.js +81 -0
- package/dist/components/conversation/ConversationList.js.map +1 -0
- package/dist/components/conversation/ConversationRow.d.ts +66 -0
- package/dist/components/conversation/ConversationRow.d.ts.map +1 -0
- package/dist/components/conversation/ConversationRow.js +65 -0
- package/dist/components/conversation/ConversationRow.js.map +1 -0
- package/dist/components/conversation/conversation-status.d.ts +21 -0
- package/dist/components/conversation/conversation-status.d.ts.map +1 -0
- package/dist/components/conversation/conversation-status.js +33 -0
- package/dist/components/conversation/conversation-status.js.map +1 -0
- package/dist/components/intervention/ApprovalDiff.d.ts +14 -0
- package/dist/components/intervention/ApprovalDiff.d.ts.map +1 -0
- package/dist/components/intervention/ApprovalDiff.js +25 -0
- package/dist/components/intervention/ApprovalDiff.js.map +1 -0
- package/dist/components/intervention/ApprovalPanel.d.ts +57 -0
- package/dist/components/intervention/ApprovalPanel.d.ts.map +1 -0
- package/dist/components/intervention/ApprovalPanel.js +111 -0
- package/dist/components/intervention/ApprovalPanel.js.map +1 -0
- package/dist/components/intervention/ErrorRecoveryNotice.d.ts +28 -0
- package/dist/components/intervention/ErrorRecoveryNotice.d.ts.map +1 -0
- package/dist/components/intervention/ErrorRecoveryNotice.js +31 -0
- package/dist/components/intervention/ErrorRecoveryNotice.js.map +1 -0
- package/dist/components/intervention/GrantList.d.ts +49 -0
- package/dist/components/intervention/GrantList.d.ts.map +1 -0
- package/dist/components/intervention/GrantList.js +58 -0
- package/dist/components/intervention/GrantList.js.map +1 -0
- package/dist/components/intervention/InterventionDock.d.ts +24 -0
- package/dist/components/intervention/InterventionDock.d.ts.map +1 -0
- package/dist/components/intervention/InterventionDock.js +18 -0
- package/dist/components/intervention/InterventionDock.js.map +1 -0
- package/dist/components/intervention/QuestionnaireCard.d.ts +81 -0
- package/dist/components/intervention/QuestionnaireCard.d.ts.map +1 -0
- package/dist/components/intervention/QuestionnaireCard.js +333 -0
- package/dist/components/intervention/QuestionnaireCard.js.map +1 -0
- package/dist/components/intervention/action-lock.d.ts +20 -0
- package/dist/components/intervention/action-lock.d.ts.map +1 -0
- package/dist/components/intervention/action-lock.js +65 -0
- package/dist/components/intervention/action-lock.js.map +1 -0
- package/dist/components/intervention/icons.d.ts +8 -0
- package/dist/components/intervention/icons.d.ts.map +1 -0
- package/dist/components/intervention/icons.js +11 -0
- package/dist/components/intervention/icons.js.map +1 -0
- package/dist/components/intervention/questionnaire-answers.d.ts +34 -0
- package/dist/components/intervention/questionnaire-answers.d.ts.map +1 -0
- package/dist/components/intervention/questionnaire-answers.js +97 -0
- package/dist/components/intervention/questionnaire-answers.js.map +1 -0
- package/dist/components/message/AgentMessage.d.ts +98 -0
- package/dist/components/message/AgentMessage.d.ts.map +1 -0
- package/dist/components/message/AgentMessage.js +94 -0
- package/dist/components/message/AgentMessage.js.map +1 -0
- package/dist/components/message/CitationChip.d.ts +38 -0
- package/dist/components/message/CitationChip.d.ts.map +1 -0
- package/dist/components/message/CitationChip.js +32 -0
- package/dist/components/message/CitationChip.js.map +1 -0
- package/dist/components/message/CodeBlock.d.ts +45 -0
- package/dist/components/message/CodeBlock.d.ts.map +1 -0
- package/dist/components/message/CodeBlock.js +21 -0
- package/dist/components/message/CodeBlock.js.map +1 -0
- package/dist/components/message/JumpToLatest.d.ts +27 -0
- package/dist/components/message/JumpToLatest.d.ts.map +1 -0
- package/dist/components/message/JumpToLatest.js +17 -0
- package/dist/components/message/JumpToLatest.js.map +1 -0
- package/dist/components/message/Markdown.d.ts +21 -0
- package/dist/components/message/Markdown.d.ts.map +1 -0
- package/dist/components/message/Markdown.js +21 -0
- package/dist/components/message/Markdown.js.map +1 -0
- package/dist/components/message/MessageActions.d.ts +67 -0
- package/dist/components/message/MessageActions.d.ts.map +1 -0
- package/dist/components/message/MessageActions.js +83 -0
- package/dist/components/message/MessageActions.js.map +1 -0
- package/dist/components/message/MessageList.d.ts +106 -0
- package/dist/components/message/MessageList.d.ts.map +1 -0
- package/dist/components/message/MessageList.js +327 -0
- package/dist/components/message/MessageList.js.map +1 -0
- package/dist/components/message/MessagePart.d.ts +44 -0
- package/dist/components/message/MessagePart.d.ts.map +1 -0
- package/dist/components/message/MessagePart.js +150 -0
- package/dist/components/message/MessagePart.js.map +1 -0
- package/dist/components/message/RunDetails.d.ts +26 -0
- package/dist/components/message/RunDetails.d.ts.map +1 -0
- package/dist/components/message/RunDetails.js +113 -0
- package/dist/components/message/RunDetails.js.map +1 -0
- package/dist/components/message/SkillUseList.d.ts +22 -0
- package/dist/components/message/SkillUseList.d.ts.map +1 -0
- package/dist/components/message/SkillUseList.js +20 -0
- package/dist/components/message/SkillUseList.js.map +1 -0
- package/dist/components/message/ThinkingBlock.d.ts +44 -0
- package/dist/components/message/ThinkingBlock.d.ts.map +1 -0
- package/dist/components/message/ThinkingBlock.js +34 -0
- package/dist/components/message/ThinkingBlock.js.map +1 -0
- package/dist/components/message/icons.d.ts +14 -0
- package/dist/components/message/icons.d.ts.map +1 -0
- package/dist/components/message/icons.js +16 -0
- package/dist/components/message/icons.js.map +1 -0
- package/dist/components/message/plain-text.d.ts +11 -0
- package/dist/components/message/plain-text.d.ts.map +1 -0
- package/dist/components/message/plain-text.js +58 -0
- package/dist/components/message/plain-text.js.map +1 -0
- package/dist/components/message/renderers.d.ts +30 -0
- package/dist/components/message/renderers.d.ts.map +1 -0
- package/dist/components/message/renderers.js +2 -0
- package/dist/components/message/renderers.js.map +1 -0
- package/dist/components/message/use-copy.d.ts +19 -0
- package/dist/components/message/use-copy.d.ts.map +1 -0
- package/dist/components/message/use-copy.js +67 -0
- package/dist/components/message/use-copy.js.map +1 -0
- package/dist/components/process/AgentProcess.d.ts +47 -0
- package/dist/components/process/AgentProcess.d.ts.map +1 -0
- package/dist/components/process/AgentProcess.js +78 -0
- package/dist/components/process/AgentProcess.js.map +1 -0
- package/dist/components/process/RunStatus.d.ts +60 -0
- package/dist/components/process/RunStatus.d.ts.map +1 -0
- package/dist/components/process/RunStatus.js +34 -0
- package/dist/components/process/RunStatus.js.map +1 -0
- package/dist/components/shell/AgentEmptyState.d.ts +35 -0
- package/dist/components/shell/AgentEmptyState.d.ts.map +1 -0
- package/dist/components/shell/AgentEmptyState.js +20 -0
- package/dist/components/shell/AgentEmptyState.js.map +1 -0
- package/dist/components/shell/AgentHeader.d.ts +84 -0
- package/dist/components/shell/AgentHeader.d.ts.map +1 -0
- package/dist/components/shell/AgentHeader.js +43 -0
- package/dist/components/shell/AgentHeader.js.map +1 -0
- package/dist/components/shell/AgentShell.d.ts +154 -0
- package/dist/components/shell/AgentShell.d.ts.map +1 -0
- package/dist/components/shell/AgentShell.js +210 -0
- package/dist/components/shell/AgentShell.js.map +1 -0
- package/dist/components/shell/AgentSidePane.d.ts +54 -0
- package/dist/components/shell/AgentSidePane.d.ts.map +1 -0
- package/dist/components/shell/AgentSidePane.js +26 -0
- package/dist/components/shell/AgentSidePane.js.map +1 -0
- package/dist/components/shell/ResizeHandle.d.ts +54 -0
- package/dist/components/shell/ResizeHandle.d.ts.map +1 -0
- package/dist/components/shell/ResizeHandle.js +94 -0
- package/dist/components/shell/ResizeHandle.js.map +1 -0
- package/dist/components/shell/use-controllable.d.ts +9 -0
- package/dist/components/shell/use-controllable.d.ts.map +1 -0
- package/dist/components/shell/use-controllable.js +26 -0
- package/dist/components/shell/use-controllable.js.map +1 -0
- package/dist/components/tools/ChunkPager.d.ts +48 -0
- package/dist/components/tools/ChunkPager.d.ts.map +1 -0
- package/dist/components/tools/ChunkPager.js +68 -0
- package/dist/components/tools/ChunkPager.js.map +1 -0
- package/dist/components/tools/CodeModeToolTree.d.ts +64 -0
- package/dist/components/tools/CodeModeToolTree.d.ts.map +1 -0
- package/dist/components/tools/CodeModeToolTree.js +97 -0
- package/dist/components/tools/CodeModeToolTree.js.map +1 -0
- package/dist/components/tools/DiffPreview.d.ts +83 -0
- package/dist/components/tools/DiffPreview.d.ts.map +1 -0
- package/dist/components/tools/DiffPreview.js +95 -0
- package/dist/components/tools/DiffPreview.js.map +1 -0
- package/dist/components/tools/ToolActivity.d.ts +63 -0
- package/dist/components/tools/ToolActivity.d.ts.map +1 -0
- package/dist/components/tools/ToolActivity.js +45 -0
- package/dist/components/tools/ToolActivity.js.map +1 -0
- package/dist/components/tools/ToolDetails.d.ts +118 -0
- package/dist/components/tools/ToolDetails.d.ts.map +1 -0
- package/dist/components/tools/ToolDetails.js +258 -0
- package/dist/components/tools/ToolDetails.js.map +1 -0
- package/dist/components/tools/ToolHistory.d.ts +48 -0
- package/dist/components/tools/ToolHistory.d.ts.map +1 -0
- package/dist/components/tools/ToolHistory.js +37 -0
- package/dist/components/tools/ToolHistory.js.map +1 -0
- package/dist/components/tools/ToolOutput.d.ts +61 -0
- package/dist/components/tools/ToolOutput.d.ts.map +1 -0
- package/dist/components/tools/ToolOutput.js +45 -0
- package/dist/components/tools/ToolOutput.js.map +1 -0
- package/dist/components/tools/ToolRecord.d.ts +58 -0
- package/dist/components/tools/ToolRecord.d.ts.map +1 -0
- package/dist/components/tools/ToolRecord.js +79 -0
- package/dist/components/tools/ToolRecord.js.map +1 -0
- package/dist/components/tools/shared.d.ts +93 -0
- package/dist/components/tools/shared.d.ts.map +1 -0
- package/dist/components/tools/shared.js +160 -0
- package/dist/components/tools/shared.js.map +1 -0
- package/dist/components/workspace/ActivityLedger.d.ts +44 -0
- package/dist/components/workspace/ActivityLedger.d.ts.map +1 -0
- package/dist/components/workspace/ActivityLedger.js +63 -0
- package/dist/components/workspace/ActivityLedger.js.map +1 -0
- package/dist/components/workspace/CompactionNotice.d.ts +63 -0
- package/dist/components/workspace/CompactionNotice.d.ts.map +1 -0
- package/dist/components/workspace/CompactionNotice.js +36 -0
- package/dist/components/workspace/CompactionNotice.js.map +1 -0
- package/dist/components/workspace/ContextUsage.d.ts +50 -0
- package/dist/components/workspace/ContextUsage.d.ts.map +1 -0
- package/dist/components/workspace/ContextUsage.js +106 -0
- package/dist/components/workspace/ContextUsage.js.map +1 -0
- package/dist/components/workspace/PersistentTerminal.d.ts +86 -0
- package/dist/components/workspace/PersistentTerminal.d.ts.map +1 -0
- package/dist/components/workspace/PersistentTerminal.js +155 -0
- package/dist/components/workspace/PersistentTerminal.js.map +1 -0
- package/dist/components/workspace/PinnedSummary.d.ts +43 -0
- package/dist/components/workspace/PinnedSummary.d.ts.map +1 -0
- package/dist/components/workspace/PinnedSummary.js +33 -0
- package/dist/components/workspace/PinnedSummary.js.map +1 -0
- package/dist/components/workspace/RunOverview.d.ts +29 -0
- package/dist/components/workspace/RunOverview.d.ts.map +1 -0
- package/dist/components/workspace/RunOverview.js +20 -0
- package/dist/components/workspace/RunOverview.js.map +1 -0
- package/dist/components/workspace/RunSummary.d.ts +35 -0
- package/dist/components/workspace/RunSummary.d.ts.map +1 -0
- package/dist/components/workspace/RunSummary.js +46 -0
- package/dist/components/workspace/RunSummary.js.map +1 -0
- package/dist/components/workspace/SubAgentCard.d.ts +64 -0
- package/dist/components/workspace/SubAgentCard.d.ts.map +1 -0
- package/dist/components/workspace/SubAgentCard.js +78 -0
- package/dist/components/workspace/SubAgentCard.js.map +1 -0
- package/dist/components/workspace/TerminalRow.d.ts +61 -0
- package/dist/components/workspace/TerminalRow.d.ts.map +1 -0
- package/dist/components/workspace/TerminalRow.js +65 -0
- package/dist/components/workspace/TerminalRow.js.map +1 -0
- package/dist/components/workspace/shared.d.ts +26 -0
- package/dist/components/workspace/shared.d.ts.map +1 -0
- package/dist/components/workspace/shared.js +41 -0
- package/dist/components/workspace/shared.js.map +1 -0
- package/dist/index.d.ts +136 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -0
- package/dist/motion/agent-motion.d.ts +62 -0
- package/dist/motion/agent-motion.d.ts.map +1 -0
- package/dist/motion/agent-motion.js +61 -0
- package/dist/motion/agent-motion.js.map +1 -0
- package/dist/primitives/AgentSpark.d.ts +17 -0
- package/dist/primitives/AgentSpark.d.ts.map +1 -0
- package/dist/primitives/AgentSpark.js +11 -0
- package/dist/primitives/AgentSpark.js.map +1 -0
- package/dist/primitives/AgentStatus.d.ts +32 -0
- package/dist/primitives/AgentStatus.d.ts.map +1 -0
- package/dist/primitives/AgentStatus.js +13 -0
- package/dist/primitives/AgentStatus.js.map +1 -0
- package/dist/primitives/StatusGlyph.d.ts +16 -0
- package/dist/primitives/StatusGlyph.d.ts.map +1 -0
- package/dist/primitives/StatusGlyph.js +31 -0
- package/dist/primitives/StatusGlyph.js.map +1 -0
- package/dist/primitives/icons.d.ts +13 -0
- package/dist/primitives/icons.d.ts.map +1 -0
- package/dist/primitives/icons.js +55 -0
- package/dist/primitives/icons.js.map +1 -0
- package/dist/provider/AgentMessages.d.ts +61 -0
- package/dist/provider/AgentMessages.d.ts.map +1 -0
- package/dist/provider/AgentMessages.js +81 -0
- package/dist/provider/AgentMessages.js.map +1 -0
- package/dist/provider/messages/composer.d.ts +112 -0
- package/dist/provider/messages/composer.d.ts.map +1 -0
- package/dist/provider/messages/composer.js +165 -0
- package/dist/provider/messages/composer.js.map +1 -0
- package/dist/provider/messages/intervention.d.ts +136 -0
- package/dist/provider/messages/intervention.d.ts.map +1 -0
- package/dist/provider/messages/intervention.js +321 -0
- package/dist/provider/messages/intervention.js.map +1 -0
- package/dist/provider/messages/message.d.ts +119 -0
- package/dist/provider/messages/message.d.ts.map +1 -0
- package/dist/provider/messages/message.js +224 -0
- package/dist/provider/messages/message.js.map +1 -0
- package/dist/provider/messages/shell.d.ts +70 -0
- package/dist/provider/messages/shell.d.ts.map +1 -0
- package/dist/provider/messages/shell.js +109 -0
- package/dist/provider/messages/shell.js.map +1 -0
- package/dist/provider/messages/status.d.ts +21 -0
- package/dist/provider/messages/status.d.ts.map +1 -0
- package/dist/provider/messages/status.js +195 -0
- package/dist/provider/messages/status.js.map +1 -0
- package/dist/provider/messages/tools.d.ts +217 -0
- package/dist/provider/messages/tools.d.ts.map +1 -0
- package/dist/provider/messages/tools.js +496 -0
- package/dist/provider/messages/tools.js.map +1 -0
- package/dist/provider/messages/workspace.d.ts +187 -0
- package/dist/provider/messages/workspace.d.ts.map +1 -0
- package/dist/provider/messages/workspace.js +333 -0
- package/dist/provider/messages/workspace.js.map +1 -0
- package/dist/styles/artifact.css +564 -0
- package/dist/styles/base.css +220 -0
- package/dist/styles/composer.css +1001 -0
- package/dist/styles/conversation.css +275 -0
- package/dist/styles/intervention.css +929 -0
- package/dist/styles/message.css +917 -0
- package/dist/styles/process.css +207 -0
- package/dist/styles/shell.css +453 -0
- package/dist/styles/tools.css +929 -0
- package/dist/styles/workspace.css +1297 -0
- package/dist/styles/wpi-adoption.css +24 -0
- package/dist/utils/cx.d.ts +3 -0
- package/dist/utils/cx.d.ts.map +1 -0
- package/dist/utils/cx.js +5 -0
- package/dist/utils/cx.js.map +1 -0
- package/package.json +64 -3
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { motion } from 'motion/react';
|
|
5
|
+
import { Alert, Button, Collapsible, EmptyState, Input, Skeleton } from '@wzrhine/react';
|
|
6
|
+
import { useAgentFormat, useAgentMessages } from '../../provider/AgentMessages.js';
|
|
7
|
+
import { AgentIcon } from '../../primitives/icons.js';
|
|
8
|
+
import { cx } from '../../utils/cx.js';
|
|
9
|
+
import { ConversationRow, ConversationRowContext } from './ConversationRow.js';
|
|
10
|
+
const ROW_SELECTOR = '.rl-agent-row__main';
|
|
11
|
+
export const ConversationList = React.forwardRef(function ConversationList({ sections, selectedId, onSelect, search, onSearchChange, loading = false, error, onRetry, renderActions, onPin, onArchive, onUnarchive, onDelete, isDisabled, headingLevel = 2, label, empty, now, skeletonRows = 5, collapsibleGroups = false, collapsedGroups = [], onCollapsedGroupsChange, className, ...rest }, ref) {
|
|
12
|
+
const shell = useAgentMessages().shell;
|
|
13
|
+
const format = useAgentFormat();
|
|
14
|
+
const uid = React.useId();
|
|
15
|
+
const searchId = `${uid}-search`;
|
|
16
|
+
const viewportRef = React.useRef(null);
|
|
17
|
+
const [focusedId, setFocusedId] = React.useState(null);
|
|
18
|
+
const lastFocused = React.useRef(null);
|
|
19
|
+
const visible = React.useMemo(() => sections.filter((section) => section.items.length > 0), [sections]);
|
|
20
|
+
const ids = React.useMemo(() => visible.flatMap((section) => section.items.map((item) => item.id)), [visible]);
|
|
21
|
+
const total = ids.length;
|
|
22
|
+
const query = search?.trim() ?? '';
|
|
23
|
+
const tabStopId = focusedId && ids.includes(focusedId) ? focusedId : selectedId && ids.includes(selectedId) ? selectedId : (ids[0] ?? null);
|
|
24
|
+
const rowContext = React.useMemo(() => ({
|
|
25
|
+
tabStopId,
|
|
26
|
+
ghostId: `${uid}-ghost`,
|
|
27
|
+
selectedId,
|
|
28
|
+
onFocusRow: (id) => {
|
|
29
|
+
setFocusedId(id);
|
|
30
|
+
lastFocused.current = { id, index: ids.indexOf(id) };
|
|
31
|
+
},
|
|
32
|
+
}), [tabStopId, uid, selectedId, ids]);
|
|
33
|
+
// A refresh that removed the focused row leaves focus on <body>: move it to the nearest row.
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const last = lastFocused.current;
|
|
36
|
+
if (!last || ids.includes(last.id))
|
|
37
|
+
return;
|
|
38
|
+
lastFocused.current = null;
|
|
39
|
+
if (typeof document === 'undefined' || (document.activeElement && document.activeElement !== document.body))
|
|
40
|
+
return;
|
|
41
|
+
const buttons = viewportRef.current?.querySelectorAll(`${ROW_SELECTOR}:not(:disabled)`);
|
|
42
|
+
if (!buttons || buttons.length === 0)
|
|
43
|
+
return;
|
|
44
|
+
buttons[Math.min(last.index, buttons.length - 1)]?.focus();
|
|
45
|
+
}, [ids]);
|
|
46
|
+
const onKeyDown = (event) => {
|
|
47
|
+
const viewport = viewportRef.current;
|
|
48
|
+
const target = event.target;
|
|
49
|
+
// Events from portalled menus bubble through React; only handle keys from rows in this list.
|
|
50
|
+
if (!viewport || !viewport.contains(target) || !target.closest('.rl-agent-row'))
|
|
51
|
+
return;
|
|
52
|
+
if (!['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key) || event.altKey || event.ctrlKey || event.metaKey)
|
|
53
|
+
return;
|
|
54
|
+
const buttons = Array.from(viewport.querySelectorAll(`${ROW_SELECTOR}:not(:disabled)`));
|
|
55
|
+
if (buttons.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
const row = target.closest('.rl-agent-row');
|
|
58
|
+
const current = buttons.findIndex((button) => row?.contains(button));
|
|
59
|
+
let next = current;
|
|
60
|
+
if (event.key === 'ArrowDown')
|
|
61
|
+
next = current < 0 ? 0 : Math.min(current + 1, buttons.length - 1);
|
|
62
|
+
else if (event.key === 'ArrowUp')
|
|
63
|
+
next = current < 0 ? 0 : Math.max(current - 1, 0);
|
|
64
|
+
else if (event.key === 'Home')
|
|
65
|
+
next = 0;
|
|
66
|
+
else
|
|
67
|
+
next = buttons.length - 1;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
const button = buttons[next];
|
|
70
|
+
button?.focus();
|
|
71
|
+
button?.scrollIntoView?.({ block: 'nearest' });
|
|
72
|
+
};
|
|
73
|
+
const Heading = `h${headingLevel}`;
|
|
74
|
+
const showSkeleton = loading && total === 0 && !error;
|
|
75
|
+
const errorText = error === true ? shell.error : error;
|
|
76
|
+
return (_jsxs("div", { ...rest, ref: ref, className: cx('rl-agent-list', className), "data-loading": loading || undefined, children: [onSearchChange && (_jsxs("div", { className: "rl-agent-list__search", children: [_jsx("label", { htmlFor: searchId, className: "rl-agent-sr", children: shell.searchLabel }), _jsx(Input, { id: searchId, type: "search", size: "sm", value: search ?? '', placeholder: shell.searchPlaceholder, prefix: _jsx(AgentIcon, { name: "search" }), autoComplete: "off", onChange: (event) => onSearchChange(event.currentTarget.value) }), _jsx("span", { className: "rl-agent-sr", role: "status", children: query && !loading ? shell.searchResults(format.number(total)) : '' })] })), _jsxs(motion.div, { ref: viewportRef, layoutScroll: true, className: "rl-agent-list__viewport", role: "region", "aria-label": label ?? shell.listLabel, "aria-busy": loading || undefined, tabIndex: -1, onKeyDown: onKeyDown, children: [errorText != null && errorText !== false && (_jsx(Alert, { tone: "danger", className: "rl-agent-list__error", title: errorText, action: onRetry ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: onRetry, children: shell.retry })) : undefined })), showSkeleton && (_jsxs("div", { className: "rl-agent-list__skeleton", children: [_jsx("span", { className: "rl-agent-sr", children: shell.loading }), Array.from({ length: skeletonRows }, (_, i) => (_jsxs("div", { className: "rl-agent-list__skeleton-row", "aria-hidden": "true", children: [_jsx(Skeleton, { shape: "circle", width: "var(--rl-icon-size-sm)" }), _jsx(Skeleton, { width: i % 2 ? '70%' : '85%' })] }, i)))] })), !showSkeleton && total === 0 && !errorText && (_jsx("div", { className: "rl-agent-list__empty", children: query ? (_jsx(EmptyState, { kind: "no-results", size: "sm", headingLevel: headingLevel, title: shell.searchEmptyTitle(query), description: shell.searchEmptyDescription })) : ((empty ?? _jsx(EmptyState, { kind: "first-use", size: "sm", headingLevel: headingLevel, title: shell.emptyTitle, description: shell.emptyDescription }))) })), _jsx(ConversationRowContext.Provider, { value: rowContext, children: visible.map((section) => {
|
|
77
|
+
const headingId = `${uid}-${section.id}`;
|
|
78
|
+
return (_jsxs("div", { className: "rl-agent-list__section", children: [collapsibleGroups && _jsx(Collapsible, { open: !collapsedGroups.includes(section.id), onOpenChange: (open) => onCollapsedGroupsChange?.(open ? collapsedGroups.filter((id) => id !== section.id) : [...collapsedGroups, section.id]), trigger: section.label, children: _jsx("ul", { className: "rl-agent-list__rows", "aria-label": section.label, children: section.items.map((item) => _jsx(ConversationRow, { item: item, selected: item.id === selectedId, disabled: isDisabled?.(item), onSelect: onSelect, onPin: onPin, onArchive: onArchive, onUnarchive: onUnarchive, onDelete: onDelete, actions: renderActions?.(item), now: now }, item.id)) }) }), !collapsibleGroups && _jsxs(_Fragment, { children: [_jsx(Heading, { id: headingId, className: "rl-agent-list__heading", children: section.label }), _jsx("ul", { className: "rl-agent-list__rows", "aria-labelledby": headingId, children: section.items.map((item) => (_jsx(ConversationRow, { item: item, selected: item.id === selectedId, disabled: isDisabled?.(item), onSelect: onSelect, onPin: onPin, onArchive: onArchive, onUnarchive: onUnarchive, onDelete: onDelete, actions: renderActions?.(item), now: now }, item.id))) })] })] }, section.id));
|
|
79
|
+
}) })] })] }));
|
|
80
|
+
});
|
|
81
|
+
//# sourceMappingURL=ConversationList.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationList.js","sourceRoot":"","sources":["../../../src/components/conversation/ConversationList.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAEzF,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AA4D/E,MAAM,YAAY,GAAG,qBAAqB,CAAC;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAAwC,SAAS,gBAAgB,CAC/G,EACE,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,MAAM,EACN,cAAc,EACd,OAAO,GAAG,KAAK,EACf,KAAK,EACL,OAAO,EACP,aAAa,EACb,KAAK,EACL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,UAAU,EACV,YAAY,GAAG,CAAC,EAChB,KAAK,EACL,KAAK,EACL,GAAG,EACH,Y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VH,IAAI,CAAC,EAAE,CAWZ,CACH,CAAC,GACC,IACF,KAvBK,OAAO,CAAC,EAAE,CAwBd,CACP,CAAC;wBACJ,CAAC,CAAC,GAC8B,IACvB,IACT,CACP,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { ConversationView } from '@wzrhine/agent-core';
|
|
3
|
+
/**
|
|
4
|
+
* ConversationRow (atlas 04): one conversation in the index.
|
|
5
|
+
*
|
|
6
|
+
* Structure: `<li>` with two sibling buttons, never nested: the main button selects the
|
|
7
|
+
* conversation (`aria-current="true"` when selected) and the "more" IconButton opens a Menu
|
|
8
|
+
* (@wzrhine/react). Because they are siblings, nothing in the menu bubbles into selection.
|
|
9
|
+
*
|
|
10
|
+
* - Accessible name of the main button = title + pinned + status + unread (joined with the
|
|
11
|
+
* locale separator); time and preview are its description. Status = glyph + text, never colour
|
|
12
|
+
* alone; settled runs (idle / completed / cancelled) draw nothing, attention (approval,
|
|
13
|
+
* question, children, error) always wins over the run status.
|
|
14
|
+
* - Running rows show a breathing glyph through the shared loop lifecycle (`useAgentLoop`), so
|
|
15
|
+
* off-screen rows, hidden pages and reduced motion keep it static; only active rows pay for it.
|
|
16
|
+
* - The title is one ellipsised line (full text in `title`); time and unread live in a fixed
|
|
17
|
+
* column, so a long title never pushes them out and an unread change never changes the height.
|
|
18
|
+
* - The "more" button is visible on hover / focus-within / while its menu is open (always on
|
|
19
|
+
* touch screens) and keeps its space reserved. A capability without a callback renders no item;
|
|
20
|
+
* with no item at all there is no button.
|
|
21
|
+
* - Archive is reversible, so it confirms inline: the first 「归档」 keeps the menu open and turns
|
|
22
|
+
* the item into 「确认归档」; closing the menu resets it. Delete is not reversible: it opens an
|
|
23
|
+
* AlertDialog; `onDelete` may return a Promise (the dialog waits, and stays open on rejection).
|
|
24
|
+
* - `disabled` disables both buttons.
|
|
25
|
+
*/
|
|
26
|
+
export type ConversationRowProps = Omit<React.LiHTMLAttributes<HTMLLIElement>, 'onSelect' | 'title' | 'children'> & {
|
|
27
|
+
item: ConversationView;
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
onSelect?: (id: string) => void;
|
|
31
|
+
/** Toggle pin; receives the requested state. */
|
|
32
|
+
onPin?: (item: ConversationView, pinned: boolean) => void;
|
|
33
|
+
onArchive?: (item: ConversationView) => void;
|
|
34
|
+
onUnarchive?: (item: ConversationView) => void;
|
|
35
|
+
/** Confirmed delete. Return a Promise to keep the dialog open until it settles. */
|
|
36
|
+
onDelete?: (item: ConversationView) => void | Promise<unknown>;
|
|
37
|
+
/** Extra controls next to the "more" button. */
|
|
38
|
+
actions?: React.ReactNode;
|
|
39
|
+
/** Reference time for the today / earlier format (default: now). */
|
|
40
|
+
now?: Date;
|
|
41
|
+
};
|
|
42
|
+
/** Internal wiring from ConversationList: roving tab stop and the shared selection ghost. */
|
|
43
|
+
export interface ConversationRowListContext {
|
|
44
|
+
tabStopId: string | null;
|
|
45
|
+
ghostId: string;
|
|
46
|
+
selectedId: string | undefined;
|
|
47
|
+
onFocusRow: (id: string) => void;
|
|
48
|
+
}
|
|
49
|
+
export declare const ConversationRowContext: React.Context<ConversationRowListContext | null>;
|
|
50
|
+
export declare const ConversationRow: React.ForwardRefExoticComponent<Omit<React.LiHTMLAttributes<HTMLLIElement>, "children" | "title" | "onSelect"> & {
|
|
51
|
+
item: ConversationView;
|
|
52
|
+
selected?: boolean;
|
|
53
|
+
disabled?: boolean;
|
|
54
|
+
onSelect?: (id: string) => void;
|
|
55
|
+
/** Toggle pin; receives the requested state. */
|
|
56
|
+
onPin?: (item: ConversationView, pinned: boolean) => void;
|
|
57
|
+
onArchive?: (item: ConversationView) => void;
|
|
58
|
+
onUnarchive?: (item: ConversationView) => void;
|
|
59
|
+
/** Confirmed delete. Return a Promise to keep the dialog open until it settles. */
|
|
60
|
+
onDelete?: (item: ConversationView) => void | Promise<unknown>;
|
|
61
|
+
/** Extra controls next to the "more" button. */
|
|
62
|
+
actions?: React.ReactNode;
|
|
63
|
+
/** Reference time for the today / earlier format (default: now). */
|
|
64
|
+
now?: Date;
|
|
65
|
+
} & React.RefAttributes<HTMLLIElement>>;
|
|
66
|
+
//# sourceMappingURL=ConversationRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConversationRow.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/ConversationRow.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,EAAa,gBAAgB,EAAmB,MAAM,qBAAqB,CAAC;AAQxF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC,GAAG;IAClH,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,gDAAgD;IAChD,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1D,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC7C,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC/C,mFAAmF;IACnF,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,gDAAgD;IAChD,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oEAAoE;IACpE,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,CAAC;AAEF,6FAA6F;AAC7F,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CAClC;AAED,eAAO,MAAM,sBAAsB,kDAA+D,CAAC;AAyBnG,eAAO,MAAM,eAAe;UAjDpB,gBAAgB;eACX,OAAO;eACP,OAAO;eACP,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI;IAC/B,gDAAgD;YACxC,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI;gBAC7C,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI;kBAC9B,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI;IAC9C,mFAAmF;eACxE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAC9D,gDAAgD;cACtC,KAAK,CAAC,SAAS;IACzB,oEAAoE;UAC9D,IAAI;uCA4MV,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { motion } from 'motion/react';
|
|
5
|
+
import { AlertDialog, IconButton, Menu, MenuItem, MenuSeparator, useRhineMotion } from '@wzrhine/react';
|
|
6
|
+
import { useAgentFormat, useAgentMessages } from '../../provider/AgentMessages.js';
|
|
7
|
+
import { AgentIcon } from '../../primitives/icons.js';
|
|
8
|
+
import { StatusGlyph } from '../../primitives/StatusGlyph.js';
|
|
9
|
+
import { loopAttributes, useAgentLoop } from '../../motion/agent-motion.js';
|
|
10
|
+
import { cx } from '../../utils/cx.js';
|
|
11
|
+
import { conversationStatus, isSameDay } from './conversation-status.js';
|
|
12
|
+
export const ConversationRowContext = React.createContext(null);
|
|
13
|
+
function ActiveGlyph({ glyph, tone }) {
|
|
14
|
+
const { ref, lifecycle } = useAgentLoop(true);
|
|
15
|
+
return (_jsx("span", { ref: ref, className: "rl-agent-row__glyph", children: _jsx(StatusGlyph, { name: glyph, tone: tone, active: true, ...loopAttributes(lifecycle) }) }));
|
|
16
|
+
}
|
|
17
|
+
function SelectionGhost({ layoutId, selectedId }) {
|
|
18
|
+
const { resolve } = useRhineMotion();
|
|
19
|
+
return (_jsx(motion.span, { "aria-hidden": "true", className: "rl-agent-row__ghost", layoutId: layoutId, layoutDependency: selectedId, initial: false, transition: resolve('transform', 'base') }));
|
|
20
|
+
}
|
|
21
|
+
export const ConversationRow = React.forwardRef(function ConversationRow({ item, selected = false, disabled = false, onSelect, onPin, onArchive, onUnarchive, onDelete, actions, now, className, ...rest }, ref) {
|
|
22
|
+
const messages = useAgentMessages();
|
|
23
|
+
const shell = messages.shell;
|
|
24
|
+
const format = useAgentFormat();
|
|
25
|
+
const list = React.useContext(ConversationRowContext);
|
|
26
|
+
const descId = React.useId();
|
|
27
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
28
|
+
const [confirmArchive, setConfirmArchive] = React.useState(false);
|
|
29
|
+
const [deleteOpen, setDeleteOpen] = React.useState(false);
|
|
30
|
+
const [deleteMounted, setDeleteMounted] = React.useState(false);
|
|
31
|
+
const title = item.title.trim() || shell.untitled;
|
|
32
|
+
const status = conversationStatus(item, messages.status, shell);
|
|
33
|
+
const unread = item.unread && item.unread > 0 ? item.unread : 0;
|
|
34
|
+
const nameParts = [title, item.pinned ? shell.pinned : null, status?.label ?? null, unread ? shell.unread(format.number(unread)) : null];
|
|
35
|
+
const name = nameParts.filter(Boolean).join(shell.separator);
|
|
36
|
+
let time = null;
|
|
37
|
+
if (item.updatedAt) {
|
|
38
|
+
const date = new Date(item.updatedAt);
|
|
39
|
+
if (!Number.isNaN(date.getTime()))
|
|
40
|
+
time = isSameDay(date, now ?? new Date()) ? format.time(item.updatedAt) : format.date(item.updatedAt);
|
|
41
|
+
}
|
|
42
|
+
const canPin = !!onPin && !item.archived;
|
|
43
|
+
const canArchive = !!onArchive && !item.archived;
|
|
44
|
+
const canUnarchive = !!onUnarchive && !!item.archived;
|
|
45
|
+
const canDelete = !!onDelete;
|
|
46
|
+
const hasMenu = canPin || canArchive || canUnarchive || canDelete;
|
|
47
|
+
const tabbable = list ? list.tabStopId === item.id : true;
|
|
48
|
+
return (_jsxs("li", { ...rest, ref: ref, className: cx('rl-agent-row', className), "data-id": item.id, "data-selected": selected || undefined, "data-disabled": disabled || undefined, "data-status": status?.kind, "data-menu-open": menuOpen || undefined, "data-has-menu": hasMenu || actions != null || undefined, children: [selected && list && _jsx(SelectionGhost, { layoutId: list.ghostId, selectedId: list.selectedId }), _jsxs("button", { type: "button", className: "rl-agent-row__main", "aria-current": selected ? 'true' : undefined, "aria-label": name, "aria-describedby": time || item.preview ? descId : undefined, disabled: disabled, tabIndex: tabbable ? 0 : -1, onFocus: () => list?.onFocusRow(item.id), onClick: () => onSelect?.(item.id), children: [_jsx("span", { className: "rl-agent-row__status", "aria-hidden": "true", children: status &&
|
|
49
|
+
(status.active ? (_jsx(ActiveGlyph, { glyph: status.glyph, tone: status.tone })) : (_jsx("span", { className: "rl-agent-row__glyph", children: _jsx(StatusGlyph, { name: status.glyph, tone: status.tone }) }))) }), _jsxs("span", { className: "rl-agent-row__title", title: title, children: [item.pinned && _jsx(AgentIcon, { name: "pin", className: "rl-agent-row__pin" }), _jsx("span", { className: "rl-agent-row__title-text", children: title })] }), _jsxs("span", { className: "rl-agent-row__meta", "aria-hidden": "true", children: [unread > 0 && _jsx("span", { className: "rl-agent-row__unread", children: format.compact(unread) }), time && (_jsx("time", { className: "rl-agent-row__time", dateTime: item.updatedAt, children: time }))] }), item.preview && (_jsx("span", { className: "rl-agent-row__preview", "aria-hidden": "true", children: item.preview })), _jsx("span", { id: descId, className: "rl-agent-sr", children: [time, item.preview].filter(Boolean).join(shell.separator) })] }), (hasMenu || actions != null) && (_jsxs("span", { className: "rl-agent-row__actions", children: [actions, hasMenu && (_jsxs(Menu, { open: menuOpen, onOpenChange: (open) => {
|
|
50
|
+
setMenuOpen(open);
|
|
51
|
+
if (!open)
|
|
52
|
+
setConfirmArchive(false);
|
|
53
|
+
}, align: "end", disabled: disabled, trigger: _jsx(IconButton, { className: "rl-agent-row__more", size: "sm", icon: _jsx(AgentIcon, { name: "more" }), label: shell.more(title), disabled: disabled, tabIndex: tabbable ? 0 : -1, onFocus: () => list?.onFocusRow(item.id) }), children: [canPin && (_jsx(MenuItem, { icon: _jsx(AgentIcon, { name: "pin" }), onSelect: () => onPin(item, !item.pinned), children: item.pinned ? shell.unpin : shell.pin })), canArchive && (_jsx(MenuItem, { icon: _jsx(AgentIcon, { name: "archive" }), keepOpen: !confirmArchive, onSelect: () => {
|
|
54
|
+
if (!confirmArchive) {
|
|
55
|
+
setConfirmArchive(true);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
setConfirmArchive(false);
|
|
59
|
+
onArchive(item);
|
|
60
|
+
}, children: confirmArchive ? shell.confirmArchive : shell.archive })), canUnarchive && (_jsx(MenuItem, { icon: _jsx(AgentIcon, { name: "unarchive" }), onSelect: () => onUnarchive(item), children: shell.unarchive })), canDelete && (canPin || canArchive || canUnarchive) && _jsx(MenuSeparator, {}), canDelete && (_jsx(MenuItem, { icon: _jsx(AgentIcon, { name: "trash" }), tone: "danger", onSelect: () => {
|
|
61
|
+
setDeleteMounted(true);
|
|
62
|
+
setDeleteOpen(true);
|
|
63
|
+
}, children: shell.delete }))] }))] })), canDelete && deleteMounted && (_jsx(AlertDialog, { open: deleteOpen, onOpenChange: setDeleteOpen, title: shell.deleteTitle, description: shell.deleteDescription(title), confirmLabel: shell.deleteConfirm, errorText: shell.deleteError, onConfirm: () => onDelete(item) }))] }));
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=ConversationRow.js.map
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';
|
|
2
|
+
import type { AgentStatusMessages } from '../../provider/messages/status.js';
|
|
3
|
+
import type { AgentShellMessages } from '../../provider/messages/shell.js';
|
|
4
|
+
/** What a conversation row shows as its status: glyph + tone + label, or nothing. */
|
|
5
|
+
export interface RowStatus {
|
|
6
|
+
glyph: StatusGlyphName;
|
|
7
|
+
tone: AgentTone;
|
|
8
|
+
label: string;
|
|
9
|
+
/** Ongoing activity: the glyph breathes (lifecycle-gated). */
|
|
10
|
+
active: boolean;
|
|
11
|
+
kind: 'attention' | 'run';
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Attention (needs the user) wins over the run status. Settled, uneventful runs (`idle`,
|
|
15
|
+
* `completed`, `cancelled`) show no glyph: the list would otherwise be a column of check marks.
|
|
16
|
+
* `failed` / `interrupted` stay visible. No run status = nothing (unknown is never shown as success).
|
|
17
|
+
*/
|
|
18
|
+
export declare function conversationStatus(item: ConversationView, status: AgentStatusMessages, shell: AgentShellMessages): RowStatus | null;
|
|
19
|
+
/** Same calendar day in local time. */
|
|
20
|
+
export declare function isSameDay(a: Date, b: Date): boolean;
|
|
21
|
+
//# sourceMappingURL=conversation-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-status.d.ts","sourceRoot":"","sources":["../../../src/components/conversation/conversation-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAExF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,qFAAqF;AACrF,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,eAAe,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,EAAE,WAAW,GAAG,KAAK,CAAC;CAC3B;AASD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,mBAAmB,EAAE,KAAK,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAcnI;AAED,uCAAuC;AACvC,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,GAAG,OAAO,CAEnD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { effectivePhase, runPhaseMeta, runStatusMeta } from '@wzrhine/agent-core';
|
|
2
|
+
const attentionGlyph = {
|
|
3
|
+
approval: { glyph: 'approval', tone: 'warning' },
|
|
4
|
+
question: { glyph: 'waiting-user', tone: 'warning' },
|
|
5
|
+
children: { glyph: 'children', tone: 'info' },
|
|
6
|
+
error: { glyph: 'failed', tone: 'danger' },
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Attention (needs the user) wins over the run status. Settled, uneventful runs (`idle`,
|
|
10
|
+
* `completed`, `cancelled`) show no glyph: the list would otherwise be a column of check marks.
|
|
11
|
+
* `failed` / `interrupted` stay visible. No run status = nothing (unknown is never shown as success).
|
|
12
|
+
*/
|
|
13
|
+
export function conversationStatus(item, status, shell) {
|
|
14
|
+
if (item.attention) {
|
|
15
|
+
const meta = attentionGlyph[item.attention];
|
|
16
|
+
return { ...meta, label: shell.attention[item.attention], active: false, kind: 'attention' };
|
|
17
|
+
}
|
|
18
|
+
const run = item.runStatus;
|
|
19
|
+
if (!run || run === 'idle' || run === 'completed' || run === 'cancelled')
|
|
20
|
+
return null;
|
|
21
|
+
const phase = effectivePhase(run, item.runPhase);
|
|
22
|
+
const runMeta = runStatusMeta[run];
|
|
23
|
+
if (phase && runMeta.active) {
|
|
24
|
+
const meta = runPhaseMeta[phase];
|
|
25
|
+
return { glyph: meta.glyph, tone: meta.tone, label: status.phase[phase], active: meta.active, kind: 'run' };
|
|
26
|
+
}
|
|
27
|
+
return { glyph: runMeta.glyph, tone: runMeta.tone, label: status.run[run], active: runMeta.active, kind: 'run' };
|
|
28
|
+
}
|
|
29
|
+
/** Same calendar day in local time. */
|
|
30
|
+
export function isSameDay(a, b) {
|
|
31
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=conversation-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversation-status.js","sourceRoot":"","sources":["../../../src/components/conversation/conversation-status.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAclF,MAAM,cAAc,GAAoG;IACtH,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IAChD,QAAQ,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE;IACpD,QAAQ,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;IAC7C,KAAK,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAsB,EAAE,MAA2B,EAAE,KAAyB;IAC/G,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;QACnB,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,OAAO,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;IAC/F,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC;IAC3B,IAAI,CAAC,GAAG,IAAI,GAAG,KAAK,MAAM,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACtF,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;QACjC,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAC9G,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;AACnH,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,SAAS,CAAC,CAAO,EAAE,CAAO;IACxC,OAAO,CAAC,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;AAC7G,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { FileDiffView } from '@wzrhine/agent-core';
|
|
3
|
+
/**
|
|
4
|
+
* Minimal read-only diff list for approval material (internal; not exported). Hosts that want
|
|
5
|
+
* the full tools `DiffPreview` pass it through `ApprovalPanel renderMaterial`.
|
|
6
|
+
*
|
|
7
|
+
* A11y: a `<figure>` named by the path; each hunk is an `<ol>` whose rows carry the sign as text
|
|
8
|
+
* (`+` / `−`, plus a visually hidden "新增 / 删除" word) so the change is never colour only.
|
|
9
|
+
* Long lines scroll horizontally inside the bounded frame instead of widening the page.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ApprovalDiff({ diff }: {
|
|
12
|
+
diff: FileDiffView;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
//# sourceMappingURL=ApprovalDiff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApprovalDiff.d.ts","sourceRoot":"","sources":["../../../src/components/intervention/ApprovalDiff.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,qBAoD5D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useAgentMessages } from '../../provider/AgentMessages.js';
|
|
5
|
+
/**
|
|
6
|
+
* Minimal read-only diff list for approval material (internal; not exported). Hosts that want
|
|
7
|
+
* the full tools `DiffPreview` pass it through `ApprovalPanel renderMaterial`.
|
|
8
|
+
*
|
|
9
|
+
* A11y: a `<figure>` named by the path; each hunk is an `<ol>` whose rows carry the sign as text
|
|
10
|
+
* (`+` / `−`, plus a visually hidden "新增 / 删除" word) so the change is never colour only.
|
|
11
|
+
* Long lines scroll horizontally inside the bounded frame instead of widening the page.
|
|
12
|
+
*/
|
|
13
|
+
export function ApprovalDiff({ diff }) {
|
|
14
|
+
const m = useAgentMessages().intervention;
|
|
15
|
+
const captionId = React.useId();
|
|
16
|
+
const additions = diff.additions ?? diff.hunks.reduce((n, h) => n + h.lines.filter((l) => l.kind === 'add').length, 0);
|
|
17
|
+
const deletions = diff.deletions ?? diff.hunks.reduce((n, h) => n + h.lines.filter((l) => l.kind === 'remove').length, 0);
|
|
18
|
+
const empty = diff.hunks.every((h) => h.lines.length === 0);
|
|
19
|
+
return (_jsxs("figure", { className: "rl-agent-approval-diff", "aria-labelledby": captionId, children: [_jsxs("figcaption", { id: captionId, className: "rl-agent-approval-diff__caption", children: [_jsx("span", { className: "rl-agent-approval-diff__change", children: m.diffChange[diff.change] }), _jsxs("span", { className: "rl-agent-approval-diff__path", children: [diff.path, diff.movedTo ? ` → ${diff.movedTo}` : ''] }), _jsx("span", { className: "rl-agent-approval-diff__stats", children: m.diffStats(additions, deletions) }), _jsx("span", { className: "rl-agent-sr", children: m.diffLabel(diff.path) })] }), diff.binary ? (_jsx("p", { className: "rl-agent-approval-diff__note", children: m.diffBinary })) : empty ? (_jsx("p", { className: "rl-agent-approval-diff__note", children: m.diffEmpty })) : (_jsx("div", { className: "rl-agent-approval-diff__scroll", tabIndex: 0, role: "group", "aria-labelledby": captionId, children: diff.hunks.map((hunk) => (_jsxs("div", { className: "rl-agent-approval-diff__hunk", children: [hunk.header && _jsx("p", { className: "rl-agent-approval-diff__header", children: hunk.header }), _jsx("ol", { className: "rl-agent-approval-diff__lines", children: hunk.lines.map((line, i) => {
|
|
20
|
+
const sign = line.kind === 'add' ? '+' : line.kind === 'remove' ? '−' : ' ';
|
|
21
|
+
const number = line.kind === 'remove' ? line.oldLine : (line.newLine ?? line.oldLine);
|
|
22
|
+
return (_jsxs("li", { className: "rl-agent-approval-diff__line", "data-kind": line.kind, children: [_jsx("span", { className: "rl-agent-approval-diff__no", "aria-hidden": "true", children: number ?? '' }), _jsx("span", { className: "rl-agent-approval-diff__sign", "aria-hidden": "true", children: sign }), line.kind === 'add' && _jsxs("span", { className: "rl-agent-sr", children: [m.diffAdded, " "] }), line.kind === 'remove' && _jsxs("span", { className: "rl-agent-sr", children: [m.diffRemoved, " "] }), _jsx("code", { className: "rl-agent-approval-diff__text", children: line.text === '' ? ' ' : line.text })] }, i));
|
|
23
|
+
}) })] }, hunk.id))) })), diff.truncated && _jsx("p", { className: "rl-agent-approval-diff__note", children: m.diffTruncated })] }));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ApprovalDiff.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApprovalDiff.js","sourceRoot":"","sources":["../../../src/components/intervention/ApprovalDiff.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,IAAI,EAA0B;IAC3D,MAAM,CAAC,GAAG,gBAAgB,EAAE,CAAC,YAAY,CAAC;IAC1C,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IACvH,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,MAAM,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E,CACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { AgentActionContext, AgentActionHandler, ApprovalScope, ApprovalView } from '@wzrhine/agent-core';
|
|
3
|
+
/**
|
|
4
|
+
* Tool-permission approval card (atlas 20, ADR-0011 §6).
|
|
5
|
+
*
|
|
6
|
+
* Behaviour
|
|
7
|
+
* - **Reject is always possible** while a decision is open (waiting, material-loading,
|
|
8
|
+
* unavailable, unknown): it never depends on the material. It is busy only while a decision is
|
|
9
|
+
* being submitted and gone once the request is approved, rejected or expired.
|
|
10
|
+
* - **Allow** needs `status === 'waiting'` and `availability.allowed` (the adapter verified the
|
|
11
|
+
* full material and revision). Otherwise it is disabled and the reason is shown as visible text
|
|
12
|
+
* linked with `aria-describedby`. "Trust for this session" appears only when `scopes` offers
|
|
13
|
+
* `'session'` and `onApprove` exists. A capability without a callback renders no button.
|
|
14
|
+
* - Every decision emits `AgentActionContext { actionId, targetId: operationId, baseRevision:
|
|
15
|
+
* revision }`. `actionId` = stable per-mount id + counter. Re-entry is blocked synchronously
|
|
16
|
+
* (double click) until the handler settles, and for `accepted` / `unknown` results until the
|
|
17
|
+
* view-model changes.
|
|
18
|
+
* - `unknown`: a warning explains the decision may or may not have arrived; the control that sent
|
|
19
|
+
* it becomes 「重试提交」, which calls the same handler with the **same** `actionId` and scope.
|
|
20
|
+
* No retry is offered when `receipt.retryable === false` or the attempt was made in another mount.
|
|
21
|
+
* - `approved` / `rejected` are static receipts; `expired` hides the decision and offers only
|
|
22
|
+
* `onRefresh` when given. Buttons only emit intent; the host adapter is the authority.
|
|
23
|
+
*
|
|
24
|
+
* A11y: `<section aria-labelledby>` on the title; the status pill pairs glyph + text; a visually
|
|
25
|
+
* hidden `role="status"` region (mounted with the card) announces submitting / unknown / receipts.
|
|
26
|
+
* New approvals never steal focus; `autoFocus` focuses the title (`tabIndex=-1`) once on mount.
|
|
27
|
+
*
|
|
28
|
+
* Motion: none of its own. Wrap in `AgentEntrance kind="card"` (InterventionDock does) for the
|
|
29
|
+
* first entrance; the evidence disclosure is the Collapsible height transition. Reduced motion
|
|
30
|
+
* changes nothing that carries information.
|
|
31
|
+
*/
|
|
32
|
+
export interface ApprovalPanelProps extends Omit<React.HTMLAttributes<HTMLElement>, 'title' | 'children'> {
|
|
33
|
+
approval: ApprovalView;
|
|
34
|
+
onApprove?: AgentActionHandler<[ApprovalScope, AgentActionContext]>;
|
|
35
|
+
onReject?: AgentActionHandler<[AgentActionContext]>;
|
|
36
|
+
/** Shown in `unavailable`: reload the approval material. */
|
|
37
|
+
onRetryMaterial?: () => void;
|
|
38
|
+
/** Shown in `expired`: refresh the approval state from the runtime. */
|
|
39
|
+
onRefresh?: () => void;
|
|
40
|
+
/** Custom material view (e.g. tools `DiffPreview`). Default: an internal read-only diff of `approval.diff`. */
|
|
41
|
+
renderMaterial?: (approval: ApprovalView) => React.ReactNode;
|
|
42
|
+
/** `compact` docks above the composer: tighter spacing, evidence always behind a disclosure. */
|
|
43
|
+
density?: 'compact' | 'full';
|
|
44
|
+
/** Focus the title once on mount. Off by default: new approvals never steal focus. */
|
|
45
|
+
autoFocus?: boolean;
|
|
46
|
+
/** Title element level. Default 3. */
|
|
47
|
+
headingLevel?: 2 | 3 | 4;
|
|
48
|
+
/** Evidence with more items than this (or with long values) goes behind a disclosure. Default 3. */
|
|
49
|
+
evidenceCollapseAt?: number;
|
|
50
|
+
/** Overrides of the footer note and button labels. */
|
|
51
|
+
rejectNote?: React.ReactNode;
|
|
52
|
+
rejectLabel?: string;
|
|
53
|
+
allowLabel?: string;
|
|
54
|
+
allowSessionLabel?: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const ApprovalPanel: React.ForwardRefExoticComponent<ApprovalPanelProps & React.RefAttributes<HTMLElement>>;
|
|
57
|
+
//# sourceMappingURL=ApprovalPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApprovalPanel.d.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@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { Button, Callout, Collapsible, Skeleton, StatusBadge } from '@wzrhine/react';
|
|
5
|
+
import { AgentStatus } from '../../primitives/AgentStatus.js';
|
|
6
|
+
import { AgentIcon } from '../../primitives/icons.js';
|
|
7
|
+
import { useAgentFormat, useAgentMessages } from '../../provider/AgentMessages.js';
|
|
8
|
+
import { cx } from '../../utils/cx.js';
|
|
9
|
+
import { useActionLock } from './action-lock.js';
|
|
10
|
+
import { ApprovalDiff } from './ApprovalDiff.js';
|
|
11
|
+
import { InterventionIcon } from './icons.js';
|
|
12
|
+
const statusGlyph = {
|
|
13
|
+
waiting: { glyph: 'approval', tone: 'warning' },
|
|
14
|
+
'material-loading': { glyph: 'pending', tone: 'info', active: true },
|
|
15
|
+
unavailable: { glyph: 'unknown', tone: 'warning' },
|
|
16
|
+
submitting: { glyph: 'pending', tone: 'info', active: true },
|
|
17
|
+
unknown: { glyph: 'unknown', tone: 'warning' },
|
|
18
|
+
approved: { glyph: 'done', tone: 'success' },
|
|
19
|
+
rejected: { glyph: 'stopped', tone: 'danger' },
|
|
20
|
+
expired: { glyph: 'stopped', tone: 'neutral' },
|
|
21
|
+
};
|
|
22
|
+
const riskStatus = { low: 'neutral', medium: 'warning', high: 'danger' };
|
|
23
|
+
const OPEN = ['waiting', 'material-loading', 'unavailable', 'unknown'];
|
|
24
|
+
function isLong(item) {
|
|
25
|
+
return item.value.length > 160 || item.value.split('\n').length > 4;
|
|
26
|
+
}
|
|
27
|
+
function EvidenceList({ evidence }) {
|
|
28
|
+
return (_jsx("dl", { className: "rl-agent-approval__evidence", children: evidence.map((item) => (_jsxs("div", { className: "rl-agent-approval__evidence-row", "data-format": item.format ?? 'text', children: [_jsx("dt", { children: item.label }), _jsx("dd", { children: item.format === 'code' || item.format === 'json' ? (_jsx("pre", { className: "rl-agent-approval__pre", tabIndex: 0, children: _jsx("code", { children: item.value }) })) : item.format === 'path' ? (_jsx("code", { className: "rl-agent-approval__mono", children: item.value })) : (item.value) })] }, item.id))) }));
|
|
29
|
+
}
|
|
30
|
+
export const ApprovalPanel = React.forwardRef(function ApprovalPanel({ approval, onApprove, onReject, onRetryMaterial, onRefresh, renderMaterial, density = 'full', autoFocus = false, headingLevel = 3, evidenceCollapseAt = 3, rejectNote, rejectLabel, allowLabel, allowSessionLabel, className, ...rest }, ref) {
|
|
31
|
+
const m = useAgentMessages().intervention;
|
|
32
|
+
const fmt = useAgentFormat();
|
|
33
|
+
const id = React.useId();
|
|
34
|
+
const titleId = `${id}-title`;
|
|
35
|
+
const allowReasonId = `${id}-allow-reason`;
|
|
36
|
+
const headingRef = React.useRef(null);
|
|
37
|
+
const { status, operationId, revision } = approval;
|
|
38
|
+
const lock = useActionLock(`${operationId}:${revision}:${status}`);
|
|
39
|
+
const [attempt, setAttempt] = React.useState(null);
|
|
40
|
+
// A different operation in the same mount starts from a clean slate.
|
|
41
|
+
const [seenOperation, setSeenOperation] = React.useState(operationId);
|
|
42
|
+
if (seenOperation !== operationId) {
|
|
43
|
+
setSeenOperation(operationId);
|
|
44
|
+
setAttempt(null);
|
|
45
|
+
}
|
|
46
|
+
React.useEffect(() => {
|
|
47
|
+
if (autoFocus)
|
|
48
|
+
headingRef.current?.focus();
|
|
49
|
+
// Mount only: later approvals never move focus.
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, []);
|
|
52
|
+
const open = OPEN.includes(status);
|
|
53
|
+
const submitting = status === 'submitting' || (lock.locked && open);
|
|
54
|
+
const scopes = approval.scopes ?? ['once'];
|
|
55
|
+
const toolName = approval.tool.displayName ?? approval.tool.name;
|
|
56
|
+
const Heading = `h${headingLevel}`;
|
|
57
|
+
const send = (kind, scope, ctx) => {
|
|
58
|
+
const handler = kind === 'approve' ? onApprove : onReject;
|
|
59
|
+
if (!handler)
|
|
60
|
+
return;
|
|
61
|
+
lock.run(() => {
|
|
62
|
+
setAttempt({ kind, scope, ctx });
|
|
63
|
+
return kind === 'approve' ? onApprove(scope, ctx) : onReject(ctx);
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
const fresh = () => ({ actionId: lock.nextActionId(), targetId: operationId, baseRevision: revision });
|
|
67
|
+
// ----- allow gating -----
|
|
68
|
+
const allowEnabled = status === 'waiting' && approval.availability.allowed && !submitting;
|
|
69
|
+
let allowReason;
|
|
70
|
+
if (!allowEnabled && open) {
|
|
71
|
+
if (status === 'waiting')
|
|
72
|
+
allowReason = submitting ? m.approvalAllowBlocked.submitting : (approval.availability.reason ?? m.approvalNotAllowed);
|
|
73
|
+
else
|
|
74
|
+
allowReason = m.approvalAllowBlocked[status] ?? approval.availability.reason;
|
|
75
|
+
}
|
|
76
|
+
const retryable = approval.receipt?.retryable !== false;
|
|
77
|
+
const canRetry = status === 'unknown' && attempt !== null && retryable && (attempt.kind === 'approve' ? !!onApprove : !!onReject);
|
|
78
|
+
const sr = status === 'submitting'
|
|
79
|
+
? m.approvalSubmitting
|
|
80
|
+
: status === 'unknown'
|
|
81
|
+
? m.approvalUnknownTitle
|
|
82
|
+
: status === 'approved'
|
|
83
|
+
? m.approvalApproved
|
|
84
|
+
: status === 'rejected'
|
|
85
|
+
? m.approvalRejected
|
|
86
|
+
: status === 'expired'
|
|
87
|
+
? m.approvalExpiredTitle
|
|
88
|
+
: '';
|
|
89
|
+
const evidence = approval.evidence ?? [];
|
|
90
|
+
const collapseEvidence = evidence.length > 0 && (density === 'compact' || evidence.length > evidenceCollapseAt || evidence.some(isLong));
|
|
91
|
+
// ----- material -----
|
|
92
|
+
let material = null;
|
|
93
|
+
if (status === 'material-loading') {
|
|
94
|
+
material = (_jsxs("div", { className: "rl-agent-approval__loading", "aria-busy": "true", children: [_jsx("p", { className: "rl-agent-approval__loading-text", children: m.approvalMaterialLoading }), _jsx(Skeleton, { lines: 3 })] }));
|
|
95
|
+
}
|
|
96
|
+
else if (status === 'unavailable') {
|
|
97
|
+
material = (_jsxs("div", { className: "rl-agent-approval__unavailable", children: [_jsx(Callout, { tone: "warning", title: m.approvalUnavailable, className: "rl-agent-approval__callout", children: approval.availability.reason ?? m.approvalUnavailableHint }), onRetryMaterial && (_jsx(Button, { size: "sm", variant: "secondary", iconStart: _jsx(AgentIcon, { name: "retry" }), onClick: onRetryMaterial, children: m.approvalRetryMaterial }))] }));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const custom = renderMaterial?.(approval);
|
|
101
|
+
material = custom ?? (approval.diff ? _jsx(ApprovalDiff, { diff: approval.diff }) : null);
|
|
102
|
+
}
|
|
103
|
+
const receiptTime = approval.receipt?.at ? (_jsx("time", { className: "rl-agent-approval__receipt-time", dateTime: approval.receipt.at, children: m.approvalReceiptAt(fmt.time(approval.receipt.at)) })) : null;
|
|
104
|
+
const busyKind = submitting ? attempt?.kind : undefined;
|
|
105
|
+
const showReject = !!onReject && (open || status === 'submitting') && !(status === 'unknown' && attempt?.kind === 'reject');
|
|
106
|
+
const showAllow = !!onApprove && (open || status === 'submitting') && !(status === 'unknown' && attempt?.kind === 'approve');
|
|
107
|
+
const meta = statusGlyph[status];
|
|
108
|
+
return (_jsxs("section", { ...rest, ref: ref, className: cx('rl-agent-approval', className), "aria-labelledby": titleId, "data-status": status, "data-density": density, "data-risk": approval.risk, children: [_jsxs("header", { className: "rl-agent-approval__header", children: [_jsxs("div", { className: "rl-agent-approval__eyebrow", children: [_jsx(InterventionIcon, { name: "shield-alert", className: "rl-agent-approval__shield" }), _jsx("span", { className: "rl-agent-approval__operation", children: m.approvalOperation(operationId) }), _jsx(AgentStatus, { glyph: meta.glyph, tone: meta.tone, active: meta.active, label: m.approvalStatus[status] }), approval.risk && (_jsx(StatusBadge, { size: "sm", status: riskStatus[approval.risk], className: "rl-agent-approval__risk", children: m.approvalRisk[approval.risk] }))] }), _jsxs(Heading, { id: titleId, ref: headingRef, tabIndex: -1, className: "rl-agent-approval__title", children: [_jsx("span", { className: "rl-agent-approval__tool", children: toolName }), approval.reason && (_jsxs(_Fragment, { children: [_jsx("span", { className: "rl-agent-approval__sep", "aria-hidden": "true", children: "\u00B7" }), _jsx("span", { className: "rl-agent-approval__reason", children: approval.reason })] }))] })] }), _jsxs("div", { className: "rl-agent-approval__body", children: [approval.tool.subject && (_jsxs("p", { className: "rl-agent-approval__line", children: [_jsx("span", { className: "rl-agent-approval__label", children: m.approvalSubject }), _jsx("code", { className: "rl-agent-approval__subject", children: approval.tool.subject })] })), _jsx("p", { className: "rl-agent-approval__summary", children: approval.summary }), (approval.scope || approval.expiresAt) && (_jsxs("p", { className: "rl-agent-approval__meta", children: [approval.scope && (_jsxs("span", { children: [_jsx("span", { className: "rl-agent-approval__label", children: m.approvalScope }), " ", approval.scope] })), approval.expiresAt && (_jsxs("span", { children: [_jsx("span", { className: "rl-agent-approval__label", children: m.approvalExpires }), ' ', _jsx("time", { dateTime: approval.expiresAt, children: fmt.time(approval.expiresAt) })] }))] })), approval.irreversible && (_jsx(Callout, { tone: "danger", title: m.approvalIrreversibleTitle, icon: _jsx(InterventionIcon, { name: "trash-warning" }), children: approval.irreversible })), approval.unsandboxed && (_jsx(Callout, { tone: "warning", title: m.approvalUnsandboxedTitle, icon: _jsx(InterventionIcon, { name: "lock-open" }), children: m.approvalUnsandboxed })), material != null && material !== false && _jsx("div", { className: "rl-agent-approval__material", children: material }), evidence.length > 0 &&
|
|
109
|
+
(collapseEvidence ? (_jsx(Collapsible, { className: "rl-agent-approval__details", trigger: _jsx("span", { children: m.approvalEvidenceToggle(evidence.length) }), children: _jsx(EvidenceList, { evidence: evidence }) })) : (_jsxs("div", { className: "rl-agent-approval__details", children: [_jsx("p", { className: "rl-agent-approval__label", children: m.approvalEvidence }), _jsx(EvidenceList, { evidence: evidence })] })))] }), status === 'unknown' && (_jsx("div", { className: "rl-agent-approval__unknown", children: _jsx(Callout, { tone: "warning", title: m.approvalUnknownTitle, children: approval.receipt?.reason ?? (retryable ? m.approvalUnknownBody : m.approvalUnknownNotRetryable) }) })), status === 'approved' && (_jsxs("p", { className: "rl-agent-approval__receipt", "data-tone": "success", children: [_jsx(AgentIcon, { name: "check" }), _jsx("span", { children: attempt?.scope === 'session' ? m.approvalApprovedSession : m.approvalApproved }), receiptTime] })), status === 'rejected' && (_jsxs("p", { className: "rl-agent-approval__receipt", "data-tone": "danger", children: [_jsx(AgentIcon, { name: "close" }), _jsx("span", { children: approval.receipt?.reason ?? m.approvalRejected }), receiptTime] })), status === 'expired' && (_jsxs("div", { className: "rl-agent-approval__expired", children: [_jsx(Callout, { tone: "neutral", title: m.approvalExpiredTitle, icon: _jsx(AgentIcon, { name: "clock" }), className: "rl-agent-approval__callout", children: m.approvalExpiredBody }), onRefresh && (_jsx(Button, { size: "sm", variant: "secondary", iconStart: _jsx(AgentIcon, { name: "retry" }), onClick: onRefresh, children: m.approvalRefresh }))] })), (showReject || showAllow || canRetry) && (_jsxs("footer", { className: "rl-agent-approval__footer", children: [showReject && _jsx("p", { className: "rl-agent-approval__note", children: rejectNote ?? m.approvalRejectNote }), allowReason && showAllow && (_jsxs("p", { id: allowReasonId, className: "rl-agent-approval__allow-reason", children: [_jsx(AgentIcon, { name: "info" }), _jsx("span", { children: allowReason })] })), _jsxs("div", { className: "rl-agent-approval__actions", children: [canRetry && (_jsx(Button, { size: "sm", variant: "primary", loading: submitting, iconStart: _jsx(AgentIcon, { name: "retry" }), onClick: () => attempt && send(attempt.kind, attempt.scope, attempt.ctx), children: m.approvalRetrySubmit })), showReject && (_jsx(Button, { size: "sm", variant: "secondary", loading: busyKind === 'reject', disabled: submitting && busyKind !== 'reject', onClick: () => send('reject', 'once', fresh()), children: rejectLabel ?? m.approvalReject })), showAllow && scopes.includes('session') && (_jsx(Button, { size: "sm", variant: "secondary", loading: busyKind === 'approve' && attempt?.scope === 'session', disabled: !allowEnabled && !(busyKind === 'approve' && attempt?.scope === 'session'), "aria-describedby": allowReason ? allowReasonId : undefined, onClick: () => send('approve', 'session', fresh()), children: allowSessionLabel ?? m.approvalAllowSession })), showAllow && (_jsx(Button, { size: "sm", variant: "accent", loading: busyKind === 'approve' && attempt?.scope !== 'session', disabled: !allowEnabled && !(busyKind === 'approve' && attempt?.scope !== 'session'), "aria-describedby": allowReason ? allowReasonId : undefined, onClick: () => send('approve', 'once', fresh()), children: allowLabel ?? m.approvalAllowOnce }))] })] })), _jsx("p", { className: "rl-agent-sr", role: "status", children: sr })] }));
|
|
110
|
+
});
|
|
111
|
+
//# sourceMappingURL=ApprovalPanel.js.map
|