@vetta-org/theme-ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +195 -0
- package/src/action-approval/AppearanceActionPickerView.tsx +291 -0
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +69 -0
- package/src/action-approval/AppearancePickerApprovalView.tsx +31 -0
- package/src/action-approval/ApprovalParts.tsx +376 -0
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +138 -0
- package/src/action-approval/BatchTasksExecutionApprovalView.tsx +158 -0
- package/src/action-approval/BatchTasksTaskApprovalView.tsx +152 -0
- package/src/action-approval/GeneralSetExecutionModeApprovalView.tsx +76 -0
- package/src/action-approval/GenericActionApprovalView.tsx +127 -0
- package/src/action-approval/ManageActionApprovalFrameTypes.ts +27 -0
- package/src/action-approval/ManageActionApprovalFrameView.tsx +136 -0
- package/src/action-approval/NavigationOpenApprovalView.tsx +119 -0
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +191 -0
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +113 -0
- package/src/action-approval/SchedulerUpdateApprovalView.tsx +14 -0
- package/src/action-approval/ThemeChangeApprovalView.tsx +30 -0
- package/src/action-approval/WebhookDeleteApprovalView.tsx +56 -0
- package/src/action-approval/WebhookTestApprovalView.tsx +51 -0
- package/src/action-approval/cn.ts +4 -0
- package/src/action-approval/index.ts +88 -0
- package/src/activity/ActivityPanel.tsx +269 -0
- package/src/activity/ActivityPanelFrame.tsx +36 -0
- package/src/activity/BackgroundTasksTabPanelView.tsx +382 -0
- package/src/activity/BatchProgressTabPanelView.tsx +22 -0
- package/src/activity/BrowserPanelView.tsx +169 -0
- package/src/activity/ChatTabPanelView.tsx +36 -0
- package/src/activity/CodePreview.tsx +57 -0
- package/src/activity/DebugTabPanelView.tsx +67 -0
- package/src/activity/FileTabContentView.tsx +46 -0
- package/src/activity/FloatingActivityTabView.tsx +107 -0
- package/src/activity/HtmlPreviewView.tsx +135 -0
- package/src/activity/JourneyPanelView.tsx +327 -0
- package/src/activity/KnowledgeHistoryPanelView.tsx +93 -0
- package/src/activity/MarkdownPreviewView.tsx +217 -0
- package/src/activity/PluginTabPickerView.tsx +182 -0
- package/src/activity/RequestHistorySubTabView.tsx +102 -0
- package/src/activity/ScheduleExecutionTabPanelView.tsx +162 -0
- package/src/activity/TodoTabPanelView.tsx +66 -0
- package/src/activity/ToolCallsSubTabView.tsx +184 -0
- package/src/activity/WorkflowTabPanelView.tsx +129 -0
- package/src/activity/index.ts +110 -0
- package/src/app/AppBackground.tsx +24 -0
- package/src/app/AppBootLoadingView.tsx +51 -0
- package/src/app/RouteContentLoadingView.tsx +20 -0
- package/src/app/index.ts +13 -0
- package/src/app-boot.ts +1 -0
- package/src/app-shell/DefaultPageHeader.tsx +46 -0
- package/src/app-shell/DefaultWindowControls.tsx +32 -0
- package/src/app-shell/PageHeaderActionGroup.tsx +15 -0
- package/src/app-shell/PageHeaderContent.tsx +70 -0
- package/src/app-shell/PageHeaderFrame.tsx +53 -0
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +21 -0
- package/src/app-shell/PageHeaderTitle.tsx +25 -0
- package/src/app-shell/PageHeaderWindowActions.tsx +22 -0
- package/src/app-shell/WindowControlButton.tsx +35 -0
- package/src/app-shell/index.ts +49 -0
- package/src/appearance/BackgroundImageFrame.tsx +57 -0
- package/src/appearance/CenterSliceImageFrame.tsx +64 -0
- package/src/appearance/CornerImageFrame.tsx +63 -0
- package/src/appearance/HorizontalSliceImageFrame.tsx +97 -0
- package/src/appearance/NineSliceImageFrame.tsx +65 -0
- package/src/appearance/ThemeSurface.tsx +91 -0
- package/src/appearance/index.ts +12 -0
- package/src/batch-tasks/BatchProjectArtifactFieldView.tsx +36 -0
- package/src/batch-tasks/BatchProjectDialogView.tsx +61 -0
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +108 -0
- package/src/batch-tasks/BatchProjectGroupView.tsx +77 -0
- package/src/batch-tasks/BatchProjectNameFieldView.tsx +29 -0
- package/src/batch-tasks/BatchProjectNotificationFieldView.tsx +42 -0
- package/src/batch-tasks/BatchProjectRuntimeFieldsView.tsx +67 -0
- package/src/batch-tasks/BatchTaskActionButtonsView.tsx +67 -0
- package/src/batch-tasks/BatchTaskCardView.tsx +142 -0
- package/src/batch-tasks/BatchTaskGridView.tsx +95 -0
- package/src/batch-tasks/BatchTaskListView.tsx +10 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +73 -0
- package/src/batch-tasks/BatchTaskProjectBlockView.tsx +117 -0
- package/src/batch-tasks/BatchTaskProjectHeaderView.tsx +74 -0
- package/src/batch-tasks/BatchTasksPageView.tsx +126 -0
- package/src/batch-tasks/batchTaskUi.tsx +101 -0
- package/src/batch-tasks/index.ts +70 -0
- package/src/batch-tasks/types.ts +120 -0
- package/src/chat/ActionButtonBarView.tsx +45 -0
- package/src/chat/AgentAvatarView.tsx +59 -0
- package/src/chat/AppshotCardView.tsx +89 -0
- package/src/chat/AskUserQuestionView.tsx +177 -0
- package/src/chat/AssistantMessageView.tsx +147 -0
- package/src/chat/AtPanelView.tsx +220 -0
- package/src/chat/BackgroundTasksBadgeView.tsx +28 -0
- package/src/chat/BashTerminalCard.tsx +225 -0
- package/src/chat/ChatExportHostView.tsx +17 -0
- package/src/chat/ChatHeaderActionsView.tsx +75 -0
- package/src/chat/ContextRingView.tsx +100 -0
- package/src/chat/CopyIconButton.tsx +61 -0
- package/src/chat/DefaultGuidingWords.tsx +75 -0
- package/src/chat/DefaultSceneCarousel.tsx +113 -0
- package/src/chat/DefaultSkillBadgeRow.tsx +103 -0
- package/src/chat/DrawerCard.tsx +149 -0
- package/src/chat/EditDiffView.tsx +137 -0
- package/src/chat/ExecutionModeSelectorView.tsx +124 -0
- package/src/chat/ExportMessageListView.tsx +20 -0
- package/src/chat/GuideBadgeSwiperView.tsx +79 -0
- package/src/chat/InlineTokenChip.tsx +68 -0
- package/src/chat/InputActionBarView.tsx +112 -0
- package/src/chat/InputBarBackground.tsx +25 -0
- package/src/chat/InputBarCapsule.tsx +56 -0
- package/src/chat/InputBarContextMenuView.tsx +79 -0
- package/src/chat/InputBarPlaceholder.tsx +84 -0
- package/src/chat/InputBarToolbarButton.tsx +42 -0
- package/src/chat/KnowledgeToolViews.tsx +119 -0
- package/src/chat/LiveThinkingView.tsx +102 -0
- package/src/chat/MessageActions.tsx +109 -0
- package/src/chat/MessageBlockSegmentsView.tsx +203 -0
- package/src/chat/MessageBoundaryViews.tsx +93 -0
- package/src/chat/MessageCardsView.tsx +126 -0
- package/src/chat/MessageFeedContext.tsx +14 -0
- package/src/chat/MessageFeedLayoutView.tsx +97 -0
- package/src/chat/MessageFeedView.tsx +228 -0
- package/src/chat/MessageInputView.tsx +193 -0
- package/src/chat/MessageLayoutView.tsx +156 -0
- package/src/chat/MessageListFooterView.tsx +127 -0
- package/src/chat/MessageSelectionContextMenuView.tsx +66 -0
- package/src/chat/MessageTimelineView.tsx +261 -0
- package/src/chat/MessageView.tsx +82 -0
- package/src/chat/MessageVisualView.tsx +43 -0
- package/src/chat/ModelSelectorView.tsx +407 -0
- package/src/chat/NewSession.ts +107 -0
- package/src/chat/NewSessionBackground.tsx +54 -0
- package/src/chat/NewSessionPageLayoutView.tsx +96 -0
- package/src/chat/NewSessionPicker.tsx +270 -0
- package/src/chat/ProgressGroupView.tsx +323 -0
- package/src/chat/ProjectSelectorView.tsx +253 -0
- package/src/chat/QueueCardView.tsx +151 -0
- package/src/chat/ReadImageView.tsx +73 -0
- package/src/chat/SandboxGrantsBadgeView.tsx +101 -0
- package/src/chat/SandboxPermissionCard.tsx +64 -0
- package/src/chat/SceneCard.tsx +138 -0
- package/src/chat/SendButton.tsx +135 -0
- package/src/chat/SessionDropZoneView.tsx +85 -0
- package/src/chat/SessionViewerPageView.tsx +56 -0
- package/src/chat/SkillCard.tsx +56 -0
- package/src/chat/SkillPromptAreaView.tsx +129 -0
- package/src/chat/SuggestionBubblesView.tsx +58 -0
- package/src/chat/TextBlockView.tsx +770 -0
- package/src/chat/TextPreview.tsx +37 -0
- package/src/chat/ThinkingBlockView.tsx +183 -0
- package/src/chat/TodoCard.tsx +243 -0
- package/src/chat/TodoProgress.tsx +205 -0
- package/src/chat/TodoStatusBarView.tsx +140 -0
- package/src/chat/ToolCallBlockView.tsx +188 -0
- package/src/chat/UsageBarView.tsx +19 -0
- package/src/chat/UserMessageContextMenuView.tsx +87 -0
- package/src/chat/UserMessageView.tsx +241 -0
- package/src/chat/WorkflowFooterItemsView.tsx +170 -0
- package/src/chat/WriteContentView.tsx +12 -0
- package/src/chat/index.ts +524 -0
- package/src/chat/markdown-link.test.ts +238 -0
- package/src/chat/markdown-link.ts +279 -0
- package/src/chat/send-button.css +318 -0
- package/src/chat/useHorizontalDragScroll.ts +146 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +62 -0
- package/src/file-explorer/FileContextMenuView.tsx +209 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +82 -0
- package/src/file-explorer/FileTreeNodeView.tsx +274 -0
- package/src/file-explorer/FileTreeView.tsx +301 -0
- package/src/file-explorer/FilesPanelView.tsx +91 -0
- package/src/file-explorer/drag-target.test.ts +34 -0
- package/src/file-explorer/drag-target.ts +26 -0
- package/src/file-explorer/fileIcons.ts +1 -0
- package/src/file-explorer/index.ts +28 -0
- package/src/file-explorer/nativeFileDrag.test.ts +30 -0
- package/src/file-explorer/nativeFileDrag.ts +14 -0
- package/src/file-explorer/types.ts +40 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +115 -0
- package/src/file-preview/FilePreviewDialogView.tsx +241 -0
- package/src/file-preview/FilePreviewView.tsx +162 -0
- package/src/file-preview/LightboxImageView.tsx +131 -0
- package/src/file-preview/PluginFilePreviewView.tsx +24 -0
- package/src/file-preview/PreviewBodyView.tsx +99 -0
- package/src/file-preview/PreviewErrorBoundary.tsx +51 -0
- package/src/file-preview/TextCodeEditorView.tsx +72 -0
- package/src/file-preview/TextFileEditorView.tsx +213 -0
- package/src/file-preview/index.ts +56 -0
- package/src/file-preview/keyboard-target.test.ts +49 -0
- package/src/file-preview/keyboard-target.ts +33 -0
- package/src/file-preview/syntax-tokens.css +77 -0
- package/src/file-preview/syntax-tokens.test.ts +31 -0
- package/src/file-preview/syntax-tokens.ts +155 -0
- package/src/file-preview/text-code-editor-theme.ts +321 -0
- package/src/file-preview/text-editor-language.test.ts +58 -0
- package/src/file-preview/text-editor-language.ts +182 -0
- package/src/file-preview/types.ts +29 -0
- package/src/flowing/FlowingPanelView.tsx +79 -0
- package/src/flowing/FlowingWorkflowView.tsx +54 -0
- package/src/flowing/UserNodeView.tsx +148 -0
- package/src/flowing/WorkflowBindDialogView.tsx +145 -0
- package/src/flowing/WorkflowProgressView.tsx +149 -0
- package/src/flowing/index.ts +27 -0
- package/src/flowing-chat/ChatBubbleView.tsx +219 -0
- package/src/flowing-chat/ChatComposerView.tsx +362 -0
- package/src/flowing-chat/ChatMembersBarView.tsx +86 -0
- package/src/flowing-chat/ChatPanelView.tsx +73 -0
- package/src/flowing-chat/index.ts +21 -0
- package/src/index.ts +22 -0
- package/src/knowledge/KnowledgeBaseSwitcherView.tsx +154 -0
- package/src/knowledge/KnowledgeBreadcrumbView.tsx +92 -0
- package/src/knowledge/KnowledgeContentsPanelView.tsx +77 -0
- package/src/knowledge/KnowledgeContextMenuView.tsx +70 -0
- package/src/knowledge/KnowledgeFilesSkeleton.tsx +22 -0
- package/src/knowledge/KnowledgeGridView.tsx +113 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +85 -0
- package/src/knowledge/KnowledgeImportDialogView.tsx +153 -0
- package/src/knowledge/KnowledgeListView.tsx +107 -0
- package/src/knowledge/KnowledgePendingFilesDialogView.tsx +76 -0
- package/src/knowledge/KnowledgeProcessingBadgeView.tsx +18 -0
- package/src/knowledge/KnowledgeRenameDialogView.tsx +66 -0
- package/src/knowledge/KnowledgeSourcePickerView.tsx +60 -0
- package/src/knowledge/KnowledgeViewShared.tsx +103 -0
- package/src/knowledge/cn.ts +4 -0
- package/src/knowledge/coloredFileIcons.ts +1 -0
- package/src/knowledge/index.ts +66 -0
- package/src/knowledge/types.ts +31 -0
- package/src/knowledge/useMarqueeSelection.ts +95 -0
- package/src/layout/AppFrame.tsx +34 -0
- package/src/layout/MainContentFrame.tsx +54 -0
- package/src/layout/ResizeHandle.tsx +91 -0
- package/src/layout/SidebarDock.tsx +33 -0
- package/src/layout/SidebarOverlay.tsx +36 -0
- package/src/layout/index.ts +10 -0
- package/src/overlays/CommandMenuRow.tsx +119 -0
- package/src/overlays/CommandMenuView.tsx +183 -0
- package/src/overlays/ConfirmDialogView.tsx +109 -0
- package/src/overlays/DetailDrawer.tsx +63 -0
- package/src/overlays/DetailDrawerEnter.tsx +37 -0
- package/src/overlays/KnowledgeDropOverlayView.tsx +43 -0
- package/src/overlays/RouteErrorPageView.tsx +72 -0
- package/src/overlays/ToasterView.tsx +76 -0
- package/src/overlays/UpdateCheckerView.tsx +206 -0
- package/src/overlays/UpdateRestartDialogView.tsx +107 -0
- package/src/overlays/command-menu-types.ts +47 -0
- package/src/overlays/command-menu.css +69 -0
- package/src/overlays/detail-drawer-guard.test.ts +16 -0
- package/src/overlays/detail-drawer-guard.ts +13 -0
- package/src/overlays/index.ts +44 -0
- package/src/plugin-ui/index.ts +26 -0
- package/src/project/BatchQueueStatusView.tsx +352 -0
- package/src/project/ConversationTagDotsView.tsx +130 -0
- package/src/project/ConversationTagEditorDialogView.tsx +273 -0
- package/src/project/DefaultConversationSectionView.tsx +74 -0
- package/src/project/DefaultSessionListView.tsx +128 -0
- package/src/project/DefaultSessionRowView.tsx +125 -0
- package/src/project/NewProjectDialogView.tsx +140 -0
- package/src/project/ProjectContextMenuView.tsx +187 -0
- package/src/project/ProjectDetailPageView.tsx +351 -0
- package/src/project/ProjectGroupView.tsx +37 -0
- package/src/project/ProjectRowView.tsx +111 -0
- package/src/project/ProjectSessionsLoadingView.tsx +14 -0
- package/src/project/ProjectSessionsView.tsx +96 -0
- package/src/project/ProjectsLoadingView.tsx +15 -0
- package/src/project/ProjectsPanelMenusView.tsx +23 -0
- package/src/project/ProjectsPanelView.tsx +56 -0
- package/src/project/QuickScrollOverlay.tsx +188 -0
- package/src/project/ScheduleStatusView.tsx +110 -0
- package/src/project/SessionContextMenuView.tsx +71 -0
- package/src/project/SessionRenameInputView.tsx +49 -0
- package/src/project/SessionRowView.tsx +119 -0
- package/src/project/SidebarProjectsSectionView.tsx +35 -0
- package/src/project/index.ts +87 -0
- package/src/project/types.ts +21 -0
- package/src/project/useActiveSessionAutoScroll.ts +171 -0
- package/src/registry.ts +62 -0
- package/src/scheduler/AutomationPageView.tsx +159 -0
- package/src/scheduler/ExecutionHistoryView.tsx +179 -0
- package/src/scheduler/HistoryDrawerView.tsx +149 -0
- package/src/scheduler/TaskFormDialogView.tsx +60 -0
- package/src/scheduler/TaskListView.tsx +219 -0
- package/src/scheduler/index.ts +30 -0
- package/src/settings/AchievementNavigationButtonView.tsx +90 -0
- package/src/settings/AchievementPromotionDialogView.tsx +91 -0
- package/src/settings/AchievementSettingsView.tsx +44 -0
- package/src/settings/AppshotSettingsView.tsx +132 -0
- package/src/settings/ArchivedProjectsSettingsView.tsx +80 -0
- package/src/settings/BuiltinMcpSecretsDialogView.tsx +278 -0
- package/src/settings/BuiltinMcpSectionView.tsx +164 -0
- package/src/settings/EnvironmentSettingsView.tsx +176 -0
- package/src/settings/GeneralSettingsView.tsx +174 -0
- package/src/settings/ImChannelCardView.tsx +152 -0
- package/src/settings/ImChannelGuideDialogView.tsx +126 -0
- package/src/settings/ImFeishuDialogView.tsx +156 -0
- package/src/settings/ImLegacyImportBannerView.tsx +44 -0
- package/src/settings/ImLogDrawerView.tsx +75 -0
- package/src/settings/ImStatusBadgeView.tsx +39 -0
- package/src/settings/McpDefaultIcon.tsx +27 -0
- package/src/settings/McpJsonEditorView.tsx +56 -0
- package/src/settings/ModelsProviderFormView.tsx +128 -0
- package/src/settings/ModelsProvidersSectionView.tsx +52 -0
- package/src/settings/MotionSelect.tsx +125 -0
- package/src/settings/PermissionsSettingsView.tsx +106 -0
- package/src/settings/PetBubbleStylePreviewView.tsx +44 -0
- package/src/settings/PetSettingsView.tsx +165 -0
- package/src/settings/PresetProviderModelsListView.tsx +58 -0
- package/src/settings/PresetProviderRowView.tsx +302 -0
- package/src/settings/PresetProvidersSectionView.tsx +70 -0
- package/src/settings/QrBindDialogView.tsx +165 -0
- package/src/settings/QuickPanelSettingsSectionView.tsx +66 -0
- package/src/settings/RemoteMcpSectionView.tsx +192 -0
- package/src/settings/SettingChrome.tsx +104 -0
- package/src/settings/SettingsAiAssistButtonView.tsx +150 -0
- package/src/settings/SettingsAiAssistDialogView.tsx +251 -0
- package/src/settings/SettingsFormFields.tsx +121 -0
- package/src/settings/SettingsPageShellView.tsx +84 -0
- package/src/settings/SettingsSidebarView.tsx +133 -0
- package/src/settings/ShortcutRecorderView.tsx +88 -0
- package/src/settings/ShortcutsSettingsView.tsx +66 -0
- package/src/settings/SubscriptionActionsView.tsx +63 -0
- package/src/settings/SubscriptionCardsView.tsx +212 -0
- package/src/settings/TeamDetailView.tsx +148 -0
- package/src/settings/TeamDialogsView.tsx +151 -0
- package/src/settings/TeamListView.tsx +57 -0
- package/src/settings/TeamSettingsView.tsx +51 -0
- package/src/settings/TokenActivityChartView.tsx +286 -0
- package/src/settings/UsageStatsView.tsx +101 -0
- package/src/settings/WebhookEndpointListView.tsx +123 -0
- package/src/settings/WechatBindDialogView.tsx +45 -0
- package/src/settings/achievements/AchievementCurtains.tsx +50 -0
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +350 -0
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +71 -0
- package/src/settings/achievements/AchievementTitle.tsx +52 -0
- package/src/settings/achievements/index.ts +13 -0
- package/src/settings/index.ts +226 -0
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +135 -0
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +40 -0
- package/src/settings/token-activity.test.ts +195 -0
- package/src/settings/token-activity.ts +320 -0
- package/src/shared/AvatarStackView.tsx +45 -0
- package/src/shared/BotAvatar.tsx +395 -0
- package/src/shared/CodeBlockCopyButton.tsx +48 -0
- package/src/shared/CollapsePanel.tsx +125 -0
- package/src/shared/ContextMenuView.tsx +134 -0
- package/src/shared/MacKeyboardPreview.tsx +260 -0
- package/src/shared/MarkdownTable.tsx +216 -0
- package/src/shared/MultiplierTag.tsx +15 -0
- package/src/shared/ScrollFade.tsx +114 -0
- package/src/shared/SegmentedControl.tsx +82 -0
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.tsx +696 -0
- package/src/shared/TimePicker.tsx +96 -0
- package/src/shared/connected-tab-outline.test.ts +22 -0
- package/src/shared/connected-tab-outline.ts +39 -0
- package/src/shared/fileIcons.test.ts +28 -0
- package/src/shared/fileIcons.ts +322 -0
- package/src/shared/index.ts +38 -0
- package/src/shared/markdown-table-clipboard.ts +31 -0
- package/src/shared/provider-icon/icons.ts +56 -0
- package/src/shared/provider-icon/index.tsx +42 -0
- package/src/shared/provider-icon/svg-url.d.ts +4 -0
- package/src/shared/tab-drag.test.ts +14 -0
- package/src/shared/tab-drag.ts +15 -0
- package/src/shared/useDelayedUnmount.ts +36 -0
- package/src/sidebar/AddProjectMenuItem.tsx +21 -0
- package/src/sidebar/AddProjectMenuPopoverView.tsx +52 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +50 -0
- package/src/sidebar/ChatMessageListView.tsx +66 -0
- package/src/sidebar/DefaultSidebar.tsx +91 -0
- package/src/sidebar/FlowingMessageListView.tsx +111 -0
- package/src/sidebar/MessageCenterDialogView.tsx +81 -0
- package/src/sidebar/MessageCenterEmptyState.tsx +24 -0
- package/src/sidebar/MessageCenterTabs.tsx +86 -0
- package/src/sidebar/MessageCenterToolbarButton.tsx +25 -0
- package/src/sidebar/MessageCenterTriggerView.tsx +39 -0
- package/src/sidebar/NotificationMessageListView.tsx +136 -0
- package/src/sidebar/ProjectsPanelEmptyState.tsx +20 -0
- package/src/sidebar/RunningPulseDot.tsx +10 -0
- package/src/sidebar/SessionStatusIcon.tsx +43 -0
- package/src/sidebar/SettingsMenuAccountSection.tsx +32 -0
- package/src/sidebar/SettingsMenuActionButton.tsx +24 -0
- package/src/sidebar/SettingsMenuDivider.tsx +5 -0
- package/src/sidebar/SettingsMenuQuotaSection.tsx +45 -0
- package/src/sidebar/SettingsMenuSettingsItem.tsx +18 -0
- package/src/sidebar/SettingsMenuThemeSection.tsx +51 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +65 -0
- package/src/sidebar/ShowMoreSessionsButton.tsx +37 -0
- package/src/sidebar/SidebarFilterSelectView.tsx +95 -0
- package/src/sidebar/SidebarNavBadgeView.tsx +58 -0
- package/src/sidebar/SidebarNavIcon.tsx +33 -0
- package/src/sidebar/SidebarNavItemButton.tsx +59 -0
- package/src/sidebar/SidebarNavMorePanel.tsx +199 -0
- package/src/sidebar/SidebarNavigation.tsx +223 -0
- package/src/sidebar/SidebarPanel.tsx +48 -0
- package/src/sidebar/SidebarTopBar.tsx +103 -0
- package/src/sidebar/SidebarUpdateIcon.tsx +79 -0
- package/src/sidebar/index.ts +118 -0
- package/src/sidebar/nav-badge-text.test.ts +23 -0
- package/src/sidebar/nav-badge-text.ts +19 -0
- package/src/sidebar/useSidebarNavDrag.ts +139 -0
- package/src/skills/PluginCardView.tsx +150 -0
- package/src/skills/SceneCardView.tsx +194 -0
- package/src/skills/SkillCardView.tsx +186 -0
- package/src/skills/SkillDetailDialogView.tsx +138 -0
- package/src/skills/SkillTagGroupView.tsx +56 -0
- package/src/skills/SkillToggleSwitch.tsx +31 -0
- package/src/skills/index.ts +29 -0
- package/src/skills/skill-icon.test.ts +38 -0
- package/src/skills/skill-icon.tsx +126 -0
- package/src/styles.css +75 -0
- package/src/utils/platform.ts +2 -0
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState, type JSX } from "react";
|
|
2
|
+
import ReactMarkdown from "react-markdown";
|
|
3
|
+
import type { Components } from "react-markdown";
|
|
4
|
+
import remarkGfm from "remark-gfm";
|
|
5
|
+
import { CodeBlockCopyButtonView } from "../shared/CodeBlockCopyButton";
|
|
6
|
+
import {
|
|
7
|
+
MarkdownTable,
|
|
8
|
+
MarkdownTableBody,
|
|
9
|
+
MarkdownTableCell,
|
|
10
|
+
MarkdownTableHead,
|
|
11
|
+
MarkdownTableHeaderCell,
|
|
12
|
+
MarkdownTableRow,
|
|
13
|
+
} from "../shared/MarkdownTable";
|
|
14
|
+
import { SyntaxHighlightedCode } from "../shared/SyntaxHighlightedCode";
|
|
15
|
+
import { SkillTypeIcon } from "../skills/skill-icon";
|
|
16
|
+
import { InlineTokenChip } from "./InlineTokenChip";
|
|
17
|
+
import {
|
|
18
|
+
chatUrlTransform,
|
|
19
|
+
classifyMarkdownLink,
|
|
20
|
+
normalizeLocalFileLinksInMarkdown,
|
|
21
|
+
} from "./markdown-link";
|
|
22
|
+
|
|
23
|
+
/** Minimal hast-like nodes for the streaming chunk rehype plugin. */
|
|
24
|
+
interface HastText {
|
|
25
|
+
type: "text";
|
|
26
|
+
value: string;
|
|
27
|
+
}
|
|
28
|
+
interface HastElement {
|
|
29
|
+
type: "element";
|
|
30
|
+
tagName: string;
|
|
31
|
+
properties?: Record<string, unknown>;
|
|
32
|
+
children: Array<HastText | HastElement>;
|
|
33
|
+
}
|
|
34
|
+
interface HastRoot {
|
|
35
|
+
type: "root";
|
|
36
|
+
children: Array<HastText | HastElement>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 文件 / 链接 badge 的公共样式:半透明主题色底 + 主题色描边与文字。 */
|
|
40
|
+
const LINK_BADGE_CLASS =
|
|
41
|
+
"inline-flex max-w-full items-center gap-1 rounded-md border border-primary/25 bg-primary/10 px-1.5 py-px align-middle text-[13px] font-medium text-primary no-underline transition-colors hover:bg-primary/20";
|
|
42
|
+
|
|
43
|
+
const remarkPlugins = [remarkGfm];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 用户消息里的行内 token(skill / scene 引用、文件、图片)。
|
|
47
|
+
* 语法归宿主所有——theme-ui 只负责渲染,解析函数由 inlineTokens.parse 注入。
|
|
48
|
+
*/
|
|
49
|
+
export type InlineTokenPiece =
|
|
50
|
+
| { kind: "text"; text: string }
|
|
51
|
+
| { kind: "skill"; name: string }
|
|
52
|
+
| { kind: "scene"; name: string }
|
|
53
|
+
| { kind: "connector"; name: string }
|
|
54
|
+
| { kind: "member"; participantId: string; handle: string }
|
|
55
|
+
| { kind: "file"; path: string; isDirectory?: boolean }
|
|
56
|
+
| { kind: "image"; path: string };
|
|
57
|
+
|
|
58
|
+
export interface InlineTokenSupport {
|
|
59
|
+
parse: (text: string) => InlineTokenPiece[];
|
|
60
|
+
/** Structured annotations into the original Markdown source; never inferred from display text. */
|
|
61
|
+
annotations?: readonly InlineTokenAnnotation[];
|
|
62
|
+
/**
|
|
63
|
+
* 图片 token 的胶囊文案(如「图 1」)。缩略图不在文本流里渲染,
|
|
64
|
+
* 它们集中在气泡上方并带同样的编号,因此这里只要一个标签。
|
|
65
|
+
*/
|
|
66
|
+
getImageLabel: (path: string) => string;
|
|
67
|
+
/** 连接器的展示名与 logo;查不到时回退成真实名 + 通用图标。 */
|
|
68
|
+
getConnector?: (name: string) => { label: string; iconUrl?: string } | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* skill 的展示名与图标。文本流里只有 slug,别名/图标要宿主回查,
|
|
71
|
+
* 否则气泡里的胶囊与输入框里刚插入的那枚对不上。查不到时回退成 slug + 默认图。
|
|
72
|
+
*/
|
|
73
|
+
getSkill?: (name: string) => { label: string; icon?: string } | undefined;
|
|
74
|
+
/** scene 与 skill 共用视觉语言,但使用场景图标和独立元数据命名空间。 */
|
|
75
|
+
getScene?: (name: string) => { label: string; icon?: string } | undefined;
|
|
76
|
+
/** Team member metadata resolved by stable participant identity. */
|
|
77
|
+
getMember?: (participantId: string) => { label: string; avatar?: string; meta?: string } | undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface InlineTokenAnnotationRange {
|
|
81
|
+
/** Exact serialized token text, used to reject stale or mismatched offsets. */
|
|
82
|
+
readonly text: string;
|
|
83
|
+
/** UTF-16 offsets into the original Markdown source. */
|
|
84
|
+
readonly start: number;
|
|
85
|
+
readonly end: number;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type InlineTokenAnnotation =
|
|
89
|
+
| ({ readonly kind: "skill" | "scene" | "connector"; readonly name: string } & InlineTokenAnnotationRange)
|
|
90
|
+
| ({
|
|
91
|
+
readonly kind: "file" | "image";
|
|
92
|
+
readonly path: string;
|
|
93
|
+
readonly isDirectory?: boolean;
|
|
94
|
+
} & InlineTokenAnnotationRange)
|
|
95
|
+
| ({
|
|
96
|
+
readonly kind: "member";
|
|
97
|
+
readonly participantId: string;
|
|
98
|
+
readonly handle: string;
|
|
99
|
+
} & InlineTokenAnnotationRange);
|
|
100
|
+
|
|
101
|
+
const INLINE_TOKEN_TAG = "vetta-inline-token";
|
|
102
|
+
|
|
103
|
+
/** 把文本节点里的 token 换成自定义元素;代码块与链接文本内不处理。 */
|
|
104
|
+
function rehypeInlineTokens(parse: (text: string) => InlineTokenPiece[]) {
|
|
105
|
+
return (tree: HastRoot): void => {
|
|
106
|
+
function visit(node: HastRoot | HastElement, inLiteral: boolean): void {
|
|
107
|
+
const newChildren: Array<(typeof node.children)[number]> = [];
|
|
108
|
+
for (const child of node.children) {
|
|
109
|
+
if (child.type === "text" && !inLiteral) {
|
|
110
|
+
const pieces = parse((child as HastText).value);
|
|
111
|
+
if (pieces.length === 1 && pieces[0].kind === "text") {
|
|
112
|
+
newChildren.push(child);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
for (const piece of pieces) {
|
|
116
|
+
if (piece.kind === "text") {
|
|
117
|
+
newChildren.push({ type: "text", value: piece.text } as HastText);
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
newChildren.push({
|
|
121
|
+
type: "element",
|
|
122
|
+
tagName: INLINE_TOKEN_TAG,
|
|
123
|
+
properties: {
|
|
124
|
+
"data-token-kind": piece.kind,
|
|
125
|
+
"data-token-value":
|
|
126
|
+
piece.kind === "skill" || piece.kind === "scene" || piece.kind === "connector"
|
|
127
|
+
? piece.name
|
|
128
|
+
: piece.kind === "member"
|
|
129
|
+
? piece.participantId
|
|
130
|
+
: piece.path,
|
|
131
|
+
"data-token-directory": piece.kind === "file" && piece.isDirectory ? "true" : "false",
|
|
132
|
+
},
|
|
133
|
+
children: [],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
newChildren.push(child);
|
|
139
|
+
if (child.type === "element") {
|
|
140
|
+
const tag = child.tagName;
|
|
141
|
+
visit(child, inLiteral || tag === "code" || tag === "pre" || tag === "a");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
node.children = newChildren as typeof node.children;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
visit(tree, false);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface MdastNode {
|
|
152
|
+
type: string;
|
|
153
|
+
value?: string;
|
|
154
|
+
children?: MdastNode[];
|
|
155
|
+
position?: { start?: { offset?: number }; end?: { offset?: number } };
|
|
156
|
+
data?: { hName?: string; hProperties?: Record<string, unknown> };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function remarkInlineTokenAnnotations(annotations: readonly InlineTokenAnnotation[]) {
|
|
160
|
+
const ordered = [...annotations].sort((left, right) => left.start - right.start || left.end - right.end);
|
|
161
|
+
return (tree: MdastNode): void => {
|
|
162
|
+
function visit(node: MdastNode, inLiteral: boolean): void {
|
|
163
|
+
if (!node.children) return;
|
|
164
|
+
const nextChildren: MdastNode[] = [];
|
|
165
|
+
for (const child of node.children) {
|
|
166
|
+
const literal = inLiteral || child.type === "code" || child.type === "inlineCode" || child.type === "link";
|
|
167
|
+
const nodeStart = child.position?.start?.offset;
|
|
168
|
+
const nodeEnd = child.position?.end?.offset;
|
|
169
|
+
if (child.type !== "text" || literal || nodeStart === undefined || nodeEnd === undefined) {
|
|
170
|
+
nextChildren.push(child);
|
|
171
|
+
visit(child, literal);
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const value = child.value ?? "";
|
|
175
|
+
const contained = ordered.filter(
|
|
176
|
+
(annotation) => annotation.start >= nodeStart && annotation.end <= nodeEnd,
|
|
177
|
+
);
|
|
178
|
+
if (contained.length === 0) {
|
|
179
|
+
nextChildren.push(child);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
let cursor = 0;
|
|
183
|
+
for (const annotation of contained) {
|
|
184
|
+
const start = annotation.start - nodeStart;
|
|
185
|
+
const end = annotation.end - nodeStart;
|
|
186
|
+
if (start < cursor || end <= start || value.slice(start, end) !== annotation.text) continue;
|
|
187
|
+
if (annotation.kind === "member" && annotation.text !== `@${annotation.handle}`) continue;
|
|
188
|
+
if (start > cursor) nextChildren.push({ type: "text", value: value.slice(cursor, start) });
|
|
189
|
+
const tokenValue =
|
|
190
|
+
"name" in annotation
|
|
191
|
+
? annotation.name
|
|
192
|
+
: "participantId" in annotation
|
|
193
|
+
? annotation.participantId
|
|
194
|
+
: annotation.path;
|
|
195
|
+
nextChildren.push({
|
|
196
|
+
type: "inlineToken",
|
|
197
|
+
data: {
|
|
198
|
+
hName: INLINE_TOKEN_TAG,
|
|
199
|
+
hProperties: {
|
|
200
|
+
"data-token-kind": annotation.kind,
|
|
201
|
+
"data-token-value": tokenValue,
|
|
202
|
+
...(annotation.kind === "member"
|
|
203
|
+
? { "data-token-handle": annotation.handle }
|
|
204
|
+
: {}),
|
|
205
|
+
...(annotation.kind === "file"
|
|
206
|
+
? { "data-token-directory": annotation.isDirectory ? "true" : "false" }
|
|
207
|
+
: {}),
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
cursor = end;
|
|
212
|
+
}
|
|
213
|
+
if (cursor < value.length) nextChildren.push({ type: "text", value: value.slice(cursor) });
|
|
214
|
+
}
|
|
215
|
+
node.children = nextChildren;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
visit(tree, false);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function projectAnnotationsToNormalizedMarkdown(
|
|
223
|
+
source: string,
|
|
224
|
+
normalizedSource: string,
|
|
225
|
+
annotations: readonly InlineTokenAnnotation[],
|
|
226
|
+
): InlineTokenAnnotation[] {
|
|
227
|
+
if (source === normalizedSource) return [...annotations];
|
|
228
|
+
return annotations.flatMap((annotation): InlineTokenAnnotation[] => {
|
|
229
|
+
if (source.slice(annotation.start, annotation.end) !== annotation.text) return [];
|
|
230
|
+
const start = normalizeLocalFileLinksInMarkdown(source.slice(0, annotation.start)).length;
|
|
231
|
+
const end = normalizeLocalFileLinksInMarkdown(source.slice(0, annotation.end)).length;
|
|
232
|
+
return normalizedSource.slice(start, end) === annotation.text ? [{ ...annotation, start, end }] : [];
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const STREAMING_CHUNK_SIZE = 10;
|
|
237
|
+
|
|
238
|
+
function rehypeStreamingChunks() {
|
|
239
|
+
return (tree: HastRoot): void => {
|
|
240
|
+
function visit(node: HastRoot | HastElement, inCode: boolean): void {
|
|
241
|
+
const newChildren: Array<(typeof node.children)[number]> = [];
|
|
242
|
+
for (const child of node.children) {
|
|
243
|
+
if (child.type === "text" && !inCode) {
|
|
244
|
+
const value = (child as HastText).value;
|
|
245
|
+
for (let index = 0; index < value.length; ) {
|
|
246
|
+
const spaceMatch = /^\s+/.exec(value.slice(index));
|
|
247
|
+
if (spaceMatch) {
|
|
248
|
+
newChildren.push({ type: "text", value: spaceMatch[0] } as HastText);
|
|
249
|
+
index += spaceMatch[0].length;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const end = getSliceEnd(value, index, STREAMING_CHUNK_SIZE);
|
|
254
|
+
newChildren.push({
|
|
255
|
+
type: "element",
|
|
256
|
+
tagName: "span",
|
|
257
|
+
properties: { className: ["streaming-chunk"] },
|
|
258
|
+
children: [{ type: "text", value: value.slice(index, end) } as HastText],
|
|
259
|
+
});
|
|
260
|
+
index = end;
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
newChildren.push(child);
|
|
264
|
+
if (child.type === "element") {
|
|
265
|
+
const tag = child.tagName;
|
|
266
|
+
// 表格也当字面量:把单元格文字拆成 inline-block 的 chunk span 会打乱
|
|
267
|
+
// 列宽测量,流式期表格会逐帧抖动。
|
|
268
|
+
visit(child, inCode || tag === "code" || tag === "pre" || tag === "table");
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
node.children = newChildren as typeof node.children;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
visit(tree, false);
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const streamingRehypePlugins = [rehypeStreamingChunks];
|
|
280
|
+
const STREAM_REVEAL_INTERVAL_MS = 500;
|
|
281
|
+
|
|
282
|
+
function getSliceEnd(text: string, start: number, count: number): number {
|
|
283
|
+
let end = Math.min(text.length, start + count);
|
|
284
|
+
if (end < text.length) {
|
|
285
|
+
const previous = text.charCodeAt(end - 1);
|
|
286
|
+
const next = text.charCodeAt(end);
|
|
287
|
+
if (previous >= 0xd800 && previous <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
|
|
288
|
+
end++;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return end;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
interface StreamingDisplayState {
|
|
295
|
+
displayText: string;
|
|
296
|
+
animateChunks: boolean;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function useStreamingDisplayText(text: string, active: boolean): StreamingDisplayState {
|
|
300
|
+
const [displayText, setDisplayText] = useState(() => (active ? "" : text));
|
|
301
|
+
const [animateChunks, setAnimateChunks] = useState(active);
|
|
302
|
+
const displayRef = useRef(active ? "" : text);
|
|
303
|
+
const targetRef = useRef(text);
|
|
304
|
+
const rafRef = useRef<number | null>(null);
|
|
305
|
+
const revealTimerRef = useRef<number | null>(null);
|
|
306
|
+
const lastRevealRef = useRef<number | null>(null);
|
|
307
|
+
const settleTimerRef = useRef<number | null>(null);
|
|
308
|
+
const wasActiveRef = useRef(active);
|
|
309
|
+
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
targetRef.current = text;
|
|
312
|
+
|
|
313
|
+
function clearSettleTimer(): void {
|
|
314
|
+
if (settleTimerRef.current !== null) {
|
|
315
|
+
window.clearTimeout(settleTimerRef.current);
|
|
316
|
+
settleTimerRef.current = null;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function clearRevealTimer(): void {
|
|
321
|
+
if (revealTimerRef.current !== null) {
|
|
322
|
+
window.clearTimeout(revealTimerRef.current);
|
|
323
|
+
revealTimerRef.current = null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function scheduleSettle(): void {
|
|
328
|
+
clearSettleTimer();
|
|
329
|
+
settleTimerRef.current = window.setTimeout(() => {
|
|
330
|
+
setAnimateChunks(false);
|
|
331
|
+
settleTimerRef.current = null;
|
|
332
|
+
}, STREAM_REVEAL_INTERVAL_MS);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function scheduleReveal(delayMs: number): void {
|
|
336
|
+
if (delayMs <= 0) {
|
|
337
|
+
if (rafRef.current === null) {
|
|
338
|
+
rafRef.current = requestAnimationFrame(tick);
|
|
339
|
+
}
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
342
|
+
if (revealTimerRef.current !== null) return;
|
|
343
|
+
revealTimerRef.current = window.setTimeout(() => {
|
|
344
|
+
revealTimerRef.current = null;
|
|
345
|
+
if (rafRef.current === null) {
|
|
346
|
+
rafRef.current = requestAnimationFrame(tick);
|
|
347
|
+
}
|
|
348
|
+
}, delayMs);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Non-tail mode (e.g. marketing story drives its own char reveal):
|
|
353
|
+
* mirror `text` immediately. Do not 500ms-batch catch-up — that dumps
|
|
354
|
+
* the whole backlog as one flash on top of the host’s progressive text.
|
|
355
|
+
*/
|
|
356
|
+
if (!active) {
|
|
357
|
+
if (rafRef.current !== null) {
|
|
358
|
+
cancelAnimationFrame(rafRef.current);
|
|
359
|
+
rafRef.current = null;
|
|
360
|
+
}
|
|
361
|
+
clearRevealTimer();
|
|
362
|
+
clearSettleTimer();
|
|
363
|
+
displayRef.current = text;
|
|
364
|
+
setDisplayText(text);
|
|
365
|
+
setAnimateChunks(false);
|
|
366
|
+
lastRevealRef.current = null;
|
|
367
|
+
wasActiveRef.current = active;
|
|
368
|
+
return () => {
|
|
369
|
+
clearRevealTimer();
|
|
370
|
+
clearSettleTimer();
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (!text.startsWith(displayRef.current)) {
|
|
375
|
+
if (rafRef.current !== null) {
|
|
376
|
+
cancelAnimationFrame(rafRef.current);
|
|
377
|
+
rafRef.current = null;
|
|
378
|
+
}
|
|
379
|
+
clearRevealTimer();
|
|
380
|
+
clearSettleTimer();
|
|
381
|
+
setDisplayText(text);
|
|
382
|
+
setAnimateChunks(false);
|
|
383
|
+
displayRef.current = text;
|
|
384
|
+
lastRevealRef.current = null;
|
|
385
|
+
wasActiveRef.current = active;
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
function tick(timestamp: number): void {
|
|
390
|
+
rafRef.current = null;
|
|
391
|
+
const target = targetRef.current;
|
|
392
|
+
const current = displayRef.current;
|
|
393
|
+
const backlog = target.length - current.length;
|
|
394
|
+
|
|
395
|
+
if (backlog <= 0) {
|
|
396
|
+
lastRevealRef.current = timestamp;
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
const previousReveal = lastRevealRef.current;
|
|
401
|
+
if (previousReveal !== null && timestamp - previousReveal < STREAM_REVEAL_INTERVAL_MS) {
|
|
402
|
+
scheduleReveal(STREAM_REVEAL_INTERVAL_MS - (timestamp - previousReveal));
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
lastRevealRef.current = timestamp;
|
|
406
|
+
|
|
407
|
+
// Catch up to the host target for this interval (chunk animation via rehype).
|
|
408
|
+
const next = target;
|
|
409
|
+
displayRef.current = next;
|
|
410
|
+
setAnimateChunks(true);
|
|
411
|
+
setDisplayText(next);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (active && !wasActiveRef.current && displayRef.current.length >= text.length) {
|
|
415
|
+
clearSettleTimer();
|
|
416
|
+
displayRef.current = "";
|
|
417
|
+
setDisplayText("");
|
|
418
|
+
lastRevealRef.current = null;
|
|
419
|
+
}
|
|
420
|
+
wasActiveRef.current = active;
|
|
421
|
+
clearRevealTimer();
|
|
422
|
+
clearSettleTimer();
|
|
423
|
+
setAnimateChunks(true);
|
|
424
|
+
|
|
425
|
+
if (rafRef.current === null && displayRef.current.length < text.length) {
|
|
426
|
+
const previousReveal = lastRevealRef.current;
|
|
427
|
+
const delayMs =
|
|
428
|
+
previousReveal === null
|
|
429
|
+
? 0
|
|
430
|
+
: Math.max(0, STREAM_REVEAL_INTERVAL_MS - (performance.now() - previousReveal));
|
|
431
|
+
scheduleReveal(delayMs);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
return () => {
|
|
435
|
+
if (rafRef.current !== null) {
|
|
436
|
+
cancelAnimationFrame(rafRef.current);
|
|
437
|
+
rafRef.current = null;
|
|
438
|
+
}
|
|
439
|
+
clearRevealTimer();
|
|
440
|
+
clearSettleTimer();
|
|
441
|
+
};
|
|
442
|
+
}, [text, active]);
|
|
443
|
+
|
|
444
|
+
return { displayText, animateChunks };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function cn(...parts: Array<string | false | null | undefined>): string {
|
|
448
|
+
return parts.filter(Boolean).join(" ");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
export interface TextBlockViewLabels {
|
|
452
|
+
copy: string;
|
|
453
|
+
copied: string;
|
|
454
|
+
/** 表格工具条:复制成 GFM 表格 / CSV。 */
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export interface TextBlockViewProps {
|
|
458
|
+
text: string;
|
|
459
|
+
isStreamingTail?: boolean;
|
|
460
|
+
className?: string;
|
|
461
|
+
theme: "light" | "dark";
|
|
462
|
+
labels: TextBlockViewLabels;
|
|
463
|
+
getFileIconClass: (fileName: string) => string;
|
|
464
|
+
onOpenFile: (path: string) => void;
|
|
465
|
+
onOpenUrl: (url: string) => void;
|
|
466
|
+
/** 传入即启用行内 token 渲染;仅用户消息需要,助手 markdown 不受影响。 */
|
|
467
|
+
inlineTokens?: InlineTokenSupport;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function basename(path: string): string {
|
|
471
|
+
const normalized = path.replace(/[\\/]+$/, "");
|
|
472
|
+
const idx = Math.max(normalized.lastIndexOf("/"), normalized.lastIndexOf("\\"));
|
|
473
|
+
return idx === -1 ? normalized : normalized.slice(idx + 1);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function CodeBlockShell({
|
|
477
|
+
lang,
|
|
478
|
+
code,
|
|
479
|
+
theme,
|
|
480
|
+
labels,
|
|
481
|
+
}: {
|
|
482
|
+
lang: string;
|
|
483
|
+
code: string;
|
|
484
|
+
theme: "light" | "dark";
|
|
485
|
+
labels: TextBlockViewLabels;
|
|
486
|
+
}): JSX.Element {
|
|
487
|
+
const [copied, setCopied] = useState(false);
|
|
488
|
+
const timerRef = useRef<number | null>(null);
|
|
489
|
+
|
|
490
|
+
useEffect(() => {
|
|
491
|
+
return () => {
|
|
492
|
+
if (timerRef.current !== null) window.clearTimeout(timerRef.current);
|
|
493
|
+
};
|
|
494
|
+
}, []);
|
|
495
|
+
|
|
496
|
+
const onCopy = useCallback(() => {
|
|
497
|
+
void navigator.clipboard.writeText(code).then(() => {
|
|
498
|
+
setCopied(true);
|
|
499
|
+
if (timerRef.current !== null) window.clearTimeout(timerRef.current);
|
|
500
|
+
timerRef.current = window.setTimeout(() => setCopied(false), 1500);
|
|
501
|
+
});
|
|
502
|
+
}, [code]);
|
|
503
|
+
|
|
504
|
+
return (
|
|
505
|
+
<CodeBlockCopyButtonView copied={copied} onCopy={onCopy} labels={labels}>
|
|
506
|
+
<div className="my-2 overflow-hidden rounded-lg border border-border bg-muted">
|
|
507
|
+
{lang && (
|
|
508
|
+
<div className="border-b border-border px-3 py-1 text-[10px] font-medium text-muted-foreground/50">
|
|
509
|
+
{lang}
|
|
510
|
+
</div>
|
|
511
|
+
)}
|
|
512
|
+
<SyntaxHighlightedCode code={code} lang={lang} theme={theme} fontSizeClass="text-[13px]" />
|
|
513
|
+
</div>
|
|
514
|
+
</CodeBlockCopyButtonView>
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Memo'd markdown renderer for chat text blocks. Host injects file/url handlers and theme.
|
|
520
|
+
*
|
|
521
|
+
* `components` 映射的函数引用必须在 streaming 期间保持稳定:React 把 components.p 等
|
|
522
|
+
* 当成元素类型;引用一变就会整树 remount,`.streaming-chunk` 的 CSS 入场动画对已有
|
|
523
|
+
* 文本整段重播,表现为 text block 高频闪烁。labels / 回调通过 ref 读取,不进 deps。
|
|
524
|
+
*/
|
|
525
|
+
export const TextBlockView = memo(function TextBlockView({
|
|
526
|
+
text,
|
|
527
|
+
isStreamingTail = false,
|
|
528
|
+
className,
|
|
529
|
+
theme,
|
|
530
|
+
labels,
|
|
531
|
+
getFileIconClass,
|
|
532
|
+
onOpenFile,
|
|
533
|
+
onOpenUrl,
|
|
534
|
+
inlineTokens,
|
|
535
|
+
}: TextBlockViewProps): JSX.Element {
|
|
536
|
+
const { displayText, animateChunks } = useStreamingDisplayText(text, isStreamingTail);
|
|
537
|
+
|
|
538
|
+
const labelsRef = useRef(labels);
|
|
539
|
+
const getFileIconClassRef = useRef(getFileIconClass);
|
|
540
|
+
const onOpenFileRef = useRef(onOpenFile);
|
|
541
|
+
const onOpenUrlRef = useRef(onOpenUrl);
|
|
542
|
+
const inlineTokensRef = useRef(inlineTokens);
|
|
543
|
+
labelsRef.current = labels;
|
|
544
|
+
getFileIconClassRef.current = getFileIconClass;
|
|
545
|
+
onOpenFileRef.current = onOpenFile;
|
|
546
|
+
onOpenUrlRef.current = onOpenUrl;
|
|
547
|
+
inlineTokensRef.current = inlineTokens;
|
|
548
|
+
|
|
549
|
+
const components = useMemo<Components>(
|
|
550
|
+
() => ({
|
|
551
|
+
h1: ({ children }) => (
|
|
552
|
+
<h1 className="mb-3 mt-4 text-[20px] font-bold leading-tight text-foreground">{children}</h1>
|
|
553
|
+
),
|
|
554
|
+
h2: ({ children }) => (
|
|
555
|
+
<h2 className="mb-2 mt-3.5 text-[17px] font-bold leading-tight text-foreground">{children}</h2>
|
|
556
|
+
),
|
|
557
|
+
h3: ({ children }) => (
|
|
558
|
+
<h3 className="mb-2 mt-3 text-[15px] font-semibold leading-tight text-foreground">{children}</h3>
|
|
559
|
+
),
|
|
560
|
+
h4: ({ children }) => (
|
|
561
|
+
<h4 className="mb-1.5 mt-2.5 text-[14px] font-semibold text-foreground">{children}</h4>
|
|
562
|
+
),
|
|
563
|
+
p: ({ children }) => <p className="my-1.5 text-[14px] leading-[1.6] text-foreground">{children}</p>,
|
|
564
|
+
ul: ({ children }) => (
|
|
565
|
+
<ul className="md-bullet-list my-1.5 text-[14px] leading-[1.6] text-foreground">{children}</ul>
|
|
566
|
+
),
|
|
567
|
+
ol: ({ children }) => (
|
|
568
|
+
<ol className="my-1.5 ml-4 list-decimal space-y-0.5 text-[14px] leading-[1.6] text-foreground marker:text-primary">
|
|
569
|
+
{children}
|
|
570
|
+
</ol>
|
|
571
|
+
),
|
|
572
|
+
li: ({ children }) => <li>{children}</li>,
|
|
573
|
+
code: ({ className: codeClassName, children }) => {
|
|
574
|
+
const raw = String(children);
|
|
575
|
+
const isBlock = (codeClassName?.startsWith("language-") ?? false) || raw.includes("\n");
|
|
576
|
+
if (isBlock) {
|
|
577
|
+
const lang = codeClassName?.replace("language-", "") ?? "";
|
|
578
|
+
const code = raw.replace(/\n$/, "");
|
|
579
|
+
return (
|
|
580
|
+
<CodeBlockShell lang={lang} code={code} theme={theme} labels={labelsRef.current} />
|
|
581
|
+
);
|
|
582
|
+
}
|
|
583
|
+
return <code className="rounded bg-muted px-1 py-0.5 text-[13px] text-foreground">{children}</code>;
|
|
584
|
+
},
|
|
585
|
+
pre: ({ children }) => <>{children}</>,
|
|
586
|
+
blockquote: ({ children }) => (
|
|
587
|
+
<blockquote className="my-2 border-l-2 border-primary/10 pl-3 text-[14px] italic text-muted-foreground">
|
|
588
|
+
{children}
|
|
589
|
+
</blockquote>
|
|
590
|
+
),
|
|
591
|
+
table: ({ children }) => <MarkdownTable>{children}</MarkdownTable>,
|
|
592
|
+
thead: ({ children }) => <MarkdownTableHead>{children}</MarkdownTableHead>,
|
|
593
|
+
tbody: ({ children }) => <MarkdownTableBody>{children}</MarkdownTableBody>,
|
|
594
|
+
tr: ({ children }) => <MarkdownTableRow>{children}</MarkdownTableRow>,
|
|
595
|
+
// style 透传:remark-gfm 把 GFM 的列对齐(`|---:|`)写在这里。
|
|
596
|
+
th: ({ children, style }) => (
|
|
597
|
+
<MarkdownTableHeaderCell style={style}>{children}</MarkdownTableHeaderCell>
|
|
598
|
+
),
|
|
599
|
+
td: ({ children, style }) => <MarkdownTableCell style={style}>{children}</MarkdownTableCell>,
|
|
600
|
+
hr: () => <hr className="my-3 border-border" />,
|
|
601
|
+
a: ({ href, children }) => {
|
|
602
|
+
const kind = classifyMarkdownLink(href);
|
|
603
|
+
if (kind.type === "file") {
|
|
604
|
+
const fileName = basename(kind.path);
|
|
605
|
+
return (
|
|
606
|
+
<button
|
|
607
|
+
type="button"
|
|
608
|
+
title={kind.path}
|
|
609
|
+
className={cn(LINK_BADGE_CLASS, "cursor-pointer")}
|
|
610
|
+
onClick={() => onOpenFileRef.current(kind.path)}
|
|
611
|
+
>
|
|
612
|
+
<span
|
|
613
|
+
className={cn(getFileIconClassRef.current(fileName), "h-3.5 w-3.5 shrink-0")}
|
|
614
|
+
/>
|
|
615
|
+
<span className="truncate">{children}</span>
|
|
616
|
+
</button>
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
if (kind.type === "url") {
|
|
620
|
+
return (
|
|
621
|
+
<a
|
|
622
|
+
href={kind.url}
|
|
623
|
+
title={kind.url}
|
|
624
|
+
className={LINK_BADGE_CLASS}
|
|
625
|
+
onClick={(e) => {
|
|
626
|
+
e.preventDefault();
|
|
627
|
+
onOpenUrlRef.current(kind.url);
|
|
628
|
+
}}
|
|
629
|
+
>
|
|
630
|
+
<span className="icon-[mdi--web] h-3.5 w-3.5 shrink-0" />
|
|
631
|
+
<span className="truncate">{children}</span>
|
|
632
|
+
</a>
|
|
633
|
+
);
|
|
634
|
+
}
|
|
635
|
+
// mailto / fragment / unknown: never target=_blank — that opens the OS browser
|
|
636
|
+
// for misclassified local paths. Keep visible but non-navigating.
|
|
637
|
+
return (
|
|
638
|
+
<span
|
|
639
|
+
className="text-chart-2 underline decoration-chart-2/30"
|
|
640
|
+
title={kind.href || undefined}
|
|
641
|
+
>
|
|
642
|
+
{children}
|
|
643
|
+
</span>
|
|
644
|
+
);
|
|
645
|
+
},
|
|
646
|
+
strong: ({ children }) => <strong className="font-semibold text-foreground">{children}</strong>,
|
|
647
|
+
em: ({ children }) => <em className="italic">{children}</em>,
|
|
648
|
+
// 行内 token:与输入框里的胶囊同款(半透明主题色底 + 描边,align-middle 对齐正文)。
|
|
649
|
+
[INLINE_TOKEN_TAG]: ({ node }: { node?: HastElement }) => {
|
|
650
|
+
const properties = node?.properties ?? {};
|
|
651
|
+
const kind = String(properties["data-token-kind"] ?? "");
|
|
652
|
+
const value = String(properties["data-token-value"] ?? "");
|
|
653
|
+
if (!kind || !value) return null;
|
|
654
|
+
if (kind === "image") {
|
|
655
|
+
return (
|
|
656
|
+
<InlineTokenChip
|
|
657
|
+
icon="icon-[solar--gallery-linear]"
|
|
658
|
+
label={inlineTokensRef.current?.getImageLabel(value) ?? basename(value)}
|
|
659
|
+
title={basename(value)}
|
|
660
|
+
/>
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
if (kind === "skill" || kind === "scene") {
|
|
664
|
+
const ability =
|
|
665
|
+
kind === "scene"
|
|
666
|
+
? inlineTokensRef.current?.getScene?.(value)
|
|
667
|
+
: inlineTokensRef.current?.getSkill?.(value);
|
|
668
|
+
return (
|
|
669
|
+
<InlineTokenChip
|
|
670
|
+
iconNode={<SkillTypeIcon type={kind} icon={ability?.icon} className="h-3 w-3" />}
|
|
671
|
+
label={ability?.label ?? value}
|
|
672
|
+
title={value}
|
|
673
|
+
/>
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
if (kind === "connector") {
|
|
677
|
+
const connector = inlineTokensRef.current?.getConnector?.(value);
|
|
678
|
+
return (
|
|
679
|
+
<InlineTokenChip
|
|
680
|
+
icon="icon-[solar--plug-circle-linear]"
|
|
681
|
+
iconUrl={connector?.iconUrl}
|
|
682
|
+
label={connector?.label ?? value}
|
|
683
|
+
title={value}
|
|
684
|
+
/>
|
|
685
|
+
);
|
|
686
|
+
}
|
|
687
|
+
if (kind === "member") {
|
|
688
|
+
const member = inlineTokensRef.current?.getMember?.(value);
|
|
689
|
+
const handle = String(properties["data-token-handle"] ?? value);
|
|
690
|
+
if (!member) return <>{`@${handle}`}</>;
|
|
691
|
+
return (
|
|
692
|
+
<InlineTokenChip
|
|
693
|
+
iconNode={
|
|
694
|
+
member.avatar ? (
|
|
695
|
+
<img
|
|
696
|
+
src={member.avatar}
|
|
697
|
+
alt=""
|
|
698
|
+
draggable={false}
|
|
699
|
+
className="h-3 w-3 rounded-full object-cover"
|
|
700
|
+
/>
|
|
701
|
+
) : undefined
|
|
702
|
+
}
|
|
703
|
+
label={`@${member.label || handle}`}
|
|
704
|
+
title={member.meta ? `${member.label || handle} · ${member.meta}` : handle}
|
|
705
|
+
tone="member"
|
|
706
|
+
/>
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
const isDirectory = properties["data-token-directory"] === "true";
|
|
710
|
+
const fileName = basename(value);
|
|
711
|
+
return (
|
|
712
|
+
<InlineTokenChip
|
|
713
|
+
asButton
|
|
714
|
+
icon={
|
|
715
|
+
isDirectory
|
|
716
|
+
? "icon-[solar--folder-linear]"
|
|
717
|
+
: getFileIconClassRef.current(fileName)
|
|
718
|
+
}
|
|
719
|
+
label={fileName}
|
|
720
|
+
title={value}
|
|
721
|
+
onClick={() => onOpenFileRef.current(value)}
|
|
722
|
+
/>
|
|
723
|
+
);
|
|
724
|
+
},
|
|
725
|
+
}),
|
|
726
|
+
// theme 进 deps:代码块高亮主题变化时需要换组件树。其余 host 注入值走 ref。
|
|
727
|
+
[theme],
|
|
728
|
+
);
|
|
729
|
+
|
|
730
|
+
const hasStructuredAnnotations = inlineTokens?.annotations !== undefined;
|
|
731
|
+
const rehypePlugins = useMemo(() => {
|
|
732
|
+
const plugins = [];
|
|
733
|
+
if (animateChunks) plugins.push(rehypeStreamingChunks);
|
|
734
|
+
// Exact editor/history annotations are complete. Falling back to text parsing
|
|
735
|
+
// here would reinterpret plain text that only happens to look like a token.
|
|
736
|
+
if (inlineTokens && !hasStructuredAnnotations) plugins.push(() => rehypeInlineTokens(inlineTokens.parse));
|
|
737
|
+
return plugins.length > 0 ? plugins : undefined;
|
|
738
|
+
}, [animateChunks, hasStructuredAnnotations, inlineTokens]);
|
|
739
|
+
const markdownSource = useMemo(
|
|
740
|
+
() => normalizeLocalFileLinksInMarkdown(displayText),
|
|
741
|
+
[displayText],
|
|
742
|
+
);
|
|
743
|
+
const normalizedAnnotations = useMemo(
|
|
744
|
+
() =>
|
|
745
|
+
inlineTokens?.annotations
|
|
746
|
+
? projectAnnotationsToNormalizedMarkdown(displayText, markdownSource, inlineTokens.annotations)
|
|
747
|
+
: undefined,
|
|
748
|
+
[displayText, inlineTokens?.annotations, markdownSource],
|
|
749
|
+
);
|
|
750
|
+
const activeRemarkPlugins = useMemo(
|
|
751
|
+
() =>
|
|
752
|
+
normalizedAnnotations?.length
|
|
753
|
+
? [...remarkPlugins, () => remarkInlineTokenAnnotations(normalizedAnnotations)]
|
|
754
|
+
: remarkPlugins,
|
|
755
|
+
[normalizedAnnotations],
|
|
756
|
+
);
|
|
757
|
+
|
|
758
|
+
return (
|
|
759
|
+
<div className={cn("markdown-body break-words", animateChunks && "markdown-streaming-tail", className)}>
|
|
760
|
+
<ReactMarkdown
|
|
761
|
+
remarkPlugins={activeRemarkPlugins}
|
|
762
|
+
rehypePlugins={rehypePlugins}
|
|
763
|
+
components={components}
|
|
764
|
+
urlTransform={chatUrlTransform}
|
|
765
|
+
>
|
|
766
|
+
{markdownSource}
|
|
767
|
+
</ReactMarkdown>
|
|
768
|
+
</div>
|
|
769
|
+
);
|
|
770
|
+
});
|