@vetta-org/theme-ui 0.1.2 → 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 (78) hide show
  1. package/package.json +8 -16
  2. package/src/activity/ActivityPanelFrame.tsx +1 -1
  3. package/src/activity/CodePreview.tsx +15 -1
  4. package/src/activity/MarkdownPreviewView.test.tsx +53 -0
  5. package/src/activity/MarkdownPreviewView.tsx +86 -10
  6. package/src/chat/ContextRingView.test.tsx +81 -0
  7. package/src/chat/ContextRingView.tsx +78 -62
  8. package/src/chat/HeaderActionBarView.tsx +122 -47
  9. package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
  10. package/src/chat/MessageFeedLayoutView.tsx +6 -5
  11. package/src/chat/MessageInputView.tsx +5 -1
  12. package/src/chat/index.ts +2 -1
  13. package/src/chat/message-feed-fade.css +80 -0
  14. package/src/chat/message-feed-fade.test.tsx +75 -0
  15. package/src/file-preview/ReadonlyCodeView.tsx +46 -0
  16. package/src/file-preview/syntax-tokens.css +1 -1
  17. package/src/image-assets.d.ts +4 -0
  18. package/src/markdown/FileLinkBadge.tsx +77 -0
  19. package/src/markdown/MarkdownContent.tsx +12 -5
  20. package/src/markdown/MarkdownImage.tsx +6 -16
  21. package/src/markdown/MermaidBlock.tsx +50 -11
  22. package/src/markdown/image-actions.ts +29 -0
  23. package/src/markdown/index.ts +1 -0
  24. package/src/markdown/preview-policy.test.ts +31 -0
  25. package/src/markdown/preview-policy.ts +33 -0
  26. package/src/markdown/progressive-chunks.test.ts +43 -0
  27. package/src/markdown/progressive-chunks.ts +58 -0
  28. package/src/markdown/rich-labels.ts +6 -0
  29. package/src/overlays/CommandMenuRow.tsx +43 -12
  30. package/src/overlays/CommandMenuView.tsx +96 -11
  31. package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
  32. package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
  33. package/src/overlays/ReleaseNoteMarkdown.test.tsx +24 -0
  34. package/src/overlays/ReleaseNoteMarkdown.tsx +26 -0
  35. package/src/overlays/SplashPanel.tsx +4 -4
  36. package/src/overlays/SplashParts.tsx +6 -2
  37. package/src/overlays/UpdateRestartDialogView.tsx +65 -0
  38. package/src/overlays/assets/diagnostics-banner.webp +0 -0
  39. package/src/overlays/command-menu-types.ts +13 -1
  40. package/src/overlays/index.ts +12 -0
  41. package/src/plugin-ui/index.ts +2 -0
  42. package/src/project/DefaultConversationSectionView.tsx +13 -22
  43. package/src/project/DefaultSessionRowView.tsx +8 -0
  44. package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
  45. package/src/settings/GeneralSettingsView.tsx +2 -5
  46. package/src/settings/LauncherSettingsView.test.tsx +95 -0
  47. package/src/settings/LauncherSettingsView.tsx +273 -0
  48. package/src/settings/PetActionGalleryView.test.tsx +163 -0
  49. package/src/settings/PetActionGalleryView.tsx +216 -0
  50. package/src/settings/PetSettingsView.test.tsx +117 -0
  51. package/src/settings/PetSettingsView.tsx +86 -22
  52. package/src/settings/PresetProviderRowView.tsx +37 -98
  53. package/src/settings/ShortcutsSettingsView.tsx +0 -4
  54. package/src/settings/SpaceEditorDialogView.tsx +94 -56
  55. package/src/settings/SpacesSettingsView.tsx +53 -8
  56. package/src/settings/assets/space-editor-illustration.webp +0 -0
  57. package/src/settings/index.ts +18 -39
  58. package/src/shared/SegmentedControl.test.tsx +68 -0
  59. package/src/shared/SegmentedControl.tsx +10 -2
  60. package/src/shared/TabBar.tsx +2 -2
  61. package/src/shared/VettaKbd.tsx +20 -1
  62. package/src/shared/index.ts +2 -1
  63. package/src/shared/platform.ts +9 -0
  64. package/src/sidebar/AddProjectMenuTriggerView.tsx +11 -12
  65. package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
  66. package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
  67. package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
  68. package/src/styles.css +2 -0
  69. package/src/settings/AchievementNavigationButtonView.tsx +0 -90
  70. package/src/settings/AchievementPromotionDialogView.tsx +0 -91
  71. package/src/settings/AchievementSettingsView.tsx +0 -43
  72. package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
  73. package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
  74. package/src/settings/achievements/AchievementCurtains.tsx +0 -50
  75. package/src/settings/achievements/AchievementPromotionBadge3D.tsx +0 -350
  76. package/src/settings/achievements/AchievementPromotionConfetti.tsx +0 -71
  77. package/src/settings/achievements/AchievementTitle.tsx +0 -52
  78. package/src/settings/achievements/index.ts +0 -13
