@vetta-org/theme-ui 0.1.1 → 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/package.json +740 -20
- package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
- package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
- package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
- package/src/action-approval/GenericActionApprovalView.tsx +2 -9
- package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
- package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
- package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
- package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
- package/src/action-approval/index.ts +0 -1
- package/src/activity/ActivityPanel.tsx +13 -10
- package/src/activity/ActivityPanelFrame.test.tsx +32 -0
- package/src/activity/ActivityPanelFrame.tsx +3 -2
- package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
- package/src/activity/BrowserPanelView.tsx +48 -49
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/DebugTabPanelView.tsx +1 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +135 -62
- package/src/activity/PluginTabPickerView.tsx +5 -3
- package/src/activity/PortsTabPanelView.tsx +911 -0
- package/src/activity/ToolCallsSubTabView.tsx +1 -1
- package/src/activity/WorkflowTabPanelView.tsx +1 -1
- package/src/activity/index.ts +9 -0
- package/src/app/AppBackground.tsx +1 -1
- package/src/app/AppBootLoadingView.tsx +4 -2
- package/src/app-shell/DefaultWindowControls.tsx +1 -1
- package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
- package/src/app-shell/PageHeaderContent.tsx +36 -7
- package/src/app-shell/PageHeaderFrame.tsx +15 -3
- package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
- package/src/app-shell/PageHeaderTitle.tsx +1 -1
- package/src/app-shell/WindowControlButton.tsx +1 -1
- package/src/app-shell/header-crowding.test.ts +62 -0
- package/src/app-shell/header-crowding.tsx +137 -0
- package/src/appearance/BackgroundImageFrame.tsx +1 -1
- package/src/appearance/CenterSliceImageFrame.tsx +1 -1
- package/src/appearance/CornerImageFrame.tsx +1 -1
- package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
- package/src/appearance/NineSliceImageFrame.tsx +1 -1
- package/src/appearance/ThemeSurface.tsx +1 -1
- package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
- package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
- package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
- package/src/batch-tasks/batchTaskUi.tsx +0 -29
- package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
- package/src/bottom-panel/BottomPanelView.tsx +222 -0
- package/src/bottom-panel/index.ts +26 -0
- package/src/chat/AgentAvatarView.tsx +1 -1
- package/src/chat/AnnotationViews.tsx +107 -0
- package/src/chat/AskUserQuestionView.tsx +18 -11
- package/src/chat/AssistantMessageView.tsx +48 -13
- package/src/chat/AtPanelView.test.tsx +61 -0
- package/src/chat/AtPanelView.tsx +63 -38
- package/src/chat/BashTerminalCard.tsx +1 -2
- package/src/chat/ChatHeaderActionsView.tsx +74 -18
- package/src/chat/CompactionStepView.test.tsx +34 -0
- package/src/chat/CompactionStepView.tsx +85 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/ExecutionModeSelectorView.tsx +20 -5
- package/src/chat/HeaderActionBarView.tsx +806 -0
- package/src/chat/HeaderActionOverflowMenu.tsx +128 -0
- package/src/chat/InlineModelPicker.test.tsx +81 -0
- package/src/chat/InlineModelPicker.tsx +201 -0
- package/src/chat/InlineTokenChip.tsx +2 -68
- package/src/chat/InputBarBackground.tsx +1 -1
- package/src/chat/InputBarPlaceholder.tsx +26 -3
- package/src/chat/LiveThinkingView.tsx +51 -37
- package/src/chat/MessageBoundaryViews.tsx +21 -0
- package/src/chat/MessageFeedContext.tsx +13 -5
- package/src/chat/MessageFeedLayoutView.tsx +29 -3
- package/src/chat/MessageFeedView.test.tsx +81 -0
- package/src/chat/MessageFeedView.tsx +72 -152
- package/src/chat/MessageInputView.tsx +6 -2
- package/src/chat/MessageLayoutView.tsx +1 -1
- package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
- package/src/chat/MessageTimelineView.tsx +1 -1
- package/src/chat/MessageView.tsx +1 -1
- package/src/chat/MessageVisualView.tsx +1 -1
- package/src/chat/ModelConfiguration.tsx +283 -0
- package/src/chat/ModelSelectorTrigger.tsx +63 -0
- package/src/chat/ModelSelectorView.tsx +1037 -223
- package/src/chat/NewSession.ts +1 -37
- package/src/chat/NewSessionPicker.tsx +3 -2
- package/src/chat/ProjectSelectorView.tsx +3 -2
- package/src/chat/ReasoningStepSlider.tsx +61 -0
- package/src/chat/RemoteSessionBadgeView.tsx +24 -0
- package/src/chat/SkillPromptAreaView.tsx +5 -19
- package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
- package/src/chat/TeamMemberReplyCardView.tsx +133 -0
- package/src/chat/TextBlockView.tsx +7 -770
- package/src/chat/TodoProgress.tsx +25 -53
- package/src/chat/TodoStatusBarView.tsx +14 -5
- package/src/chat/UserMessageView.tsx +113 -33
- package/src/chat/header-action-narrow.test.ts +21 -0
- package/src/chat/header-action-narrow.ts +38 -0
- package/src/chat/index.ts +33 -27
- package/src/chat/markdown-link.ts +7 -279
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/send-button.css +4 -22
- package/src/chat/streaming-reveal.test.ts +218 -0
- package/src/chat/streaming-reveal.ts +13 -0
- package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
- package/src/file-explorer/FileContextMenuView.tsx +44 -11
- package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
- package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
- package/src/file-explorer/FileTreeNodeView.tsx +59 -18
- package/src/file-explorer/FileTreeView.tsx +236 -129
- package/src/file-explorer/file-tree-dom.ts +23 -0
- package/src/file-explorer/file-tree-rows.test.ts +74 -0
- package/src/file-explorer/file-tree-rows.ts +168 -0
- package/src/file-explorer/index.ts +17 -0
- package/src/file-explorer/types.ts +3 -0
- package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
- package/src/file-preview/FilePreviewDialogView.tsx +2 -2
- package/src/file-preview/FilePreviewView.tsx +12 -2
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/TextFileEditorView.tsx +2 -1
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/index.ts +1 -0
- package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
- package/src/layout/AppFrame.tsx +3 -2
- package/src/layout/MainContentFrame.tsx +7 -2
- package/src/layout/ResizeHandle.tsx +68 -17
- package/src/layout/SidebarDock.tsx +75 -19
- package/src/layout/SidebarOverlay.tsx +1 -1
- package/src/layout/index.ts +1 -1
- package/src/layout/resize-handle-axis.test.ts +51 -0
- package/src/live-indicators.test.ts +43 -0
- package/src/markdown/CodeBlock.tsx +123 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/InlineTokenChip.tsx +68 -0
- package/src/markdown/MarkdownContent.tsx +418 -0
- package/src/markdown/MarkdownImage.tsx +41 -0
- package/src/markdown/MathFormula.tsx +46 -0
- package/src/markdown/MermaidBlock.tsx +82 -0
- package/src/markdown/RichCodeBlock.tsx +127 -0
- package/src/markdown/SvgPreview.tsx +45 -0
- package/src/markdown/WebsiteIcon.tsx +94 -0
- package/src/markdown/builtin-renderers.tsx +43 -0
- package/src/markdown/definition.tsx +49 -0
- package/src/markdown/host.tsx +18 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +12 -0
- package/src/markdown/inline-tokens.ts +187 -0
- package/src/markdown/markdown-link.ts +279 -0
- package/src/markdown/math-client.ts +116 -0
- package/src/markdown/math-render.ts +23 -0
- package/src/markdown/math-syntax.ts +80 -0
- package/src/markdown/math.worker.ts +16 -0
- package/src/markdown/nodes.ts +15 -0
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +76 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +55 -0
- package/src/markdown/rich-syntax.ts +93 -0
- package/src/markdown/stable-blocks.test.ts +90 -0
- package/src/markdown/stable-blocks.ts +124 -0
- package/src/markdown/streaming-reveal.ts +297 -0
- package/src/markdown/streaming.test.ts +57 -0
- package/src/markdown/streaming.ts +211 -0
- package/src/markdown/use-render-snapshot.ts +24 -0
- package/src/markdown/use-rich-visibility.ts +24 -0
- package/src/overlays/CommandMenuRow.tsx +77 -17
- package/src/overlays/CommandMenuView.tsx +163 -118
- package/src/overlays/ConfirmDialogView.tsx +25 -20
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
- package/src/overlays/SplashOptionRow.tsx +46 -0
- package/src/overlays/SplashPanel.tsx +85 -0
- package/src/overlays/SplashParts.tsx +217 -0
- package/src/overlays/UpdateCheckerView.tsx +34 -18
- package/src/overlays/UpdateRestartDialogView.tsx +203 -53
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/command-menu.css +1 -20
- package/src/overlays/index.ts +26 -1
- package/src/plugin-ui/index.ts +10 -0
- package/src/project/ConversationTagDotsView.tsx +1 -1
- package/src/project/ConversationTagEditorDialogView.tsx +4 -1
- package/src/project/DefaultConversationSectionView.tsx +15 -24
- package/src/project/DefaultSessionListView.tsx +5 -31
- package/src/project/DefaultSessionRowView.tsx +114 -55
- package/src/project/ManageSessionsSplashView.tsx +439 -0
- package/src/project/NewProjectDialogView.tsx +3 -10
- package/src/project/ProjectContextMenuView.tsx +30 -139
- package/src/project/ProjectDetailPageView.test.tsx +140 -0
- package/src/project/ProjectDetailPageView.tsx +372 -165
- package/src/project/ProjectGroupView.tsx +1 -1
- package/src/project/ProjectRowView.tsx +29 -12
- package/src/project/ProjectSessionsView.tsx +25 -47
- package/src/project/QuickScrollOverlay.tsx +1 -1
- package/src/project/SessionContextMenuView.tsx +15 -7
- package/src/project/SessionRowMoreButton.tsx +50 -0
- package/src/project/SessionRowView.tsx +106 -63
- package/src/project/SessionTitleMarquee.tsx +54 -0
- package/src/project/SidebarProjectDisclosure.tsx +60 -0
- package/src/project/SidebarProjectsSectionView.tsx +6 -1
- package/src/project/index.ts +12 -0
- package/src/project/session-row-transition.ts +9 -0
- package/src/project/types.ts +4 -2
- package/src/project/useActiveSessionAutoScroll.ts +10 -4
- package/src/registry.ts +0 -2
- package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
- package/src/scheduler/AutomationPageView.tsx +118 -121
- package/src/scheduler/ExecutionHistoryView.tsx +7 -5
- package/src/scheduler/TaskListView.tsx +52 -201
- package/src/scheduler/index.ts +7 -12
- package/src/settings/AppshotSettingsView.tsx +0 -1
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/BuiltinMcpSectionView.tsx +1 -1
- package/src/settings/EnvironmentGitRowView.tsx +156 -0
- package/src/settings/EnvironmentSettingsView.tsx +25 -3
- package/src/settings/GeneralSettingsView.tsx +18 -24
- package/src/settings/ImChannelGuideDialogView.tsx +2 -2
- package/src/settings/ImFeishuDialogView.tsx +1 -1
- package/src/settings/ImLegacyImportBannerView.tsx +1 -1
- package/src/settings/ImLogDrawerView.tsx +2 -1
- package/src/settings/JsonConfigInputView.tsx +171 -0
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +273 -0
- package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
- package/src/settings/ModelsProvidersSectionView.tsx +26 -23
- package/src/settings/MotionSelect.tsx +9 -7
- package/src/settings/NotificationSettingsView.tsx +79 -0
- package/src/settings/PermissionsSettingsView.tsx +3 -7
- package/src/settings/PetActionGalleryView.test.tsx +163 -0
- package/src/settings/PetActionGalleryView.tsx +216 -0
- package/src/settings/PetSettingsView.test.tsx +117 -0
- package/src/settings/PetSettingsView.tsx +86 -22
- package/src/settings/PresetProviderModelsListView.tsx +141 -24
- package/src/settings/PresetProviderRowView.tsx +147 -185
- package/src/settings/ProxySettingsSectionView.tsx +182 -0
- package/src/settings/QrBindDialogView.tsx +1 -1
- package/src/settings/RemoteMcpSectionView.tsx +1 -1
- package/src/settings/SettingChrome.tsx +2 -2
- package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
- package/src/settings/SettingsFormFields.tsx +4 -7
- package/src/settings/SettingsSidebarView.tsx +64 -3
- package/src/settings/ShortcutRecorderView.test.tsx +108 -0
- package/src/settings/ShortcutRecorderView.tsx +15 -9
- package/src/settings/ShortcutsSettingsView.tsx +1 -5
- package/src/settings/SpaceEditorDialogView.tsx +158 -0
- package/src/settings/SpacesSettingsView.tsx +150 -0
- package/src/settings/WebhookEndpointListView.tsx +4 -5
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +59 -68
- package/src/shared/ActivityStatusDot.tsx +69 -0
- package/src/shared/AvatarStackView.tsx +13 -13
- package/src/shared/BotAvatar.tsx +11 -9
- package/src/shared/CodeBlockCopyButton.tsx +1 -1
- package/src/shared/ContextMenuView.tsx +4 -11
- package/src/shared/MarkdownTable.tsx +2 -2
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +10 -2
- package/src/shared/SyntaxHighlightedCode.tsx +0 -0
- package/src/shared/TabBar.outline.test.tsx +59 -0
- package/src/shared/TabBar.tsx +23 -18
- package/src/shared/VettaKbd.test.tsx +52 -0
- package/src/shared/VettaKbd.tsx +100 -0
- package/src/shared/connected-tab-outline.test.ts +2 -2
- package/src/shared/connected-tab-outline.ts +2 -1
- package/src/shared/index.ts +7 -0
- package/src/shared/kbd-keys.test.ts +61 -0
- package/src/shared/kbd-keys.ts +253 -0
- package/src/shared/platform.ts +9 -0
- package/src/shared/provider-icon/icons.ts +4 -2
- package/src/shared/provider-icon/index.tsx +1 -1
- package/src/shared/provider-icon/magpie.svg +1 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +33 -24
- package/src/sidebar/DefaultSidebar.tsx +3 -1
- package/src/sidebar/MessageCenterDialogView.tsx +3 -2
- package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
- package/src/sidebar/MessageCenterTabs.tsx +1 -1
- package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
- package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
- package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
- package/src/sidebar/SessionStatusIcon.tsx +16 -1
- package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
- package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
- package/src/sidebar/SettingsMenuTriggerView.tsx +29 -50
- package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
- package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
- package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
- package/src/sidebar/SidebarNavIcon.tsx +1 -1
- package/src/sidebar/SidebarNavItemButton.tsx +1 -1
- package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
- package/src/sidebar/SidebarNavigation.tsx +24 -15
- package/src/sidebar/SidebarPanel.tsx +11 -2
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
- package/src/sidebar/SidebarTopBar.tsx +10 -7
- package/src/sidebar/WaitingPulseBadge.tsx +19 -0
- package/src/sidebar/index.ts +1 -16
- package/src/skills/index.ts +0 -19
- package/src/skills/skill-icon.tsx +4 -8
- package/src/styles.css +26 -6
- package/src/chat/DefaultSceneCarousel.tsx +0 -113
- package/src/chat/SceneCard.tsx +0 -138
- package/src/scheduler/HistoryDrawerView.tsx +0 -149
- package/src/scheduler/TaskFormDialogView.tsx +0 -60
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -44
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
- package/src/settings/SubscriptionActionsView.tsx +0 -63
- package/src/settings/SubscriptionCardsView.tsx +0 -212
- package/src/settings/TeamDetailView.tsx +0 -148
- package/src/settings/TeamDialogsView.tsx +0 -151
- package/src/settings/TeamListView.tsx +0 -57
- package/src/settings/TeamSettingsView.tsx +0 -51
- package/src/settings/TokenActivityChartView.tsx +0 -286
- package/src/settings/UsageStatsView.tsx +0 -101
- package/src/settings/achievements/AchievementCurtains.tsx +0 -50
- package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
- package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
- package/src/settings/achievements/AchievementTitle.tsx +0 -52
- package/src/settings/achievements/index.ts +0 -13
- package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
- package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
- package/src/settings/token-activity.test.ts +0 -195
- package/src/settings/token-activity.ts +0 -320
- package/src/sidebar/AddProjectMenuItem.tsx +0 -21
- package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
- package/src/sidebar/NotificationMessageListView.tsx +0 -136
- package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
- package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
- package/src/skills/SceneCardView.tsx +0 -194
- package/src/skills/SkillCardView.tsx +0 -186
- package/src/skills/SkillDetailDialogView.tsx +0 -138
- package/src/skills/SkillTagGroupView.tsx +0 -56
- package/src/skills/SkillToggleSwitch.tsx +0 -31
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
2
|
+
import { useCallback, useEffect, useRef, type JSX, type ReactNode } from "react";
|
|
3
|
+
import { cn } from "@vetta-org/ui/utils";
|
|
4
|
+
import { CommandMenuRow } from "../overlays/CommandMenuRow";
|
|
5
|
+
import type { CommandMenuItemView } from "../overlays/command-menu-types";
|
|
6
|
+
import { SplashPanel } from "../overlays/SplashPanel";
|
|
7
|
+
import { SplashFooter, SplashInputHeader, SplashStep, SplashTitleHeader } from "../overlays/SplashParts";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 「管理会话」面板的纯展示层。整个流程在同一个 Splash 里完成,三个步骤只换头部与内容:
|
|
11
|
+
* - list:搜索 + 会话列表,底栏是快捷键提示与「清空全部」;
|
|
12
|
+
* - menu:选中会话的更多操作(也用来选标签),一个通用的操作列表;
|
|
13
|
+
* - rename:重命名输入。
|
|
14
|
+
* 键盘导航与快捷键由宿主负责,本组件只处理渲染与滚动跟随。
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export type ManageSessionsStep = "list" | "menu" | "rename";
|
|
18
|
+
|
|
19
|
+
export interface ManageSessionsMenuItemView {
|
|
20
|
+
readonly id: string;
|
|
21
|
+
readonly label: string;
|
|
22
|
+
/** iconify 类名;有 dotColor 时以色点代替。 */
|
|
23
|
+
readonly icon?: string;
|
|
24
|
+
readonly dotColor?: string;
|
|
25
|
+
readonly checked?: boolean;
|
|
26
|
+
readonly danger?: boolean;
|
|
27
|
+
readonly disabled?: boolean;
|
|
28
|
+
/** 右侧的快捷键提示,例如 Control X。 */
|
|
29
|
+
readonly shortcut?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ManageSessionsTabView {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
readonly label: string;
|
|
35
|
+
readonly dotColor?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ManageSessionsSplashViewLabels {
|
|
39
|
+
readonly title: string;
|
|
40
|
+
readonly searchPlaceholder: string;
|
|
41
|
+
readonly searchLabel: string;
|
|
42
|
+
readonly empty: string;
|
|
43
|
+
readonly back: string;
|
|
44
|
+
readonly renamePlaceholder: string;
|
|
45
|
+
readonly renameLabel: string;
|
|
46
|
+
readonly clearAll: string;
|
|
47
|
+
readonly clearAllDisabled: string;
|
|
48
|
+
readonly hintDelete: string;
|
|
49
|
+
readonly hintMore: string;
|
|
50
|
+
readonly hintClose: string;
|
|
51
|
+
readonly hintTab: string;
|
|
52
|
+
readonly hintBack: string;
|
|
53
|
+
readonly hintSelect: string;
|
|
54
|
+
readonly hintRename: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface ManageSessionsSplashViewProps {
|
|
58
|
+
readonly open: boolean;
|
|
59
|
+
readonly step: ManageSessionsStep;
|
|
60
|
+
readonly labels: ManageSessionsSplashViewLabels;
|
|
61
|
+
/** 快捷键修饰键的显示名,mac 为 Control,其余为 Ctrl。 */
|
|
62
|
+
readonly modifierLabel: string;
|
|
63
|
+
readonly onClose: () => void;
|
|
64
|
+
|
|
65
|
+
/** 置顶在列表上方的标签页;为空时不显示。按 Tab 在其间切换由宿主处理。 */
|
|
66
|
+
readonly tabs: readonly ManageSessionsTabView[];
|
|
67
|
+
readonly activeTabId: string;
|
|
68
|
+
readonly onSelectTab: (id: string) => void;
|
|
69
|
+
|
|
70
|
+
// list
|
|
71
|
+
readonly query: string;
|
|
72
|
+
readonly onQueryChange: (value: string) => void;
|
|
73
|
+
readonly rows: readonly CommandMenuItemView[];
|
|
74
|
+
readonly selectedId: string | null;
|
|
75
|
+
readonly onHoverRow: (id: string) => void;
|
|
76
|
+
readonly onOpenRow: (id: string) => void;
|
|
77
|
+
readonly onMoreRow: (id: string) => void;
|
|
78
|
+
readonly clearAllVisible: boolean;
|
|
79
|
+
readonly clearAllDisabled: boolean;
|
|
80
|
+
readonly clearAllDisabledReason?: string;
|
|
81
|
+
readonly onClearAll: () => void;
|
|
82
|
+
|
|
83
|
+
// menu
|
|
84
|
+
readonly menuTitle: string;
|
|
85
|
+
readonly menuItems: readonly ManageSessionsMenuItemView[];
|
|
86
|
+
readonly menuActiveId: string | null;
|
|
87
|
+
readonly onHoverMenuItem: (id: string) => void;
|
|
88
|
+
readonly onSelectMenuItem: (id: string) => void;
|
|
89
|
+
|
|
90
|
+
// rename
|
|
91
|
+
readonly renameValue: string;
|
|
92
|
+
readonly onRenameChange: (value: string) => void;
|
|
93
|
+
readonly onRenameSubmit: () => void;
|
|
94
|
+
|
|
95
|
+
readonly onBack: () => void;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function Kbd({ children }: { children: ReactNode }): JSX.Element {
|
|
99
|
+
return (
|
|
100
|
+
<kbd className="rounded bg-foreground/[0.07] px-1 py-px font-sans text-[10px] font-medium text-foreground/70">
|
|
101
|
+
{children}
|
|
102
|
+
</kbd>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function Hint({ keys, label }: { keys: readonly string[]; label: string }): JSX.Element {
|
|
107
|
+
return (
|
|
108
|
+
<span className="flex items-center gap-1 whitespace-nowrap">
|
|
109
|
+
{keys.map((key) => (
|
|
110
|
+
<Kbd key={key}>{key}</Kbd>
|
|
111
|
+
))}
|
|
112
|
+
<span>{label}</span>
|
|
113
|
+
</span>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** 行高固定为 h-9(36px),虚拟列表据此定位。 */
|
|
118
|
+
const ROW_HEIGHT = 36;
|
|
119
|
+
/** 会话不多时直接全量渲染(保留原生滚动与测试可见性),超过才开虚拟列表。 */
|
|
120
|
+
const VIRTUALIZE_THRESHOLD = 80;
|
|
121
|
+
const VIRTUAL_OVERSCAN = 8;
|
|
122
|
+
const LIST_FALLBACK_HEIGHT = 420;
|
|
123
|
+
|
|
124
|
+
const LIST_CLASS = "min-h-0 max-h-[min(420px,56vh)] overflow-y-auto overscroll-contain px-1.5 py-1.5";
|
|
125
|
+
|
|
126
|
+
function MenuRow({
|
|
127
|
+
item,
|
|
128
|
+
active,
|
|
129
|
+
onHover,
|
|
130
|
+
onSelect,
|
|
131
|
+
registerRef,
|
|
132
|
+
}: {
|
|
133
|
+
item: ManageSessionsMenuItemView;
|
|
134
|
+
active: boolean;
|
|
135
|
+
onHover: (id: string) => void;
|
|
136
|
+
onSelect: (id: string) => void;
|
|
137
|
+
registerRef: (id: string, element: HTMLButtonElement | null) => void;
|
|
138
|
+
}): JSX.Element {
|
|
139
|
+
return (
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
ref={(element) => registerRef(item.id, element)}
|
|
143
|
+
role="menuitem"
|
|
144
|
+
disabled={item.disabled}
|
|
145
|
+
title={item.disabled ? item.label : undefined}
|
|
146
|
+
onMouseMove={() => {
|
|
147
|
+
if (!item.disabled) onHover(item.id);
|
|
148
|
+
}}
|
|
149
|
+
onClick={() => {
|
|
150
|
+
if (!item.disabled) onSelect(item.id);
|
|
151
|
+
}}
|
|
152
|
+
className={cn(
|
|
153
|
+
"relative flex h-9 w-full items-center gap-2.5 rounded-lg px-2.5 text-left outline-none transition-colors",
|
|
154
|
+
item.disabled ? "cursor-not-allowed opacity-45" : "cursor-pointer",
|
|
155
|
+
active && "bg-primary/10",
|
|
156
|
+
)}
|
|
157
|
+
>
|
|
158
|
+
{item.dotColor ? (
|
|
159
|
+
<span
|
|
160
|
+
aria-hidden="true"
|
|
161
|
+
className="size-2.5 shrink-0 rounded-full"
|
|
162
|
+
style={{ backgroundColor: item.dotColor }}
|
|
163
|
+
/>
|
|
164
|
+
) : (
|
|
165
|
+
<span
|
|
166
|
+
aria-hidden="true"
|
|
167
|
+
className={cn(
|
|
168
|
+
item.icon,
|
|
169
|
+
"size-4 shrink-0",
|
|
170
|
+
item.danger ? "text-destructive" : active ? "text-foreground" : "text-muted-foreground",
|
|
171
|
+
)}
|
|
172
|
+
/>
|
|
173
|
+
)}
|
|
174
|
+
<span className={cn("min-w-0 flex-1 truncate text-[13px]", item.danger ? "text-destructive" : "text-foreground")}>
|
|
175
|
+
{item.label}
|
|
176
|
+
</span>
|
|
177
|
+
{item.checked && <span aria-hidden="true" className="icon-[solar--check-read-linear] size-4 shrink-0 text-primary" />}
|
|
178
|
+
{item.shortcut && <Kbd>{item.shortcut}</Kbd>}
|
|
179
|
+
</button>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
interface VirtualRowsProps {
|
|
184
|
+
readonly rows: readonly CommandMenuItemView[];
|
|
185
|
+
readonly scrollRef: { current: HTMLDivElement | null };
|
|
186
|
+
readonly selectedId: string | null;
|
|
187
|
+
readonly onHoverRow: (id: string) => void;
|
|
188
|
+
readonly onOpenRow: (id: string) => void;
|
|
189
|
+
readonly onMoreRow: (id: string) => void;
|
|
190
|
+
readonly moreLabel: string;
|
|
191
|
+
readonly registerRef: (id: string, element: HTMLButtonElement | null) => void;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** 会话成百上千时,只挂载可视窗口里的几十行;悬停 / 方向键切换选中也只重渲染这几行。 */
|
|
195
|
+
function VirtualRows({
|
|
196
|
+
rows,
|
|
197
|
+
scrollRef,
|
|
198
|
+
selectedId,
|
|
199
|
+
onHoverRow,
|
|
200
|
+
onOpenRow,
|
|
201
|
+
onMoreRow,
|
|
202
|
+
moreLabel,
|
|
203
|
+
registerRef,
|
|
204
|
+
}: VirtualRowsProps): JSX.Element {
|
|
205
|
+
const virtualizer = useVirtualizer({
|
|
206
|
+
count: rows.length,
|
|
207
|
+
getScrollElement: () => scrollRef.current,
|
|
208
|
+
estimateSize: () => ROW_HEIGHT,
|
|
209
|
+
getItemKey: (index) => rows[index]?.id ?? index,
|
|
210
|
+
overscan: VIRTUAL_OVERSCAN,
|
|
211
|
+
initialRect: { width: 0, height: LIST_FALLBACK_HEIGHT },
|
|
212
|
+
});
|
|
213
|
+
useEffect(() => {
|
|
214
|
+
if (!selectedId) return;
|
|
215
|
+
const index = rows.findIndex((row) => row.id === selectedId);
|
|
216
|
+
if (index >= 0) virtualizer.scrollToIndex(index, { align: "auto" });
|
|
217
|
+
}, [selectedId, rows, virtualizer]);
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<div className="relative w-full" style={{ height: virtualizer.getTotalSize() }}>
|
|
221
|
+
{virtualizer.getVirtualItems().map((item) => {
|
|
222
|
+
const row = rows[item.index];
|
|
223
|
+
if (!row) return null;
|
|
224
|
+
return (
|
|
225
|
+
<div
|
|
226
|
+
key={item.key}
|
|
227
|
+
className="absolute left-0 top-0 w-full"
|
|
228
|
+
style={{ height: item.size, transform: `translateY(${item.start}px)` }}
|
|
229
|
+
>
|
|
230
|
+
<CommandMenuRow
|
|
231
|
+
item={row}
|
|
232
|
+
active={row.id === selectedId}
|
|
233
|
+
suppressSelectionAnimation={false}
|
|
234
|
+
onActivate={onOpenRow}
|
|
235
|
+
onHover={onHoverRow}
|
|
236
|
+
onMore={onMoreRow}
|
|
237
|
+
moreLabel={moreLabel}
|
|
238
|
+
registerRef={registerRef}
|
|
239
|
+
/>
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
})}
|
|
243
|
+
</div>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function ManageSessionsSplashView(props: ManageSessionsSplashViewProps): JSX.Element {
|
|
248
|
+
const {
|
|
249
|
+
open,
|
|
250
|
+
step,
|
|
251
|
+
labels,
|
|
252
|
+
modifierLabel,
|
|
253
|
+
onClose,
|
|
254
|
+
tabs,
|
|
255
|
+
activeTabId,
|
|
256
|
+
onSelectTab,
|
|
257
|
+
query,
|
|
258
|
+
onQueryChange,
|
|
259
|
+
rows,
|
|
260
|
+
selectedId,
|
|
261
|
+
onHoverRow,
|
|
262
|
+
onOpenRow,
|
|
263
|
+
onMoreRow,
|
|
264
|
+
clearAllVisible,
|
|
265
|
+
clearAllDisabled,
|
|
266
|
+
clearAllDisabledReason,
|
|
267
|
+
onClearAll,
|
|
268
|
+
menuTitle,
|
|
269
|
+
menuItems,
|
|
270
|
+
menuActiveId,
|
|
271
|
+
onHoverMenuItem,
|
|
272
|
+
onSelectMenuItem,
|
|
273
|
+
renameValue,
|
|
274
|
+
onRenameChange,
|
|
275
|
+
onRenameSubmit,
|
|
276
|
+
onBack,
|
|
277
|
+
} = props;
|
|
278
|
+
const rowRefs = useRef(new Map<string, HTMLButtonElement>());
|
|
279
|
+
const registerRef = useCallback((id: string, element: HTMLButtonElement | null) => {
|
|
280
|
+
if (element) rowRefs.current.set(id, element);
|
|
281
|
+
else rowRefs.current.delete(id);
|
|
282
|
+
}, []);
|
|
283
|
+
|
|
284
|
+
const listRef = useRef<HTMLDivElement | null>(null);
|
|
285
|
+
const followId = step === "menu" ? menuActiveId : step === "list" ? selectedId : null;
|
|
286
|
+
// 与命令面板同理:用 nearest 且不带 smooth,连续按方向键时平滑滚动会排队堆积。
|
|
287
|
+
// 虚拟列表里目标行可能没挂载,改由 VirtualRows 自己按下标滚动。
|
|
288
|
+
useEffect(() => {
|
|
289
|
+
if (!open || !followId) return;
|
|
290
|
+
if (step === "list" && rows.length > VIRTUALIZE_THRESHOLD) return;
|
|
291
|
+
rowRefs.current.get(followId)?.scrollIntoView?.({ block: "nearest" });
|
|
292
|
+
}, [open, followId, step, rows.length]);
|
|
293
|
+
|
|
294
|
+
const showTabs = step === "list" && tabs.length > 1;
|
|
295
|
+
const listHeader = (
|
|
296
|
+
<>
|
|
297
|
+
<SplashInputHeader
|
|
298
|
+
icon="icon-[solar--magnifer-linear]"
|
|
299
|
+
value={query}
|
|
300
|
+
placeholder={labels.searchPlaceholder}
|
|
301
|
+
label={labels.searchLabel}
|
|
302
|
+
onChange={onQueryChange}
|
|
303
|
+
onSubmit={() => {
|
|
304
|
+
if (selectedId) onOpenRow(selectedId);
|
|
305
|
+
}}
|
|
306
|
+
/>
|
|
307
|
+
{showTabs && (
|
|
308
|
+
<div role="tablist" className="flex shrink-0 items-center gap-1 overflow-x-auto px-3 pb-2">
|
|
309
|
+
{tabs.map((tab) => (
|
|
310
|
+
<button
|
|
311
|
+
key={tab.id}
|
|
312
|
+
type="button"
|
|
313
|
+
role="tab"
|
|
314
|
+
tabIndex={-1}
|
|
315
|
+
aria-selected={tab.id === activeTabId}
|
|
316
|
+
onClick={() => onSelectTab(tab.id)}
|
|
317
|
+
className={cn(
|
|
318
|
+
"flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-0.5 text-[12px] outline-none transition-colors",
|
|
319
|
+
tab.id === activeTabId
|
|
320
|
+
? "bg-primary/10 text-foreground"
|
|
321
|
+
: "text-muted-foreground hover:bg-accent hover:text-foreground",
|
|
322
|
+
)}
|
|
323
|
+
>
|
|
324
|
+
{tab.dotColor && (
|
|
325
|
+
<span aria-hidden="true" className="size-2 rounded-full" style={{ backgroundColor: tab.dotColor }} />
|
|
326
|
+
)}
|
|
327
|
+
{tab.label}
|
|
328
|
+
</button>
|
|
329
|
+
))}
|
|
330
|
+
</div>
|
|
331
|
+
)}
|
|
332
|
+
</>
|
|
333
|
+
);
|
|
334
|
+
const header =
|
|
335
|
+
step === "list" ? (
|
|
336
|
+
listHeader
|
|
337
|
+
) : step === "rename" ? (
|
|
338
|
+
<SplashInputHeader
|
|
339
|
+
icon="icon-[solar--pen-2-linear]"
|
|
340
|
+
value={renameValue}
|
|
341
|
+
placeholder={labels.renamePlaceholder}
|
|
342
|
+
label={labels.renameLabel}
|
|
343
|
+
onChange={onRenameChange}
|
|
344
|
+
onSubmit={onRenameSubmit}
|
|
345
|
+
onBack={onBack}
|
|
346
|
+
backLabel={labels.back}
|
|
347
|
+
/>
|
|
348
|
+
) : (
|
|
349
|
+
<SplashTitleHeader title={menuTitle} variant="plain" onBack={onBack} backLabel={labels.back} />
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
const footer =
|
|
353
|
+
step === "list" ? (
|
|
354
|
+
// 窄窗口下提示与按钮整组换行,而不是把每个提示挤成两三行。
|
|
355
|
+
<SplashFooter className="flex-wrap gap-x-3 gap-y-1 py-1.5">
|
|
356
|
+
<Hint keys={[modifierLabel, "X"]} label={labels.hintDelete} />
|
|
357
|
+
<Hint keys={[modifierLabel, "K"]} label={labels.hintMore} />
|
|
358
|
+
{showTabs && <Hint keys={["Tab"]} label={labels.hintTab} />}
|
|
359
|
+
<span className="ml-auto flex items-center gap-3 whitespace-nowrap">
|
|
360
|
+
{clearAllVisible && (
|
|
361
|
+
<button
|
|
362
|
+
type="button"
|
|
363
|
+
disabled={clearAllDisabled}
|
|
364
|
+
title={clearAllDisabled ? clearAllDisabledReason : undefined}
|
|
365
|
+
onClick={onClearAll}
|
|
366
|
+
className="rounded px-1 text-destructive outline-none transition-colors hover:bg-destructive/10 focus-visible:bg-destructive/10 disabled:cursor-not-allowed disabled:text-muted-foreground/50 disabled:hover:bg-transparent"
|
|
367
|
+
>
|
|
368
|
+
{labels.clearAll}
|
|
369
|
+
</button>
|
|
370
|
+
)}
|
|
371
|
+
<span>{labels.hintClose}</span>
|
|
372
|
+
</span>
|
|
373
|
+
</SplashFooter>
|
|
374
|
+
) : step === "rename" ? (
|
|
375
|
+
<SplashFooter>
|
|
376
|
+
<span>{labels.hintRename}</span>
|
|
377
|
+
<span className="ml-auto">{labels.hintBack}</span>
|
|
378
|
+
</SplashFooter>
|
|
379
|
+
) : (
|
|
380
|
+
<SplashFooter>
|
|
381
|
+
<span>{labels.hintSelect}</span>
|
|
382
|
+
<span className="ml-auto">{labels.hintBack}</span>
|
|
383
|
+
</SplashFooter>
|
|
384
|
+
);
|
|
385
|
+
|
|
386
|
+
return (
|
|
387
|
+
<SplashPanel open={open} onClose={onClose} label={labels.title} width="560px" header={header} footer={footer}>
|
|
388
|
+
<SplashStep stepKey={step}>
|
|
389
|
+
{step === "list" && (
|
|
390
|
+
<div ref={listRef} role="listbox" aria-label={labels.title} className={LIST_CLASS}>
|
|
391
|
+
{rows.length > VIRTUALIZE_THRESHOLD ? (
|
|
392
|
+
<VirtualRows
|
|
393
|
+
rows={rows}
|
|
394
|
+
scrollRef={listRef}
|
|
395
|
+
selectedId={selectedId}
|
|
396
|
+
onHoverRow={onHoverRow}
|
|
397
|
+
onOpenRow={onOpenRow}
|
|
398
|
+
onMoreRow={onMoreRow}
|
|
399
|
+
moreLabel={labels.hintMore}
|
|
400
|
+
registerRef={registerRef}
|
|
401
|
+
/>
|
|
402
|
+
) : (
|
|
403
|
+
rows.map((row) => (
|
|
404
|
+
<CommandMenuRow
|
|
405
|
+
key={row.id}
|
|
406
|
+
item={row}
|
|
407
|
+
active={row.id === selectedId}
|
|
408
|
+
suppressSelectionAnimation={false}
|
|
409
|
+
onActivate={onOpenRow}
|
|
410
|
+
onHover={onHoverRow}
|
|
411
|
+
onMore={onMoreRow}
|
|
412
|
+
moreLabel={labels.hintMore}
|
|
413
|
+
registerRef={registerRef}
|
|
414
|
+
/>
|
|
415
|
+
))
|
|
416
|
+
)}
|
|
417
|
+
{rows.length === 0 && (
|
|
418
|
+
<div className="px-3 py-10 text-center text-[13px] text-muted-foreground">{labels.empty}</div>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
)}
|
|
422
|
+
{step === "menu" && (
|
|
423
|
+
<div role="menu" aria-label={menuTitle} className={LIST_CLASS}>
|
|
424
|
+
{menuItems.map((item) => (
|
|
425
|
+
<MenuRow
|
|
426
|
+
key={item.id}
|
|
427
|
+
item={item}
|
|
428
|
+
active={item.id === menuActiveId}
|
|
429
|
+
onHover={onHoverMenuItem}
|
|
430
|
+
onSelect={onSelectMenuItem}
|
|
431
|
+
registerRef={registerRef}
|
|
432
|
+
/>
|
|
433
|
+
))}
|
|
434
|
+
</div>
|
|
435
|
+
)}
|
|
436
|
+
</SplashStep>
|
|
437
|
+
</SplashPanel>
|
|
438
|
+
);
|
|
439
|
+
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState, type JSX } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
DialogContent,
|
|
6
|
-
DialogDescription,
|
|
7
|
-
DialogFooter,
|
|
8
|
-
DialogHeader,
|
|
9
|
-
DialogTitle,
|
|
10
|
-
Input,
|
|
11
|
-
} from "@vetta-org/ui";
|
|
2
|
+
import { Button } from "@vetta-org/ui/button";
|
|
3
|
+
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@vetta-org/ui/dialog";
|
|
4
|
+
import { Input } from "@vetta-org/ui/input";
|
|
12
5
|
|
|
13
6
|
export interface NewProjectDialogViewLabels {
|
|
14
7
|
readonly title: string;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import { ContextMenuView, type ContextMenuNode } from "../shared/ContextMenuView";
|
|
3
3
|
|
|
4
4
|
export type ProjectContextMenuScope = "conversation" | "claw";
|
|
5
5
|
|
|
6
6
|
export interface ProjectContextMenuViewLabels {
|
|
7
7
|
openInFolder: string;
|
|
8
|
+
manageSessions: string;
|
|
8
9
|
archiveProject: string;
|
|
9
10
|
removeFromList: string;
|
|
10
|
-
deleteProject: string;
|
|
11
11
|
clearConversation: string;
|
|
12
12
|
clearConversationDisabled: string;
|
|
13
13
|
clearClaw: string;
|
|
@@ -16,16 +16,18 @@ export interface ProjectContextMenuViewLabels {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface ProjectContextMenuViewProps {
|
|
19
|
+
canOpenInFolder?: boolean;
|
|
19
20
|
clearClawDisabled?: boolean;
|
|
20
21
|
clearConversationDisabled?: boolean;
|
|
21
22
|
defaultScope?: ProjectContextMenuScope;
|
|
23
|
+
extraItems?: readonly ContextMenuNode[];
|
|
22
24
|
isDefault: boolean;
|
|
23
25
|
labels: ProjectContextMenuViewLabels;
|
|
24
26
|
onArchive: () => void;
|
|
25
27
|
onClearClaw?: () => void;
|
|
26
28
|
onClearConversation?: () => void;
|
|
27
29
|
onClose: () => void;
|
|
28
|
-
|
|
30
|
+
onManageSessions?: () => void;
|
|
29
31
|
onOpenClawSettings?: () => void;
|
|
30
32
|
onOpenInFolder: () => void;
|
|
31
33
|
onRemove: () => void;
|
|
@@ -34,154 +36,43 @@ export interface ProjectContextMenuViewProps {
|
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export function ProjectContextMenuView({
|
|
39
|
+
canOpenInFolder = true,
|
|
37
40
|
clearClawDisabled,
|
|
38
41
|
clearConversationDisabled,
|
|
39
42
|
defaultScope,
|
|
43
|
+
extraItems = [],
|
|
40
44
|
isDefault,
|
|
41
45
|
labels,
|
|
42
46
|
onArchive,
|
|
43
47
|
onClearClaw,
|
|
44
48
|
onClearConversation,
|
|
45
49
|
onClose,
|
|
46
|
-
|
|
50
|
+
onManageSessions,
|
|
47
51
|
onOpenClawSettings,
|
|
48
52
|
onOpenInFolder,
|
|
49
53
|
onRemove,
|
|
50
54
|
x,
|
|
51
55
|
y,
|
|
52
56
|
}: ProjectContextMenuViewProps): JSX.Element {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
document.addEventListener("mousedown", handleClick);
|
|
75
|
-
return () => document.removeEventListener("mousedown", handleClick);
|
|
76
|
-
}, [onClose]);
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
function handleKey(e: KeyboardEvent) {
|
|
80
|
-
if (e.key === "Escape") onClose();
|
|
81
|
-
}
|
|
82
|
-
document.addEventListener("keydown", handleKey);
|
|
83
|
-
return () => document.removeEventListener("keydown", handleKey);
|
|
84
|
-
}, [onClose]);
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<AnimatePresence>
|
|
88
|
-
<motion.div
|
|
89
|
-
ref={menuRef}
|
|
90
|
-
initial={{ opacity: 0, scale: 0.95 }}
|
|
91
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
92
|
-
exit={{ opacity: 0, scale: 0.95 }}
|
|
93
|
-
transition={{ duration: 0.12, ease: [0.25, 0.1, 0.25, 1] }}
|
|
94
|
-
className="fixed z-[1000] w-[160px] overflow-hidden rounded-lg border border-border bg-popover p-1 shadow-xl"
|
|
95
|
-
style={{ left: `${adjustedPos.x}px`, top: `${adjustedPos.y}px` }}
|
|
96
|
-
>
|
|
97
|
-
{!isDefault && (
|
|
98
|
-
<button
|
|
99
|
-
type="button"
|
|
100
|
-
onClick={onOpenInFolder}
|
|
101
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-foreground transition-colors hover:bg-accent"
|
|
102
|
-
>
|
|
103
|
-
<span className="icon-[solar--folder-open-linear] h-3.5 w-3.5" />
|
|
104
|
-
{labels.openInFolder}
|
|
105
|
-
</button>
|
|
106
|
-
)}
|
|
107
|
-
{isDefault && defaultScope === "conversation" && onClearConversation && (
|
|
108
|
-
<button
|
|
109
|
-
type="button"
|
|
110
|
-
disabled={clearConversationDisabled}
|
|
111
|
-
title={clearConversationDisabled ? labels.clearConversationDisabled : undefined}
|
|
112
|
-
onClick={() => {
|
|
113
|
-
if (clearConversationDisabled) return;
|
|
114
|
-
onClearConversation();
|
|
115
|
-
}}
|
|
116
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-destructive transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:text-muted-foreground/50 disabled:hover:bg-transparent"
|
|
117
|
-
>
|
|
118
|
-
<span className="icon-[solar--broom-linear] h-3.5 w-3.5" />
|
|
119
|
-
{labels.clearConversation}
|
|
120
|
-
</button>
|
|
121
|
-
)}
|
|
122
|
-
{isDefault && defaultScope === "claw" && (
|
|
123
|
-
<>
|
|
124
|
-
{onClearClaw && (
|
|
125
|
-
<button
|
|
126
|
-
type="button"
|
|
127
|
-
disabled={clearClawDisabled}
|
|
128
|
-
title={clearClawDisabled ? labels.clearClawDisabled : undefined}
|
|
129
|
-
onClick={() => {
|
|
130
|
-
if (clearClawDisabled) return;
|
|
131
|
-
onClearClaw();
|
|
132
|
-
}}
|
|
133
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-destructive transition-colors hover:bg-accent disabled:cursor-not-allowed disabled:text-muted-foreground/50 disabled:hover:bg-transparent"
|
|
134
|
-
>
|
|
135
|
-
<span className="icon-[solar--broom-linear] h-3.5 w-3.5" />
|
|
136
|
-
{labels.clearClaw}
|
|
137
|
-
</button>
|
|
138
|
-
)}
|
|
139
|
-
{onOpenClawSettings && (
|
|
140
|
-
<button
|
|
141
|
-
type="button"
|
|
142
|
-
onClick={onOpenClawSettings}
|
|
143
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-foreground transition-colors hover:bg-accent"
|
|
144
|
-
>
|
|
145
|
-
<span className="icon-[solar--settings-linear] h-3.5 w-3.5" />
|
|
146
|
-
{labels.clawSettings}
|
|
147
|
-
</button>
|
|
148
|
-
)}
|
|
149
|
-
</>
|
|
150
|
-
)}
|
|
151
|
-
{!isDefault && (
|
|
152
|
-
<button
|
|
153
|
-
type="button"
|
|
154
|
-
onClick={onArchive}
|
|
155
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-foreground transition-colors hover:bg-accent"
|
|
156
|
-
>
|
|
157
|
-
<span className="icon-[solar--archive-minimalistic-linear] h-3.5 w-3.5" />
|
|
158
|
-
{labels.archiveProject}
|
|
159
|
-
</button>
|
|
160
|
-
)}
|
|
161
|
-
{!isDefault && (
|
|
162
|
-
<button
|
|
163
|
-
type="button"
|
|
164
|
-
onClick={onRemove}
|
|
165
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-foreground transition-colors hover:bg-accent"
|
|
166
|
-
>
|
|
167
|
-
<span className="icon-[solar--list-cross-minimalistic-linear] h-3.5 w-3.5" />
|
|
168
|
-
{labels.removeFromList}
|
|
169
|
-
</button>
|
|
170
|
-
)}
|
|
171
|
-
{!isDefault && (
|
|
172
|
-
<>
|
|
173
|
-
<div className="mx-1.5 my-1 h-px bg-border" />
|
|
174
|
-
<button
|
|
175
|
-
type="button"
|
|
176
|
-
onClick={onDelete}
|
|
177
|
-
className="flex w-full items-center gap-2 rounded-md px-2 py-[5px] text-[12px] font-medium text-destructive transition-colors hover:bg-accent"
|
|
178
|
-
>
|
|
179
|
-
<span className="icon-[solar--trash-bin-trash-linear] h-3.5 w-3.5" />
|
|
180
|
-
{labels.deleteProject}
|
|
181
|
-
</button>
|
|
182
|
-
</>
|
|
183
|
-
)}
|
|
184
|
-
</motion.div>
|
|
185
|
-
</AnimatePresence>
|
|
186
|
-
);
|
|
57
|
+
const items: ContextMenuNode[] = [];
|
|
58
|
+
if (onManageSessions) items.push({ kind: "item", id: "manage", label: labels.manageSessions, iconClassName: "icon-[solar--checklist-minimalistic-linear]", onSelect: onManageSessions });
|
|
59
|
+
if (!isDefault && canOpenInFolder) items.push({ kind: "item", id: "folder", label: labels.openInFolder, iconClassName: "icon-[solar--folder-open-linear]", onSelect: onOpenInFolder });
|
|
60
|
+
items.push(...extraItems);
|
|
61
|
+
if (isDefault && defaultScope === "conversation" && onClearConversation) items.push({
|
|
62
|
+
kind: "item", id: "clear-conversation", label: labels.clearConversation, title: clearConversationDisabled ? labels.clearConversationDisabled : undefined,
|
|
63
|
+
iconClassName: "icon-[solar--broom-linear]", danger: true, disabled: clearConversationDisabled, onSelect: onClearConversation,
|
|
64
|
+
});
|
|
65
|
+
if (isDefault && defaultScope === "claw") {
|
|
66
|
+
if (onClearClaw) items.push({ kind: "item", id: "clear-claw", label: labels.clearClaw, title: clearClawDisabled ? labels.clearClawDisabled : undefined,
|
|
67
|
+
iconClassName: "icon-[solar--broom-linear]", danger: true, disabled: clearClawDisabled, onSelect: onClearClaw });
|
|
68
|
+
if (onOpenClawSettings) items.push({ kind: "item", id: "claw-settings", label: labels.clawSettings, iconClassName: "icon-[solar--settings-linear]", onSelect: onOpenClawSettings });
|
|
69
|
+
}
|
|
70
|
+
if (!isDefault) {
|
|
71
|
+
if (items.length > 0) items.push({ kind: "separator", id: "project-actions" });
|
|
72
|
+
items.push(
|
|
73
|
+
{ kind: "item", id: "archive", label: labels.archiveProject, iconClassName: "icon-[solar--archive-minimalistic-linear]", onSelect: onArchive },
|
|
74
|
+
{ kind: "item", id: "remove", label: labels.removeFromList, iconClassName: "icon-[solar--list-cross-minimalistic-linear]", onSelect: onRemove },
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return <ContextMenuView items={items} onClose={onClose} x={x} y={y} />;
|
|
187
78
|
}
|