@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.
Files changed (340) hide show
  1. package/package.json +740 -20
  2. package/src/action-approval/AppearanceActionPickerView.tsx +2 -78
  3. package/src/action-approval/AppearanceApprovalDrawerView.tsx +2 -9
  4. package/src/action-approval/BatchTasksApprovalFrameView.tsx +4 -1
  5. package/src/action-approval/GenericActionApprovalView.tsx +2 -9
  6. package/src/action-approval/ManageActionApprovalFrameView.tsx +4 -1
  7. package/src/action-approval/NavigationOpenApprovalView.tsx +2 -9
  8. package/src/action-approval/SchedulerActionApprovalDialogView.tsx +3 -1
  9. package/src/action-approval/SchedulerEditApprovalDrawerView.tsx +3 -10
  10. package/src/action-approval/index.ts +0 -1
  11. package/src/activity/ActivityPanel.tsx +13 -10
  12. package/src/activity/ActivityPanelFrame.test.tsx +32 -0
  13. package/src/activity/ActivityPanelFrame.tsx +3 -2
  14. package/src/activity/BackgroundTasksTabPanelView.tsx +1 -1
  15. package/src/activity/BrowserPanelView.tsx +48 -49
  16. package/src/activity/CodePreview.tsx +15 -1
  17. package/src/activity/DebugTabPanelView.tsx +1 -1
  18. package/src/activity/MarkdownPreviewView.test.tsx +53 -0
  19. package/src/activity/MarkdownPreviewView.tsx +135 -62
  20. package/src/activity/PluginTabPickerView.tsx +5 -3
  21. package/src/activity/PortsTabPanelView.tsx +911 -0
  22. package/src/activity/ToolCallsSubTabView.tsx +1 -1
  23. package/src/activity/WorkflowTabPanelView.tsx +1 -1
  24. package/src/activity/index.ts +9 -0
  25. package/src/app/AppBackground.tsx +1 -1
  26. package/src/app/AppBootLoadingView.tsx +4 -2
  27. package/src/app-shell/DefaultWindowControls.tsx +1 -1
  28. package/src/app-shell/PageHeaderActionGroup.tsx +1 -1
  29. package/src/app-shell/PageHeaderContent.tsx +36 -7
  30. package/src/app-shell/PageHeaderFrame.tsx +15 -3
  31. package/src/app-shell/PageHeaderSidebarTrigger.tsx +1 -1
  32. package/src/app-shell/PageHeaderTitle.tsx +1 -1
  33. package/src/app-shell/WindowControlButton.tsx +1 -1
  34. package/src/app-shell/header-crowding.test.ts +62 -0
  35. package/src/app-shell/header-crowding.tsx +137 -0
  36. package/src/appearance/BackgroundImageFrame.tsx +1 -1
  37. package/src/appearance/CenterSliceImageFrame.tsx +1 -1
  38. package/src/appearance/CornerImageFrame.tsx +1 -1
  39. package/src/appearance/HorizontalSliceImageFrame.tsx +1 -1
  40. package/src/appearance/NineSliceImageFrame.tsx +1 -1
  41. package/src/appearance/ThemeSurface.tsx +1 -1
  42. package/src/batch-tasks/BatchProjectFoldersFieldView.tsx +2 -1
  43. package/src/batch-tasks/BatchTaskProjectActionsView.test.tsx +97 -0
  44. package/src/batch-tasks/BatchTaskProjectActionsView.tsx +45 -35
  45. package/src/batch-tasks/batchTaskUi.tsx +0 -29
  46. package/src/bottom-panel/BottomPanelView.test.tsx +43 -0
  47. package/src/bottom-panel/BottomPanelView.tsx +222 -0
  48. package/src/bottom-panel/index.ts +26 -0
  49. package/src/chat/AgentAvatarView.tsx +1 -1
  50. package/src/chat/AnnotationViews.tsx +107 -0
  51. package/src/chat/AskUserQuestionView.tsx +18 -11
  52. package/src/chat/AssistantMessageView.tsx +48 -13
  53. package/src/chat/AtPanelView.test.tsx +61 -0
  54. package/src/chat/AtPanelView.tsx +63 -38
  55. package/src/chat/BashTerminalCard.tsx +1 -2
  56. package/src/chat/ChatHeaderActionsView.tsx +74 -18
  57. package/src/chat/CompactionStepView.test.tsx +34 -0
  58. package/src/chat/CompactionStepView.tsx +85 -0
  59. package/src/chat/ContextRingView.test.tsx +81 -0
  60. package/src/chat/ContextRingView.tsx +78 -62
  61. package/src/chat/ExecutionModeSelectorView.tsx +20 -5
  62. package/src/chat/HeaderActionBarView.tsx +806 -0
  63. package/src/chat/HeaderActionOverflowMenu.tsx +128 -0
  64. package/src/chat/InlineModelPicker.test.tsx +81 -0
  65. package/src/chat/InlineModelPicker.tsx +201 -0
  66. package/src/chat/InlineTokenChip.tsx +2 -68
  67. package/src/chat/InputBarBackground.tsx +1 -1
  68. package/src/chat/InputBarPlaceholder.tsx +26 -3
  69. package/src/chat/LiveThinkingView.tsx +51 -37
  70. package/src/chat/MessageBoundaryViews.tsx +21 -0
  71. package/src/chat/MessageFeedContext.tsx +13 -5
  72. package/src/chat/MessageFeedLayoutView.tsx +29 -3
  73. package/src/chat/MessageFeedView.test.tsx +81 -0
  74. package/src/chat/MessageFeedView.tsx +72 -152
  75. package/src/chat/MessageInputView.tsx +6 -2
  76. package/src/chat/MessageLayoutView.tsx +1 -1
  77. package/src/chat/MessageSelectionContextMenuView.tsx +4 -1
  78. package/src/chat/MessageTimelineView.tsx +1 -1
  79. package/src/chat/MessageView.tsx +1 -1
  80. package/src/chat/MessageVisualView.tsx +1 -1
  81. package/src/chat/ModelConfiguration.tsx +283 -0
  82. package/src/chat/ModelSelectorTrigger.tsx +63 -0
  83. package/src/chat/ModelSelectorView.tsx +1037 -223
  84. package/src/chat/NewSession.ts +1 -37
  85. package/src/chat/NewSessionPicker.tsx +3 -2
  86. package/src/chat/ProjectSelectorView.tsx +3 -2
  87. package/src/chat/ReasoningStepSlider.tsx +61 -0
  88. package/src/chat/RemoteSessionBadgeView.tsx +24 -0
  89. package/src/chat/SkillPromptAreaView.tsx +5 -19
  90. package/src/chat/TeamMemberReplyCardView.test.tsx +33 -0
  91. package/src/chat/TeamMemberReplyCardView.tsx +133 -0
  92. package/src/chat/TextBlockView.tsx +7 -770
  93. package/src/chat/TodoProgress.tsx +25 -53
  94. package/src/chat/TodoStatusBarView.tsx +14 -5
  95. package/src/chat/UserMessageView.tsx +113 -33
  96. package/src/chat/header-action-narrow.test.ts +21 -0
  97. package/src/chat/header-action-narrow.ts +38 -0
  98. package/src/chat/index.ts +33 -27
  99. package/src/chat/markdown-link.ts +7 -279
  100. package/src/chat/message-feed-fade.css +80 -0
  101. package/src/chat/message-feed-fade.test.tsx +75 -0
  102. package/src/chat/send-button.css +4 -22
  103. package/src/chat/streaming-reveal.test.ts +218 -0
  104. package/src/chat/streaming-reveal.ts +13 -0
  105. package/src/file-explorer/ConfirmDeleteDialogView.tsx +2 -1
  106. package/src/file-explorer/FileContextMenuView.tsx +44 -11
  107. package/src/file-explorer/FileExplorerSettingsView.tsx +97 -0
  108. package/src/file-explorer/FileTreeCreateRow.tsx +1 -1
  109. package/src/file-explorer/FileTreeNodeView.tsx +59 -18
  110. package/src/file-explorer/FileTreeView.tsx +236 -129
  111. package/src/file-explorer/file-tree-dom.ts +23 -0
  112. package/src/file-explorer/file-tree-rows.test.ts +74 -0
  113. package/src/file-explorer/file-tree-rows.ts +168 -0
  114. package/src/file-explorer/index.ts +17 -0
  115. package/src/file-explorer/types.ts +3 -0
  116. package/src/file-explorer/useFileTreeMarqueeSelection.ts +24 -16
  117. package/src/file-preview/FilePreviewDialogView.tsx +2 -2
  118. package/src/file-preview/FilePreviewView.tsx +12 -2
  119. package/src/file-preview/ReadonlyCodeView.tsx +46 -0
  120. package/src/file-preview/TextFileEditorView.tsx +2 -1
  121. package/src/file-preview/syntax-tokens.css +1 -1
  122. package/src/image-assets.d.ts +4 -0
  123. package/src/index.ts +1 -0
  124. package/src/knowledge/KnowledgeHowItWorksDialogView.tsx +1 -1
  125. package/src/layout/AppFrame.tsx +3 -2
  126. package/src/layout/MainContentFrame.tsx +7 -2
  127. package/src/layout/ResizeHandle.tsx +68 -17
  128. package/src/layout/SidebarDock.tsx +75 -19
  129. package/src/layout/SidebarOverlay.tsx +1 -1
  130. package/src/layout/index.ts +1 -1
  131. package/src/layout/resize-handle-axis.test.ts +51 -0
  132. package/src/live-indicators.test.ts +43 -0
  133. package/src/markdown/CodeBlock.tsx +123 -0
  134. package/src/markdown/FileLinkBadge.tsx +77 -0
  135. package/src/markdown/InlineTokenChip.tsx +68 -0
  136. package/src/markdown/MarkdownContent.tsx +418 -0
  137. package/src/markdown/MarkdownImage.tsx +41 -0
  138. package/src/markdown/MathFormula.tsx +46 -0
  139. package/src/markdown/MermaidBlock.tsx +82 -0
  140. package/src/markdown/RichCodeBlock.tsx +127 -0
  141. package/src/markdown/SvgPreview.tsx +45 -0
  142. package/src/markdown/WebsiteIcon.tsx +94 -0
  143. package/src/markdown/builtin-renderers.tsx +43 -0
  144. package/src/markdown/definition.tsx +49 -0
  145. package/src/markdown/host.tsx +18 -0
  146. package/src/markdown/image-actions.ts +29 -0
  147. package/src/markdown/index.ts +12 -0
  148. package/src/markdown/inline-tokens.ts +187 -0
  149. package/src/markdown/markdown-link.ts +279 -0
  150. package/src/markdown/math-client.ts +116 -0
  151. package/src/markdown/math-render.ts +23 -0
  152. package/src/markdown/math-syntax.ts +80 -0
  153. package/src/markdown/math.worker.ts +16 -0
  154. package/src/markdown/nodes.ts +15 -0
  155. package/src/markdown/preview-policy.test.ts +31 -0
  156. package/src/markdown/preview-policy.ts +76 -0
  157. package/src/markdown/progressive-chunks.test.ts +43 -0
  158. package/src/markdown/progressive-chunks.ts +58 -0
  159. package/src/markdown/rich-labels.ts +55 -0
  160. package/src/markdown/rich-syntax.ts +93 -0
  161. package/src/markdown/stable-blocks.test.ts +90 -0
  162. package/src/markdown/stable-blocks.ts +124 -0
  163. package/src/markdown/streaming-reveal.ts +297 -0
  164. package/src/markdown/streaming.test.ts +57 -0
  165. package/src/markdown/streaming.ts +211 -0
  166. package/src/markdown/use-render-snapshot.ts +24 -0
  167. package/src/markdown/use-rich-visibility.ts +24 -0
  168. package/src/overlays/CommandMenuRow.tsx +77 -17
  169. package/src/overlays/CommandMenuView.tsx +163 -118
  170. package/src/overlays/ConfirmDialogView.tsx +25 -20
  171. package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
  172. package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
  173. package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
  174. package/src/overlays/ReleaseNoteMarkdown.tsx +55 -0
  175. package/src/overlays/SplashOptionRow.tsx +46 -0
  176. package/src/overlays/SplashPanel.tsx +85 -0
  177. package/src/overlays/SplashParts.tsx +217 -0
  178. package/src/overlays/UpdateCheckerView.tsx +34 -18
  179. package/src/overlays/UpdateRestartDialogView.tsx +203 -53
  180. package/src/overlays/assets/diagnostics-banner.webp +0 -0
  181. package/src/overlays/command-menu-types.ts +15 -1
  182. package/src/overlays/command-menu.css +1 -20
  183. package/src/overlays/index.ts +26 -1
  184. package/src/plugin-ui/index.ts +10 -0
  185. package/src/project/ConversationTagDotsView.tsx +1 -1
  186. package/src/project/ConversationTagEditorDialogView.tsx +4 -1
  187. package/src/project/DefaultConversationSectionView.tsx +15 -24
  188. package/src/project/DefaultSessionListView.tsx +5 -31
  189. package/src/project/DefaultSessionRowView.tsx +114 -55
  190. package/src/project/ManageSessionsSplashView.tsx +439 -0
  191. package/src/project/NewProjectDialogView.tsx +3 -10
  192. package/src/project/ProjectContextMenuView.tsx +30 -139
  193. package/src/project/ProjectDetailPageView.test.tsx +140 -0
  194. package/src/project/ProjectDetailPageView.tsx +372 -165
  195. package/src/project/ProjectGroupView.tsx +1 -1
  196. package/src/project/ProjectRowView.tsx +29 -12
  197. package/src/project/ProjectSessionsView.tsx +25 -47
  198. package/src/project/QuickScrollOverlay.tsx +1 -1
  199. package/src/project/SessionContextMenuView.tsx +15 -7
  200. package/src/project/SessionRowMoreButton.tsx +50 -0
  201. package/src/project/SessionRowView.tsx +106 -63
  202. package/src/project/SessionTitleMarquee.tsx +54 -0
  203. package/src/project/SidebarProjectDisclosure.tsx +60 -0
  204. package/src/project/SidebarProjectsSectionView.tsx +6 -1
  205. package/src/project/index.ts +12 -0
  206. package/src/project/session-row-transition.ts +9 -0
  207. package/src/project/types.ts +4 -2
  208. package/src/project/useActiveSessionAutoScroll.ts +10 -4
  209. package/src/registry.ts +0 -2
  210. package/src/scheduler/AutomationDetailPaneView.tsx +68 -0
  211. package/src/scheduler/AutomationPageView.tsx +118 -121
  212. package/src/scheduler/ExecutionHistoryView.tsx +7 -5
  213. package/src/scheduler/TaskListView.tsx +52 -201
  214. package/src/scheduler/index.ts +7 -12
  215. package/src/settings/AppshotSettingsView.tsx +0 -1
  216. package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
  217. package/src/settings/BuiltinMcpSectionView.tsx +1 -1
  218. package/src/settings/EnvironmentGitRowView.tsx +156 -0
  219. package/src/settings/EnvironmentSettingsView.tsx +25 -3
  220. package/src/settings/GeneralSettingsView.tsx +18 -24
  221. package/src/settings/ImChannelGuideDialogView.tsx +2 -2
  222. package/src/settings/ImFeishuDialogView.tsx +1 -1
  223. package/src/settings/ImLegacyImportBannerView.tsx +1 -1
  224. package/src/settings/ImLogDrawerView.tsx +2 -1
  225. package/src/settings/JsonConfigInputView.tsx +171 -0
  226. package/src/settings/LauncherSettingsView.test.tsx +95 -0
  227. package/src/settings/LauncherSettingsView.tsx +273 -0
  228. package/src/settings/ModelsFetchedModelsDrawerView.tsx +292 -0
  229. package/src/settings/ModelsProvidersSectionView.tsx +26 -23
  230. package/src/settings/MotionSelect.tsx +9 -7
  231. package/src/settings/NotificationSettingsView.tsx +79 -0
  232. package/src/settings/PermissionsSettingsView.tsx +3 -7
  233. package/src/settings/PetActionGalleryView.test.tsx +163 -0
  234. package/src/settings/PetActionGalleryView.tsx +216 -0
  235. package/src/settings/PetSettingsView.test.tsx +117 -0
  236. package/src/settings/PetSettingsView.tsx +86 -22
  237. package/src/settings/PresetProviderModelsListView.tsx +141 -24
  238. package/src/settings/PresetProviderRowView.tsx +147 -185
  239. package/src/settings/ProxySettingsSectionView.tsx +182 -0
  240. package/src/settings/QrBindDialogView.tsx +1 -1
  241. package/src/settings/RemoteMcpSectionView.tsx +1 -1
  242. package/src/settings/SettingChrome.tsx +2 -2
  243. package/src/settings/SettingsAiAssistButtonView.tsx +9 -119
  244. package/src/settings/SettingsFormFields.tsx +4 -7
  245. package/src/settings/SettingsSidebarView.tsx +64 -3
  246. package/src/settings/ShortcutRecorderView.test.tsx +108 -0
  247. package/src/settings/ShortcutRecorderView.tsx +15 -9
  248. package/src/settings/ShortcutsSettingsView.tsx +1 -5
  249. package/src/settings/SpaceEditorDialogView.tsx +158 -0
  250. package/src/settings/SpacesSettingsView.tsx +150 -0
  251. package/src/settings/WebhookEndpointListView.tsx +4 -5
  252. package/src/settings/assets/space-editor-illustration.webp +0 -0
  253. package/src/settings/index.ts +59 -68
  254. package/src/shared/ActivityStatusDot.tsx +69 -0
  255. package/src/shared/AvatarStackView.tsx +13 -13
  256. package/src/shared/BotAvatar.tsx +11 -9
  257. package/src/shared/CodeBlockCopyButton.tsx +1 -1
  258. package/src/shared/ContextMenuView.tsx +4 -11
  259. package/src/shared/MarkdownTable.tsx +2 -2
  260. package/src/shared/SegmentedControl.test.tsx +68 -0
  261. package/src/shared/SegmentedControl.tsx +10 -2
  262. package/src/shared/SyntaxHighlightedCode.tsx +0 -0
  263. package/src/shared/TabBar.outline.test.tsx +59 -0
  264. package/src/shared/TabBar.tsx +23 -18
  265. package/src/shared/VettaKbd.test.tsx +52 -0
  266. package/src/shared/VettaKbd.tsx +100 -0
  267. package/src/shared/connected-tab-outline.test.ts +2 -2
  268. package/src/shared/connected-tab-outline.ts +2 -1
  269. package/src/shared/index.ts +7 -0
  270. package/src/shared/kbd-keys.test.ts +61 -0
  271. package/src/shared/kbd-keys.ts +253 -0
  272. package/src/shared/platform.ts +9 -0
  273. package/src/shared/provider-icon/icons.ts +4 -2
  274. package/src/shared/provider-icon/index.tsx +1 -1
  275. package/src/shared/provider-icon/magpie.svg +1 -0
  276. package/src/sidebar/AddProjectMenuTriggerView.tsx +33 -24
  277. package/src/sidebar/DefaultSidebar.tsx +3 -1
  278. package/src/sidebar/MessageCenterDialogView.tsx +3 -2
  279. package/src/sidebar/MessageCenterEmptyState.tsx +1 -1
  280. package/src/sidebar/MessageCenterTabs.tsx +1 -1
  281. package/src/sidebar/MessageCenterToolbarButton.tsx +1 -1
  282. package/src/sidebar/MessageCenterTriggerView.tsx +2 -2
  283. package/src/sidebar/ProjectsPanelEmptyState.tsx +26 -7
  284. package/src/sidebar/SessionStatusIcon.tsx +16 -1
  285. package/src/sidebar/SettingsMenuThemeSection.tsx +1 -1
  286. package/src/sidebar/SettingsMenuTriggerView.test.tsx +42 -0
  287. package/src/sidebar/SettingsMenuTriggerView.tsx +29 -50
  288. package/src/sidebar/ShowMoreSessionsButton.tsx +1 -1
  289. package/src/sidebar/SidebarFilterSelectView.tsx +8 -16
  290. package/src/sidebar/SidebarNavBadgeView.tsx +1 -1
  291. package/src/sidebar/SidebarNavIcon.tsx +1 -1
  292. package/src/sidebar/SidebarNavItemButton.tsx +1 -1
  293. package/src/sidebar/SidebarNavMorePanel.tsx +19 -7
  294. package/src/sidebar/SidebarNavigation.tsx +24 -15
  295. package/src/sidebar/SidebarPanel.tsx +11 -2
  296. package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
  297. package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
  298. package/src/sidebar/SidebarSectionTriggerLabel.tsx +20 -0
  299. package/src/sidebar/SidebarTopBar.tsx +10 -7
  300. package/src/sidebar/WaitingPulseBadge.tsx +19 -0
  301. package/src/sidebar/index.ts +1 -16
  302. package/src/skills/index.ts +0 -19
  303. package/src/skills/skill-icon.tsx +4 -8
  304. package/src/styles.css +26 -6
  305. package/src/chat/DefaultSceneCarousel.tsx +0 -113
  306. package/src/chat/SceneCard.tsx +0 -138
  307. package/src/scheduler/HistoryDrawerView.tsx +0 -149
  308. package/src/scheduler/TaskFormDialogView.tsx +0 -60
  309. package/src/settings/AchievementNavigationButtonView.tsx +0 -90
  310. package/src/settings/AchievementPromotionDialogView.tsx +0 -91
  311. package/src/settings/AchievementSettingsView.tsx +0 -44
  312. package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
  313. package/src/settings/QuickPanelSettingsSectionView.tsx +0 -66
  314. package/src/settings/SubscriptionActionsView.tsx +0 -63
  315. package/src/settings/SubscriptionCardsView.tsx +0 -212
  316. package/src/settings/TeamDetailView.tsx +0 -148
  317. package/src/settings/TeamDialogsView.tsx +0 -151
  318. package/src/settings/TeamListView.tsx +0 -57
  319. package/src/settings/TeamSettingsView.tsx +0 -51
  320. package/src/settings/TokenActivityChartView.tsx +0 -286
  321. package/src/settings/UsageStatsView.tsx +0 -101
  322. package/src/settings/achievements/AchievementCurtains.tsx +0 -50
  323. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
  324. package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
  325. package/src/settings/achievements/AchievementTitle.tsx +0 -52
  326. package/src/settings/achievements/index.ts +0 -13
  327. package/src/settings/shouldCloseEmptyApiKeyEditor.test.ts +0 -135
  328. package/src/settings/shouldCloseEmptyApiKeyEditor.ts +0 -40
  329. package/src/settings/token-activity.test.ts +0 -195
  330. package/src/settings/token-activity.ts +0 -320
  331. package/src/sidebar/AddProjectMenuItem.tsx +0 -21
  332. package/src/sidebar/AddProjectMenuPopoverView.tsx +0 -52
  333. package/src/sidebar/NotificationMessageListView.tsx +0 -136
  334. package/src/sidebar/SettingsMenuAccountSection.tsx +0 -32
  335. package/src/sidebar/SettingsMenuQuotaSection.tsx +0 -45
  336. package/src/skills/SceneCardView.tsx +0 -194
  337. package/src/skills/SkillCardView.tsx +0 -186
  338. package/src/skills/SkillDetailDialogView.tsx +0 -138
  339. package/src/skills/SkillTagGroupView.tsx +0 -56
  340. package/src/skills/SkillToggleSwitch.tsx +0 -31
