zidane-ui 9.2.3 → 9.3.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/dist/adapters/live.d.ts +6 -0
- package/dist/adapters/live.js +16 -8
- package/dist/adapters/server-composer-host.js +22 -9
- package/dist/adapters/server-host.js +143 -18
- package/dist/adapters/server-media.d.ts +9 -1
- package/dist/adapters/server-media.js +14 -1
- package/dist/chat/HostTranscript.d.ts +0 -12
- package/dist/chat/HostTranscript.js +6 -1
- package/dist/chat/SessionStreamsProvider.d.ts +8 -0
- package/dist/chat/SessionStreamsProvider.js +11 -2
- package/dist/chat/Transcript.d.ts +20 -11
- package/dist/chat/Transcript.js +326 -160
- package/dist/chat/composer/ComposerEditor.js +1 -1
- package/dist/chat/headless/host.d.ts +43 -7
- package/dist/chat/headless/index.d.ts +7 -6
- package/dist/chat/headless/index.js +10 -9
- package/dist/chat/headless/labels.d.ts +17 -0
- package/dist/chat/headless/labels.js +17 -0
- package/dist/chat/headless/markdown-chunks.d.ts +2 -1
- package/dist/chat/headless/markdown-chunks.js +12 -20
- package/dist/chat/headless/markdown-scan.d.ts +66 -0
- package/dist/chat/headless/markdown-scan.js +124 -0
- package/dist/chat/headless/markdown-stream.d.ts +64 -0
- package/dist/chat/headless/markdown-stream.js +143 -0
- package/dist/chat/headless/output-pager.d.ts +68 -0
- package/dist/chat/headless/output-pager.js +113 -0
- package/dist/chat/headless/session-list.d.ts +10 -0
- package/dist/chat/headless/sidebar/activity.d.ts +14 -0
- package/dist/chat/headless/sidebar/activity.js +32 -0
- package/dist/chat/headless/sidebar/directory.d.ts +9 -1
- package/dist/chat/headless/sidebar/directory.js +10 -50
- package/dist/chat/headless/sidebar/labels.d.ts +11 -1
- package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
- package/dist/chat/headless/sidebar/prewarm.js +114 -0
- package/dist/chat/headless/streams/actions.d.ts +2 -0
- package/dist/chat/headless/streams/actions.js +1 -0
- package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
- package/dist/chat/headless/streams/event-bytes.js +34 -0
- package/dist/chat/headless/streams/live-events.d.ts +25 -1
- package/dist/chat/headless/streams/live-events.js +53 -2
- package/dist/chat/headless/streams/selectors.d.ts +3 -0
- package/dist/chat/headless/streams/selectors.js +8 -1
- package/dist/chat/headless/streams/session-streams.d.ts +15 -3
- package/dist/chat/headless/streams/session-streams.js +31 -3
- package/dist/chat/headless/streams/store.d.ts +24 -1
- package/dist/chat/headless/streams/store.js +51 -26
- package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
- package/dist/chat/headless/streams/transcript-map.js +88 -0
- package/dist/chat/headless/streams/transcript.d.ts +4 -2
- package/dist/chat/headless/streams/transcript.js +19 -7
- package/dist/chat/headless/transcript/batch.js +5 -1
- package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
- package/dist/chat/headless/transcript/blob-media.js +23 -0
- package/dist/chat/headless/transcript/collapse.d.ts +10 -0
- package/dist/chat/headless/transcript/collapse.js +32 -6
- package/dist/chat/headless/transcript/derive.d.ts +98 -0
- package/dist/chat/headless/transcript/derive.js +89 -0
- package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
- package/dist/chat/headless/transcript/exchange-media.js +8 -5
- package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
- package/dist/chat/headless/transcript/fold-attachments.js +3 -2
- package/dist/chat/headless/transcript/fold.d.ts +2 -1
- package/dist/chat/headless/transcript/fold.js +16 -6
- package/dist/chat/headless/transcript/incremental.d.ts +53 -0
- package/dist/chat/headless/transcript/incremental.js +181 -0
- package/dist/chat/headless/transcript/index.d.ts +2 -2
- package/dist/chat/headless/transcript/index.js +2 -2
- package/dist/chat/headless/transcript/nesting.js +2 -1
- package/dist/chat/headless/transcript/rail.d.ts +50 -1
- package/dist/chat/headless/transcript/rail.js +165 -23
- package/dist/chat/headless/transcript/rows.d.ts +5 -1
- package/dist/chat/headless/transcript/run-failures.js +2 -1
- package/dist/chat/headless/transcript/seams.d.ts +78 -0
- package/dist/chat/headless/transcript/seams.js +116 -0
- package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
- package/dist/chat/headless/transcript/tool-media.js +27 -9
- package/dist/chat/index.d.ts +8 -7
- package/dist/chat/index.js +17 -16
- package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
- package/dist/chat/sidebar/SidebarFooter.js +6 -6
- package/dist/chat/testing/contract.d.ts +5 -3
- package/dist/chat/testing/contract.js +66 -1
- package/dist/chat/transcript/DiffLines.d.ts +6 -1
- package/dist/chat/transcript/DiffLines.js +35 -20
- package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
- package/dist/chat/transcript/EditDiffBlock.js +89 -30
- package/dist/chat/transcript/LazyRow.d.ts +40 -40
- package/dist/chat/transcript/LazyRow.js +101 -149
- package/dist/chat/transcript/MermaidDiagram.js +2 -1
- package/dist/chat/transcript/SubagentBlock.js +3 -2
- package/dist/chat/transcript/TranscriptRail.d.ts +25 -2
- package/dist/chat/transcript/TranscriptRail.js +175 -17
- package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
- package/dist/chat/transcript/TranscriptRow.js +4 -3
- package/dist/chat/transcript/actions.d.ts +37 -1
- package/dist/chat/transcript/actions.js +27 -1
- package/dist/chat/transcript/clipped-output.d.ts +58 -0
- package/dist/chat/transcript/clipped-output.js +131 -0
- package/dist/chat/transcript/fold-attachments.js +10 -5
- package/dist/chat/transcript/fold-worker.js +3 -2
- package/dist/chat/transcript/fold.js +2 -1
- package/dist/chat/transcript/index.d.ts +10 -9
- package/dist/chat/transcript/index.js +9 -8
- package/dist/chat/transcript/markdown-cache.d.ts +7 -1
- package/dist/chat/transcript/markdown-cache.js +12 -1
- package/dist/chat/transcript/markdown.js +116 -54
- package/dist/chat/transcript/media-gallery.d.ts +3 -2
- package/dist/chat/transcript/media-gallery.js +10 -7
- package/dist/chat/transcript/notices.js +2 -1
- package/dist/chat/transcript/prompt.js +6 -4
- package/dist/chat/transcript/prose.js +2 -1
- package/dist/chat/transcript/root-items.d.ts +96 -0
- package/dist/chat/transcript/root-items.js +180 -0
- package/dist/chat/transcript/row-mount.d.ts +165 -0
- package/dist/chat/transcript/row-mount.js +498 -0
- package/dist/chat/transcript/row-parking.d.ts +125 -0
- package/dist/chat/transcript/row-parking.js +135 -0
- package/dist/chat/transcript/row-ui-state.d.ts +37 -0
- package/dist/chat/transcript/row-ui-state.js +53 -0
- package/dist/chat/transcript/run-rows.js +3 -2
- package/dist/chat/transcript/script-input.d.ts +1 -1
- package/dist/chat/transcript/tasks.js +3 -2
- package/dist/chat/transcript/tool-media.d.ts +4 -2
- package/dist/chat/transcript/tool-media.js +15 -7
- package/dist/chat/transcript/tool-parts.d.ts +27 -4
- package/dist/chat/transcript/tool-parts.js +31 -5
- package/dist/chat/transcript/tool-payload.js +26 -11
- package/dist/chat/transcript/tool-row.d.ts +2 -1
- package/dist/chat/transcript/tool-row.js +38 -19
- package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
- package/dist/chat/transcript/use-transcript-rows.js +28 -46
- package/dist/chat/transcript/useStickToBottom.js +2 -3
- package/dist/chat/transcript/useTranscriptSearch.js +30 -14
- package/dist/chat/transcript/view-scope.d.ts +26 -6
- package/dist/chat/transcript/view-scope.js +106 -20
- package/dist/dist/{index-E1Z0aPmi.d.ts → index-C6-t1SS9.d.ts} +2 -1
- package/dist/dist/index.d.ts +1 -1
- package/dist/session/SessionHeader.js +1 -0
- package/dist/settings/headless/fixture-performance.js +4 -2
- package/dist/settings/headless/performance.d.ts +4 -0
- package/dist/settings/headless/search.d.ts +1 -1
- package/dist/settings/sections/performance/PerformanceSection.js +8 -1
- package/dist/settings/sections/performance/labels.d.ts +2 -0
- package/dist/settings/sections/performance/labels.js +2 -0
- package/dist/styles.css +33 -2
- package/dist/views/headless/answers.d.ts +8 -2
- package/dist/views/headless/answers.js +58 -1
- package/dist/views/headless/placement.d.ts +78 -0
- package/dist/views/headless/placement.js +154 -44
- package/package.json +2 -2
- package/src/styles/transcript.css +33 -2
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { CopyButton } from "../../components/CopyButton.js";
|
|
2
2
|
import { useDisplayPath } from "../../hooks/useDisplayPath.js";
|
|
3
|
+
import { useChatLabels } from "../useChatLabels.js";
|
|
3
4
|
import { DiffLines } from "./DiffLines.js";
|
|
5
|
+
import { LoadFullOutputButton, useFullToolCall } from "./tool-parts.js";
|
|
4
6
|
import { memo, useMemo } from "react";
|
|
5
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import { computeLineDiff, summarizeOutcomes } from "zidane/chat/pure";
|
|
8
|
+
import { computeLineDiff, formatBytes, summarizeOutcomes } from "zidane/chat/pure";
|
|
7
9
|
// src/chat/transcript/EditDiffBlock.tsx
|
|
8
10
|
const HUNK_DIM_STYLE = { opacity: .55 };
|
|
9
11
|
const HUNK_FULL_STYLE = { opacity: 1 };
|
|
10
|
-
const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
12
|
+
const HunkDiffCard = memo(({ language, index, total, lines, lineNumbers, outcome }) => {
|
|
11
13
|
const kind = outcome?.kind ?? "applied";
|
|
12
14
|
return /* @__PURE__ */ jsxs("div", {
|
|
13
15
|
className: "bg-[var(--zg-code-bg)]",
|
|
@@ -33,11 +35,43 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
|
33
35
|
}), /* @__PURE__ */ jsx(DiffLines, {
|
|
34
36
|
lines,
|
|
35
37
|
maxHeight: 360,
|
|
36
|
-
language
|
|
38
|
+
language,
|
|
39
|
+
...lineNumbers ? { lineNumbers } : {}
|
|
37
40
|
})]
|
|
38
41
|
});
|
|
39
42
|
});
|
|
40
43
|
/**
|
|
44
|
+
* Each hunk's diff lines and, for a hunk the host placed in the file
|
|
45
|
+
* (`oldLine`), a line number per line: a removed line's in the old file,
|
|
46
|
+
* the others' in the new one. A `write_file`'s hunks are regions of one
|
|
47
|
+
* file, so each shifts the next one's new numbers by the lines it added or
|
|
48
|
+
* removed; an edit step's `oldLine` is in the file the earlier steps left.
|
|
49
|
+
*/
|
|
50
|
+
function hunkLines(edit) {
|
|
51
|
+
const lines = [];
|
|
52
|
+
const numbers = [];
|
|
53
|
+
let shift = 0;
|
|
54
|
+
for (const hunk of edit.hunks) {
|
|
55
|
+
const diff = computeLineDiff(hunk.oldString, hunk.newString);
|
|
56
|
+
lines.push(diff);
|
|
57
|
+
let delta = 0;
|
|
58
|
+
for (const line of diff) delta += line.op === "add" ? 1 : line.op === "remove" ? -1 : 0;
|
|
59
|
+
if (hunk.oldLine === void 0) {
|
|
60
|
+
numbers.push(void 0);
|
|
61
|
+
shift += delta;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
let oldNo = hunk.oldLine;
|
|
65
|
+
let newNo = hunk.oldLine + (edit.tool === "write_file" ? shift : 0);
|
|
66
|
+
numbers.push(diff.map((line) => line.op === "remove" ? oldNo++ : line.op === "add" ? newNo++ : (oldNo++, newNo++)));
|
|
67
|
+
shift += delta;
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
lines,
|
|
71
|
+
numbers
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
41
75
|
* Per-hunk diff renderer with approval-outcome badges. When `edit.outcomes`
|
|
42
76
|
* is set (per-edit approval landed live, or replay re-parsed it off the
|
|
43
77
|
* tool result body), each hunk gets its own card with a ✓/✕/⊘/⚠/⋯ badge;
|
|
@@ -45,45 +79,70 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
|
|
|
45
79
|
* edits with all-applied outcomes collapse back to the flat layout so
|
|
46
80
|
* the common case doesn't grow extra chrome.
|
|
47
81
|
*/
|
|
48
|
-
const EditDiffBlock = memo(({ edit, className, style }) => {
|
|
82
|
+
const EditDiffBlock = memo(({ edit: lean, callId, turnId, className, style }) => {
|
|
83
|
+
const labels = useChatLabels();
|
|
84
|
+
const { full, load, available, ready } = useFullToolCall({
|
|
85
|
+
...callId ? { callId } : {},
|
|
86
|
+
...turnId ? { turnId } : {}
|
|
87
|
+
});
|
|
88
|
+
const edit = full !== "loading" && full?.edit ? full.edit : lean;
|
|
49
89
|
const outcomes = edit.outcomes;
|
|
50
90
|
const counts = useMemo(() => summarizeOutcomes(outcomes), [outcomes]);
|
|
51
91
|
const hunks = edit.hunks;
|
|
52
92
|
const shownPath = useDisplayPath().path(edit.path);
|
|
53
93
|
const base = edit.path.split("/").pop() ?? "";
|
|
54
94
|
const language = base.includes(".") ? base.split(".").pop().toLowerCase() : "";
|
|
55
|
-
const perHunkLines = useMemo(() =>
|
|
95
|
+
const { lines: perHunkLines, numbers: perHunkNumbers } = useMemo(() => hunkLines(edit), [edit]);
|
|
96
|
+
const flatLines = useMemo(() => perHunkLines.flat(), [perHunkLines]);
|
|
97
|
+
const flatNumbers = useMemo(() => perHunkNumbers.some(Boolean) ? perHunkNumbers.flatMap((numbers, i) => numbers ?? perHunkLines[i].map(() => null)) : void 0, [perHunkLines, perHunkNumbers]);
|
|
98
|
+
const clipped = edit.clipped;
|
|
56
99
|
const hasMixedOutcomes = outcomes != null && (counts.denied > 0 || counts.skipped > 0 || counts.failed > 0 || counts.pending > 0);
|
|
57
100
|
const usePerHunkLayout = outcomes != null && (hunks.length > 1 || hasMixedOutcomes);
|
|
58
101
|
return /* @__PURE__ */ jsxs("div", {
|
|
59
102
|
className: ["group zg-tray mt-2 rounded-zg-md overflow-hidden", className].filter(Boolean).join(" "),
|
|
60
103
|
style,
|
|
61
|
-
children: [
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ jsxs("div", {
|
|
106
|
+
className: `pl-2.5 border-b border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta ${hasMixedOutcomes ? "py-1.5 pr-2.5" : "h-8 pr-1"}`,
|
|
107
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: "zg-meta text-[var(--zg-text)] truncate",
|
|
109
|
+
title: edit.path,
|
|
110
|
+
children: shownPath
|
|
111
|
+
}), hasMixedOutcomes ? /* @__PURE__ */ jsx(OutcomeSummary, { counts }) : /* @__PURE__ */ jsx(CopyButton, {
|
|
112
|
+
text: edit.path,
|
|
113
|
+
label: "Copy file path",
|
|
114
|
+
reveal: true,
|
|
115
|
+
className: "ml-auto"
|
|
116
|
+
})]
|
|
117
|
+
}),
|
|
118
|
+
usePerHunkLayout ? /* @__PURE__ */ jsx("div", {
|
|
119
|
+
className: "flex flex-col gap-px bg-[var(--zg-hairline)]",
|
|
120
|
+
children: hunks.map((_hunk, idx) => /* @__PURE__ */ jsx(HunkDiffCard, {
|
|
121
|
+
language,
|
|
122
|
+
index: idx,
|
|
123
|
+
total: hunks.length,
|
|
124
|
+
lines: perHunkLines[idx] ?? [],
|
|
125
|
+
lineNumbers: perHunkNumbers[idx],
|
|
126
|
+
outcome: outcomes?.[idx]
|
|
127
|
+
}, idx))
|
|
128
|
+
}) : /* @__PURE__ */ jsx(DiffLines, {
|
|
129
|
+
lines: flatLines,
|
|
130
|
+
maxHeight: 420,
|
|
76
131
|
language,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
132
|
+
...flatNumbers ? { lineNumbers: flatNumbers } : {}
|
|
133
|
+
}),
|
|
134
|
+
clipped && /* @__PURE__ */ jsxs("div", {
|
|
135
|
+
className: "px-2.5 py-1.5 border-t border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta text-[var(--zg-text-muted)]",
|
|
136
|
+
children: [/* @__PURE__ */ jsx("span", { children: labels.diffNotShown(clipped.hunks - hunks.length, formatBytes(clipped.bytes)) }), available && /* @__PURE__ */ jsx(LoadFullOutputButton, {
|
|
137
|
+
loading: full === "loading",
|
|
138
|
+
disabled: !ready,
|
|
139
|
+
onClick: load,
|
|
140
|
+
className: "ml-auto",
|
|
141
|
+
label: labels.loadFullDiff,
|
|
142
|
+
loadingLabel: labels.loadingFullDiff
|
|
143
|
+
})]
|
|
144
|
+
})
|
|
145
|
+
]
|
|
87
146
|
});
|
|
88
147
|
});
|
|
89
148
|
const OUTCOME_GLYPH = {
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* The wrappers of transcript rows, and what the active searches hold mounted.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* its
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* an empty box at its estimated height; once mounted it stays mounted
|
|
10
|
-
* (expanded state, selection and the browser's remembered size survive).
|
|
4
|
+
* A root row renders through `LazyRow`: a placeholder at the row's height
|
|
5
|
+
* until it nears the view, then its content, for good (`row-mount.ts`: the
|
|
6
|
+
* mounter of its transcript decides, and parks far rows only past a budget
|
|
7
|
+
* while the reader is idle). What the reader did to a row lives in
|
|
8
|
+
* `useRowUiState`, so a parked row comes back as it was left.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* Two distances. Rows entering the far margin queue up, and each frame
|
|
19
|
-
* mounts the nearest until `BUDGET_MS` is spent: a flick that brings twenty
|
|
20
|
-
* rows into the margin spreads them over a few frames. Rows within a
|
|
21
|
-
* viewport of the view mount at once, whatever the budget: a row must never
|
|
22
|
-
* reach the screen as a blank placeholder, nor change height in view (the
|
|
23
|
-
* view would reflow under the reader). Rows mounted from the queue tell
|
|
24
|
-
* their content (`useBackgroundMount`) so long text may reveal over a few
|
|
25
|
-
* frames; rows mounted near the view render whole.
|
|
10
|
+
* Rows mounted ahead of the view (`useBackgroundMount`) may reveal long
|
|
11
|
+
* text over a few frames; rows mounted near the view render whole. A row
|
|
12
|
+
* that mounts because the reader scrolled to it, or with the conversation, is
|
|
13
|
+
* quiet: no enter animation. Only a row new at the end of the transcript (its
|
|
14
|
+
* tail) plays it.
|
|
26
15
|
*/
|
|
27
16
|
import { CSSProperties, ReactNode } from "react";
|
|
17
|
+
/** What the active searches want mounted: every row, or the rows holding any of these needles (lowercased). */
|
|
18
|
+
export interface ForcedRows {
|
|
19
|
+
/** Every row (a hold with no needles). */
|
|
20
|
+
all: boolean;
|
|
21
|
+
/** The needles of the holds that named some. */
|
|
22
|
+
needles: readonly string[];
|
|
23
|
+
}
|
|
28
24
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* it outside React's render and effects: it commits synchronously.
|
|
25
|
+
* Holds rows mounted while a search is active: the rows whose text holds one
|
|
26
|
+
* of `needles` (lowercased), or every row without them. The transcript mounts
|
|
27
|
+
* them wherever they are, so a walk of the DOM finds their text. Returns the release.
|
|
33
28
|
*
|
|
34
|
-
* @param
|
|
29
|
+
* @param needles - What the search looks for, lowercased; absent, every row.
|
|
35
30
|
*/
|
|
36
|
-
export declare function
|
|
37
|
-
/**
|
|
38
|
-
export declare function holdForceMountRows(): () => void;
|
|
39
|
-
/** Returns whether every lazy row must be mounted now, for example while a search needle is active. */
|
|
31
|
+
export declare function holdForceMountRows(needles?: readonly string[]): () => void;
|
|
32
|
+
/** Returns whether a search holds rows mounted now (rows then render whole: no reveal over frames, groups open). */
|
|
40
33
|
export declare function useForceMountRows(): boolean;
|
|
34
|
+
/** What the active searches hold mounted ({@link holdForceMountRows}); a new object on every change. */
|
|
35
|
+
export declare function useForcedRows(): ForcedRows;
|
|
41
36
|
/**
|
|
42
37
|
* True while the transcript is first painting a conversation (switching to
|
|
43
38
|
* it, or its history landing). Rows mounted then were already there: they
|
|
@@ -69,26 +64,31 @@ export declare function CvRow({ style, children, className, ...rest }: CvRowProp
|
|
|
69
64
|
export declare function useBackgroundMount(): boolean;
|
|
70
65
|
/** Props for {@link LazyRow}. */
|
|
71
66
|
export interface LazyRowProps {
|
|
72
|
-
/**
|
|
73
|
-
'
|
|
74
|
-
/**
|
|
67
|
+
/** The root item's key: the row's id, or a worker block's. */
|
|
68
|
+
'itemKey': string;
|
|
69
|
+
/** The placeholder's height before the row was ever measured (px). */
|
|
75
70
|
'estimatePx': number;
|
|
76
71
|
/** Inline style for the row's wrapper, usually its content-visibility sizing. */
|
|
77
|
-
'style'
|
|
72
|
+
'style'?: CSSProperties;
|
|
78
73
|
/** The row's content. */
|
|
79
74
|
'children': ReactNode;
|
|
75
|
+
/** A plain box (a worker's block): no content-visibility, no row id on the wrapper. */
|
|
76
|
+
'box'?: boolean;
|
|
77
|
+
/** The row's id (`Row.id`): how a view that left the transcript finds its place again (`useStickToBottom`'s `restorePosition`). */
|
|
78
|
+
'data-row'?: string;
|
|
80
79
|
/** The select-turn stop the row belongs to. Set only in select mode; makes the row a hover and click target. */
|
|
81
80
|
'data-stop'?: string;
|
|
82
81
|
/** Marks the row as part of the selected stop, so the select cursor can find it. */
|
|
83
82
|
'data-sel'?: string;
|
|
84
|
-
/**
|
|
85
|
-
'data-
|
|
83
|
+
/** A user's prompt: what an app's scrollback fill and the media gallery count (mounted or not). */
|
|
84
|
+
'data-prompt'?: string;
|
|
86
85
|
/** Extra classes on the root element. */
|
|
87
86
|
'className'?: string;
|
|
88
87
|
}
|
|
89
88
|
/**
|
|
90
|
-
* Renders a transcript row that mounts its content
|
|
89
|
+
* Renders a root transcript row that mounts its content when it nears the view, and keeps it: until then (and
|
|
90
|
+
* parked) an empty box of the row's height, its last measured height when known.
|
|
91
91
|
*
|
|
92
|
-
* @param props - Row props: `
|
|
92
|
+
* @param props - Row props: `itemKey`, `estimatePx`, `style`, `children`, the row's id and the select-mode data attributes.
|
|
93
93
|
*/
|
|
94
|
-
export declare function LazyRow({
|
|
94
|
+
export declare function LazyRow({ itemKey, estimatePx, style, children, className, box, ...rest }: LazyRowProps): import("react").JSX.Element;
|
|
@@ -1,132 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { RowMountContext } from "./row-mount.js";
|
|
2
|
+
import { RowKeyContext } from "./row-ui-state.js";
|
|
3
|
+
import { createContext, useContext, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import { flushSync } from "react-dom";
|
|
5
5
|
// src/chat/transcript/LazyRow.tsx
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!mount) continue;
|
|
24
|
-
forget(target);
|
|
25
|
-
mounts.push(mount);
|
|
26
|
-
}
|
|
27
|
-
if (mounts.length > 0) flushSync(() => mounts.forEach((mount) => mount(false)));
|
|
28
|
-
}
|
|
29
|
-
function lazyObservers(root) {
|
|
30
|
-
const key = root ?? document;
|
|
31
|
-
const hit = observersByRoot.get(key);
|
|
32
|
-
if (hit) return hit;
|
|
33
|
-
const pair = [new IntersectionObserver((entries) => {
|
|
34
|
-
for (const entry of entries) {
|
|
35
|
-
if (!entry.isIntersecting) continue;
|
|
36
|
-
const mount = pendingMounts.get(entry.target);
|
|
37
|
-
if (mount) queue.set(entry.target, mount);
|
|
38
|
-
}
|
|
39
|
-
schedulePump();
|
|
40
|
-
}, {
|
|
41
|
-
root,
|
|
42
|
-
rootMargin: MARGIN
|
|
43
|
-
}), new IntersectionObserver((entries) => mountNow(entries.filter((entry) => entry.isIntersecting).map((entry) => entry.target)), {
|
|
44
|
-
root,
|
|
45
|
-
rootMargin: NEAR_MARGIN
|
|
46
|
-
})];
|
|
47
|
-
observersByRoot.set(key, pair);
|
|
48
|
-
return pair;
|
|
49
|
-
}
|
|
50
|
-
function forget(target) {
|
|
51
|
-
pendingMounts.delete(target);
|
|
52
|
-
queue.delete(target);
|
|
53
|
-
const pair = observedBy.get(target);
|
|
54
|
-
observedBy.delete(target);
|
|
55
|
-
pair?.[0].unobserve(target);
|
|
56
|
-
pair?.[1].unobserve(target);
|
|
6
|
+
const NO_FORCE = {
|
|
7
|
+
all: false,
|
|
8
|
+
needles: []
|
|
9
|
+
};
|
|
10
|
+
const holds = /* @__PURE__ */ new Set();
|
|
11
|
+
let forced = NO_FORCE;
|
|
12
|
+
const subscribers = /* @__PURE__ */ new Set();
|
|
13
|
+
function publish() {
|
|
14
|
+
const needles = /* @__PURE__ */ new Set();
|
|
15
|
+
let all = false;
|
|
16
|
+
for (const hold of holds) if (!hold.needles) all = true;
|
|
17
|
+
else hold.needles.forEach((n) => needles.add(n));
|
|
18
|
+
forced = holds.size === 0 ? NO_FORCE : {
|
|
19
|
+
all,
|
|
20
|
+
needles: [...needles]
|
|
21
|
+
};
|
|
22
|
+
for (const notify of subscribers) notify();
|
|
57
23
|
}
|
|
58
24
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* it outside React's render and effects: it commits synchronously.
|
|
25
|
+
* Holds rows mounted while a search is active: the rows whose text holds one
|
|
26
|
+
* of `needles` (lowercased), or every row without them. The transcript mounts
|
|
27
|
+
* them wherever they are, so a walk of the DOM finds their text. Returns the release.
|
|
63
28
|
*
|
|
64
|
-
* @param
|
|
65
|
-
*/
|
|
66
|
-
function mountRowNow(row) {
|
|
67
|
-
mountNow([row]);
|
|
68
|
-
}
|
|
69
|
-
function schedulePump() {
|
|
70
|
-
if (pumpScheduled || queue.size === 0) return;
|
|
71
|
-
pumpScheduled = true;
|
|
72
|
-
requestAnimationFrame(() => setTimeout(pump, 0));
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Distance from the visible part of the row's scroll root (0 = in view), and that view's height.
|
|
76
|
-
* `views` keeps each root's top and bottom for one pump: a root is measured once, not per row.
|
|
29
|
+
* @param needles - What the search looks for, lowercased; absent, every row.
|
|
77
30
|
*/
|
|
78
|
-
function
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
if (!view) {
|
|
83
|
-
const rect = root?.getBoundingClientRect();
|
|
84
|
-
view = rect ? [rect.top, rect.bottom] : [0, window.innerHeight];
|
|
85
|
-
views.set(root, view);
|
|
86
|
-
}
|
|
87
|
-
const [top, bottom] = view;
|
|
88
|
-
return [r.bottom >= top && r.top <= bottom ? 0 : r.top > bottom ? r.top - bottom : top - r.bottom, bottom - top];
|
|
89
|
-
}
|
|
90
|
-
function pump() {
|
|
91
|
-
pumpScheduled = false;
|
|
92
|
-
const views = /* @__PURE__ */ new Map();
|
|
93
|
-
const order = [...queue.keys()].filter((el) => el.isConnected).map((el) => [el, ...distanceToView(el, views)]).sort((a, b) => a[1] - b[1]);
|
|
94
|
-
const isNear = ([, distance, view]) => distance <= view;
|
|
95
|
-
mountNow(order.filter(isNear).map(([el]) => el));
|
|
96
|
-
const start = performance.now();
|
|
97
|
-
for (const entry of order) {
|
|
98
|
-
if (isNear(entry)) continue;
|
|
99
|
-
const el = entry[0];
|
|
100
|
-
if (performance.now() - start > BUDGET_MS) break;
|
|
101
|
-
const mount = queue.get(el);
|
|
102
|
-
forget(el);
|
|
103
|
-
if (mount) flushSync(() => mount(true));
|
|
104
|
-
}
|
|
105
|
-
for (const el of queue.keys()) if (!el.isConnected) queue.delete(el);
|
|
106
|
-
schedulePump();
|
|
107
|
-
}
|
|
108
|
-
/** How many active searches want every row mounted; any one is enough. */
|
|
109
|
-
let forceHolds = 0;
|
|
110
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
111
|
-
/** Every lazy row mounts while held (and stays mounted after release). Returns the release. */
|
|
112
|
-
function holdForceMountRows() {
|
|
113
|
-
forceHolds++;
|
|
114
|
-
if (forceHolds === 1) for (const notify of subscribers) notify();
|
|
31
|
+
function holdForceMountRows(needles) {
|
|
32
|
+
const hold = { needles: needles ?? null };
|
|
33
|
+
holds.add(hold);
|
|
34
|
+
publish();
|
|
115
35
|
let released = false;
|
|
116
36
|
return () => {
|
|
117
37
|
if (released) return;
|
|
118
38
|
released = true;
|
|
119
|
-
|
|
120
|
-
|
|
39
|
+
holds.delete(hold);
|
|
40
|
+
publish();
|
|
121
41
|
};
|
|
122
42
|
}
|
|
123
43
|
function subscribe(notify) {
|
|
124
44
|
subscribers.add(notify);
|
|
125
45
|
return () => subscribers.delete(notify);
|
|
126
46
|
}
|
|
127
|
-
const getForced = () =>
|
|
128
|
-
|
|
47
|
+
const getForced = () => forced;
|
|
48
|
+
const getForcing = () => forced !== NO_FORCE;
|
|
49
|
+
/** Returns whether a search holds rows mounted now (rows then render whole: no reveal over frames, groups open). */
|
|
129
50
|
function useForceMountRows() {
|
|
51
|
+
return useSyncExternalStore(subscribe, getForcing, getForcing);
|
|
52
|
+
}
|
|
53
|
+
/** What the active searches hold mounted ({@link holdForceMountRows}); a new object on every change. */
|
|
54
|
+
function useForcedRows() {
|
|
130
55
|
return useSyncExternalStore(subscribe, getForced, getForced);
|
|
131
56
|
}
|
|
132
57
|
/**
|
|
@@ -148,7 +73,10 @@ function CvRow({ style, children, className, ...rest }) {
|
|
|
148
73
|
style,
|
|
149
74
|
"data-quiet": quiet ? "" : void 0,
|
|
150
75
|
...rest,
|
|
151
|
-
children
|
|
76
|
+
children: rest["data-row"] === void 0 ? children : /* @__PURE__ */ jsx(RowKeyContext.Provider, {
|
|
77
|
+
value: rest["data-row"],
|
|
78
|
+
children
|
|
79
|
+
})
|
|
152
80
|
});
|
|
153
81
|
}
|
|
154
82
|
const BackgroundMount = createContext(false);
|
|
@@ -157,51 +85,75 @@ function useBackgroundMount() {
|
|
|
157
85
|
return useContext(BackgroundMount);
|
|
158
86
|
}
|
|
159
87
|
/**
|
|
160
|
-
* Renders a transcript row that mounts its content
|
|
88
|
+
* Renders a root transcript row that mounts its content when it nears the view, and keeps it: until then (and
|
|
89
|
+
* parked) an empty box of the row's height, its last measured height when known.
|
|
161
90
|
*
|
|
162
|
-
* @param props - Row props: `
|
|
91
|
+
* @param props - Row props: `itemKey`, `estimatePx`, `style`, `children`, the row's id and the select-mode data attributes.
|
|
163
92
|
*/
|
|
164
|
-
function LazyRow({
|
|
165
|
-
const
|
|
166
|
-
const force = useForceMountRows();
|
|
167
|
-
const [near, setNear] = useState(eager);
|
|
168
|
-
const [background, setBackground] = useState(false);
|
|
93
|
+
function LazyRow({ itemKey, estimatePx, style, children, className, box = false, ...rest }) {
|
|
94
|
+
const mounter = useContext(RowMountContext);
|
|
169
95
|
const settling = useContext(TranscriptSettling);
|
|
170
|
-
const [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
96
|
+
const [state, setState] = useState(() => {
|
|
97
|
+
const start = mounter?.start(itemKey) ?? {
|
|
98
|
+
mounted: true,
|
|
99
|
+
eager: true,
|
|
100
|
+
seen: false
|
|
101
|
+
};
|
|
102
|
+
return {
|
|
103
|
+
phase: start.mounted ? "mounted" : "lazy",
|
|
104
|
+
background: false,
|
|
105
|
+
parkedPx: void 0,
|
|
106
|
+
quiet: settling() || !start.eager || start.seen
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
const ref = useRef(null);
|
|
110
|
+
const phase = useRef(state.phase);
|
|
111
|
+
phase.current = state.phase;
|
|
112
|
+
useLayoutEffect(() => {
|
|
174
113
|
const el = ref.current;
|
|
175
|
-
if (!
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
114
|
+
if (!mounter || !el) return void 0;
|
|
115
|
+
return mounter.register({
|
|
116
|
+
key: itemKey,
|
|
117
|
+
el,
|
|
118
|
+
cv: !box,
|
|
119
|
+
phase: phase.current,
|
|
120
|
+
set: (next, background, parkedPx) => setState((s) => ({
|
|
121
|
+
...s,
|
|
122
|
+
phase: next,
|
|
123
|
+
background,
|
|
124
|
+
parkedPx
|
|
125
|
+
}))
|
|
186
126
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
127
|
+
}, [
|
|
128
|
+
mounter,
|
|
129
|
+
itemKey,
|
|
130
|
+
box
|
|
131
|
+
]);
|
|
132
|
+
const mounted = state.phase === "mounted";
|
|
133
|
+
const known = mounter?.sizeOf(itemKey);
|
|
134
|
+
const px = state.parkedPx ?? known ?? estimatePx;
|
|
135
|
+
const wrapperStyle = box ? mounted ? void 0 : { height: px } : {
|
|
136
|
+
...style,
|
|
137
|
+
containIntrinsicSize: `auto ${Math.round(known ?? estimatePx)}px`,
|
|
138
|
+
...mounted ? null : { height: px }
|
|
139
|
+
};
|
|
140
|
+
const rowKey = rest["data-row"];
|
|
191
141
|
return /* @__PURE__ */ jsx("div", {
|
|
192
142
|
ref,
|
|
193
|
-
className: ["zg-cv-row", className].filter(Boolean).join(" "),
|
|
194
|
-
style:
|
|
195
|
-
|
|
196
|
-
height: estimatePx
|
|
197
|
-
},
|
|
143
|
+
className: box ? className : ["zg-cv-row", className].filter(Boolean).join(" "),
|
|
144
|
+
style: wrapperStyle,
|
|
145
|
+
"data-item": itemKey,
|
|
198
146
|
"data-lazy": mounted ? void 0 : "",
|
|
199
|
-
"data-
|
|
147
|
+
"data-parked": state.phase === "parked" ? "" : void 0,
|
|
148
|
+
"data-quiet": state.quiet ? "" : void 0,
|
|
200
149
|
...rest,
|
|
201
|
-
children: mounted ? /* @__PURE__ */ jsx(
|
|
202
|
-
value:
|
|
203
|
-
children
|
|
150
|
+
children: mounted ? /* @__PURE__ */ jsx(RowKeyContext.Provider, {
|
|
151
|
+
value: rowKey,
|
|
152
|
+
children: /* @__PURE__ */ jsx(BackgroundMount.Provider, {
|
|
153
|
+
value: state.background,
|
|
154
|
+
children
|
|
155
|
+
})
|
|
204
156
|
}) : null
|
|
205
157
|
});
|
|
206
158
|
}
|
|
207
|
-
export { CvRow, LazyRow, TranscriptSettling, holdForceMountRows,
|
|
159
|
+
export { CvRow, LazyRow, TranscriptSettling, holdForceMountRows, useBackgroundMount, useForceMountRows, useForcedRows };
|
|
@@ -3,6 +3,7 @@ import { CodeFrame } from "../../components/CodeFrame.js";
|
|
|
3
3
|
import { Notice } from "../../components/Notice.js";
|
|
4
4
|
import { useNearViewport } from "../../hooks/useNearViewport.js";
|
|
5
5
|
import { useChatLabels } from "../useChatLabels.js";
|
|
6
|
+
import { textKey, useRowPartKey, useRowUiState } from "./row-ui-state.js";
|
|
6
7
|
import { memo, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
7
8
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
// src/chat/transcript/MermaidDiagram.tsx
|
|
@@ -321,7 +322,7 @@ function failureOf(code, error) {
|
|
|
321
322
|
*/
|
|
322
323
|
const MermaidDiagram = memo(({ code, streaming = false, className, style, view = false, still = false, highlight }) => {
|
|
323
324
|
const labels = useChatLabels();
|
|
324
|
-
const [showSource, setShowSource] =
|
|
325
|
+
const [showSource, setShowSource] = useRowUiState(useRowPartKey(`mermaid:${textKey(code)}`), false);
|
|
325
326
|
const [failure, setFailure] = useState(null);
|
|
326
327
|
const failed = !streaming && failure?.code === code ? failure : null;
|
|
327
328
|
const sourceToggle = (buttonClass) => {
|
|
@@ -2,8 +2,9 @@ import { useStaysMounted } from "../../motion/collapse.js";
|
|
|
2
2
|
import { RunEstimateChip, useRunEstimate } from "../RunEstimateChip.js";
|
|
3
3
|
import { useChatLabels } from "../useChatLabels.js";
|
|
4
4
|
import { Caret, Dot, FailedMark, lineStateOf, useRowIcons } from "./frame.js";
|
|
5
|
+
import { useRowUiState } from "./row-ui-state.js";
|
|
5
6
|
import { ToolTiming } from "./tool-parts.js";
|
|
6
|
-
import { useMemo
|
|
7
|
+
import { useMemo } from "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
9
|
import { previewLine, spawnStartParts } from "zidane/chat/pure";
|
|
9
10
|
// src/chat/transcript/SubagentBlock.tsx
|
|
@@ -69,7 +70,7 @@ function subagentDot(status, streaming) {
|
|
|
69
70
|
*/
|
|
70
71
|
function SubagentBlock({ childId, sessionId, depth, parentDepth, rows, defaultCollapsed, streaming, children, "data-row": rowId, className, style }) {
|
|
71
72
|
const labels = useChatLabels();
|
|
72
|
-
const [userOpen, setUserOpen] =
|
|
73
|
+
const [userOpen, setUserOpen] = useRowUiState(`worker-block:${childId}`, null);
|
|
73
74
|
const open = userOpen ?? !defaultCollapsed;
|
|
74
75
|
const mounted = useStaysMounted(open);
|
|
75
76
|
const { task, status, durationMs, turns } = useMemo(() => subagentHeaderMeta(rows), [rows]);
|