@vetta-org/theme-ui 0.1.2 → 0.2.1
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 +8 -16
- package/src/action-approval/StorageCleanListView.test.tsx +36 -0
- package/src/action-approval/StorageCleanListView.tsx +52 -0
- package/src/action-approval/index.ts +2 -0
- package/src/activity/ActivityPanel.tsx +7 -1
- package/src/activity/ActivityPanelFrame.tsx +1 -1
- package/src/activity/BackgroundTasksTabPanelView.tsx +18 -2
- package/src/activity/BrowserPanelView.tsx +15 -1
- package/src/activity/BrowserSelectionView.tsx +199 -0
- package/src/activity/CodePreview.tsx +15 -1
- package/src/activity/MarkdownPreviewView.test.tsx +53 -0
- package/src/activity/MarkdownPreviewView.tsx +86 -10
- package/src/activity/index.ts +1 -0
- package/src/chat/ContextRingView.test.tsx +81 -0
- package/src/chat/ContextRingView.tsx +78 -62
- package/src/chat/EditDiffView.tsx +4 -4
- package/src/chat/HeaderActionBarView.tsx +135 -48
- package/src/chat/HeaderActionOverflowMenu.tsx +11 -20
- package/src/chat/MessageFeedLayoutView.tsx +6 -5
- package/src/chat/MessageInputView.tsx +5 -1
- package/src/chat/index.ts +2 -1
- package/src/chat/message-feed-fade.css +80 -0
- package/src/chat/message-feed-fade.test.tsx +75 -0
- package/src/chat/streaming-reveal.test.ts +1 -74
- package/src/chat/streaming-reveal.ts +0 -3
- package/src/file-preview/FilePreviewDialogView.tsx +2 -1
- package/src/file-preview/ReadonlyCodeView.tsx +46 -0
- package/src/file-preview/syntax-tokens.css +1 -1
- package/src/image-assets.d.ts +4 -0
- package/src/layout/ResizeHandle.tsx +4 -1
- package/src/layout/resize-handle-reset.test.tsx +50 -0
- package/src/markdown/FileLinkBadge.tsx +77 -0
- package/src/markdown/MarkdownContent.tsx +61 -31
- package/src/markdown/MarkdownImage.tsx +6 -16
- package/src/markdown/MermaidBlock.tsx +50 -11
- package/src/markdown/UrlLinkBadge.tsx +84 -0
- package/src/markdown/image-actions.ts +29 -0
- package/src/markdown/index.ts +2 -0
- package/src/markdown/nodes.ts +6 -1
- package/src/markdown/preview-policy.test.ts +31 -0
- package/src/markdown/preview-policy.ts +33 -0
- package/src/markdown/progressive-chunks.test.ts +43 -0
- package/src/markdown/progressive-chunks.ts +58 -0
- package/src/markdown/rich-labels.ts +9 -0
- package/src/markdown/streaming-fade.test.ts +83 -0
- package/src/markdown/streaming-fade.tsx +141 -0
- package/src/markdown/streaming-reveal.ts +0 -67
- package/src/markdown/streaming.ts +64 -131
- package/src/overlays/CommandMenuRow.tsx +47 -26
- package/src/overlays/CommandMenuView.tsx +107 -15
- package/src/overlays/DiagnosticsExportDialogView.tsx +236 -0
- package/src/overlays/MagpieHandoverDialogView.tsx +217 -0
- package/src/overlays/ReleaseNoteImage.test.tsx +105 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +49 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +120 -7
- package/src/overlays/SplashPanel.tsx +4 -4
- package/src/overlays/SplashParts.tsx +6 -2
- package/src/overlays/UpdateCheckerView.tsx +17 -15
- package/src/overlays/UpdateRestartDialogView.tsx +76 -2
- package/src/overlays/assets/diagnostics-banner.webp +0 -0
- package/src/overlays/command-menu-types.ts +15 -1
- package/src/overlays/index.ts +13 -0
- package/src/plugin-ui/index.ts +4 -0
- package/src/project/DefaultConversationSectionView.tsx +17 -22
- package/src/project/DefaultSessionRowView.tsx +8 -0
- package/src/project/ManageSessionsSplashView.tsx +0 -2
- package/src/settings/ArchivedProjectsSettingsView.tsx +122 -1
- package/src/settings/GeneralSettingsView.tsx +21 -5
- package/src/settings/LauncherSettingsView.test.tsx +95 -0
- package/src/settings/LauncherSettingsView.tsx +272 -0
- 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/PresetProviderRowView.tsx +37 -98
- package/src/settings/ShortcutsSettingsView.tsx +0 -4
- package/src/settings/SpaceEditorDialogView.tsx +94 -56
- package/src/settings/SpacesSettingsView.tsx +53 -8
- package/src/settings/StorageBar.tsx +70 -0
- package/src/settings/StorageExplorer.tsx +488 -0
- package/src/settings/StorageReadout.tsx +64 -0
- package/src/settings/StorageSettingsView.test.tsx +181 -0
- package/src/settings/StorageSettingsView.tsx +458 -0
- package/src/settings/assets/space-editor-illustration.webp +0 -0
- package/src/settings/index.ts +28 -39
- package/src/settings/storage-treemap-layout.test.ts +32 -0
- package/src/settings/storage-treemap-layout.ts +55 -0
- package/src/shared/SegmentedControl.test.tsx +68 -0
- package/src/shared/SegmentedControl.tsx +18 -11
- package/src/shared/StageDialogContent.test.tsx +61 -0
- package/src/shared/StageDialogContent.tsx +80 -0
- package/src/shared/TabBar.tsx +2 -2
- package/src/shared/VettaKbd.tsx +20 -1
- package/src/shared/index.ts +4 -1
- package/src/shared/platform.ts +9 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +13 -12
- package/src/sidebar/SettingsMenuTriggerView.tsx +2 -1
- package/src/sidebar/SidebarSectionActionButton.test.tsx +91 -0
- package/src/sidebar/SidebarSectionActionButton.tsx +52 -0
- package/src/styles.css +7 -0
- package/src/markdown/streaming.test.ts +0 -57
- package/src/settings/AchievementNavigationButtonView.tsx +0 -90
- package/src/settings/AchievementPromotionDialogView.tsx +0 -91
- package/src/settings/AchievementSettingsView.tsx +0 -43
- package/src/settings/PetBubbleStylePreviewView.tsx +0 -44
- package/src/settings/QuickPanelSettingsSectionView.tsx +0 -64
- 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
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
2
|
+
import { type JSX, type ReactNode, useRef } from "react";
|
|
3
|
+
import { cn, OVERLAY_BACKDROP_CLASS, PANEL_SHADOW_CLASS } from "@vetta-org/ui/utils";
|
|
4
|
+
|
|
5
|
+
export interface MagpieHandoverDialogViewLabels {
|
|
6
|
+
/** 标题上方的小字,点明这是一次接入方式的变化。 */
|
|
7
|
+
readonly eyebrow: string;
|
|
8
|
+
readonly title: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly stepInstall: string;
|
|
11
|
+
readonly stepConnect: string;
|
|
12
|
+
readonly stepUse: string;
|
|
13
|
+
/** 要在 Magpie 插件页搜索的包名,做成可复制的小标签。 */
|
|
14
|
+
readonly pluginName: string;
|
|
15
|
+
/** 插件名旁的说明,让用户认准官方发布者(如「发布者 openvetta」)。 */
|
|
16
|
+
readonly pluginPublisher: string;
|
|
17
|
+
readonly copy: string;
|
|
18
|
+
readonly copied: string;
|
|
19
|
+
readonly defaultModelCleared: string;
|
|
20
|
+
/** 删掉的是用户唯一的服务商:讲明接入前发不了消息。 */
|
|
21
|
+
readonly noProvidersLeft: string;
|
|
22
|
+
readonly primary: string;
|
|
23
|
+
readonly guide: string;
|
|
24
|
+
readonly close: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface MagpieHandoverDialogViewProps {
|
|
28
|
+
readonly visible: boolean;
|
|
29
|
+
readonly labels: MagpieHandoverDialogViewLabels;
|
|
30
|
+
/** 默认模型原本是 Magpie 的,随旧配置一起被清掉了。 */
|
|
31
|
+
readonly defaultModelCleared: boolean;
|
|
32
|
+
/** 删完后没有别的可用服务商:比默认模型被清掉更要紧,两条都成立时只显示这一条。 */
|
|
33
|
+
readonly noProvidersLeft: boolean;
|
|
34
|
+
readonly copied: boolean;
|
|
35
|
+
/** 顶部两枚图标:Vetta 的应用图标与 Magpie 的服务商图标,由宿主提供。 */
|
|
36
|
+
readonly vettaIcon: ReactNode;
|
|
37
|
+
readonly magpieIcon: ReactNode;
|
|
38
|
+
readonly onCopyPluginName: () => void;
|
|
39
|
+
readonly onOpenGuide: () => void;
|
|
40
|
+
readonly onClose: () => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const pillClass =
|
|
44
|
+
"inline-flex h-11 w-full items-center justify-center 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";
|
|
45
|
+
|
|
46
|
+
// 图标块在任何主题下都是白底,单色图标(跟随文字颜色)要固定成深色,否则深色模式下是浅灰、看不清。
|
|
47
|
+
const iconTileClass =
|
|
48
|
+
"flex size-16 items-center justify-center overflow-hidden rounded-[18px] bg-white text-neutral-900 shadow-[0_10px_28px_rgba(15,23,42,0.18),0_2px_6px_rgba(15,23,42,0.12)] ring-1 ring-black/5";
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 升级后告诉老用户:Magpie 改由 Magpie 在其 Agents 页接入 Vetta。
|
|
52
|
+
* 与「版本介绍」同一套外观:大圆角面板、顶部横幅、通栏胶囊主按钮、右上角白色关闭钮。
|
|
53
|
+
* 横幅是静态的两枚图标加一条连线,表示模型从 Magpie 流向 Vetta。
|
|
54
|
+
*/
|
|
55
|
+
export function MagpieHandoverDialogView({
|
|
56
|
+
visible,
|
|
57
|
+
labels,
|
|
58
|
+
defaultModelCleared,
|
|
59
|
+
noProvidersLeft,
|
|
60
|
+
copied,
|
|
61
|
+
vettaIcon,
|
|
62
|
+
magpieIcon,
|
|
63
|
+
onCopyPluginName,
|
|
64
|
+
onOpenGuide,
|
|
65
|
+
onClose,
|
|
66
|
+
}: MagpieHandoverDialogViewProps): JSX.Element {
|
|
67
|
+
const overlayRef = useRef<HTMLDivElement>(null);
|
|
68
|
+
const steps = [
|
|
69
|
+
{ text: labels.stepInstall, extra: true },
|
|
70
|
+
{ text: labels.stepConnect, extra: false },
|
|
71
|
+
{ text: labels.stepUse, extra: false },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<AnimatePresence>
|
|
76
|
+
{visible && (
|
|
77
|
+
<motion.div
|
|
78
|
+
ref={overlayRef}
|
|
79
|
+
initial={{ opacity: 0 }}
|
|
80
|
+
animate={{ opacity: 1 }}
|
|
81
|
+
exit={{ opacity: 0 }}
|
|
82
|
+
transition={{ duration: 0.15 }}
|
|
83
|
+
className={cn("pointer-events-auto fixed inset-0 z-[100] flex items-center justify-center", OVERLAY_BACKDROP_CLASS)}
|
|
84
|
+
onClick={(event) => {
|
|
85
|
+
if (event.target === overlayRef.current) onClose();
|
|
86
|
+
}}
|
|
87
|
+
onKeyDown={(event) => {
|
|
88
|
+
if (event.key === "Escape") onClose();
|
|
89
|
+
}}
|
|
90
|
+
>
|
|
91
|
+
<motion.div
|
|
92
|
+
role="dialog"
|
|
93
|
+
aria-modal="true"
|
|
94
|
+
aria-label={labels.title}
|
|
95
|
+
initial={{ opacity: 0, scale: 0.95 }}
|
|
96
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
97
|
+
exit={{ opacity: 0, scale: 0.95 }}
|
|
98
|
+
transition={{ duration: 0.15, ease: [0.25, 0.1, 0.25, 1] }}
|
|
99
|
+
className={cn(
|
|
100
|
+
"relative flex max-h-[min(780px,calc(100vh-48px))] w-[min(520px,calc(100vw-32px))] flex-col overflow-hidden rounded-3xl bg-popover",
|
|
101
|
+
PANEL_SHADOW_CLASS,
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
<button
|
|
105
|
+
type="button"
|
|
106
|
+
onClick={onClose}
|
|
107
|
+
aria-label={labels.close}
|
|
108
|
+
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"
|
|
109
|
+
>
|
|
110
|
+
<span className="icon-[mdi--close] h-4 w-4" />
|
|
111
|
+
</button>
|
|
112
|
+
|
|
113
|
+
<div className="no-scrollbar min-h-0 flex-1 overflow-y-auto [mask-image:linear-gradient(to_bottom,black_calc(100%-20px),transparent)]">
|
|
114
|
+
<HandoverBanner vettaIcon={vettaIcon} magpieIcon={magpieIcon} />
|
|
115
|
+
|
|
116
|
+
<div className="px-7 pt-5 pb-5">
|
|
117
|
+
<p className="text-[11px] font-semibold tracking-[0.08em] text-primary uppercase">{labels.eyebrow}</p>
|
|
118
|
+
<h3 className="mt-1.5 text-[19px] leading-snug font-semibold tracking-tight text-foreground">
|
|
119
|
+
{labels.title}
|
|
120
|
+
</h3>
|
|
121
|
+
<p className="mt-2 text-[13px] leading-relaxed text-muted-foreground">{labels.description}</p>
|
|
122
|
+
|
|
123
|
+
<ol className="mt-5 flex flex-col gap-2">
|
|
124
|
+
{steps.map((step, index) => (
|
|
125
|
+
<li
|
|
126
|
+
key={step.text}
|
|
127
|
+
className="flex items-start gap-3 rounded-2xl border border-border/70 bg-muted/40 px-4 py-3"
|
|
128
|
+
>
|
|
129
|
+
<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">
|
|
130
|
+
{index + 1}
|
|
131
|
+
</span>
|
|
132
|
+
<div className="min-w-0 flex-1">
|
|
133
|
+
<p className="text-[13px] leading-6 text-foreground">{step.text}</p>
|
|
134
|
+
{step.extra && (
|
|
135
|
+
<div className="mt-1.5 flex flex-wrap items-center gap-x-2.5 gap-y-1">
|
|
136
|
+
<button
|
|
137
|
+
type="button"
|
|
138
|
+
onClick={onCopyPluginName}
|
|
139
|
+
title={copied ? labels.copied : labels.copy}
|
|
140
|
+
className="group inline-flex h-7 items-center gap-1.5 rounded-lg border border-border bg-background px-2.5 font-mono text-[12px] text-foreground transition-colors outline-none hover:border-primary/50 focus-visible:ring-2 focus-visible:ring-ring/50"
|
|
141
|
+
>
|
|
142
|
+
{labels.pluginName}
|
|
143
|
+
<span
|
|
144
|
+
className={cn(
|
|
145
|
+
"h-3.5 w-3.5 transition-colors",
|
|
146
|
+
copied
|
|
147
|
+
? "icon-[mdi--check] text-emerald-500"
|
|
148
|
+
: "icon-[mdi--content-copy] text-muted-foreground group-hover:text-foreground",
|
|
149
|
+
)}
|
|
150
|
+
/>
|
|
151
|
+
<span className="sr-only">{copied ? labels.copied : labels.copy}</span>
|
|
152
|
+
</button>
|
|
153
|
+
<span className="inline-flex items-center gap-1 text-[12px] text-muted-foreground">
|
|
154
|
+
<span className="icon-[mdi--check-decagram] h-3.5 w-3.5 text-primary" />
|
|
155
|
+
{labels.pluginPublisher}
|
|
156
|
+
</span>
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
159
|
+
</div>
|
|
160
|
+
</li>
|
|
161
|
+
))}
|
|
162
|
+
</ol>
|
|
163
|
+
|
|
164
|
+
{(noProvidersLeft || defaultModelCleared) && (
|
|
165
|
+
<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">
|
|
166
|
+
<span className="mt-0.5 icon-[mdi--information-outline] h-4 w-4 shrink-0 text-amber-500" />
|
|
167
|
+
<p className="text-[12.5px] leading-relaxed text-foreground/90">
|
|
168
|
+
{noProvidersLeft ? labels.noProvidersLeft : labels.defaultModelCleared}
|
|
169
|
+
</p>
|
|
170
|
+
</div>
|
|
171
|
+
)}
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
|
|
175
|
+
<div className="flex flex-col items-center gap-2 px-7 pt-2 pb-6">
|
|
176
|
+
<button type="button" onClick={onClose} className={pillClass}>
|
|
177
|
+
{labels.primary}
|
|
178
|
+
</button>
|
|
179
|
+
<button
|
|
180
|
+
type="button"
|
|
181
|
+
onClick={onOpenGuide}
|
|
182
|
+
className="inline-flex h-8 items-center gap-1 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"
|
|
183
|
+
>
|
|
184
|
+
{labels.guide}
|
|
185
|
+
<span className="icon-[mdi--open-in-new] h-3.5 w-3.5" />
|
|
186
|
+
</button>
|
|
187
|
+
</div>
|
|
188
|
+
</motion.div>
|
|
189
|
+
</motion.div>
|
|
190
|
+
)}
|
|
191
|
+
</AnimatePresence>
|
|
192
|
+
);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** 静态横幅:Magpie 在左、Vetta 在右,中间虚线与箭头表示模型由 Magpie 接入 Vetta。 */
|
|
196
|
+
function HandoverBanner({ vettaIcon, magpieIcon }: { readonly vettaIcon: ReactNode; readonly magpieIcon: ReactNode }): JSX.Element {
|
|
197
|
+
return (
|
|
198
|
+
<div className="relative flex h-[148px] items-center justify-center overflow-hidden bg-[radial-gradient(120%_90%_at_50%_0%,color-mix(in_oklab,var(--primary)_22%,transparent),transparent_70%),linear-gradient(180deg,color-mix(in_oklab,var(--primary)_10%,var(--popover)),var(--popover))]">
|
|
199
|
+
{/* 淡淡的网格底纹,呼应 Vetta 图标的蓝格背景。 */}
|
|
200
|
+
<div
|
|
201
|
+
aria-hidden
|
|
202
|
+
className="absolute inset-0 opacity-[0.35] [background-image:linear-gradient(to_right,color-mix(in_oklab,var(--primary)_18%,transparent)_1px,transparent_1px),linear-gradient(to_bottom,color-mix(in_oklab,var(--primary)_18%,transparent)_1px,transparent_1px)] [background-size:28px_28px] [mask-image:radial-gradient(70%_80%_at_50%_45%,black,transparent)]"
|
|
203
|
+
/>
|
|
204
|
+
<div className="relative flex items-center gap-4">
|
|
205
|
+
<div className={iconTileClass}>{magpieIcon}</div>
|
|
206
|
+
<div aria-hidden className="flex items-center gap-1.5 text-primary">
|
|
207
|
+
<span className="h-px w-6 border-t-2 border-dashed border-primary/45" />
|
|
208
|
+
<span className="inline-flex size-7 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-md shadow-primary/30">
|
|
209
|
+
<span className="icon-[mdi--arrow-right] h-4 w-4" />
|
|
210
|
+
</span>
|
|
211
|
+
<span className="h-px w-6 border-t-2 border-dashed border-primary/45" />
|
|
212
|
+
</div>
|
|
213
|
+
<div className={iconTileClass}>{vettaIcon}</div>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { act, type JSX, useState } from "react";
|
|
4
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
5
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
6
|
+
import { ReleaseNoteMarkdown } from "./ReleaseNoteMarkdown";
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
9
|
+
|
|
10
|
+
const URL_ZH = "https://github.com/openvetta/open-vetta/releases/download/v0.6.34/whats-new-zh.webp";
|
|
11
|
+
const mounted: Array<{ root: Root; container: HTMLDivElement }> = [];
|
|
12
|
+
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
for (const { root, container } of mounted.splice(0)) {
|
|
15
|
+
act(() => root.unmount());
|
|
16
|
+
container.remove();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
function mount(note: string, onOpenImage?: (image: { src: string; alt: string }) => void): HTMLDivElement {
|
|
21
|
+
const container = document.createElement("div");
|
|
22
|
+
document.body.append(container);
|
|
23
|
+
const root = createRoot(container);
|
|
24
|
+
mounted.push({ root, container });
|
|
25
|
+
act(() => root.render(<ReleaseNoteMarkdown onOpenImage={onOpenImage}>{note}</ReleaseNoteMarkdown>));
|
|
26
|
+
return container;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** 最小宿主:点图后显示一个灯箱,测的是用户看到的结果而不是回调本身。 */
|
|
30
|
+
function HostWithLightbox({ note }: { readonly note: string }): JSX.Element {
|
|
31
|
+
const [opened, setOpened] = useState<{ src: string; alt: string } | null>(null);
|
|
32
|
+
return (
|
|
33
|
+
<>
|
|
34
|
+
<ReleaseNoteMarkdown onOpenImage={setOpened}>{note}</ReleaseNoteMarkdown>
|
|
35
|
+
{opened && (
|
|
36
|
+
<div role="dialog" data-src={opened.src}>
|
|
37
|
+
{opened.alt}
|
|
38
|
+
</div>
|
|
39
|
+
)}
|
|
40
|
+
</>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
describe("release note images", () => {
|
|
45
|
+
it("shows the image once it has loaded", () => {
|
|
46
|
+
const container = mount(`\n\n- 一条`);
|
|
47
|
+
const image = container.querySelector("img") as HTMLImageElement;
|
|
48
|
+
expect(image.classList.contains("hidden")).toBe(true);
|
|
49
|
+
|
|
50
|
+
act(() => {
|
|
51
|
+
image.dispatchEvent(new Event("load"));
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
expect(image.classList.contains("hidden")).toBe(false);
|
|
55
|
+
expect(image.dataset.releaseImage).toBe("loaded");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("renders as if there were no image when loading fails, keeping the text", () => {
|
|
59
|
+
const container = mount(`[](${URL_ZH})\n\n- 一条`);
|
|
60
|
+
const image = container.querySelector("img") as HTMLImageElement;
|
|
61
|
+
|
|
62
|
+
act(() => {
|
|
63
|
+
image.dispatchEvent(new Event("error"));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
expect(container.querySelector("img")).toBeNull();
|
|
67
|
+
expect(container.textContent?.trim()).toBe("一条");
|
|
68
|
+
// 只装着配图的段落要收起边距,否则失败后会多出一段空白。
|
|
69
|
+
const paragraph = container.querySelector("p") as HTMLParagraphElement;
|
|
70
|
+
expect(paragraph.querySelector('[data-release-image="failed"]')).not.toBeNull();
|
|
71
|
+
expect(paragraph.className).toContain("[&:has([data-release-image])]:my-0");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("opens the loaded image in the host lightbox instead of following the GitHub link", () => {
|
|
75
|
+
const container = document.createElement("div");
|
|
76
|
+
document.body.append(container);
|
|
77
|
+
const root = createRoot(container);
|
|
78
|
+
mounted.push({ root, container });
|
|
79
|
+
act(() => root.render(<HostWithLightbox note={`[](${URL_ZH})`} />));
|
|
80
|
+
const image = container.querySelector("img") as HTMLImageElement;
|
|
81
|
+
const button = container.querySelector("button") as HTMLButtonElement;
|
|
82
|
+
expect(button.className).toBe("hidden");
|
|
83
|
+
|
|
84
|
+
act(() => {
|
|
85
|
+
image.dispatchEvent(new Event("load"));
|
|
86
|
+
});
|
|
87
|
+
expect(button.className).toContain("cursor-zoom-in");
|
|
88
|
+
expect(button.getAttribute("aria-label")).toBe("本版介绍");
|
|
89
|
+
expect(container.querySelector('[role="dialog"]')).toBeNull();
|
|
90
|
+
|
|
91
|
+
const click = new MouseEvent("click", { bubbles: true, cancelable: true });
|
|
92
|
+
act(() => {
|
|
93
|
+
button.dispatchEvent(click);
|
|
94
|
+
});
|
|
95
|
+
const lightbox = container.querySelector('[role="dialog"]') as HTMLElement;
|
|
96
|
+
expect(lightbox.getAttribute("data-src")).toBe(URL_ZH);
|
|
97
|
+
expect(lightbox.textContent).toBe("本版介绍");
|
|
98
|
+
expect(click.defaultPrevented).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it("is not clickable when the host offers no lightbox", () => {
|
|
102
|
+
const container = mount(``);
|
|
103
|
+
expect(container.querySelector("button")).toBeNull();
|
|
104
|
+
});
|
|
105
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { ReleaseNoteMarkdown } from "./ReleaseNoteMarkdown";
|
|
4
|
+
|
|
5
|
+
function renderNote(note: string): string {
|
|
6
|
+
return renderToStaticMarkup(<ReleaseNoteMarkdown>{note}</ReleaseNoteMarkdown>);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe("ReleaseNoteMarkdown", () => {
|
|
10
|
+
it("opens web links in a new window so the host hands them to the system browser", () => {
|
|
11
|
+
const html = renderNote("See [the issue](https://github.com/openvetta/open-vetta/issues/8).");
|
|
12
|
+
|
|
13
|
+
expect(html).toContain('href="https://github.com/openvetta/open-vetta/issues/8"');
|
|
14
|
+
expect(html).toContain('target="_blank"');
|
|
15
|
+
expect(html).toContain('rel="noopener noreferrer"');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("renders non-web links as plain text so clicking cannot navigate the app window", () => {
|
|
19
|
+
const html = renderNote("Read [the docs](./docs/guide.md).");
|
|
20
|
+
|
|
21
|
+
expect(html).not.toContain("<a");
|
|
22
|
+
expect(html).toContain("the docs");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("keeps a release image hidden until it loads, so a failed load shows nothing", () => {
|
|
26
|
+
const url = "https://github.com/openvetta/open-vetta/releases/download/v0.6.34/whats-new-zh.webp";
|
|
27
|
+
const html = renderNote(`\n\n- 一条`);
|
|
28
|
+
|
|
29
|
+
expect(html).toContain(`src="${url}"`);
|
|
30
|
+
expect(html).toContain('alt="本版介绍"');
|
|
31
|
+
expect(html).toContain('data-release-image="loading"');
|
|
32
|
+
expect(html).toMatch(/<img[^>]*class="hidden"/);
|
|
33
|
+
expect(html).not.toContain('loading="lazy"');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("does not load images from non-https addresses", () => {
|
|
37
|
+
for (const src of ["file:///etc/hosts", "http://example.com/a.png"]) {
|
|
38
|
+
const html = renderNote(``);
|
|
39
|
+
expect(html).not.toContain("<img");
|
|
40
|
+
expect(html).toContain('data-release-image="failed"');
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("shows inline image data used by the development preview, but no other data URLs", () => {
|
|
45
|
+
const html = renderNote("");
|
|
46
|
+
expect(html).toContain('src="data:image/webp;base64,UklGRg=="');
|
|
47
|
+
expect(renderNote("")).not.toContain("<img");
|
|
48
|
+
});
|
|
49
|
+
});
|