zidane-gui 8.2.5 → 9.0.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/README.md +3 -2
- package/out/main/chunks/{history-pager-DWgllMof.js → history-pager-DUFgTrih.js} +2 -13
- package/out/main/chunks/tool-results-sql-C0MqWcQc.js +41 -0
- package/out/main/chunks/usage-sql-DiITGx8Q.js +67 -0
- package/out/main/history-worker.js +1 -4
- package/out/main/index.js +2183 -3189
- package/out/main/lsp-host.js +17 -4
- package/out/main/tool-results-worker.js +17 -0
- package/out/main/usage-worker.js +5 -19
- package/out/preload/index.mjs +67 -4
- package/out/renderer/assets/CodeEditor-in2F3Rz-.js +12771 -0
- package/out/renderer/assets/ComposerEditor-DzKoxH6Z.js +68 -0
- package/out/renderer/assets/DiffsTab-Ceh4E5wW.js +540 -0
- package/out/renderer/assets/EditorWorkers-Bhv2OJRb.js +67 -0
- package/out/renderer/assets/FileIcon-CYgGSQ59.js +781 -0
- package/out/renderer/assets/FilesTab-DESQMqGK.js +11763 -0
- package/out/renderer/assets/core-xOIU6ifr.js +9977 -0
- package/out/renderer/assets/file-tabs-Cozt9Sho.js +105 -0
- package/out/renderer/assets/{ghostty-web-wgkS5jGl.js → ghostty-web-BTHoKwMc.js} +1 -1
- package/out/renderer/assets/index-DkE-xvCG.js +9525 -0
- package/out/renderer/assets/index-DogoEzwx.js +10868 -0
- package/out/renderer/assets/{index-DqGrzqUj.css → index-DrLLItLS.css} +2481 -2639
- package/out/renderer/assets/kit-BUt8oFlT.js +64699 -0
- package/out/renderer/assets/pierre-theme-Bj5EAt1L.js +4312 -0
- package/out/renderer/assets/useDetachCleanup-Bb7k1ePf.js +3138 -0
- package/out/renderer/assets/useFolderChanges-B4X4n6NV.js +7896 -0
- package/out/renderer/assets/vendor-BvslLX9q.js +20410 -0
- package/out/renderer/assets/vendor-D_E2rLzO.css +388 -0
- package/out/renderer/assets/vendor-editor-Bx3dRdBD.js +26391 -0
- package/out/renderer/assets/vendor-motion-BLeNAEjH.js +9376 -0
- package/out/renderer/assets/vendor-react-DltKc0Ts.js +14275 -0
- package/out/renderer/assets/vendor-shiki-ba8IDo5s.js +459 -0
- package/out/renderer/index.html +11 -3
- package/package.json +10 -4
- package/scripts/postinstall.mjs +2 -1
- package/out/main/chunks/context-77_UZfgL.js +0 -61
- package/out/main/chunks/usage-sql-C2Tg1u44.js +0 -81
- package/out/renderer/assets/index-CebkAnp4.js +0 -191640
- /package/out/renderer/assets/{working-tree-parse.worker-BAW1QWyk.js → patch-parse.worker-BAW1QWyk.js} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DltKc0Ts.js";
|
|
2
|
+
import { u as useEditor, c as src_default, d as src_default$1, E as EditorContent } from "./vendor-editor-Bx3dRdBD.js";
|
|
3
|
+
import { s as suggestionExtension, p as plainTextToDocJson } from "./kit-BUt8oFlT.js";
|
|
4
|
+
import "./vendor-BvslLX9q.js";
|
|
5
|
+
import "./vendor-motion-BLeNAEjH.js";
|
|
6
|
+
import "./core-xOIU6ifr.js";
|
|
7
|
+
import "./vendor-shiki-ba8IDo5s.js";
|
|
8
|
+
function ComposerEditor({
|
|
9
|
+
text,
|
|
10
|
+
disabled,
|
|
11
|
+
autoFocus,
|
|
12
|
+
mentions,
|
|
13
|
+
commands,
|
|
14
|
+
bridge,
|
|
15
|
+
onEditor
|
|
16
|
+
}) {
|
|
17
|
+
const editor = useEditor(
|
|
18
|
+
{
|
|
19
|
+
immediatelyRender: false,
|
|
20
|
+
shouldRerenderOnTransaction: false,
|
|
21
|
+
editable: !disabled,
|
|
22
|
+
autofocus: autoFocus ? "end" : false,
|
|
23
|
+
content: plainTextToDocJson(text),
|
|
24
|
+
extensions: [
|
|
25
|
+
// What is typed is what is sent: no input rules, no marks, no blocks but paragraphs.
|
|
26
|
+
src_default.configure({
|
|
27
|
+
heading: false,
|
|
28
|
+
horizontalRule: false,
|
|
29
|
+
bold: false,
|
|
30
|
+
italic: false,
|
|
31
|
+
strike: false,
|
|
32
|
+
underline: false,
|
|
33
|
+
code: false,
|
|
34
|
+
codeBlock: false,
|
|
35
|
+
blockquote: false,
|
|
36
|
+
bulletList: false,
|
|
37
|
+
orderedList: false,
|
|
38
|
+
listItem: false,
|
|
39
|
+
listKeymap: false,
|
|
40
|
+
link: false
|
|
41
|
+
}),
|
|
42
|
+
src_default$1.configure({ placeholder: () => bridge.placeholder.current, showOnlyWhenEditable: false }),
|
|
43
|
+
...mentions ? [suggestionExtension("mention", bridge.mentions, bridge.suggest, bridge.setSuggest)] : [],
|
|
44
|
+
...commands ? [suggestionExtension("command", bridge.commands, bridge.suggest, bridge.setSuggest)] : []
|
|
45
|
+
],
|
|
46
|
+
editorProps: {
|
|
47
|
+
attributes: () => ({
|
|
48
|
+
role: "textbox",
|
|
49
|
+
"aria-multiline": "true",
|
|
50
|
+
"aria-label": bridge.name.current,
|
|
51
|
+
class: "zg-composer-editor",
|
|
52
|
+
"data-testid": "composer-input"
|
|
53
|
+
}),
|
|
54
|
+
handleKeyDown: (_view, event) => bridge.keyDown(event),
|
|
55
|
+
handlePaste: (_view, event) => bridge.paste(event),
|
|
56
|
+
// Files land as attachments (the card's drop handler), never as editor content.
|
|
57
|
+
handleDrop: (_view, event) => Boolean(event.dataTransfer?.files.length)
|
|
58
|
+
},
|
|
59
|
+
onUpdate: ({ editor: ed }) => bridge.update(ed)
|
|
60
|
+
},
|
|
61
|
+
[mentions, commands]
|
|
62
|
+
);
|
|
63
|
+
reactExports.useLayoutEffect(() => onEditor(editor), [editor, onEditor]);
|
|
64
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(EditorContent, { editor });
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
ComposerEditor
|
|
68
|
+
};
|
|
@@ -0,0 +1,540 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DltKc0Ts.js";
|
|
2
|
+
import { m as mediaTypeOfPath, h as useFilesHost, i as useFilesLabels, j as filesRootOf, k as collectSessionDiffs, l as groupByPath, n as usePanelVisible, o as fileDiffCounts, q as buildDiffTree, r as fileOrder, v as visibleRows, w as useAppearanceReducedMotion, x as relativeTo, y as matchRanges, z as steppedIndex, S as Segmented, A as DiffCounts, I as IconToggle, P as PanelLoading, B as PanelEmpty, C as DiffFileTree } from "./kit-BUt8oFlT.js";
|
|
3
|
+
import { M as MediaView, u as useDiagnosticsRun, c as countBySeverity, a as useFolderChanges, b as createPatchParser, d as useNoEdits, n as nameMatches, e as useNoKeyScope, F as FilesChatContext, S as SearchPanel, D as DiffScroller, R as ReviewableDiff, f as DiffView, p as parseFilePatch } from "./useFolderChanges-B4X4n6NV.js";
|
|
4
|
+
import { T as TreeChevron, F as FileIcon } from "./FileIcon-CYgGSQ59.js";
|
|
5
|
+
import { u as useFind, F as FindBar, d as diffLines, s as settleScroll } from "./useDetachCleanup-Bb7k1ePf.js";
|
|
6
|
+
import "./vendor-motion-BLeNAEjH.js";
|
|
7
|
+
import "./core-xOIU6ifr.js";
|
|
8
|
+
import "./vendor-BvslLX9q.js";
|
|
9
|
+
import "./vendor-editor-Bx3dRdBD.js";
|
|
10
|
+
import "./vendor-shiki-ba8IDo5s.js";
|
|
11
|
+
import "./pierre-theme-Bj5EAt1L.js";
|
|
12
|
+
import "./index-DogoEzwx.js";
|
|
13
|
+
function isMediaDiff(file) {
|
|
14
|
+
return file.hunks.length === 0 && mediaTypeOfPath(file.name) !== null;
|
|
15
|
+
}
|
|
16
|
+
const MediaDiff = reactExports.memo(function MediaDiff2({ file, cwd }) {
|
|
17
|
+
const mediaUrl = useFilesHost().mediaUrl;
|
|
18
|
+
const labels = useFilesLabels();
|
|
19
|
+
const type = mediaTypeOfPath(file.name);
|
|
20
|
+
const name = file.name.slice(file.name.lastIndexOf("/") + 1);
|
|
21
|
+
const oldPath = file.prevName ?? file.name;
|
|
22
|
+
const sides = [
|
|
23
|
+
...file.type === "new" ? [] : [
|
|
24
|
+
{
|
|
25
|
+
label: labels.filesBefore,
|
|
26
|
+
src: mediaUrl({ kind: "diff", cwd, path: oldPath, side: "old", version: file.prevObjectId })
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
...file.type === "deleted" ? [] : [
|
|
30
|
+
{
|
|
31
|
+
label: labels.filesAfter,
|
|
32
|
+
src: mediaUrl({ kind: "diff", cwd, path: file.name, side: "new", version: file.newObjectId })
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
];
|
|
36
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col", children: [
|
|
37
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-meta px-3 py-2 truncate", title: file.name, children: file.name }),
|
|
38
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-3 px-3 pb-3 grid-cols-[repeat(auto-fit,minmax(12rem,1fr))]", "data-testid": "media-diff", children: sides.map((side) => /* @__PURE__ */ jsxRuntimeExports.jsxs("figure", { className: "m-0 flex flex-col items-center gap-1.5 min-w-0", children: [
|
|
39
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(MediaView, { kind: type.kind, src: side.src, name, fit: "row" }, side.src),
|
|
40
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("figcaption", { className: "zg-meta", children: side.label })
|
|
41
|
+
] }, side.label)) })
|
|
42
|
+
] });
|
|
43
|
+
});
|
|
44
|
+
function useFilesDiagnostics(cwd, paths, version) {
|
|
45
|
+
const { result } = useDiagnosticsRun(cwd, paths, {
|
|
46
|
+
version: useVersionKey(version),
|
|
47
|
+
settle: true,
|
|
48
|
+
// These files are not open in a language server: the project-wide checks run for them.
|
|
49
|
+
lsp: false
|
|
50
|
+
});
|
|
51
|
+
return reactExports.useMemo(() => {
|
|
52
|
+
if (!result) return null;
|
|
53
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
54
|
+
for (const d of result.diagnostics) byPath.set(d.path, [...byPath.get(d.path) ?? [], d]);
|
|
55
|
+
return new Map([...byPath].map(([p, items]) => [p, countBySeverity(items)]));
|
|
56
|
+
}, [result]);
|
|
57
|
+
}
|
|
58
|
+
function useVersionKey(version) {
|
|
59
|
+
const last = reactExports.useRef({ value: version, counter: 0 });
|
|
60
|
+
if (version === null || version === void 0 || typeof version !== "object") return String(version);
|
|
61
|
+
if (last.current.value !== version) last.current = { value: version, counter: last.current.counter + 1 };
|
|
62
|
+
const length = Array.isArray(version) ? version.length : 0;
|
|
63
|
+
return `${length}:${last.current.counter}`;
|
|
64
|
+
}
|
|
65
|
+
const SETTLE_MS = 400;
|
|
66
|
+
const NO_FILES = [];
|
|
67
|
+
const parsers = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
const ON_THIS_THREAD = createPatchParser(null);
|
|
69
|
+
function parserFor(createWorker) {
|
|
70
|
+
if (!createWorker || typeof Worker === "undefined") return ON_THIS_THREAD;
|
|
71
|
+
let parser = parsers.get(createWorker);
|
|
72
|
+
if (!parser) parsers.set(createWorker, parser = createPatchParser(createWorker));
|
|
73
|
+
return parser;
|
|
74
|
+
}
|
|
75
|
+
function useWorkingTreeDiff(scope, active, createWorker) {
|
|
76
|
+
const diffOf = useFilesHost().workingTreeDiff;
|
|
77
|
+
const calls = reactExports.useRef({ diffOf, parse: parserFor(createWorker) });
|
|
78
|
+
calls.current = { diffOf, parse: parserFor(createWorker) };
|
|
79
|
+
const cwd = diffOf ? filesRootOf(scope) || null : null;
|
|
80
|
+
const onFolderChange = useFolderChanges(scope);
|
|
81
|
+
const [files, setFiles] = reactExports.useState(null);
|
|
82
|
+
const byKey = reactExports.useRef(/* @__PURE__ */ new Map());
|
|
83
|
+
const cwdRef = reactExports.useRef(cwd);
|
|
84
|
+
cwdRef.current = cwd;
|
|
85
|
+
const flight = reactExports.useRef(null);
|
|
86
|
+
const stale = reactExports.useRef(true);
|
|
87
|
+
const lastPatch = reactExports.useRef(null);
|
|
88
|
+
const read = reactExports.useCallback(async () => {
|
|
89
|
+
const at = cwdRef.current;
|
|
90
|
+
if (!at) return;
|
|
91
|
+
if (flight.current?.cwd === at) {
|
|
92
|
+
flight.current.again = true;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
flight.current = { cwd: at, again: false };
|
|
96
|
+
try {
|
|
97
|
+
const { diffOf: diff, parse } = calls.current;
|
|
98
|
+
const patch = diff ? await diff(at).catch(() => null) : null;
|
|
99
|
+
if (cwdRef.current !== at) return;
|
|
100
|
+
if (patch === null) {
|
|
101
|
+
setFiles((prev) => prev ?? []);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (patch === lastPatch.current) return;
|
|
105
|
+
lastPatch.current = patch;
|
|
106
|
+
if (!patch.trim()) {
|
|
107
|
+
byKey.current = /* @__PURE__ */ new Map();
|
|
108
|
+
setFiles([]);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const res = await parse(patch, [...byKey.current.keys()]);
|
|
112
|
+
if (cwdRef.current !== at) return;
|
|
113
|
+
const next = /* @__PURE__ */ new Map();
|
|
114
|
+
const list = [];
|
|
115
|
+
for (const { key, file } of res.files) {
|
|
116
|
+
const parsed = file === void 0 ? byKey.current.get(key) : file;
|
|
117
|
+
if (!parsed) continue;
|
|
118
|
+
next.set(key, parsed);
|
|
119
|
+
list.push(parsed);
|
|
120
|
+
}
|
|
121
|
+
byKey.current = next;
|
|
122
|
+
setFiles((prev) => prev && prev.length === list.length && prev.every((f, i) => f === list[i]) ? prev : list);
|
|
123
|
+
} finally {
|
|
124
|
+
const again = flight.current?.cwd === at && flight.current.again;
|
|
125
|
+
if (flight.current?.cwd === at) flight.current = null;
|
|
126
|
+
if (again || cwdRef.current && cwdRef.current !== at) void read();
|
|
127
|
+
}
|
|
128
|
+
}, []);
|
|
129
|
+
reactExports.useEffect(() => {
|
|
130
|
+
byKey.current = /* @__PURE__ */ new Map();
|
|
131
|
+
lastPatch.current = null;
|
|
132
|
+
stale.current = true;
|
|
133
|
+
setFiles(null);
|
|
134
|
+
}, [cwd]);
|
|
135
|
+
reactExports.useEffect(() => {
|
|
136
|
+
if (!cwd) return void 0;
|
|
137
|
+
if (active && stale.current) {
|
|
138
|
+
stale.current = false;
|
|
139
|
+
void read();
|
|
140
|
+
}
|
|
141
|
+
let timer;
|
|
142
|
+
const off = onFolderChange(() => {
|
|
143
|
+
if (!active) {
|
|
144
|
+
stale.current = true;
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
clearTimeout(timer);
|
|
148
|
+
timer = setTimeout(() => void read(), SETTLE_MS);
|
|
149
|
+
});
|
|
150
|
+
return () => {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
off();
|
|
153
|
+
};
|
|
154
|
+
}, [cwd, onFolderChange, active, read]);
|
|
155
|
+
return diffOf ? files : NO_FILES;
|
|
156
|
+
}
|
|
157
|
+
const MAX_SEARCH_LINES = 2e3;
|
|
158
|
+
const renderFileIcon = (path) => /* @__PURE__ */ jsxRuntimeExports.jsx(FileIcon, { path });
|
|
159
|
+
const renderChevron = (open) => /* @__PURE__ */ jsxRuntimeExports.jsx(TreeChevron, { open, className: "text-[var(--zg-text-muted)]" });
|
|
160
|
+
function DiffsTab({
|
|
161
|
+
scope,
|
|
162
|
+
useEdits = useNoEdits,
|
|
163
|
+
useKeyScope = useNoKeyScope,
|
|
164
|
+
chat = null,
|
|
165
|
+
workingTreeRequest = 0,
|
|
166
|
+
onWorkingTreeTaken,
|
|
167
|
+
createParseWorker,
|
|
168
|
+
className,
|
|
169
|
+
style
|
|
170
|
+
}) {
|
|
171
|
+
const host = useFilesHost();
|
|
172
|
+
const labels = useFilesLabels();
|
|
173
|
+
const bound = typeof scope.session === "string";
|
|
174
|
+
const hasWorking = host.workingTreeDiff !== void 0;
|
|
175
|
+
const edits = useEdits(bound ? scope.session : null);
|
|
176
|
+
const cwd = filesRootOf(scope) || null;
|
|
177
|
+
const [picked, setSource] = reactExports.useState(() => workingTreeRequest > 0 || !bound ? "working" : "session");
|
|
178
|
+
const source = bound && hasWorking ? picked : bound ? "session" : "working";
|
|
179
|
+
reactExports.useEffect(() => {
|
|
180
|
+
if (!workingTreeRequest) return;
|
|
181
|
+
onWorkingTreeTaken?.();
|
|
182
|
+
setSource("working");
|
|
183
|
+
}, [workingTreeRequest]);
|
|
184
|
+
const sourceOptions = reactExports.useMemo(
|
|
185
|
+
() => [
|
|
186
|
+
{ value: "session", label: labels.filesSourceSession },
|
|
187
|
+
{ value: "working", label: labels.filesSourceWorking }
|
|
188
|
+
],
|
|
189
|
+
[labels]
|
|
190
|
+
);
|
|
191
|
+
const [diffStyle, setDiffStyle] = reactExports.useState("unified");
|
|
192
|
+
const [wrap, setWrap] = reactExports.useState(false);
|
|
193
|
+
const [listOpen, setListOpen] = reactExports.useState(true);
|
|
194
|
+
const anchors = reactExports.useRef(/* @__PURE__ */ new Map());
|
|
195
|
+
const sessionEntries = reactExports.useMemo(() => collectSessionDiffs(edits), [edits]);
|
|
196
|
+
const sessionGroups = reactExports.useMemo(() => groupByPath(sessionEntries), [sessionEntries]);
|
|
197
|
+
const tabShown = usePanelVisible();
|
|
198
|
+
const working = useWorkingTreeDiff(scope, tabShown && source === "working", createParseWorker);
|
|
199
|
+
const list = reactExports.useMemo(
|
|
200
|
+
() => source === "session" ? sessionGroups.map((g) => ({ key: g.path, added: g.added, removed: g.removed })) : (working ?? []).map((f) => ({
|
|
201
|
+
key: f.name,
|
|
202
|
+
...f.prevName && f.prevName !== f.name ? { prevPath: f.prevName } : {},
|
|
203
|
+
...fileDiffCounts(f)
|
|
204
|
+
})),
|
|
205
|
+
[source, sessionGroups, working]
|
|
206
|
+
);
|
|
207
|
+
const tree = reactExports.useMemo(() => buildDiffTree(list, cwd), [list, cwd]);
|
|
208
|
+
const order = reactExports.useMemo(() => fileOrder(tree).map((f) => f.key), [tree]);
|
|
209
|
+
const orderedSession = reactExports.useMemo(() => {
|
|
210
|
+
const byKey = new Map(sessionGroups.map((g) => [g.path, g]));
|
|
211
|
+
return order.flatMap((k) => byKey.get(k) ?? []);
|
|
212
|
+
}, [order, sessionGroups]);
|
|
213
|
+
const orderedWorking = reactExports.useMemo(() => {
|
|
214
|
+
const byKey = new Map((working ?? []).map((f) => [f.name, f]));
|
|
215
|
+
return order.flatMap((k) => byKey.get(k) ?? []);
|
|
216
|
+
}, [order, working]);
|
|
217
|
+
const [collapsed, setCollapsed] = reactExports.useState(() => /* @__PURE__ */ new Set());
|
|
218
|
+
const rows = reactExports.useMemo(() => visibleRows(tree, collapsed), [tree, collapsed]);
|
|
219
|
+
const toggleDir = reactExports.useCallback(
|
|
220
|
+
(path) => setCollapsed((prev) => {
|
|
221
|
+
const next = new Set(prev);
|
|
222
|
+
if (!next.delete(path)) next.add(path);
|
|
223
|
+
return next;
|
|
224
|
+
}),
|
|
225
|
+
[]
|
|
226
|
+
);
|
|
227
|
+
const stats = {
|
|
228
|
+
files: list.length,
|
|
229
|
+
added: list.reduce((n, f) => n + f.added, 0),
|
|
230
|
+
removed: list.reduce((n, f) => n + f.removed, 0)
|
|
231
|
+
};
|
|
232
|
+
const scroller = reactExports.useRef(null);
|
|
233
|
+
const reducedMotion = useAppearanceReducedMotion();
|
|
234
|
+
const stopScroll = reactExports.useRef(null);
|
|
235
|
+
const scrollTo = (key) => {
|
|
236
|
+
const root = scroller.current;
|
|
237
|
+
if (!root) return;
|
|
238
|
+
stopScroll.current?.();
|
|
239
|
+
stopScroll.current = settleScroll(root, () => anchors.current.get(key), {
|
|
240
|
+
offset: 0,
|
|
241
|
+
smooth: !reducedMotion
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
reactExports.useEffect(() => () => stopScroll.current?.(), []);
|
|
245
|
+
const [visible, setVisible] = reactExports.useState(() => /* @__PURE__ */ new Set());
|
|
246
|
+
const observed = reactExports.useRef(null);
|
|
247
|
+
reactExports.useEffect(() => {
|
|
248
|
+
const root = scroller.current;
|
|
249
|
+
const cur = observed.current;
|
|
250
|
+
if (cur && cur.root === root && cur.keyOf.size === anchors.current.size && [...anchors.current].every(([key, el]) => cur.keyOf.get(el) === key))
|
|
251
|
+
return;
|
|
252
|
+
cur?.observer.disconnect();
|
|
253
|
+
observed.current = null;
|
|
254
|
+
setVisible((prev) => prev.size === 0 ? prev : /* @__PURE__ */ new Set());
|
|
255
|
+
if (!root) return;
|
|
256
|
+
const keyOf = /* @__PURE__ */ new Map();
|
|
257
|
+
for (const [key, el] of anchors.current) keyOf.set(el, key);
|
|
258
|
+
const shown = /* @__PURE__ */ new Set();
|
|
259
|
+
const observer = new IntersectionObserver(
|
|
260
|
+
(entries) => {
|
|
261
|
+
for (const entry of entries) {
|
|
262
|
+
const key = keyOf.get(entry.target);
|
|
263
|
+
if (key === void 0) continue;
|
|
264
|
+
if (entry.isIntersecting) shown.add(key);
|
|
265
|
+
else shown.delete(key);
|
|
266
|
+
}
|
|
267
|
+
setVisible(
|
|
268
|
+
(prev) => prev.size === shown.size && [...shown].every((k) => prev.has(k)) ? prev : new Set(shown)
|
|
269
|
+
);
|
|
270
|
+
},
|
|
271
|
+
// Files touch edge to edge: a file scrolled just out above shares the
|
|
272
|
+
// pane's top edge, which would still count as intersecting.
|
|
273
|
+
{ root, rootMargin: "-1px 0px 0px 0px" }
|
|
274
|
+
);
|
|
275
|
+
for (const el of keyOf.keys()) observer.observe(el);
|
|
276
|
+
observed.current = { root, keyOf, observer };
|
|
277
|
+
});
|
|
278
|
+
reactExports.useEffect(
|
|
279
|
+
() => () => {
|
|
280
|
+
observed.current?.observer.disconnect();
|
|
281
|
+
observed.current = null;
|
|
282
|
+
},
|
|
283
|
+
[]
|
|
284
|
+
);
|
|
285
|
+
const listRef = reactExports.useRef(null);
|
|
286
|
+
const listBrowsed = reactExports.useRef(false);
|
|
287
|
+
const [listLeft, setListLeft] = reactExports.useState(0);
|
|
288
|
+
const onListBrowse = reactExports.useCallback((browsing) => {
|
|
289
|
+
if (listBrowsed.current && !browsing) setListLeft((n) => n + 1);
|
|
290
|
+
listBrowsed.current = browsing;
|
|
291
|
+
}, []);
|
|
292
|
+
reactExports.useEffect(() => {
|
|
293
|
+
const ul = listRef.current;
|
|
294
|
+
const browsing = listBrowsed.current && ul?.matches(":hover");
|
|
295
|
+
if (!ul || !listOpen || browsing || visible.size === 0) return;
|
|
296
|
+
const lit = [...ul.querySelectorAll(":scope > li:has(> [data-active])")];
|
|
297
|
+
const first = lit[0];
|
|
298
|
+
const last = lit[lit.length - 1];
|
|
299
|
+
if (!first || !last) return;
|
|
300
|
+
const top = first.offsetTop - ul.offsetTop;
|
|
301
|
+
const bottom = last.offsetTop - ul.offsetTop + last.offsetHeight;
|
|
302
|
+
const pad = 8;
|
|
303
|
+
const viewTop = ul.scrollTop;
|
|
304
|
+
const viewBottom = viewTop + ul.clientHeight;
|
|
305
|
+
let next = null;
|
|
306
|
+
if (bottom - top > ul.clientHeight - pad * 2 || top < viewTop + pad) next = top - pad;
|
|
307
|
+
else if (bottom > viewBottom - pad) next = bottom - ul.clientHeight + pad;
|
|
308
|
+
if (next === null) return;
|
|
309
|
+
next = Math.max(0, Math.min(next, ul.scrollHeight - ul.clientHeight));
|
|
310
|
+
if (Math.abs(next - viewTop) < 1) return;
|
|
311
|
+
ul.scrollTo({ top: next, behavior: reducedMotion ? "auto" : "smooth" });
|
|
312
|
+
}, [visible, rows, listOpen, reducedMotion, listLeft]);
|
|
313
|
+
const anchorRef = (key) => (el) => {
|
|
314
|
+
if (el) anchors.current.set(key, el);
|
|
315
|
+
else anchors.current.delete(key);
|
|
316
|
+
};
|
|
317
|
+
const filePaths = reactExports.useMemo(
|
|
318
|
+
() => source === "session" ? sessionGroups.map((g) => g.path) : (working ?? []).map((f) => f.name),
|
|
319
|
+
[source, sessionGroups, working]
|
|
320
|
+
);
|
|
321
|
+
const findings = useFilesDiagnostics(cwd, filePaths, source === "session" ? edits.length : working);
|
|
322
|
+
const findParts = () => source === "session" ? orderedSession.flatMap(
|
|
323
|
+
(g) => g.entries.map((e, j) => {
|
|
324
|
+
const diff = parseSessionPatch(e.id, e.patch);
|
|
325
|
+
return { part: `${g.path}#${j}`, lines: diff ? diffLines(diff) : [] };
|
|
326
|
+
})
|
|
327
|
+
) : orderedWorking.map((f) => ({ part: `${f.name}#0`, lines: diffLines(f) }));
|
|
328
|
+
const find = useFind({
|
|
329
|
+
parts: findParts,
|
|
330
|
+
version: source === "session" ? orderedSession : orderedWorking,
|
|
331
|
+
surfaces: () => [...anchors.current].flatMap(
|
|
332
|
+
([key, section]) => [...section.querySelectorAll("diffs-container")].flatMap(
|
|
333
|
+
(host2, j) => host2.shadowRoot ? [{ part: `${key}#${j}`, root: host2.shadowRoot }] : []
|
|
334
|
+
)
|
|
335
|
+
),
|
|
336
|
+
scroller: () => scroller.current,
|
|
337
|
+
fallback: (m) => anchors.current.get(m.part.slice(0, m.part.lastIndexOf("#"))),
|
|
338
|
+
smooth: !reducedMotion
|
|
339
|
+
});
|
|
340
|
+
const [searchOpen, setSearchOpen] = reactExports.useState(false);
|
|
341
|
+
const [searchAsk, setSearchAsk] = reactExports.useState(0);
|
|
342
|
+
const findPartsRef = reactExports.useRef(findParts);
|
|
343
|
+
findPartsRef.current = findParts;
|
|
344
|
+
const searchNames = reactExports.useCallback(
|
|
345
|
+
(query, opts) => nameMatches(
|
|
346
|
+
order.map((k) => relativeTo(cwd, k)),
|
|
347
|
+
query,
|
|
348
|
+
opts
|
|
349
|
+
),
|
|
350
|
+
[order, cwd]
|
|
351
|
+
);
|
|
352
|
+
const searchContents = reactExports.useCallback(
|
|
353
|
+
async (query, opts) => {
|
|
354
|
+
const matches = [];
|
|
355
|
+
let capped = false;
|
|
356
|
+
for (const { part, lines } of findPartsRef.current()) {
|
|
357
|
+
const path = relativeTo(cwd, part.slice(0, part.lastIndexOf("#")));
|
|
358
|
+
for (const l of lines) {
|
|
359
|
+
const ranges = matchRanges(l.text, query, opts);
|
|
360
|
+
if (ranges.length === 0) continue;
|
|
361
|
+
if (matches.length >= MAX_SEARCH_LINES) {
|
|
362
|
+
capped = true;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
matches.push({ path, line: l.line, text: l.text, ranges, part, side: l.side });
|
|
366
|
+
}
|
|
367
|
+
if (capped) break;
|
|
368
|
+
}
|
|
369
|
+
return { matches, capped, engine: "none" };
|
|
370
|
+
},
|
|
371
|
+
[cwd]
|
|
372
|
+
);
|
|
373
|
+
const { jumpTo } = find;
|
|
374
|
+
const openSearchLine = reactExports.useCallback(
|
|
375
|
+
(m, query, opts) => jumpTo(query, opts, { part: m.part ?? "", side: m.side ?? "new", line: m.line, start: m.ranges[0]?.start ?? 0 }),
|
|
376
|
+
[jumpTo]
|
|
377
|
+
);
|
|
378
|
+
const openSearchFile = reactExports.useCallback(
|
|
379
|
+
(path) => {
|
|
380
|
+
const key = order.find((k) => relativeTo(cwd, k) === path);
|
|
381
|
+
if (key) scrollTo(key);
|
|
382
|
+
},
|
|
383
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- scrollTo reads refs
|
|
384
|
+
[order, cwd]
|
|
385
|
+
);
|
|
386
|
+
const closeSearch = reactExports.useCallback(() => setSearchOpen(false), []);
|
|
387
|
+
const current = reactExports.useRef(null);
|
|
388
|
+
const rootRef = reactExports.useRef(null);
|
|
389
|
+
useKeyScope(rootRef, {
|
|
390
|
+
step: (direction) => {
|
|
391
|
+
const keys = order;
|
|
392
|
+
const from = current.current && keys.includes(current.current) ? current.current : keys.find((k) => visible.has(k));
|
|
393
|
+
const next = steppedIndex(from ? keys.indexOf(from) : -1, keys.length, direction);
|
|
394
|
+
if (next < 0) return false;
|
|
395
|
+
current.current = keys[next];
|
|
396
|
+
scrollTo(keys[next]);
|
|
397
|
+
return true;
|
|
398
|
+
},
|
|
399
|
+
// Nothing of its own to close, and ctrl+w inside Diffs leaves the tab open.
|
|
400
|
+
close: () => true,
|
|
401
|
+
find: (mode) => {
|
|
402
|
+
if (order.length === 0) return false;
|
|
403
|
+
if (mode === "files") {
|
|
404
|
+
setListOpen(true);
|
|
405
|
+
setSearchOpen(true);
|
|
406
|
+
setSearchAsk((n) => n + 1);
|
|
407
|
+
} else {
|
|
408
|
+
find.show();
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(FilesChatContext.Provider, { value: chat, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ref: rootRef, className: `flex-1 min-h-0 flex flex-col${className ? ` ${className}` : ""}`, style, children: [
|
|
414
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
415
|
+
"div",
|
|
416
|
+
{
|
|
417
|
+
role: "toolbar",
|
|
418
|
+
"aria-label": labels.filesDiffsToolbar,
|
|
419
|
+
className: "shrink-0 flex items-center gap-2 px-2 h-10",
|
|
420
|
+
children: [
|
|
421
|
+
bound && hasWorking ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
422
|
+
Segmented,
|
|
423
|
+
{
|
|
424
|
+
size: "sm",
|
|
425
|
+
ariaLabel: labels.filesDiffSource,
|
|
426
|
+
value: source,
|
|
427
|
+
onChange: setSource,
|
|
428
|
+
options: sourceOptions
|
|
429
|
+
}
|
|
430
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "zg-meta px-1", children: bound ? labels.filesSourceSession : labels.filesSourceWorking }),
|
|
431
|
+
stats.files > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(DiffCounts, { added: stats.added, removed: stats.removed }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "zg-segment ml-auto shrink-0", children: [
|
|
433
|
+
list.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
434
|
+
IconToggle,
|
|
435
|
+
{
|
|
436
|
+
active: listOpen,
|
|
437
|
+
onClick: () => setListOpen((v) => !v),
|
|
438
|
+
icon: "i-ph-list-bullets",
|
|
439
|
+
label: listOpen ? labels.filesHideFileList : labels.filesShowFileList,
|
|
440
|
+
badge: String(list.length)
|
|
441
|
+
}
|
|
442
|
+
),
|
|
443
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
444
|
+
IconToggle,
|
|
445
|
+
{
|
|
446
|
+
active: diffStyle === "split",
|
|
447
|
+
onClick: () => setDiffStyle((s) => s === "split" ? "unified" : "split"),
|
|
448
|
+
icon: "i-ph-columns",
|
|
449
|
+
label: labels.filesSplit
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
453
|
+
IconToggle,
|
|
454
|
+
{
|
|
455
|
+
active: wrap,
|
|
456
|
+
onClick: () => setWrap((w) => !w),
|
|
457
|
+
icon: "i-ph-text-align-left",
|
|
458
|
+
label: labels.filesWrap
|
|
459
|
+
}
|
|
460
|
+
)
|
|
461
|
+
] })
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
),
|
|
465
|
+
source === "working" && working === null ? /* @__PURE__ */ jsxRuntimeExports.jsx(PanelLoading, {}) : list.length === 0 ? source === "session" ? /* @__PURE__ */ jsxRuntimeExports.jsx(PanelEmpty, { icon: "i-ph-git-diff", title: labels.filesNoChangesYet, hint: labels.filesNoChangesHint }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
466
|
+
PanelEmpty,
|
|
467
|
+
{
|
|
468
|
+
icon: "i-ph-git-diff",
|
|
469
|
+
title: cwd ? hasWorking ? labels.filesWorkingTreeClean : labels.filesNoWorkingTree : bound ? labels.filesSessionNoFolder : labels.filesNoFolder
|
|
470
|
+
}
|
|
471
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
472
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `zg-collapse shrink-0 ${searchOpen ? "max-h-[45%]" : "max-h-[30%]"}`, "data-open": listOpen, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "min-h-0 overflow-hidden flex flex-col", children: searchOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
473
|
+
SearchPanel,
|
|
474
|
+
{
|
|
475
|
+
label: labels.filesSearchInChanges,
|
|
476
|
+
asked: searchAsk,
|
|
477
|
+
names: searchNames,
|
|
478
|
+
search: searchContents,
|
|
479
|
+
onOpenFile: openSearchFile,
|
|
480
|
+
onOpenLine: openSearchLine,
|
|
481
|
+
onClose: closeSearch
|
|
482
|
+
}
|
|
483
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
484
|
+
DiffFileTree,
|
|
485
|
+
{
|
|
486
|
+
rows,
|
|
487
|
+
visible,
|
|
488
|
+
collapsed,
|
|
489
|
+
findings,
|
|
490
|
+
onToggle: toggleDir,
|
|
491
|
+
onOpen: scrollTo,
|
|
492
|
+
fileIcon: renderFileIcon,
|
|
493
|
+
chevron: renderChevron,
|
|
494
|
+
listRef,
|
|
495
|
+
onBrowse: onListBrowse
|
|
496
|
+
}
|
|
497
|
+
) }) }),
|
|
498
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
499
|
+
"div",
|
|
500
|
+
{
|
|
501
|
+
className: "relative flex-1 min-h-0 flex flex-col",
|
|
502
|
+
ref: (el) => {
|
|
503
|
+
scroller.current = el?.firstElementChild ?? null;
|
|
504
|
+
},
|
|
505
|
+
children: [
|
|
506
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DiffScroller, { className: "flex-1 min-h-0 overflow-y-auto", contentClassName: "flex flex-col", children: source === "session" ? orderedSession.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsx("section", { ref: anchorRef(g.path), "data-diff-key": g.path, className: "zg-diff-file", children: g.entries.map((e) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "zg-diff-edit", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SessionDiff, { id: e.id, patch: e.patch, diffStyle, wrap }) }, e.id)) }, g.path)) : orderedWorking.map((f) => /* @__PURE__ */ jsxRuntimeExports.jsx("section", { ref: anchorRef(f.name), "data-diff-key": f.name, className: "zg-diff-file", children: cwd && host.mediaUrl && isMediaDiff(f) ? /* @__PURE__ */ jsxRuntimeExports.jsx(MediaDiff, { file: f, cwd }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ReviewableDiff, { fileDiff: f, diffStyle, wrap }) }, f.name)) }),
|
|
507
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FindBar, { find, label: labels.filesFindInDiffs })
|
|
508
|
+
]
|
|
509
|
+
}
|
|
510
|
+
)
|
|
511
|
+
] })
|
|
512
|
+
] }) });
|
|
513
|
+
}
|
|
514
|
+
const SessionDiff = reactExports.memo(function SessionDiff2({
|
|
515
|
+
id,
|
|
516
|
+
patch,
|
|
517
|
+
diffStyle,
|
|
518
|
+
wrap
|
|
519
|
+
}) {
|
|
520
|
+
const fileDiff = reactExports.useMemo(() => parseSessionPatch(id, patch), [id, patch]);
|
|
521
|
+
if (!fileDiff) return /* @__PURE__ */ jsxRuntimeExports.jsx(DiffView, { patch, diffStyle, wrap });
|
|
522
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(ReviewableDiff, { fileDiff, diffStyle, wrap });
|
|
523
|
+
});
|
|
524
|
+
const parsedPatches = /* @__PURE__ */ new Map();
|
|
525
|
+
function parseSessionPatch(id, patch) {
|
|
526
|
+
const hit = parsedPatches.get(id);
|
|
527
|
+
if (hit && hit.patch === patch) return hit.diff;
|
|
528
|
+
let diff = null;
|
|
529
|
+
try {
|
|
530
|
+
diff = parseFilePatch(patch, `${id}:`) ?? null;
|
|
531
|
+
} catch {
|
|
532
|
+
diff = null;
|
|
533
|
+
}
|
|
534
|
+
if (parsedPatches.size > 2e3) parsedPatches.clear();
|
|
535
|
+
parsedPatches.set(id, { patch, diff });
|
|
536
|
+
return diff;
|
|
537
|
+
}
|
|
538
|
+
export {
|
|
539
|
+
DiffsTab
|
|
540
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { r as reactExports, j as jsxRuntimeExports } from "./vendor-react-DltKc0Ts.js";
|
|
2
|
+
import { r as retainEditorWorkers, t as trackRendererWorker } from "./index-DkE-xvCG.js";
|
|
3
|
+
import { W as WorkerPoolContextProvider, P as PREFERRED_HIGHLIGHTER, u as useWorkerPool } from "./pierre-theme-Bj5EAt1L.js";
|
|
4
|
+
import { g as useEditorEnvironment } from "./kit-BUt8oFlT.js";
|
|
5
|
+
import "./vendor-BvslLX9q.js";
|
|
6
|
+
import "./core-xOIU6ifr.js";
|
|
7
|
+
import "./vendor-shiki-ba8IDo5s.js";
|
|
8
|
+
import "./index-DogoEzwx.js";
|
|
9
|
+
import "./vendor-motion-BLeNAEjH.js";
|
|
10
|
+
import "./vendor-editor-Bx3dRdBD.js";
|
|
11
|
+
const HIGHLIGHTER = {
|
|
12
|
+
useTokenTransformer: true,
|
|
13
|
+
preferredHighlighter: PREFERRED_HIGHLIGHTER,
|
|
14
|
+
tokenizeMaxLineLength: 1e3
|
|
15
|
+
};
|
|
16
|
+
function HighlightWorkers({ createWorker: createWorker2, children }) {
|
|
17
|
+
const theme = useEditorEnvironment().shikiTheme;
|
|
18
|
+
const pool = reactExports.useMemo(
|
|
19
|
+
() => createWorker2 && {
|
|
20
|
+
workerFactory: createWorker2,
|
|
21
|
+
poolSize: 2,
|
|
22
|
+
totalASTLRUCacheSize: 240
|
|
23
|
+
},
|
|
24
|
+
[createWorker2]
|
|
25
|
+
);
|
|
26
|
+
if (!pool) return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children });
|
|
27
|
+
return (
|
|
28
|
+
/*
|
|
29
|
+
* Tokens come back already transformed (`useTokenTransformer`): that is
|
|
30
|
+
* the shape pierre's editor needs, so arming edit mode on a
|
|
31
|
+
* worker-highlighted file reuses the result instead of re-tokenising on
|
|
32
|
+
* the main thread. The pool is a singleton: options only seed it.
|
|
33
|
+
*/
|
|
34
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(WorkerPoolContextProvider, { poolOptions: pool, highlighterOptions: { ...HIGHLIGHTER, theme }, children: [
|
|
35
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(ThemeFollower, { theme }),
|
|
36
|
+
children
|
|
37
|
+
] })
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function ThemeFollower({ theme }) {
|
|
41
|
+
const pool = useWorkerPool();
|
|
42
|
+
reactExports.useEffect(() => {
|
|
43
|
+
void pool?.setRenderOptions({ theme });
|
|
44
|
+
}, [pool, theme]);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
function WorkerWrapper(options) {
|
|
48
|
+
return new Worker(
|
|
49
|
+
"" + new URL("worker-DNIQ0wG8.js", import.meta.url).href,
|
|
50
|
+
{
|
|
51
|
+
type: "module",
|
|
52
|
+
name: options?.name
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
const createWorker = typeof Worker !== "undefined" && typeof WorkerWrapper === "function" ? () => trackRendererWorker("Editor highlighting", new WorkerWrapper()) : null;
|
|
57
|
+
function EditorWorkerPool({ children }) {
|
|
58
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(HighlightWorkers, { createWorker, children });
|
|
59
|
+
}
|
|
60
|
+
function EditorWorkers({ children }) {
|
|
61
|
+
reactExports.useEffect(retainEditorWorkers, []);
|
|
62
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(EditorWorkerPool, { children });
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
EditorWorkerPool,
|
|
66
|
+
EditorWorkers
|
|
67
|
+
};
|