@vetta-org/theme-ui 0.2.0 → 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 +1 -1
- 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/BackgroundTasksTabPanelView.tsx +18 -2
- package/src/activity/BrowserPanelView.tsx +15 -1
- package/src/activity/BrowserSelectionView.tsx +199 -0
- package/src/activity/index.ts +1 -0
- package/src/chat/EditDiffView.tsx +4 -4
- package/src/chat/HeaderActionBarView.tsx +16 -4
- 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/layout/ResizeHandle.tsx +4 -1
- package/src/layout/resize-handle-reset.test.tsx +50 -0
- package/src/markdown/MarkdownContent.tsx +49 -26
- package/src/markdown/UrlLinkBadge.tsx +84 -0
- package/src/markdown/index.ts +1 -0
- package/src/markdown/nodes.ts +6 -1
- package/src/markdown/rich-labels.ts +3 -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 +4 -14
- package/src/overlays/CommandMenuView.tsx +11 -4
- package/src/overlays/ReleaseNoteImage.test.tsx +105 -0
- package/src/overlays/ReleaseNoteMarkdown.test.tsx +25 -0
- package/src/overlays/ReleaseNoteMarkdown.tsx +94 -7
- package/src/overlays/UpdateCheckerView.tsx +17 -15
- package/src/overlays/UpdateRestartDialogView.tsx +14 -5
- package/src/overlays/command-menu-types.ts +2 -0
- package/src/overlays/index.ts +1 -0
- package/src/plugin-ui/index.ts +2 -0
- package/src/project/DefaultConversationSectionView.tsx +4 -0
- package/src/project/ManageSessionsSplashView.tsx +0 -2
- package/src/settings/GeneralSettingsView.tsx +19 -0
- package/src/settings/LauncherSettingsView.tsx +0 -1
- 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/index.ts +10 -0
- package/src/settings/storage-treemap-layout.test.ts +32 -0
- package/src/settings/storage-treemap-layout.ts +55 -0
- package/src/shared/SegmentedControl.tsx +10 -11
- package/src/shared/StageDialogContent.test.tsx +61 -0
- package/src/shared/StageDialogContent.tsx +80 -0
- package/src/shared/index.ts +2 -0
- package/src/sidebar/AddProjectMenuTriggerView.tsx +4 -2
- package/src/styles.css +5 -0
- package/src/markdown/streaming.test.ts +0 -57
package/package.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
|
|
3
|
+
import { act } from "react";
|
|
4
|
+
import { createRoot } from "react-dom/client";
|
|
5
|
+
import { expect, it } from "vitest";
|
|
6
|
+
import { StorageCleanListView } from "./StorageCleanListView";
|
|
7
|
+
|
|
8
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
9
|
+
|
|
10
|
+
it("展示理由与恢复方式,点击整行切换勾选,占用中的条目不能勾选", () => {
|
|
11
|
+
const toggled: unknown[] = [];
|
|
12
|
+
const item = { path: "workspace/a", size: "1 GB", reason: "Idle", restore: "npm ci", checked: true, disabled: false };
|
|
13
|
+
const container = document.createElement("div");
|
|
14
|
+
document.body.append(container);
|
|
15
|
+
const root = createRoot(container);
|
|
16
|
+
act(() =>
|
|
17
|
+
root.render(
|
|
18
|
+
<StorageCleanListView
|
|
19
|
+
items={[
|
|
20
|
+
{ ...item, id: "a", title: "Dependencies" },
|
|
21
|
+
{ ...item, id: "b", title: "Busy", checked: false, disabled: true },
|
|
22
|
+
]}
|
|
23
|
+
summary="1 selected"
|
|
24
|
+
onToggle={(id, checked) => toggled.push([id, checked])}
|
|
25
|
+
/>,
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
const [first, second] = [...container.querySelectorAll("label")];
|
|
29
|
+
expect(first?.textContent).toContain("Idle");
|
|
30
|
+
expect(first?.textContent).toContain("npm ci");
|
|
31
|
+
act(() => first?.click());
|
|
32
|
+
act(() => second?.click());
|
|
33
|
+
expect(toggled).toEqual([["a", false]]);
|
|
34
|
+
act(() => root.unmount());
|
|
35
|
+
container.remove();
|
|
36
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { JSX } from "react";
|
|
2
|
+
import { cn } from "./cn";
|
|
3
|
+
|
|
4
|
+
export interface StorageCleanListItemView {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly title: string;
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly size: string;
|
|
9
|
+
readonly reason: string;
|
|
10
|
+
/** 清理之后怎么恢复,由宿主给出。 */
|
|
11
|
+
readonly restore: string;
|
|
12
|
+
readonly checked: boolean;
|
|
13
|
+
readonly disabled: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface StorageCleanListViewProps {
|
|
17
|
+
readonly items: readonly StorageCleanListItemView[];
|
|
18
|
+
readonly summary: string;
|
|
19
|
+
readonly onToggle: (id: string, checked: boolean) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function StorageCleanListView({ items, summary, onToggle }: StorageCleanListViewProps): JSX.Element {
|
|
23
|
+
return (
|
|
24
|
+
<div className="space-y-2">
|
|
25
|
+
<ul className="max-h-[320px] overflow-y-auto rounded-lg border border-border/50 bg-background/50">
|
|
26
|
+
{items.map((item, index) => (
|
|
27
|
+
<li key={item.id} className={cn(index > 0 && "border-t border-border/40")}>
|
|
28
|
+
<label className={cn("flex items-start gap-3 p-3", item.disabled ? "opacity-50" : "cursor-pointer")}>
|
|
29
|
+
<input
|
|
30
|
+
type="checkbox"
|
|
31
|
+
className="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary"
|
|
32
|
+
checked={item.checked}
|
|
33
|
+
disabled={item.disabled}
|
|
34
|
+
onChange={(event) => onToggle(item.id, event.target.checked)}
|
|
35
|
+
/>
|
|
36
|
+
<span className="min-w-0 flex-1">
|
|
37
|
+
<span className="flex justify-between gap-3 text-[12px] font-medium text-foreground">
|
|
38
|
+
<span>{item.title}</span>
|
|
39
|
+
<span className="shrink-0 tabular-nums">{item.size}</span>
|
|
40
|
+
</span>
|
|
41
|
+
<span className="mt-0.5 block break-all font-mono text-[10px] text-muted-foreground">{item.path}</span>
|
|
42
|
+
<span className="mt-1 block text-[11px] text-foreground">{item.reason}</span>
|
|
43
|
+
<span className="mt-0.5 block text-[11px] text-muted-foreground">{item.restore}</span>
|
|
44
|
+
</span>
|
|
45
|
+
</label>
|
|
46
|
+
</li>
|
|
47
|
+
))}
|
|
48
|
+
</ul>
|
|
49
|
+
<p className="text-[11px] text-muted-foreground">{summary}</p>
|
|
50
|
+
</div>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -79,6 +79,8 @@ export type {
|
|
|
79
79
|
export { SchedulerEditApprovalDrawerView } from "./SchedulerEditApprovalDrawerView";
|
|
80
80
|
export type { SchedulerUpdateApprovalViewProps } from "./SchedulerUpdateApprovalView";
|
|
81
81
|
export { SchedulerUpdateApprovalView } from "./SchedulerUpdateApprovalView";
|
|
82
|
+
export type { StorageCleanListItemView, StorageCleanListViewProps } from "./StorageCleanListView";
|
|
83
|
+
export { StorageCleanListView } from "./StorageCleanListView";
|
|
82
84
|
export type { ThemeChangeApprovalViewProps } from "./ThemeChangeApprovalView";
|
|
83
85
|
export { ThemeChangeApprovalView } from "./ThemeChangeApprovalView";
|
|
84
86
|
export type { WebhookDeleteApprovalViewProps } from "./WebhookDeleteApprovalView";
|
|
@@ -21,6 +21,7 @@ interface ActivityPanelContextValue {
|
|
|
21
21
|
readonly resize: (delta: number) => void;
|
|
22
22
|
readonly resizeEnd: () => void;
|
|
23
23
|
readonly resizeStart: () => void;
|
|
24
|
+
readonly resizeReset?: () => void;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const ActivityPanelContext = createContext<ActivityPanelContextValue | null>(null);
|
|
@@ -37,6 +38,8 @@ export interface ActivityPanelRootProps {
|
|
|
37
38
|
/** Reports the absolute live width while the local shell follows the pointer. */
|
|
38
39
|
readonly onResize?: (width: number) => void;
|
|
39
40
|
readonly onResizeEnd?: (width: number) => void;
|
|
41
|
+
/** 双击分隔条:宿主把宽度恢复成默认值。 */
|
|
42
|
+
readonly onResizeReset?: () => void;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
/** Owns controlled panel state and resize behavior. Layout remains explicit children. */
|
|
@@ -51,6 +54,7 @@ export function ActivityPanelRoot({
|
|
|
51
54
|
onResizeStart,
|
|
52
55
|
onResize,
|
|
53
56
|
onResizeEnd,
|
|
57
|
+
onResizeReset,
|
|
54
58
|
}: ActivityPanelRootProps): JSX.Element {
|
|
55
59
|
const liveWidthRef = useRef(width);
|
|
56
60
|
const [liveWidth, setLiveWidth] = useState(width);
|
|
@@ -94,6 +98,7 @@ export function ActivityPanelRoot({
|
|
|
94
98
|
isResizing: locallyResizing || isResizing,
|
|
95
99
|
resize,
|
|
96
100
|
resizeEnd,
|
|
101
|
+
resizeReset: onResizeReset,
|
|
97
102
|
resizeStart,
|
|
98
103
|
}}
|
|
99
104
|
>
|
|
@@ -194,7 +199,7 @@ export const ActivityPanelBody = forwardRef<HTMLDivElement, ActivityPanelBodyPro
|
|
|
194
199
|
);
|
|
195
200
|
|
|
196
201
|
export function ActivityPanelResizeHandle(): JSX.Element | null {
|
|
197
|
-
const { isOpen, resize, resizeEnd, resizeStart } = useActivityPanelContext("ResizeHandle");
|
|
202
|
+
const { isOpen, resize, resizeEnd, resizeReset, resizeStart } = useActivityPanelContext("ResizeHandle");
|
|
198
203
|
if (!isOpen) return null;
|
|
199
204
|
return (
|
|
200
205
|
<ResizeHandle
|
|
@@ -202,6 +207,7 @@ export function ActivityPanelResizeHandle(): JSX.Element | null {
|
|
|
202
207
|
onResizeStart={resizeStart}
|
|
203
208
|
onResize={resize}
|
|
204
209
|
onResizeEnd={resizeEnd}
|
|
210
|
+
onReset={resizeReset}
|
|
205
211
|
/>
|
|
206
212
|
);
|
|
207
213
|
}
|
|
@@ -19,6 +19,9 @@ export interface BackgroundTaskViewItem {
|
|
|
19
19
|
statusLabel: string;
|
|
20
20
|
statusClassName: string;
|
|
21
21
|
durationLabel: string;
|
|
22
|
+
/** Replaces the default `bash` badge, e.g. for processes a command left running. */
|
|
23
|
+
badgeLabel?: string;
|
|
24
|
+
badgeTitle?: string;
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
/** Subagent child row (explorer / future types) — same tab, different card. */
|
|
@@ -126,9 +129,18 @@ function WorkCardHeader({
|
|
|
126
129
|
);
|
|
127
130
|
}
|
|
128
131
|
|
|
129
|
-
function KindBadge({
|
|
132
|
+
function KindBadge({
|
|
133
|
+
tone,
|
|
134
|
+
title,
|
|
135
|
+
children,
|
|
136
|
+
}: {
|
|
137
|
+
tone: "neutral" | "primary";
|
|
138
|
+
title?: string;
|
|
139
|
+
children: ReactNode;
|
|
140
|
+
}): JSX.Element {
|
|
130
141
|
return (
|
|
131
142
|
<span
|
|
143
|
+
title={title}
|
|
132
144
|
className={`shrink-0 rounded-md px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide ${
|
|
133
145
|
tone === "primary" ? "bg-primary/10 text-primary" : "bg-muted text-muted-foreground"
|
|
134
146
|
}`}
|
|
@@ -203,7 +215,11 @@ function BashTaskCard({
|
|
|
203
215
|
statusClassName={task.statusClassName}
|
|
204
216
|
statusLabel={task.statusLabel}
|
|
205
217
|
durationLabel={task.durationLabel}
|
|
206
|
-
badge={
|
|
218
|
+
badge={
|
|
219
|
+
<KindBadge tone="neutral" title={task.badgeTitle}>
|
|
220
|
+
{task.badgeLabel ?? "bash"}
|
|
221
|
+
</KindBadge>
|
|
222
|
+
}
|
|
207
223
|
identity={
|
|
208
224
|
<span className="block truncate font-mono text-[10px] text-muted-foreground/70" title={task.id}>
|
|
209
225
|
{task.id}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Button, ButtonGroup, ButtonGroupItem } from "@vetta-org/ui";
|
|
2
|
-
import type { FormEvent, JSX, Ref } from "react";
|
|
2
|
+
import type { FormEvent, JSX, Ref, ReactNode } from "react";
|
|
3
3
|
|
|
4
4
|
export interface BrowserPanelLabels {
|
|
5
5
|
noSession: string;
|
|
@@ -16,6 +16,8 @@ export interface BrowserPanelLabels {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export interface BrowserPanelViewProps {
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
captureAction?: { label: string; disabled: boolean; onClick: () => void };
|
|
19
21
|
/** Null when the host has no bound workspace — show empty state. */
|
|
20
22
|
workspaceId: string | null;
|
|
21
23
|
labels: BrowserPanelLabels;
|
|
@@ -46,6 +48,8 @@ function toolbarIcon(icon: string): JSX.Element {
|
|
|
46
48
|
* Session-scoped built-in browser shell. Host owns webview event wiring via ref.
|
|
47
49
|
*/
|
|
48
50
|
export function BrowserPanelView({
|
|
51
|
+
children,
|
|
52
|
+
captureAction,
|
|
49
53
|
workspaceId,
|
|
50
54
|
labels,
|
|
51
55
|
address,
|
|
@@ -120,6 +124,15 @@ export function BrowserPanelView({
|
|
|
120
124
|
/>
|
|
121
125
|
</form>
|
|
122
126
|
<ButtonGroup blur={false} className="shrink-0">
|
|
127
|
+
{captureAction && (
|
|
128
|
+
<ButtonGroupItem
|
|
129
|
+
icon={toolbarIcon("icon-[mdi--camera-outline]")}
|
|
130
|
+
title={captureAction.label}
|
|
131
|
+
aria-label={captureAction.label}
|
|
132
|
+
disabled={captureAction.disabled}
|
|
133
|
+
onClick={captureAction.onClick}
|
|
134
|
+
/>
|
|
135
|
+
)}
|
|
123
136
|
<ButtonGroupItem
|
|
124
137
|
icon={toolbarIcon("icon-[mdi--open-in-new]")}
|
|
125
138
|
title={labels.openExternal}
|
|
@@ -141,6 +154,7 @@ export function BrowserPanelView({
|
|
|
141
154
|
allowpopups={true}
|
|
142
155
|
className="h-full w-full"
|
|
143
156
|
/>
|
|
157
|
+
{children}
|
|
144
158
|
{!hasPage && (
|
|
145
159
|
<div className="absolute inset-0 flex flex-col items-center justify-center gap-2 bg-muted p-6 text-center">
|
|
146
160
|
<span className="icon-[mdi--web] h-8 w-8 text-muted-foreground/30" />
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import type { PointerEvent, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
interface Rect {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
interface BrowserSelectionViewProps {
|
|
11
|
+
mode: "element" | "region";
|
|
12
|
+
viewport: { width: number; height: number };
|
|
13
|
+
rect: Rect | null;
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
label: string;
|
|
16
|
+
onInspect: (x: number, y: number, lock: boolean) => void;
|
|
17
|
+
onRegionChange: (rect: Rect) => void;
|
|
18
|
+
onScroll: (x: number, y: number, point: { x: number; y: number }) => void;
|
|
19
|
+
/** Floats above the page while selecting; a sibling of the surface so its clicks never start a selection. */
|
|
20
|
+
toolbar?: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Host overlay intercepts pointer input; selecting never clicks the guest page. */
|
|
24
|
+
export function BrowserSelectionView({
|
|
25
|
+
mode,
|
|
26
|
+
viewport,
|
|
27
|
+
rect,
|
|
28
|
+
disabled,
|
|
29
|
+
label,
|
|
30
|
+
onInspect,
|
|
31
|
+
onRegionChange,
|
|
32
|
+
onScroll,
|
|
33
|
+
toolbar,
|
|
34
|
+
}: BrowserSelectionViewProps) {
|
|
35
|
+
const surface = useRef<HTMLDivElement>(null);
|
|
36
|
+
const drag = useRef<{
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
clientX: number;
|
|
40
|
+
clientY: number;
|
|
41
|
+
rect: Rect | null;
|
|
42
|
+
action: string;
|
|
43
|
+
pending: boolean;
|
|
44
|
+
} | null>(null);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
const node = surface.current;
|
|
47
|
+
if (!node) return;
|
|
48
|
+
const wheel = (event: WheelEvent) => {
|
|
49
|
+
event.preventDefault();
|
|
50
|
+
if (!disabled && !drag.current && mode === "element") {
|
|
51
|
+
const bounds = node.getBoundingClientRect();
|
|
52
|
+
onScroll(event.deltaX, event.deltaY, {
|
|
53
|
+
x: ((event.clientX - bounds.left) * viewport.width) / (bounds.width || 1),
|
|
54
|
+
y: ((event.clientY - bounds.top) * viewport.height) / (bounds.height || 1),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
node.addEventListener("wheel", wheel, { passive: false });
|
|
59
|
+
return () => node.removeEventListener("wheel", wheel);
|
|
60
|
+
}, [mode, disabled, onScroll, viewport.width, viewport.height]);
|
|
61
|
+
const point = (event: PointerEvent) => {
|
|
62
|
+
const bounds = surface.current?.getBoundingClientRect();
|
|
63
|
+
return {
|
|
64
|
+
x: Math.max(
|
|
65
|
+
0,
|
|
66
|
+
Math.min(viewport.width, ((event.clientX - (bounds?.left ?? 0)) * viewport.width) / (bounds?.width || 1)),
|
|
67
|
+
),
|
|
68
|
+
y: Math.max(
|
|
69
|
+
0,
|
|
70
|
+
Math.min(viewport.height, ((event.clientY - (bounds?.top ?? 0)) * viewport.height) / (bounds?.height || 1)),
|
|
71
|
+
),
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
const move = (event: PointerEvent) => {
|
|
75
|
+
if (disabled) return;
|
|
76
|
+
const current = point(event),
|
|
77
|
+
start = drag.current;
|
|
78
|
+
if (!start && mode === "element") {
|
|
79
|
+
void onInspect(current.x, current.y, false);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (!start) return;
|
|
83
|
+
if (start.pending) {
|
|
84
|
+
if (Math.hypot(event.clientX - start.clientX, event.clientY - start.clientY) < 4) return;
|
|
85
|
+
start.pending = false;
|
|
86
|
+
}
|
|
87
|
+
if (start.action === "move" && start.rect) {
|
|
88
|
+
onRegionChange({
|
|
89
|
+
...start.rect,
|
|
90
|
+
x: Math.max(0, Math.min(viewport.width - start.rect.width, start.rect.x + current.x - start.x)),
|
|
91
|
+
y: Math.max(0, Math.min(viewport.height - start.rect.height, start.rect.y + current.y - start.y)),
|
|
92
|
+
});
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
let anchorX = start.x,
|
|
96
|
+
anchorY = start.y;
|
|
97
|
+
if (start.rect && start.action !== "new") {
|
|
98
|
+
anchorX = start.action.includes("w") ? start.rect.x + start.rect.width : start.rect.x;
|
|
99
|
+
anchorY = start.action.includes("n") ? start.rect.y + start.rect.height : start.rect.y;
|
|
100
|
+
}
|
|
101
|
+
onRegionChange({
|
|
102
|
+
x: Math.min(anchorX, current.x),
|
|
103
|
+
y: Math.min(anchorY, current.y),
|
|
104
|
+
width: Math.abs(current.x - anchorX),
|
|
105
|
+
height: Math.abs(current.y - anchorY),
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return (
|
|
109
|
+
<>
|
|
110
|
+
<div
|
|
111
|
+
ref={surface}
|
|
112
|
+
role="application"
|
|
113
|
+
aria-label={label}
|
|
114
|
+
tabIndex={0}
|
|
115
|
+
className="absolute inset-0 z-10 cursor-crosshair touch-none select-none"
|
|
116
|
+
onPointerDown={(event) => {
|
|
117
|
+
if (disabled || event.button !== 0) return;
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
const current = point(event);
|
|
120
|
+
const action =
|
|
121
|
+
mode === "region" && event.target instanceof HTMLElement
|
|
122
|
+
? (event.target.dataset.captureAction ?? "new")
|
|
123
|
+
: "new";
|
|
124
|
+
drag.current = {
|
|
125
|
+
...current,
|
|
126
|
+
clientX: event.clientX,
|
|
127
|
+
clientY: event.clientY,
|
|
128
|
+
rect,
|
|
129
|
+
action,
|
|
130
|
+
pending: mode === "element",
|
|
131
|
+
};
|
|
132
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
133
|
+
}}
|
|
134
|
+
onPointerMove={move}
|
|
135
|
+
onPointerUp={(event) => {
|
|
136
|
+
if (drag.current) move(event);
|
|
137
|
+
if (!disabled && drag.current?.pending) {
|
|
138
|
+
const current = point(event);
|
|
139
|
+
void onInspect(current.x, current.y, true);
|
|
140
|
+
}
|
|
141
|
+
drag.current = null;
|
|
142
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId))
|
|
143
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
144
|
+
}}
|
|
145
|
+
onPointerCancel={() => {
|
|
146
|
+
drag.current = null;
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{rect ? (
|
|
150
|
+
<svg
|
|
151
|
+
aria-hidden="true"
|
|
152
|
+
className="pointer-events-none absolute inset-0 h-full w-full fill-background/60"
|
|
153
|
+
viewBox={`0 0 ${viewport.width} ${viewport.height}`}
|
|
154
|
+
preserveAspectRatio="none"
|
|
155
|
+
>
|
|
156
|
+
<path
|
|
157
|
+
fillRule="evenodd"
|
|
158
|
+
d={`M0 0H${viewport.width}V${viewport.height}H0Z M${rect.x} ${rect.y}h${rect.width}v${rect.height}h${-rect.width}Z`}
|
|
159
|
+
/>
|
|
160
|
+
</svg>
|
|
161
|
+
) : null}
|
|
162
|
+
{rect ? (
|
|
163
|
+
<div
|
|
164
|
+
data-capture-action="move"
|
|
165
|
+
className={`absolute border-3 border-browser-selection ${mode === "region" ? "cursor-move" : "cursor-crosshair"}`}
|
|
166
|
+
style={{
|
|
167
|
+
left: `${(rect.x / viewport.width) * 100}%`,
|
|
168
|
+
top: `${(rect.y / viewport.height) * 100}%`,
|
|
169
|
+
width: `${(rect.width / viewport.width) * 100}%`,
|
|
170
|
+
height: `${(rect.height / viewport.height) * 100}%`,
|
|
171
|
+
}}
|
|
172
|
+
>
|
|
173
|
+
{mode === "region"
|
|
174
|
+
? ["nw", "ne", "sw", "se"].map((corner) => (
|
|
175
|
+
<span
|
|
176
|
+
key={corner}
|
|
177
|
+
data-capture-action={corner}
|
|
178
|
+
className="absolute h-3 w-3 rounded-full border border-browser-selection bg-background"
|
|
179
|
+
style={{
|
|
180
|
+
left: corner.includes("w") ? -6 : undefined,
|
|
181
|
+
right: corner.includes("e") ? -6 : undefined,
|
|
182
|
+
top: corner.includes("n") ? -6 : undefined,
|
|
183
|
+
bottom: corner.includes("s") ? -6 : undefined,
|
|
184
|
+
cursor: `${corner}-resize`,
|
|
185
|
+
}}
|
|
186
|
+
/>
|
|
187
|
+
))
|
|
188
|
+
: null}
|
|
189
|
+
</div>
|
|
190
|
+
) : null}
|
|
191
|
+
</div>
|
|
192
|
+
{toolbar ? (
|
|
193
|
+
<div className="pointer-events-none absolute inset-x-0 bottom-3 z-20 flex justify-center px-3">
|
|
194
|
+
<div className="pointer-events-auto max-w-full">{toolbar}</div>
|
|
195
|
+
</div>
|
|
196
|
+
) : null}
|
|
197
|
+
</>
|
|
198
|
+
);
|
|
199
|
+
}
|
package/src/activity/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ export type { BatchProgressTabPanelViewProps } from "./BatchProgressTabPanelView
|
|
|
41
41
|
export { BatchProgressTabPanelView } from "./BatchProgressTabPanelView";
|
|
42
42
|
export type { BrowserPanelLabels, BrowserPanelViewProps } from "./BrowserPanelView";
|
|
43
43
|
export { BrowserPanelView } from "./BrowserPanelView";
|
|
44
|
+
export { BrowserSelectionView } from "./BrowserSelectionView.js";
|
|
44
45
|
export type { ChatTabPanelViewProps } from "./ChatTabPanelView";
|
|
45
46
|
export { ChatTabPanelView } from "./ChatTabPanelView";
|
|
46
47
|
export type { CodePreviewProps } from "./CodePreview";
|
|
@@ -17,7 +17,7 @@ export interface DiffPreviewViewProps {
|
|
|
17
17
|
statsAdded: number;
|
|
18
18
|
statsRemoved: number;
|
|
19
19
|
netLabel: string;
|
|
20
|
-
/**
|
|
20
|
+
/** 编辑模式徽标(如「分块编辑」)。undefined = 不显示。 */
|
|
21
21
|
modeBadge?: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -58,7 +58,7 @@ export function DiffPreviewView({
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface AnchorEditItemView {
|
|
61
|
-
/**
|
|
61
|
+
/** 定位文本(块首行;区间为「首行 – 末行」) */
|
|
62
62
|
anchorLabel: string;
|
|
63
63
|
/** 动作描述(替换/插入/删除,已本地化) */
|
|
64
64
|
actionLabel: string;
|
|
@@ -67,13 +67,13 @@ export interface AnchorEditItemView {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
export interface AnchorEditsFallbackViewProps {
|
|
70
|
-
/**
|
|
70
|
+
/** 模式徽标(如「分块编辑」) */
|
|
71
71
|
badge: string;
|
|
72
72
|
items: readonly AnchorEditItemView[];
|
|
73
73
|
textPreviewLabels: TextPreviewLabels;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
76
|
+
/** 分块模式的降级视图:diff 尚未产出时展示每块编辑的定位文本与新文本。 */
|
|
77
77
|
export function AnchorEditsFallbackView({
|
|
78
78
|
badge,
|
|
79
79
|
items,
|
|
@@ -64,6 +64,11 @@ export interface HeaderActionBarItem {
|
|
|
64
64
|
readonly icon: ReactNode;
|
|
65
65
|
/** 图标右侧的文字:只在顶栏上、且顶栏不拥挤时显示(见 `LABELED_TOP_ACTIONS_MAX`)。 */
|
|
66
66
|
readonly label?: string;
|
|
67
|
+
/**
|
|
68
|
+
* `"readout"`:文字本身就是要展示的状态值(tok/s、费用),顶栏超过 4 格也照样显示,
|
|
69
|
+
* 被露出到活动面板开关旁时同样显示。默认(不传)是按钮名称的补充,格子一多就收起。
|
|
70
|
+
*/
|
|
71
|
+
readonly labelRole?: "readout";
|
|
67
72
|
readonly badge?: number | true;
|
|
68
73
|
/** 角标与图标的语义色;`neutral` 与不传同义。 */
|
|
69
74
|
readonly tone?: HeaderActionTone;
|
|
@@ -229,7 +234,12 @@ function BarItem({
|
|
|
229
234
|
const common = {
|
|
230
235
|
title: tooltip,
|
|
231
236
|
"aria-label": item.title,
|
|
232
|
-
|
|
237
|
+
// 读数用等宽数字:数字一变,按钮宽度不跟着抖。
|
|
238
|
+
label: showLabel
|
|
239
|
+
? item.labelRole === "readout" && item.label
|
|
240
|
+
? <span className="tabular-nums">{item.label}</span>
|
|
241
|
+
: item.label
|
|
242
|
+
: undefined,
|
|
233
243
|
icon: (
|
|
234
244
|
<IconBox jiggle={jiggle} tone={item.tone}>
|
|
235
245
|
{item.icon}
|
|
@@ -534,7 +544,9 @@ export function HeaderActionBarView({
|
|
|
534
544
|
|
|
535
545
|
const topFull = top.length >= maxTop;
|
|
536
546
|
// 文字比图标宽一倍:顶栏格子多了或页头已挤窄时只留图标,免得整排被推进「更多」。
|
|
537
|
-
|
|
547
|
+
// 读数例外:它的文字就是内容,退回图标就没有意义了;放不下时由挤窄收进「更多」兜底。
|
|
548
|
+
const roomy = !crowded && top.length <= LABELED_TOP_ACTIONS_MAX;
|
|
549
|
+
const showLabelFor = (item: HeaderActionBarItem): boolean => !crowded && (roomy || item.labelRole === "readout");
|
|
538
550
|
// 收纳里的角标不能被藏起来:汇总到小白条上(红色)。
|
|
539
551
|
const trayAlert = tray.some((item) => item.badge !== undefined && item.badge !== 0);
|
|
540
552
|
const draggingFromTop = dragKey !== null && top.some((item) => item.key === dragKey);
|
|
@@ -647,7 +659,7 @@ export function HeaderActionBarView({
|
|
|
647
659
|
<BarItem
|
|
648
660
|
key={item.key}
|
|
649
661
|
item={item}
|
|
650
|
-
showLabel={
|
|
662
|
+
showLabel={showLabelFor(item)}
|
|
651
663
|
jiggle={editing ? index : undefined}
|
|
652
664
|
stowLabel={labels.moveToTray}
|
|
653
665
|
onStow={() => onMove(item.key, "tray", Number.MAX_SAFE_INTEGER)}
|
|
@@ -796,7 +808,7 @@ export function HeaderActionBarView({
|
|
|
796
808
|
{pinned || beside.length > 0 ? (
|
|
797
809
|
<ButtonGroup blur={false} variant={chromeButtonGroupVariant}>
|
|
798
810
|
{beside.map((item) => (
|
|
799
|
-
<BarItem key={item.key} item={item} />
|
|
811
|
+
<BarItem key={item.key} item={item} showLabel={!crowded && item.labelRole === "readout"} />
|
|
800
812
|
))}
|
|
801
813
|
{pinned}
|
|
802
814
|
</ButtonGroup>
|
|
@@ -1,78 +1,5 @@
|
|
|
1
1
|
import { describe, expect, test } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
HOLD_MAX_MS,
|
|
4
|
-
holdBackUnclosedInline,
|
|
5
|
-
nextPhraseEnd,
|
|
6
|
-
planReveal,
|
|
7
|
-
snapToTokenBoundary,
|
|
8
|
-
splitStreamingSegments,
|
|
9
|
-
} from "./streaming-reveal";
|
|
10
|
-
|
|
11
|
-
describe("nextPhraseEnd", () => {
|
|
12
|
-
test("ends a phrase after latin punctuation followed by whitespace", () => {
|
|
13
|
-
expect(nextPhraseEnd("Hello there, world", 0, false)).toBe("Hello there,".length);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test("keeps trailing latin punctuation pending until the next character arrives", () => {
|
|
17
|
-
expect(nextPhraseEnd("Hello there,", 0, false)).toBeNull();
|
|
18
|
-
expect(nextPhraseEnd("Hello there,", 0, true)).toBe("Hello there,".length);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test("does not break inside numbers or dotted words", () => {
|
|
22
|
-
expect(nextPhraseEnd("pi is 3.14 and more", 0, false)).toBeNull();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("ends a phrase after CJK punctuation including closing quotes", () => {
|
|
26
|
-
expect(nextPhraseEnd("他说:“秋天到了。”然后走了", 0, false)).toBe("他说:".length);
|
|
27
|
-
expect(nextPhraseEnd("他说:“秋天到了。”然后走了", 3, false)).toBe("他说:“秋天到了。”".length);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test("ends a phrase at a newline", () => {
|
|
31
|
-
expect(nextPhraseEnd("const a = 1\nconst b", 0, false)).toBe("const a = 1\n".length);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
test("treats an unfinished tail as pending unless final", () => {
|
|
35
|
-
expect(nextPhraseEnd("still typing", 0, false)).toBeNull();
|
|
36
|
-
expect(nextPhraseEnd("still typing", 0, true)).toBe("still typing".length);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("caps long unpunctuated runs, preferring whitespace", () => {
|
|
40
|
-
const latin = "word ".repeat(30);
|
|
41
|
-
const end = nextPhraseEnd(latin, 0, false);
|
|
42
|
-
expect(end).not.toBeNull();
|
|
43
|
-
expect(end).toBeLessThanOrEqual(48);
|
|
44
|
-
expect(latin[end as number]).toBe(" ");
|
|
45
|
-
|
|
46
|
-
const cjk = "秋".repeat(100);
|
|
47
|
-
expect(nextPhraseEnd(cjk, 0, false)).toBe(48);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test("does not split a surrogate pair when capping", () => {
|
|
51
|
-
const text = `${"秋".repeat(47)}😀tail`;
|
|
52
|
-
expect(nextPhraseEnd(text, 0, false)).toBe(49);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
describe("splitStreamingSegments", () => {
|
|
57
|
-
test("round-trips the source text", () => {
|
|
58
|
-
const text = "Hello, world! 你好世界,这是流式输出。\n indented 3.14 and more";
|
|
59
|
-
expect(splitStreamingSegments(text).join("")).toBe(text);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test("splits into phrases with leading whitespace attached", () => {
|
|
63
|
-
expect(splitStreamingSegments("As twilight falls, the city wakes. Lights flicker")).toEqual([
|
|
64
|
-
"As twilight falls,",
|
|
65
|
-
" the city wakes.",
|
|
66
|
-
" Lights flicker",
|
|
67
|
-
]);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
test("keeps earlier segments stable as text grows by whole phrases", () => {
|
|
71
|
-
const before = splitStreamingSegments("秋天来了,天气凉了,");
|
|
72
|
-
const after = splitStreamingSegments("秋天来了,天气凉了,树叶黄了。");
|
|
73
|
-
expect(after.slice(0, before.length)).toEqual(before);
|
|
74
|
-
});
|
|
75
|
-
});
|
|
2
|
+
import { HOLD_MAX_MS, holdBackUnclosedInline, planReveal, snapToTokenBoundary } from "./streaming-reveal";
|
|
76
3
|
|
|
77
4
|
describe("snapToTokenBoundary", () => {
|
|
78
5
|
test("never splits a latin word or a number", () => {
|
|
@@ -3,11 +3,8 @@ export {
|
|
|
3
3
|
DEFAULT_RATE_PER_MS,
|
|
4
4
|
HOLD_MAX_MS,
|
|
5
5
|
holdBackUnclosedInline,
|
|
6
|
-
nextPhraseEnd,
|
|
7
6
|
planReveal,
|
|
8
7
|
REVEAL_TICK_MS,
|
|
9
|
-
STREAMING_SETTLE_MS,
|
|
10
8
|
STREAMING_STALL_FLUSH_MS,
|
|
11
9
|
snapToTokenBoundary,
|
|
12
|
-
splitStreamingSegments,
|
|
13
10
|
} from "../markdown/streaming-reveal";
|
|
@@ -64,7 +64,8 @@ export function FilePreviewDialogView({
|
|
|
64
64
|
{context && item && (
|
|
65
65
|
<motion.div
|
|
66
66
|
// no-drag:盖住下层页面顶部的 -webkit-app-region: drag,否则那块区域的点击会被系统拖窗口接管,浮层按钮点不了
|
|
67
|
-
|
|
67
|
+
// z-[110]:灯箱总是用户主动打开的,要盖过 z-[100] 的模态弹窗(如版本介绍里点配图),仍低于右键菜单 z-[120]
|
|
68
|
+
className="no-drag fixed inset-0 z-[110] bg-background/95"
|
|
68
69
|
initial={{ opacity: 0 }}
|
|
69
70
|
animate={{ opacity: 1 }}
|
|
70
71
|
exit={{ opacity: 0 }}
|
|
@@ -11,6 +11,8 @@ export interface ResizeHandleProps {
|
|
|
11
11
|
onResizeStart?: () => void;
|
|
12
12
|
onResize: (delta: number) => void;
|
|
13
13
|
onResizeEnd?: () => void;
|
|
14
|
+
/** 双击把手(常见约定:恢复默认尺寸)。 */
|
|
15
|
+
onReset?: () => void;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export interface ResizeHandleAxis {
|
|
@@ -58,7 +60,7 @@ export function resizeHandleDelta(side: ResizeHandleSide, pointerDelta: number):
|
|
|
58
60
|
return side === "right" || side === "bottom" ? pointerDelta : -pointerDelta;
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: ResizeHandleProps): JSX.Element {
|
|
63
|
+
export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd, onReset }: ResizeHandleProps): JSX.Element {
|
|
62
64
|
const startRef = useRef(0);
|
|
63
65
|
const axis = resolveResizeHandleAxis(side);
|
|
64
66
|
|
|
@@ -125,6 +127,7 @@ export function ResizeHandle({ side, onResizeStart, onResize, onResizeEnd }: Res
|
|
|
125
127
|
<div
|
|
126
128
|
data-resize-handle={side}
|
|
127
129
|
onPointerDown={onPointerDown}
|
|
130
|
+
onDoubleClick={onReset}
|
|
128
131
|
className={`group absolute z-30 ${axis.cursorClass} ${axis.track} ${axis.edge}`}
|
|
129
132
|
>
|
|
130
133
|
<div
|