@@ -2,11 +2,12 @@ import { motion } from "motion/react";
2
2
  import { memo, type JSX } from "react";
3
3
  import { cn } from "@vetta-org/ui/utils";
4
4
  import { ConversationTagDotsView } from "../project/ConversationTagDotsView";
5
+ import { SessionStatusIcon } from "../sidebar/SessionStatusIcon";
5
6
  import type { CommandMenuHighlightRange, CommandMenuItemView } from "./command-menu-types";
6
7
 
7
8
  /**
8
- * 结果行。选中态由**静态 CSS 背景**表达,只有 2px 的左侧指示条参与 layout 动画
9
- * ——对齐 `chat/AtPanelView` 的既有做法:整行背景每次都做布局动画在低端机上代价过高。
9
+ * 结果行。选中态是一块与 ButtonGroup 选中项同语言的玻璃圆角底(前景色低透明度叠层 + 上沿亮线),
10
+ * 只在用户上下移动选中项时让这块底滑过去;结果重算时直接落位,不逐击键播放。
10
11
  */
11
12
 
12
13
  /** 把命中区间渲染成高亮片段;区间由调用方保证已排序且互不重叠。 */
@@ -79,12 +80,10 @@ export const CommandMenuRow = memo(function CommandMenuRow({
79
80
  "group relative flex h-9 w-full items-center gap-2.5 rounded-lg px-2.5 text-left outline-none transition-colors",
80
81
  disabled ? "cursor-not-allowed opacity-45" : "cursor-pointer",
81
82
  )}
82
- style={{
83
- background: active ? "color-mix(in srgb, var(--primary) 9%, transparent)" : "transparent",
84
- }}
85
83
  >
86
84
  {active && (
87
85
  <motion.span
86
+ aria-hidden="true"
88
87
  layoutId="command-menu-active-marker"
89
88
  // 结果重算时 layout 动画会把指示条从旧行“弹”到新行,逐击键播放既抖又费;
90
89
  // 只有用户主动上下移动选中项时才让它滑动。
@@ -94,19 +93,34 @@ export const CommandMenuRow = memo(function CommandMenuRow({
94
93
  ? { duration: 0 }
95
94
  : { type: "spring", stiffness: 500, damping: 32 }
96
95
  }
97
- className="absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-primary"
96
+ className="absolute inset-0 rounded-lg bg-foreground/[0.06] dark:bg-white/[0.08] dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.08)]"
98
97
  />
99
98
  )}
100
- {item.tagColors && item.tagColors.length > 0 ? (
99
+ {item.status === "unread" ? (
100
+ // 跑完未看:保留会话图标,右上角叠一颗强调色圆点,和「在转 / 问号」区分开。
101
+ <span aria-hidden="true" data-session-unread="true" className="relative flex size-4 shrink-0 items-center justify-center">
102
+ <span className={cn(item.icon, "size-4", active ? "text-foreground" : "text-muted-foreground")} />
103
+ <span className="absolute -right-0.5 -top-0.5 size-1.5 rounded-full bg-primary" />
104
+ </span>
105
+ ) : item.status ? (
106
+ <span aria-hidden="true" className="relative flex size-4 shrink-0 items-center justify-center">
107
+ <SessionStatusIcon
108
+ active={active}
109
+ running={item.status === "running"}
110
+ waiting={item.status === "waiting"}
111
+ scheduled={false}
112
+ />
113
+ </span>
114
+ ) : item.tagColors && item.tagColors.length > 0 ? (
101
115
  // 与侧栏会话一致:标签色点占据行首图标的位置,多个标签就画多个。
102
- <ConversationTagDotsView colors={item.tagColors} className="size-4" />
116
+ <ConversationTagDotsView colors={item.tagColors} className="relative size-4" />
103
117
  ) : (
104
118
  <span
105
119
  aria-hidden="true"
106
- className={cn(item.icon, "size-4 shrink-0", active ? "text-foreground" : "text-muted-foreground")}
120
+ className={cn(item.icon, "relative size-4 shrink-0", active ? "text-foreground" : "text-muted-foreground")}
107
121
  />
108
122
  )}
109
- <span className="flex min-w-0 flex-1 items-baseline gap-2">
123
+ <span className="relative flex min-w-0 flex-1 items-baseline gap-2">
110
124
  {/*
111
125
  * 标题不参与收缩(shrink-0),只受 max-w 约束:标题和副标题都可收缩时,
112
126
  * flex 会按内容等比压缩,一条长描述能把名字挤成两三个字。让副标题先让位。
@@ -120,8 +134,25 @@ export const CommandMenuRow = memo(function CommandMenuRow({
120
134
  </span>
121
135
  )}
122
136
  </span>
137
+ {item.status && item.statusLabel && (
138
+ <span
139
+ className={cn(
140
+ "relative shrink-0 text-[11px]",
141
+ item.status === "waiting" ? "text-amber-600 dark:text-amber-400" : "text-muted-foreground",
142
+ )}
143
+ >
144
+ {item.statusLabel}
145
+ </span>
146
+ )}
123
147
  {item.badge && (
124
- <span className="shrink-0 rounded-full bg-secondary px-1.5 py-0.5 text-[10px] font-medium text-secondary-foreground">
148
+ <span
149
+ className={cn(
150
+ "relative max-w-[40%] shrink-0 truncate rounded-[5px] px-1.5 py-px text-[10px] font-medium leading-4",
151
+ item.badgeTone === "accent"
152
+ ? "bg-primary/15 text-primary"
153
+ : "bg-foreground/[0.06] text-muted-foreground dark:bg-white/[0.08]",
154
+ )}
155
+ >
125
156
  {item.badge}
126
157
  </span>
127
158
  )}
@@ -136,7 +167,7 @@ export const CommandMenuRow = memo(function CommandMenuRow({
136
167
  onMore(item.id);
137
168
  }}
138
169
  className={cn(
139
- "-mr-1 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-accent hover:text-foreground",
170
+ "relative -mr-1 flex size-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-opacity hover:bg-accent hover:text-foreground",
140
171
  active ? "opacity-100" : "opacity-0 group-hover:opacity-100",
141
172
  )}
142
173
  >
@@ -1,7 +1,10 @@
1
+ import { ButtonGroup, ButtonGroupItem } from "@vetta-org/ui/button-group";
1
2
  import { useCallback, useEffect, useRef, type JSX, type RefObject } from "react";
3
+ import { detectKbdPlatform, resolveKbdKeys } from "../shared/kbd-keys";
4
+ import { VettaKbd } from "../shared/VettaKbd";
2
5
  import { CommandMenuRow } from "./CommandMenuRow";
3
6
  import type { CommandMenuGroupView, CommandMenuViewLabels } from "./command-menu-types";
4
- import { SplashFooter, SplashInputHeader } from "./SplashParts";
7
+ import { SplashInputHeader } from "./SplashParts";
5
8
  import { SplashPanel } from "./SplashPanel";
6
9
  import "./command-menu.css";
7
10
 
@@ -12,12 +15,32 @@ import "./command-menu.css";
12
15
  * 面板顶部对齐而非垂直居中:结果条数会变,垂直居中会让输入框随每次击键上下跳。
13
16
  */
14
17
 
18
+ /**
19
+ * 浮在列表上的按钮组在浅色下补一层玻璃:通用 ButtonGroup 的浅色只有一层淡灰底(贴在普通页面上够用),
20
+ * 压在白色玻璃面板和列表内容上就成了一块灰片。这里只覆盖浅色的底色与阴影(深色沿用 ButtonGroup
21
+ * 自带的 dark: 样式不变),不改通用组件。
22
+ */
23
+ export const COMMAND_MENU_FLOATING_GROUP_CLASS =
24
+ "pointer-events-auto bg-white/65 shadow-[inset_0_1px_0_rgb(255_255_255/0.95),0_0_0_1px_rgb(0_0_0/0.07),0_6px_18px_-6px_rgb(0_0_0/0.18)]";
25
+
26
+ /** 悬停提示里的快捷键文字,例如 mac 上的「⌘N」、Windows 上的「Ctrl N」。 */
27
+ function formatKbdTitle(keys: string): string {
28
+ const platform = detectKbdPlatform();
29
+ return resolveKbdKeys(keys, platform).join(platform === "mac" ? "" : " ");
30
+ }
31
+
15
32
  export interface CommandMenuViewProps {
16
33
  readonly open: boolean;
17
34
  readonly query: string;
18
35
  readonly groups: readonly CommandMenuGroupView[];
19
36
  readonly selectedId: string | null;
20
37
  readonly labels: CommandMenuViewLabels;
38
+ /** 唤起 / 关闭面板的快捷键(例如 "mod+t"),显示在输入框右侧。 */
39
+ readonly toggleShortcut?: string;
40
+ /** 给了就在左下角显示「新会话」按钮,与右下角操作按钮组对称。 */
41
+ readonly onNewSession?: () => void;
42
+ /** 新建会话的生效快捷键,显示在按钮里。 */
43
+ readonly newSessionShortcut?: string;
21
44
  /** 结果集因击键刚变化:抑制选中指示条的位移动画。 */
22
45
  readonly suppressSelectionAnimation: boolean;
23
46
  readonly inputRef?: RefObject<HTMLInputElement | null>;
@@ -33,6 +56,9 @@ export function CommandMenuView({
33
56
  groups,
34
57
  selectedId,
35
58
  labels,
59
+ toggleShortcut,
60
+ onNewSession,
61
+ newSessionShortcut,
36
62
  suppressSelectionAnimation,
37
63
  inputRef,
38
64
  onQueryChange,
@@ -47,10 +73,28 @@ export function CommandMenuView({
47
73
  else rowRefs.current.delete(id);
48
74
  }, []);
49
75
 
50
- // 选中项滚动跟随。用 "nearest" 且不带 smooth:连续按方向键时平滑滚动会排队堆积。
76
+ // 鼠标悬停也会改选中项,但指针指着的行本来就在眼前,此时滚动只会让列表从指针下溜走。
77
+ const selectedByPointerRef = useRef(false);
78
+ const handleHoverItem = useCallback(
79
+ (id: string) => {
80
+ // mousemove 会在同一行上反复触发;选中项没变就不会有滚动副作用,别留下标记吞掉下一次键盘跟随。
81
+ if (id !== selectedId) selectedByPointerRef.current = true;
82
+ onHoverItem(id);
83
+ },
84
+ [onHoverItem, selectedId],
85
+ );
86
+
87
+ // 键盘选中项滚动跟随。用 "nearest" 且不带 smooth:连续按方向键时平滑滚动会排队堆积。
88
+ // 留白靠列表的 scroll-padding(见下方 className):底部要越过渐隐区和浮动按钮组再多留一行,
89
+ // 选中行才不会沉到按钮后面,往下按时也总能看到下一行是什么;顶部同样多留一行。
90
+ // 不用 "center":那样每按一下整张列表都要挪动,眼睛跟不住。
51
91
  // 可选链到方法本身:jsdom 与部分老 webview 没有实现 scrollIntoView,不能让它把渲染打断。
52
92
  useEffect(() => {
53
93
  if (!open || !selectedId) return;
94
+ if (selectedByPointerRef.current) {
95
+ selectedByPointerRef.current = false;
96
+ return;
97
+ }
54
98
  rowRefs.current.get(selectedId)?.scrollIntoView?.({ block: "nearest" });
55
99
  }, [open, selectedId]);
56
100
 
@@ -72,6 +116,7 @@ export function CommandMenuView({
72
116
  onChange={onQueryChange}
73
117
  // 打开后的聚焦由宿主在 open 变化时负责(见 desktop CommandMenu)。
74
118
  autoFocus={false}
119
+ trailing={toggleShortcut ? <VettaKbd keys={toggleShortcut} size="sm" variant="flat" /> : undefined}
75
120
  inputProps={{
76
121
  role: "combobox",
77
122
  "aria-expanded": hasResults,
@@ -80,19 +125,15 @@ export function CommandMenuView({
80
125
  }}
81
126
  />
82
127
  }
83
- footer={
84
- <SplashFooter>
85
- <span>{labels.hintNavigate}</span>
86
- <span>{labels.hintSelect}</span>
87
- <span className="ml-auto">{labels.hintClose}</span>
88
- </SplashFooter>
89
- }
90
128
  >
129
+ <div className="relative flex min-h-0 flex-col">
91
130
  <div
92
131
  id="command-menu-list"
93
132
  role="listbox"
94
133
  aria-label={labels.title}
95
- className="min-h-0 max-h-[min(420px,56vh)] overflow-y-auto overscroll-contain px-1.5 py-1.5"
134
+ // 底部留出浮动按钮组的高度,最后一行滚到底时不会被它盖住;同一段高度做渐隐,
135
+ // 滚动中的内容在按钮后面淡出,而不是被按钮生硬地截断。
136
+ className="min-h-0 max-h-[min(460px,60vh)] overflow-y-auto overscroll-contain px-1.5 pt-1.5 pb-14 scroll-pt-10 scroll-pb-24 [mask-image:linear-gradient(to_bottom,black_calc(100%-56px),transparent)]"
96
137
  >
97
138
  {groups.map((group) => {
98
139
  if (group.items.length === 0 && !group.loading) return null;
@@ -108,7 +149,7 @@ export function CommandMenuView({
108
149
  active={item.id === selectedId}
109
150
  suppressSelectionAnimation={suppressSelectionAnimation}
110
151
  onActivate={onActivateItem}
111
- onHover={onHoverItem}
152
+ onHover={handleHoverItem}
112
153
  registerRef={registerRef}
113
154
  />
114
155
  ))}
@@ -138,6 +179,50 @@ export function CommandMenuView({
138
179
  </div>
139
180
  )}
140
181
  </div>
182
+ {/*
183
+ * 操作提示做成浮在列表底部的两组按钮(复用通用 ButtonGroup 的玻璃胶囊),既是提示也能点:
184
+ * 左边「新会话」(只有图标),右边「打开」作用于当前选中项、「关闭」等同 esc;左右对称。
185
+ * 上下选择只靠方向键,不占一个按钮。外层不接收指针,按钮之间的空隙仍能滚动 / 点到列表。
186
+ */}
187
+ <div className="pointer-events-none absolute inset-x-2.5 bottom-2.5 z-10 flex items-center justify-between gap-2">
188
+ {onNewSession ? (
189
+ // 只有图标的圆形按钮:胶囊里单个纯图标项正好是一颗与右侧按钮组等高的圆。
190
+ <ButtonGroup className={COMMAND_MENU_FLOATING_GROUP_CLASS}>
191
+ <ButtonGroupItem
192
+ onClick={onNewSession}
193
+ aria-label={labels.newSession}
194
+ title={newSessionShortcut ? `${labels.newSession} (${formatKbdTitle(newSessionShortcut)})` : labels.newSession}
195
+ icon={<span aria-hidden="true" className="icon-[solar--pen-new-square-linear] size-4" />}
196
+ />
197
+ </ButtonGroup>
198
+ ) : (
199
+ <span />
200
+ )}
201
+ <ButtonGroup className={COMMAND_MENU_FLOATING_GROUP_CLASS} aria-label={labels.actionsLabel}>
202
+ <ButtonGroupItem
203
+ disabled={!selectedId}
204
+ onClick={() => {
205
+ if (selectedId) onActivateItem(selectedId);
206
+ }}
207
+ label={
208
+ <span className="inline-flex items-center gap-2">
209
+ {labels.hintSelect}
210
+ <VettaKbd keys="enter" size="sm" variant="flat" />
211
+ </span>
212
+ }
213
+ />
214
+ <ButtonGroupItem
215
+ onClick={onClose}
216
+ label={
217
+ <span className="inline-flex items-center gap-2">
218
+ {labels.hintClose}
219
+ <VettaKbd keys="esc" size="sm" variant="flat" />
220
+ </span>
221
+ }
222
+ />
223
+ </ButtonGroup>
224
+ </div>
225
+ </div>
141
226
  </SplashPanel>
142
227
  );
143
228
  }
@@ -0,0 +1,236 @@
1
+ import { AnimatePresence, motion } from "motion/react";
2
+ import { type JSX, useRef } from "react";
3
+ import { cn, OVERLAY_BACKDROP_CLASS, PANEL_SHADOW_CLASS } from "@vetta-org/ui/utils";
4
+ import diagnosticsBannerUrl from "./assets/diagnostics-banner.webp";
5
+
6
+ /** idle:还没导出;exporting:保存对话框已确认,正在打包;done:已写到用户选的位置;error:打包或写盘失败。 */
7
+ export type DiagnosticsExportDialogPhase = "idle" | "exporting" | "done" | "error";
8
+
9
+ export interface DiagnosticsExportDialogViewLabels {
10
+ readonly eyebrow: string;
11
+ readonly title: string;
12
+ readonly description: string;
13
+ /** 讲明 Vetta 不收集用户数据、诊断包只在用户主动附上时才被看到。 */
14
+ readonly noCollection: string;
15
+ /** 「诊断包里有什么」小标题与三项内容。 */
16
+ readonly contentsTitle: string;
17
+ readonly contentsLogs: string;
18
+ readonly contentsRecentLogs: string;
19
+ readonly contentsSystem: string;
20
+ /** 提醒诊断包里可能有项目路径、文件名和报错内容,由用户酌情发送。 */
21
+ readonly privacyNote: string;
22
+ /** 「怎么反馈」小标题与三步;最后一步不限渠道,GitHub Issue 与私聊都行。 */
23
+ readonly stepsTitle: string;
24
+ readonly stepExport: string;
25
+ readonly stepDescribe: string;
26
+ readonly stepAttach: string;
27
+ readonly export: string;
28
+ readonly exporting: string;
29
+ /** 导出成功后的提示,前缀接文件名。 */
30
+ readonly saved: string;
31
+ readonly showInFolder: string;
32
+ readonly failed: string;
33
+ /** 次要入口:打开 GitHub 的 Bug 反馈页,只是渠道之一。 */
34
+ readonly openIssue: string;
35
+ readonly close: string;
36
+ }
37
+
38
+ export interface DiagnosticsExportDialogViewProps {
39
+ readonly visible: boolean;
40
+ readonly phase: DiagnosticsExportDialogPhase;
41
+ readonly labels: DiagnosticsExportDialogViewLabels;
42
+ /** phase 为 done 时保存下来的文件名。 */
43
+ readonly savedFileName?: string;
44
+ /** phase 为 error 时的原因。 */
45
+ readonly errorMessage?: string;
46
+ readonly onExport: () => void;
47
+ readonly onShowInFolder: () => void;
48
+ readonly onOpenIssue: () => void;
49
+ readonly onClose: () => void;
50
+ }
51
+
52
+ const pillClass =
53
+ "inline-flex h-11 w-full items-center justify-center gap-2 rounded-full bg-primary px-5 text-[14px] font-medium whitespace-nowrap text-primary-foreground shadow-lg shadow-black/15 transition-all outline-none select-none hover:bg-primary/90 focus-visible:ring-2 focus-visible:ring-ring/50 active:translate-y-px disabled:pointer-events-none disabled:opacity-70";
54
+
55
+ /**
56
+ * 「导出诊断包」引导弹窗:说明 Vetta 不收集数据、包里有什么、怎么把它发给开发者。
57
+ * 外观沿用 Magpie 接入弹窗:大圆角面板、静态横幅、编号步骤、通栏胶囊主按钮。
58
+ * 主按钮随阶段变化:导出 → 正在打包 → 在文件夹中显示。
59
+ */
60
+ export function DiagnosticsExportDialogView({
61
+ visible,
62
+ phase,
63
+ labels,
64
+ savedFileName,
65
+ errorMessage,
66
+ onExport,
67
+ onShowInFolder,
68
+ onOpenIssue,
69
+ onClose,
70
+ }: DiagnosticsExportDialogViewProps): JSX.Element {
71
+ const overlayRef = useRef<HTMLDivElement>(null);
72
+ const exporting = phase === "exporting";
73
+ const contents = [
74
+ { icon: "icon-[mdi--file-document-outline]", text: labels.contentsLogs },
75
+ { icon: "icon-[mdi--history]", text: labels.contentsRecentLogs },
76
+ { icon: "icon-[mdi--monitor]", text: labels.contentsSystem },
77
+ ];
78
+ const steps = [labels.stepExport, labels.stepDescribe, labels.stepAttach];
79
+ const close = () => {
80
+ if (!exporting) onClose();
81
+ };
82
+
83
+ return (
84
+ <AnimatePresence>
85
+ {visible && (
86
+ <motion.div
87
+ ref={overlayRef}
88
+ initial={{ opacity: 0 }}
89
+ animate={{ opacity: 1 }}
90
+ exit={{ opacity: 0 }}
91
+ transition={{ duration: 0.15 }}
92
+ className={cn("pointer-events-auto fixed inset-0 z-[100] flex items-center justify-center", OVERLAY_BACKDROP_CLASS)}
93
+ onClick={(event) => {
94
+ if (event.target === overlayRef.current) close();
95
+ }}
96
+ onKeyDown={(event) => {
97
+ if (event.key === "Escape") close();
98
+ }}
99
+ >
100
+ <motion.div
101
+ role="dialog"
102
+ aria-modal="true"
103
+ aria-label={labels.title}
104
+ initial={{ opacity: 0, scale: 0.95 }}
105
+ animate={{ opacity: 1, scale: 1 }}
106
+ exit={{ opacity: 0, scale: 0.95 }}
107
+ transition={{ duration: 0.15, ease: [0.25, 0.1, 0.25, 1] }}
108
+ className={cn(
109
+ "relative flex max-h-[min(780px,calc(100vh-48px))] w-[min(520px,calc(100vw-32px))] flex-col overflow-hidden rounded-3xl bg-popover",
110
+ PANEL_SHADOW_CLASS,
111
+ )}
112
+ >
113
+ <button
114
+ type="button"
115
+ onClick={close}
116
+ disabled={exporting}
117
+ aria-label={labels.close}
118
+ className="absolute top-4 right-4 z-20 inline-flex size-8 items-center justify-center rounded-full bg-white text-neutral-900 shadow-[0_6px_18px_rgba(0,0,0,0.28),0_1px_3px_rgba(0,0,0,0.22)] transition-transform outline-none hover:scale-105 focus-visible:ring-2 focus-visible:ring-white/70 active:scale-95 disabled:opacity-50"
119
+ >
120
+ <span className="icon-[mdi--close] h-4 w-4" />
121
+ </button>
122
+
123
+ <div className="no-scrollbar min-h-0 flex-1 overflow-y-auto [mask-image:linear-gradient(to_bottom,black_calc(100%-20px),transparent)]">
124
+ <DiagnosticsBanner />
125
+
126
+ <div className="px-7 pt-5 pb-5">
127
+ <p className="text-[11px] font-semibold tracking-[0.08em] text-primary uppercase">{labels.eyebrow}</p>
128
+ <h3 className="mt-1.5 text-[19px] leading-snug font-semibold tracking-tight text-foreground">
129
+ {labels.title}
130
+ </h3>
131
+ <p className="mt-2 text-[13px] leading-relaxed text-muted-foreground">{labels.description}</p>
132
+
133
+ <div className="mt-4 flex items-start gap-2.5 rounded-2xl border border-primary/25 bg-primary/8 px-4 py-3">
134
+ <span className="mt-0.5 icon-[mdi--shield-check-outline] h-4 w-4 shrink-0 text-primary" />
135
+ <p className="text-[12.5px] leading-relaxed text-foreground/90">{labels.noCollection}</p>
136
+ </div>
137
+
138
+ <p className="mt-5 text-[12px] font-medium text-muted-foreground">{labels.contentsTitle}</p>
139
+ <ul className="mt-2 flex flex-col gap-1.5">
140
+ {contents.map((item) => (
141
+ <li key={item.text} className="flex items-start gap-2.5 text-[13px] leading-6 text-foreground">
142
+ <span className={cn("mt-1 h-4 w-4 shrink-0 text-primary", item.icon)} />
143
+ {item.text}
144
+ </li>
145
+ ))}
146
+ </ul>
147
+
148
+ <div className="mt-3 flex items-start gap-2.5 rounded-2xl border border-amber-500/30 bg-amber-500/10 px-4 py-3">
149
+ <span className="mt-0.5 icon-[mdi--information-outline] h-4 w-4 shrink-0 text-amber-500" />
150
+ <p className="text-[12.5px] leading-relaxed text-foreground/90">{labels.privacyNote}</p>
151
+ </div>
152
+
153
+ <p className="mt-5 text-[12px] font-medium text-muted-foreground">{labels.stepsTitle}</p>
154
+ <ol className="mt-2 flex flex-col gap-2">
155
+ {steps.map((step, index) => (
156
+ <li
157
+ key={step}
158
+ className="flex items-start gap-3 rounded-2xl border border-border/70 bg-muted/40 px-4 py-3"
159
+ >
160
+ <span className="mt-px inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-primary/12 text-[12px] font-semibold text-primary tabular-nums">
161
+ {index + 1}
162
+ </span>
163
+ <p className="min-w-0 flex-1 text-[13px] leading-6 text-foreground">{step}</p>
164
+ </li>
165
+ ))}
166
+ </ol>
167
+
168
+ {phase === "done" && savedFileName && (
169
+ <div
170
+ role="status"
171
+ className="mt-3 flex items-start gap-2.5 rounded-2xl border border-emerald-500/30 bg-emerald-500/10 px-4 py-3"
172
+ >
173
+ <span className="mt-0.5 icon-[mdi--check-circle] h-4 w-4 shrink-0 text-emerald-500" />
174
+ <p className="min-w-0 text-[12.5px] leading-relaxed break-all text-foreground/90">
175
+ {labels.saved}
176
+ <span className="font-mono">{savedFileName}</span>
177
+ </p>
178
+ </div>
179
+ )}
180
+ {phase === "error" && (
181
+ <div
182
+ role="alert"
183
+ className="mt-3 flex items-start gap-2.5 rounded-2xl border border-destructive/30 bg-destructive/10 px-4 py-3"
184
+ >
185
+ <span className="mt-0.5 icon-[mdi--alert-circle-outline] h-4 w-4 shrink-0 text-destructive" />
186
+ <div className="min-w-0 text-[12.5px] leading-relaxed break-words text-foreground/90">
187
+ <p className="font-medium">{labels.failed}</p>
188
+ {errorMessage && <p className="mt-0.5 text-muted-foreground">{errorMessage}</p>}
189
+ </div>
190
+ </div>
191
+ )}
192
+ </div>
193
+ </div>
194
+
195
+ <div className="flex flex-col items-center gap-2 px-7 pt-2 pb-6">
196
+ {phase === "done" ? (
197
+ <button type="button" onClick={onShowInFolder} className={pillClass}>
198
+ <span className="icon-[mdi--folder-open-outline] h-4 w-4" />
199
+ {labels.showInFolder}
200
+ </button>
201
+ ) : (
202
+ <button type="button" onClick={onExport} disabled={exporting} className={pillClass}>
203
+ {exporting && <span className="icon-[mdi--loading] h-4 w-4 animate-spin" />}
204
+ {exporting ? labels.exporting : labels.export}
205
+ </button>
206
+ )}
207
+ <button
208
+ type="button"
209
+ onClick={onOpenIssue}
210
+ className="inline-flex h-8 items-center gap-1.5 rounded-full px-3 text-[12.5px] text-muted-foreground transition-colors outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/50"
211
+ >
212
+ <span className="icon-[mdi--github] h-3.5 w-3.5" />
213
+ {labels.openIssue}
214
+ <span className="icon-[mdi--open-in-new] h-3.5 w-3.5" />
215
+ </button>
216
+ </div>
217
+ </motion.div>
218
+ </motion.div>
219
+ )}
220
+ </AnimatePresence>
221
+ );
222
+ }
223
+
224
+ /** 静态横幅:海底像素风插画,小气泡拿放大镜查找故障。纯装饰,读屏跳过。 */
225
+ function DiagnosticsBanner(): JSX.Element {
226
+ return (
227
+ <img
228
+ src={diagnosticsBannerUrl}
229
+ alt=""
230
+ aria-hidden
231
+ draggable={false}
232
+ decoding="async"
233
+ className="block aspect-[8/3] w-full object-cover select-none"
234
+ />
235
+ );
236
+ }