@@ -1,14 +1,17 @@
1
- import type { JSX } from "react";
1
+ import type { JSX, ReactNode } from "react";
2
2
  import { useEffect, useState } from "react";
3
3
 
4
4
  /**
5
5
  * 逐字符入场改为纯 CSS:原来每个字符一个 motion.span,流式全程 JS 每帧写内联
6
6
  * style + 触发样式重算;CSS animation-delay 错峰能给出一模一样的画面,主线程零参与。
7
+ *
8
+ * 只动 opacity 和 transform:早先每个字符还带一段 blur(6px)→0,流式全程有几十个滤镜
9
+ * 动画同时在跑,每一帧都要重新栅格化;毛玻璃窗口上这类每帧重绘代价很高。
7
10
  */
8
11
  const STREAM_CHAR_CSS = `
9
12
  @keyframes stream-char-in {
10
- from { opacity: 0; filter: blur(6px); }
11
- to { opacity: 1; filter: blur(0px); }
13
+ from { opacity: 0; transform: translateY(3px); }
14
+ to { opacity: 1; transform: translateY(0); }
12
15
  }
13
16
  .stream-char {
14
17
  display: inline-block;
@@ -22,6 +25,7 @@ export interface AssistantMessageFoldLabels {
22
25
  waitingFold: (elapsed: number) => string;
23
26
  expandFold: (count: number) => string;
24
27
  collapseFold: (count: number) => string;
28
+ doneFold?: string;
25
29
  }
26
30
 
27
31
  function useElapsedSeconds(startedAt: number | undefined, active: boolean): number {
@@ -70,7 +74,7 @@ export function AssistantMessageFold({
70
74
  );
71
75
  }
72
76
  return (
73
- <div className="mb-3">
77
+ <div className={expanded ? "mb-0" : "mb-3"}>
74
78
  <button
75
79
  type="button"
76
80
  onClick={onToggle}
@@ -78,16 +82,22 @@ export function AssistantMessageFold({
78
82
  data-export-label-collapsed={labels.expandFold(count)}
79
83
  data-export-label-expanded={labels.collapseFold(count)}
80
84
  aria-expanded={expanded}
81
- className="mb-2 inline-flex w-fit items-center gap-1.5 rounded-lg py-1 pr-1.5 text-[12px] font-medium text-muted-foreground/55 transition-colors hover:bg-muted/60 hover:text-muted-foreground"
85
+ className="group inline-flex w-fit items-center gap-1.5 text-[14px] font-bold text-foreground transition-colors hover:opacity-85"
82
86
  >
83
87
  <span
84
- className={`icon-[mdi--chevron-right] h-3.5 w-3.5 shrink-0 transition-transform duration-200 ${expanded ? "rotate-90" : ""}`}
85
- />
86
- <span data-export-toggle-label="">
88
+ data-export-toggle-label=""
89
+ className={
90
+ expanded
91
+ ? ""
92
+ : "pb-0.5 [background-image:linear-gradient(to_right,color-mix(in_srgb,currentColor_40%,transparent)_6px,transparent_6px)] [background-position:bottom] [background-repeat:repeat-x] [background-size:9px_1px]"
93
+ }
94
+ >
87
95
  {expanded ? labels.collapseFold(count) : labels.expandFold(count)}
88
96
  </span>
97
+ <span
98
+ className={`icon-[mdi--chevron-right] h-4 w-4 shrink-0 transition-transform duration-200 ${expanded ? "rotate-90" : ""}`}
99
+ />
89
100
  </button>
90
- <div className="h-px w-full rounded-full bg-border/80" />
91
101
  </div>
92
102
  );
93
103
  }
@@ -126,10 +136,7 @@ export function StreamingIndicator({ phrases }: { phrases: string[] }): JSX.Elem
126
136
  export function AssistantMessageStreamingStatus({ label }: { readonly label: string }): JSX.Element {
127
137
  return (
128
138
  <>
129
- <span
130
- className="h-1.5 w-1.5 rounded-full bg-primary/60"
131
- style={{ animation: "pulse 1.5s infinite" }}
132
- />
139
+ <span className="vetta-live-dot h-1.5 w-1.5 rounded-full bg-primary/60" />
133
140
  <span className="text-[11px] text-muted-foreground/35">{label}</span>
134
141
  </>
135
142
  );
@@ -139,8 +146,36 @@ export function AssistantMessagePredictingStatus({ label }: { readonly label: st
139
146
  return <span className="processing-shimmer text-[11px] font-medium">{label}</span>;
140
147
  }
141
148
 
149
+ export function AssistantMessageProcessContainer({
150
+ children,
151
+ completedLabel = "完成",
152
+ }: {
153
+ readonly children: ReactNode;
154
+ readonly completedLabel?: string;
155
+ }): JSX.Element {
156
+ return (
157
+ <div className="relative mt-0.5 mb-2.5 flex flex-col gap-2">
158
+ <div
159
+ aria-hidden="true"
160
+ className="absolute left-2 -translate-x-1/2 -top-2 bottom-4 w-px bg-border/70"
161
+ />
162
+ <div className="flex flex-col gap-2 pl-6">
163
+ {children}
164
+ </div>
165
+ <div className="relative flex items-center gap-2 text-[14px] font-bold text-foreground">
166
+ <span
167
+ aria-hidden="true"
168
+ className="icon-[solar--check-circle-linear] h-4 w-4 shrink-0 text-foreground"
169
+ />
170
+ <span className="text-[14px] font-bold text-foreground">{completedLabel}</span>
171
+ </div>
172
+ </div>
173
+ );
174
+ }
175
+
142
176
  export const AssistantMessage = {
143
177
  Fold: AssistantMessageFold,
178
+ ProcessContainer: AssistantMessageProcessContainer,
144
179
  StreamingStatus: AssistantMessageStreamingStatus,
145
180
  PredictingStatus: AssistantMessagePredictingStatus,
146
181
  StreamingIndicator,
@@ -0,0 +1,61 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { createRef } from "react";
4
+ import { renderToStaticMarkup } from "react-dom/server";
5
+ import { describe, expect, it } from "vitest";
6
+ import { AtPanelView, type AtPanelEntryModel, type AtPanelViewProps } from "./AtPanelView";
7
+
8
+ const labels: AtPanelViewProps["labels"] = {
9
+ header: "Reference",
10
+ headingMeta: "/",
11
+ loading: "Loading",
12
+ noResults: "None",
13
+ emptyDirectory: "Empty",
14
+ goUp: "..",
15
+ enterDirectory: "Tab to enter",
16
+ citeDirectory: "Attach folder",
17
+ citeDirectoryHint: "Attach this folder (⌘↩)",
18
+ };
19
+
20
+ function entry(overrides: Partial<AtPanelEntryModel> = {}): AtPanelEntryModel {
21
+ return {
22
+ path: "/workspace/src",
23
+ name: "src",
24
+ isDirectory: true,
25
+ index: 0,
26
+ active: false,
27
+ icon: "icon-folder",
28
+ ...overrides,
29
+ };
30
+ }
31
+
32
+ function markup(entries: AtPanelEntryModel[]): string {
33
+ return renderToStaticMarkup(
34
+ <AtPanelView
35
+ open
36
+ loading={false}
37
+ normalizedFilter=""
38
+ canGoUp={false}
39
+ goUpActive={false}
40
+ entries={entries}
41
+ labels={labels}
42
+ panelRef={createRef()}
43
+ onGoUp={() => undefined}
44
+ onHoverIndex={() => undefined}
45
+ onEntryClick={() => undefined}
46
+ onCiteDirectory={() => undefined}
47
+ />,
48
+ );
49
+ }
50
+
51
+ describe("AtPanelView directory citation", () => {
52
+ it("浏览目录时给出单独的引用按钮,搜索结果里的目录没有", () => {
53
+ const browsing = markup([entry()]);
54
+ expect(browsing).toContain("Attach folder");
55
+ expect(browsing).toContain("Tab to enter");
56
+
57
+ const searching = markup([entry({ relPath: "src" })]);
58
+ expect(searching).not.toContain("Attach folder");
59
+ expect(searching).not.toContain("Tab to enter");
60
+ });
61
+ });
@@ -32,6 +32,9 @@ export interface AtPanelLabels {
32
32
  emptyDirectory: string;
33
33
  goUp: string;
34
34
  enterDirectory: string;
35
+ /** 浏览目录时的「引用此目录」。旧主题可以不提供,那时不显示按钮。 */
36
+ citeDirectory?: string;
37
+ citeDirectoryHint?: string;
35
38
  }
36
39
 
37
40
  export interface AtPanelViewProps {
@@ -48,6 +51,7 @@ export interface AtPanelViewProps {
48
51
  onGoUp: () => void;
49
52
  onHoverIndex: (index: number) => void;
50
53
  onEntryClick: (entry: AtPanelEntryModel) => void;
54
+ onCiteDirectory?: (entry: AtPanelEntryModel) => void;
51
55
  }
52
56
 
53
57
  export function AtPanelView({
@@ -64,6 +68,7 @@ export function AtPanelView({
64
68
  onGoUp,
65
69
  onHoverIndex,
66
70
  onEntryClick,
71
+ onCiteDirectory,
67
72
  }: AtPanelViewProps): JSX.Element {
68
73
  return (
69
74
  <AnimatePresence>
@@ -141,8 +146,11 @@ export function AtPanelView({
141
146
  entry={entry}
142
147
  className={classNames?.item}
143
148
  enterDirectoryLabel={labels.enterDirectory}
149
+ citeDirectoryLabel={labels.citeDirectory}
150
+ citeDirectoryHint={labels.citeDirectoryHint}
144
151
  onHover={() => onHoverIndex(entry.index)}
145
152
  onClick={() => onEntryClick(entry)}
153
+ onCite={onCiteDirectory ? () => onCiteDirectory(entry) : undefined}
146
154
  />
147
155
  ))}
148
156
  </div>
@@ -159,62 +167,79 @@ function AtPanelEntry({
159
167
  entry,
160
168
  className,
161
169
  enterDirectoryLabel,
170
+ citeDirectoryLabel,
171
+ citeDirectoryHint,
162
172
  onHover,
163
173
  onClick,
174
+ onCite,
164
175
  }: {
165
176
  entry: AtPanelEntryModel;
166
177
  className?: string;
167
178
  enterDirectoryLabel: string;
179
+ citeDirectoryLabel?: string;
180
+ citeDirectoryHint?: string;
168
181
  onHover: () => void;
169
182
  onClick: () => void;
183
+ onCite?: () => void;
170
184
  }): JSX.Element {
185
+ // 搜索结果带 relPath,整行点击就是引用;只有浏览中的目录才需要单独的引用按钮。
186
+ const browsingDirectory = entry.isDirectory && entry.relPath === undefined;
187
+ const citeLabel = browsingDirectory && onCite && citeDirectoryLabel ? citeDirectoryLabel : undefined;
171
188
  return (
172
- <button
173
- type="button"
189
+ <div
174
190
  data-index={entry.index}
175
191
  onMouseEnter={onHover}
176
- onClick={onClick}
177
- className={["relative flex w-full items-center gap-3 px-4 py-1.5 text-left transition-colors", className]
178
- .filter(Boolean)
179
- .join(" ")}
192
+ className={["relative flex w-full items-center transition-colors", className].filter(Boolean).join(" ")}
180
193
  style={{
181
194
  background: entry.active ? "color-mix(in srgb, var(--primary) 9%, transparent)" : "transparent",
182
195
  }}
183
196
  >
184
- {entry.active && (
185
- <motion.span
186
- layoutId="at-active-marker"
187
- className="absolute inset-y-1 left-0 w-0.5 rounded-full bg-primary"
188
- transition={{ type: "spring", stiffness: 500, damping: 32 }}
189
- />
190
- )}
191
- {entry.avatar ? (
192
- <img src={entry.avatar} alt="" className="h-5 w-5 shrink-0 rounded-full object-cover" />
193
- ) : (
197
+ <button type="button" onClick={onClick} className="flex min-w-0 flex-1 items-center gap-3 px-4 py-1.5 text-left">
198
+ {entry.active && (
199
+ <motion.span
200
+ layoutId="at-active-marker"
201
+ className="absolute inset-y-1 left-0 w-0.5 rounded-full bg-primary"
202
+ transition={{ type: "spring", stiffness: 500, damping: 32 }}
203
+ />
204
+ )}
205
+ {entry.avatar ? (
206
+ <img src={entry.avatar} alt="" className="h-5 w-5 shrink-0 rounded-full object-cover" />
207
+ ) : (
208
+ <span
209
+ className={`${entry.icon} h-4 w-4 shrink-0 ${entry.isDirectory ? "text-muted-foreground" : "text-muted-foreground/50"}`}
210
+ />
211
+ )}
194
212
  <span
195
- className={`${entry.icon} h-4 w-4 shrink-0 ${entry.isDirectory ? "text-muted-foreground" : "text-muted-foreground/50"}`}
196
- />
197
- )}
198
- <span
199
- className={`shrink-0 truncate text-[12.5px] ${entry.isDirectory ? "font-medium text-foreground" : "text-foreground"}`}
200
- >
201
- {entry.name}
202
- </span>
203
- {entry.meta ? (
204
- <span className="ml-auto truncate text-right text-[11px] text-muted-foreground/50" title={entry.meta}>
205
- {entry.meta}
206
- </span>
207
- ) : null}
208
- {entry.relPath && entry.relPath !== entry.name && (
209
- <span className="ml-auto truncate text-right font-mono text-[10px] text-muted-foreground/40">
210
- {entry.relPath}
211
- </span>
212
- )}
213
- {entry.isDirectory && (
214
- <span className="ml-auto text-[10px] text-muted-foreground/50" title={enterDirectoryLabel}>
215
- {enterDirectoryLabel}
213
+ className={`shrink-0 truncate text-[12.5px] ${entry.isDirectory ? "font-medium text-foreground" : "text-foreground"}`}
214
+ >
215
+ {entry.name}
216
216
  </span>
217
+ {entry.meta ? (
218
+ <span className="ml-auto truncate text-right text-[11px] text-muted-foreground/50" title={entry.meta}>
219
+ {entry.meta}
220
+ </span>
221
+ ) : null}
222
+ {entry.relPath && entry.relPath !== entry.name && (
223
+ <span className="ml-auto truncate text-right font-mono text-[10px] text-muted-foreground/40">
224
+ {entry.relPath}
225
+ </span>
226
+ )}
227
+ {browsingDirectory && (
228
+ <span className="ml-auto text-[10px] text-muted-foreground/50" title={enterDirectoryLabel}>
229
+ {enterDirectoryLabel}
230
+ </span>
231
+ )}
232
+ </button>
233
+ {citeLabel && (
234
+ <button
235
+ type="button"
236
+ onClick={onCite}
237
+ title={citeDirectoryHint ?? citeLabel}
238
+ className="mr-3 shrink-0 rounded-md px-1.5 py-0.5 text-[10px] text-muted-foreground/70 hover:bg-primary/10 hover:text-foreground"
239
+ >
240
+ {citeLabel}
241
+ </button>
217
242
  )}
218
- </button>
243
+ </div>
219
244
  );
220
245
  }
@@ -89,9 +89,8 @@ export function BashTerminalStatusDot(): JSX.Element {
89
89
  return (
90
90
  <span
91
91
  className={`h-1.5 w-1.5 shrink-0 rounded-full ${
92
- failed ? "bg-destructive/70" : pending ? "bg-primary/60" : "bg-muted-foreground/40"
92
+ failed ? "bg-destructive/70" : pending ? "vetta-live-dot bg-primary/60" : "bg-muted-foreground/40"
93
93
  }`}
94
- style={pending ? { animation: "pulse 1.5s infinite" } : undefined}
95
94
  />
96
95
  );
97
96
  }
@@ -1,4 +1,5 @@
1
- import { Button } from "@vetta-org/ui";
1
+ import type { ReactNode } from "react";
2
+ import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
2
3
 
3
4
  export function ChatHeaderExportAction({
4
5
  disabled,
@@ -12,15 +13,15 @@ export function ChatHeaderExportAction({
12
13
  readonly title?: string;
13
14
  }): JSX.Element {
14
15
  return (
15
- <Button size="icon-xs" variant="ghost" title={title} disabled={disabled} onClick={onClick}>
16
+ <ButtonGroupItem title={title} aria-label={title} disabled={disabled} onClick={onClick} icon={
16
17
  <span
17
18
  className={
18
19
  exporting
19
20
  ? "icon-[mdi--loading] animate-spin text-[14px]"
20
21
  : "icon-[solar--square-share-line-linear] text-[14px]"
21
22
  }
22
- />
23
- </Button>
23
+ />}
24
+ />
24
25
  );
25
26
  }
26
27
 
@@ -34,15 +35,14 @@ export function ChatHeaderPinAction({
34
35
  readonly title: string;
35
36
  }): JSX.Element {
36
37
  return (
37
- <Button
38
- size="icon-xs"
39
- variant="ghost"
38
+ <ButtonGroupItem
40
39
  title={title}
40
+ aria-label={title}
41
+ active={pinned}
41
42
  onClick={onClick}
42
- className={pinned ? "bg-accent text-foreground" : ""}
43
- >
44
- <span className={`${pinned ? "icon-[solar--pin-bold]" : "icon-[solar--pin-linear]"} text-[14px]`} />
45
- </Button>
43
+ icon={
44
+ <span className={`${pinned ? "icon-[solar--pin-bold]" : "icon-[solar--pin-linear]"} text-[14px]`} />}
45
+ />
46
46
  );
47
47
  }
48
48
 
@@ -56,20 +56,76 @@ export function ChatHeaderPanelAction({
56
56
  readonly title: string;
57
57
  }): JSX.Element {
58
58
  return (
59
- <Button
60
- size="icon-xs"
61
- variant="ghost"
59
+ <ButtonGroupItem
62
60
  title={title}
61
+ aria-label={title}
62
+ active={open}
63
63
  onClick={onClick}
64
- className={open ? "bg-accent text-foreground" : ""}
65
- >
66
- <span className="icon-[solar--sidebar-minimalistic-linear] -scale-x-100 text-[14px]" />
67
- </Button>
64
+ icon={
65
+ <span className="icon-[solar--sidebar-minimalistic-linear] -scale-x-100 text-[14px]" />}
66
+ />
68
67
  );
69
68
  }
70
69
 
70
+ export function ChatHeaderBottomPanelAction({
71
+ onClick,
72
+ open,
73
+ title,
74
+ }: {
75
+ readonly onClick: () => void;
76
+ readonly open: boolean;
77
+ readonly title: string;
78
+ }): JSX.Element {
79
+ return (
80
+ <ButtonGroupItem
81
+ title={title}
82
+ aria-label={title}
83
+ active={open}
84
+ onClick={onClick}
85
+ icon={
86
+ <span className="icon-[solar--window-frame-linear] text-[14px]" />}
87
+ />
88
+ );
89
+ }
90
+
91
+ /**
92
+ * 一步到位打开终端。`focused` 表示此刻已经在终端里(再点不会有任何动作),
93
+ * 高亮与底部面板按钮的「展开」态同一套视觉。
94
+ */
95
+ export function ChatHeaderTerminalAction({
96
+ disabled,
97
+ focused,
98
+ onClick,
99
+ title,
100
+ }: {
101
+ readonly disabled?: boolean;
102
+ readonly focused: boolean;
103
+ readonly onClick: () => void;
104
+ readonly title: string;
105
+ }): JSX.Element {
106
+ return (
107
+ <ButtonGroupItem
108
+ title={title}
109
+ aria-label={title}
110
+ active={focused}
111
+ disabled={disabled}
112
+ onClick={onClick}
113
+ icon={
114
+ <span className="icon-[solar--programming-linear] text-[14px]" />}
115
+ />
116
+ );
117
+ }
118
+
119
+ /** 标题栏右侧的玻璃按钮组容器,把上面的各个动作按钮包在一起。 */
120
+ export function ChatHeaderActionGroup({ children }: { readonly children: ReactNode }): JSX.Element {
121
+ return <ButtonGroup>{children}</ButtonGroup>;
122
+ }
123
+
71
124
  export const ChatHeaderActions = {
125
+ Group: ChatHeaderActionGroup,
72
126
  Export: ChatHeaderExportAction,
73
127
  Pin: ChatHeaderPinAction,
74
128
  Panel: ChatHeaderPanelAction,
129
+ BottomPanel: ChatHeaderBottomPanelAction,
130
+ Terminal: ChatHeaderTerminalAction,
75
131
  } as const;
@@ -0,0 +1,34 @@
1
+ import { renderToStaticMarkup } from "react-dom/server";
2
+ import { describe, expect, it } from "vitest";
3
+ import { CompactionStepView } from "./CompactionStepView";
4
+
5
+ describe("CompactionStepView", () => {
6
+ it("shows the summary that replaced earlier context once opened", () => {
7
+ const closed = renderToStaticMarkup(
8
+ <CompactionStepView status="success" label="Context compacted" detail="120k tokens before" summary="earlier work" />,
9
+ );
10
+ expect(closed).toContain("Context compacted");
11
+ expect(closed).toContain("120k tokens before");
12
+ expect(closed).toContain('aria-expanded="false"');
13
+ expect(closed).not.toContain("earlier work");
14
+
15
+ const open = renderToStaticMarkup(
16
+ <CompactionStepView status="success" label="Context compacted" summary="earlier work" expanded />,
17
+ );
18
+ expect(open).toContain('aria-expanded="true"');
19
+ expect(open).toContain("earlier work");
20
+ });
21
+
22
+ it("cannot open while running because there is no summary yet", () => {
23
+ const markup = renderToStaticMarkup(<CompactionStepView status="running" label="Compacting context…" />);
24
+ expect(markup).toContain('data-compaction-step="running"');
25
+ expect(markup).toContain("disabled");
26
+ expect(markup).toContain("tool-call-shimmer-text");
27
+ });
28
+
29
+ it("keeps a failed compaction visibly distinct", () => {
30
+ const markup = renderToStaticMarkup(<CompactionStepView status="error" label="Context compaction failed" />);
31
+ expect(markup).toContain("icon-[solar--danger-circle-linear]");
32
+ expect(markup).toContain("text-destructive/80");
33
+ });
34
+ });
@@ -0,0 +1,85 @@
1
+ import { useId, useState, type JSX } from "react";
2
+ import { CollapsePanel } from "../shared/CollapsePanel";
3
+
4
+ export interface CompactionStepViewProps {
5
+ readonly status: "running" | "success" | "error";
6
+ /** Row title, e.g. "Compacting context…" / "Context compacted". */
7
+ readonly label: string;
8
+ /** Secondary text after the title, e.g. the context size before compaction. */
9
+ readonly detail?: string;
10
+ /** The summary that replaced the earlier conversation; the row opens to show it. */
11
+ readonly summary?: string;
12
+ readonly expanded?: boolean;
13
+ readonly onToggle?: () => void;
14
+ readonly exportMode?: boolean;
15
+ }
16
+
17
+ const STATUS_ICON: Record<CompactionStepViewProps["status"], string> = {
18
+ running: "icon-[mdi--compress] animate-pulse text-sky-500/80 dark:text-sky-400/80",
19
+ success: "icon-[mdi--compress] text-sky-500 dark:text-sky-400",
20
+ error: "icon-[solar--danger-circle-linear] text-destructive/70",
21
+ };
22
+
23
+ /**
24
+ * Automatic context compaction as a step of the reply: same row rhythm as a
25
+ * tool step, set apart by its icon and accent so it never reads as agent work.
26
+ */
27
+ export function CompactionStepView({
28
+ status,
29
+ label,
30
+ detail,
31
+ summary,
32
+ expanded: expandedProp,
33
+ onToggle,
34
+ exportMode = false,
35
+ }: CompactionStepViewProps): JSX.Element {
36
+ const [uncontrolled, setUncontrolled] = useState(false);
37
+ const expanded = expandedProp ?? uncontrolled;
38
+ const generatedId = useId();
39
+ const panelId = exportMode ? `export-compaction-step-${generatedId}` : undefined;
40
+ const hasSummary = Boolean(summary?.trim());
41
+ const open = hasSummary && (expanded || exportMode);
42
+ return (
43
+ <div className="min-w-0 w-full" data-compaction-step={status}>
44
+ <button
45
+ type="button"
46
+ disabled={!hasSummary}
47
+ aria-expanded={open}
48
+ data-export-toggle={hasSummary ? panelId : undefined}
49
+ onClick={() => (onToggle ? onToggle() : setUncontrolled((value) => !value))}
50
+ className="inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-lg px-1.5 py-1 text-left transition-colors enabled:hover:bg-sky-500/10"
51
+ >
52
+ <span className={`h-3.5 w-3.5 shrink-0 ${STATUS_ICON[status]}`} aria-hidden="true" />
53
+ <span
54
+ className={`min-w-0 truncate text-[13px] ${
55
+ status === "running"
56
+ ? "tool-call-shimmer-text"
57
+ : status === "error"
58
+ ? "text-destructive/80"
59
+ : "text-sky-600/90 dark:text-sky-300/85"
60
+ }`}
61
+ >
62
+ {label}
63
+ </span>
64
+ {detail ? (
65
+ <span className="shrink-0 text-[12px] text-muted-foreground/50 tabular-nums">{detail}</span>
66
+ ) : null}
67
+ {hasSummary ? (
68
+ <span
69
+ className={`icon-[solar--alt-arrow-right-linear] h-3.5 w-3.5 shrink-0 text-muted-foreground/40 transition-transform duration-200 ${open ? "rotate-90" : ""}`}
70
+ aria-hidden="true"
71
+ />
72
+ ) : null}
73
+ </button>
74
+ {hasSummary ? (
75
+ <CollapsePanel open={open} id={panelId} exportPanel={exportMode} hidden={exportMode && !expanded}>
76
+ <div className="ml-4 border-sky-500/25 border-l pb-1 pl-3">
77
+ <div className="max-h-72 overflow-y-auto whitespace-pre-wrap break-words py-1 text-[12px] leading-relaxed text-muted-foreground/80">
78
+ {summary}
79
+ </div>
80
+ </div>
81
+ </CollapsePanel>
82
+ ) : null}
83
+ </div>
84
+ );
85
+ }
@@ -0,0 +1,81 @@
1
+ // @vitest-environment jsdom
2
+
3
+ import { act, createElement, type ReactElement } from "react";
4
+ import { createRoot } from "react-dom/client";
5
+ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
6
+ import { ContextRingView } from "./ContextRingView";
7
+
8
+ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
9
+
10
+ // Radix 的定位靠 floating-ui 的 autoUpdate,jsdom 没有 ResizeObserver。
11
+ if (typeof globalThis.ResizeObserver === "undefined") {
12
+ class NoopResizeObserver implements ResizeObserver {
13
+ observe(): void {}
14
+ unobserve(): void {}
15
+ disconnect(): void {}
16
+ }
17
+ Object.assign(globalThis, { ResizeObserver: NoopResizeObserver });
18
+ }
19
+
20
+ // 同一批 jsdom 版本也没有 PointerEvent,而 Radix 靠它区分鼠标与触摸。
21
+ if (typeof globalThis.PointerEvent === "undefined") {
22
+ class MousePointerEvent extends MouseEvent {
23
+ readonly pointerType: string;
24
+ constructor(type: string, init: MouseEventInit & { pointerType?: string } = {}) {
25
+ super(type, init);
26
+ this.pointerType = init.pointerType ?? "mouse";
27
+ }
28
+ }
29
+ Object.assign(globalThis, { PointerEvent: MousePointerEvent });
30
+ }
31
+
32
+ const TOOLTIP = "上下文已使用 234k tokens(22.4%,1.0M 窗口)";
33
+
34
+ describe("ContextRingView tooltip", () => {
35
+ beforeEach(() => {
36
+ vi.useFakeTimers();
37
+ });
38
+
39
+ afterEach(() => {
40
+ vi.useRealTimers();
41
+ });
42
+
43
+ it("悬停提示挂在 body 上,不留在输入栏那一列里被裁掉、被活动面板盖住", async () => {
44
+ const container = document.createElement("div");
45
+ document.body.append(container);
46
+ const root = createRoot(container);
47
+ await act(async () => root.render(view()));
48
+
49
+ const trigger = container.firstElementChild;
50
+ if (!(trigger instanceof HTMLElement)) throw new Error("missing ring trigger");
51
+ await act(async () => {
52
+ trigger.dispatchEvent(pointerEvent("pointerenter", false));
53
+ trigger.dispatchEvent(pointerEvent("pointermove", true));
54
+ vi.advanceTimersByTime(300);
55
+ });
56
+
57
+ const tip = document.querySelector('[role="tooltip"]');
58
+ expect(tip?.textContent).toBe(TOOLTIP);
59
+ // 关键断言:提示不是触发器的后代。留在原地的话父级的 overflow-clip 会裁掉它,
60
+ // isolate 又把它关在自己的层里,压不过右边的活动面板。
61
+ expect(container.contains(tip as Node)).toBe(false);
62
+ expect(document.body.contains(tip as Node)).toBe(true);
63
+
64
+ await act(async () => root.unmount());
65
+ container.remove();
66
+ });
67
+ });
68
+
69
+ function view(): ReactElement {
70
+ return createElement(ContextRingView, {
71
+ percent: 22.4,
72
+ offset: 10,
73
+ color: "currentColor",
74
+ isCompacting: false,
75
+ tooltip: TOOLTIP,
76
+ });
77
+ }
78
+
79
+ function pointerEvent(type: string, bubbles: boolean): PointerEvent {
80
+ return new PointerEvent(type, { bubbles, pointerType: "mouse", clientX: 0, clientY: 0 });
81
+ }