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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// src/chat/transcript/row-parking.ts
|
|
2
|
+
/**
|
|
3
|
+
* The pure rules of how transcript rows mount (`row-mount.ts`), numbers in
|
|
4
|
+
* and decisions out, so a test drives them without a layout:
|
|
5
|
+
*
|
|
6
|
+
* - which queued row mounts first (`pumpOrder`): the nearest, the rows
|
|
7
|
+
* ahead of the scroll before the rows behind it;
|
|
8
|
+
* - when a row's measured height is its true height (`keepsSize`): only
|
|
9
|
+
* while it is mounted and rendered, never while `content-visibility`
|
|
10
|
+
* skips it (it then reports its placeholder size);
|
|
11
|
+
* - which mounted rows park when the transcript holds too many
|
|
12
|
+
* (`parkCandidates`, `parkPlan`): only past a budget, only far from the
|
|
13
|
+
* view, never a held row nor the bottom of the transcript, farthest first.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Mounted root rows past which far rows park, once the reader is idle. The DOM nodes are the real cost: this
|
|
17
|
+
* bounds a transcript of light rows (compact density's folds, ~17 nodes a row), whose nodes stay under theirs.
|
|
18
|
+
*/
|
|
19
|
+
const PARK_MAX_ROWS = 1500;
|
|
20
|
+
/** DOM nodes under the timeline past which far rows park. */
|
|
21
|
+
const PARK_MAX_NODES = 25e3;
|
|
22
|
+
/** Parking goes down to this share of each budget, so one pass holds for a while. */
|
|
23
|
+
const PARK_TARGET = .8;
|
|
24
|
+
/** A row parks only when it is farther than this many view heights from the view. */
|
|
25
|
+
const PARK_FAR_VIEWS = 12;
|
|
26
|
+
/** The transcript's last view heights never park: where a live run lands and the reader returns. */
|
|
27
|
+
const PARK_KEEP_BOTTOM_VIEWS = 3;
|
|
28
|
+
/** How long the reader holds still (no scroll, wheel, touch or key) before parking runs. */
|
|
29
|
+
const PARK_IDLE_MS = 1e3;
|
|
30
|
+
/** Main-thread time one slice of parking may take. */
|
|
31
|
+
const PARK_SLICE_MS = 4;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a row's reported height is its true height, to keep by its id.
|
|
34
|
+
*
|
|
35
|
+
* @param s - The {@link SizeSample}.
|
|
36
|
+
*/
|
|
37
|
+
function keepsSize(s) {
|
|
38
|
+
if (!s.mounted) return false;
|
|
39
|
+
if (!s.cv) return true;
|
|
40
|
+
if (s.skipped !== null) return !s.skipped;
|
|
41
|
+
return !s.cvEvents && s.nearView;
|
|
42
|
+
}
|
|
43
|
+
/** Rows behind the scroll count as this many times farther than they are. */
|
|
44
|
+
const BEHIND_FACTOR = 3;
|
|
45
|
+
/**
|
|
46
|
+
* The order queued rows mount in: within a view height of the view first (at once), then the rest, nearest first,
|
|
47
|
+
* the rows ahead of the scroll before those behind it.
|
|
48
|
+
*
|
|
49
|
+
* @param queued - The rows and their distances.
|
|
50
|
+
* @param viewPx - The view's height.
|
|
51
|
+
* @returns The rows to mount now, and the rest in order.
|
|
52
|
+
*/
|
|
53
|
+
function pumpOrder(queued, viewPx) {
|
|
54
|
+
const now = [];
|
|
55
|
+
const later = [];
|
|
56
|
+
for (const q of queued) if (q.distance <= viewPx) now.push(q.row);
|
|
57
|
+
else later.push(q);
|
|
58
|
+
const cost = (q) => q.distance * (q.ahead ? 1 : BEHIND_FACTOR);
|
|
59
|
+
later.sort((a, b) => cost(a) - cost(b));
|
|
60
|
+
return {
|
|
61
|
+
now,
|
|
62
|
+
later: later.map((q) => q.row)
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The default budget. */
|
|
66
|
+
const PARK_BUDGET = {
|
|
67
|
+
rows: PARK_MAX_ROWS,
|
|
68
|
+
nodes: PARK_MAX_NODES
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Whether the transcript holds more than its budget.
|
|
72
|
+
*
|
|
73
|
+
* @param mounted - Mounted root rows.
|
|
74
|
+
* @param nodes - DOM nodes under the timeline.
|
|
75
|
+
* @param budget - The budget.
|
|
76
|
+
*/
|
|
77
|
+
function overBudget(mounted, nodes, budget = PARK_BUDGET) {
|
|
78
|
+
return mounted > budget.rows || nodes > budget.nodes;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The mounted rows that may park, farthest from the view first: not held, farther than {@link PARK_FAR_VIEWS} view
|
|
82
|
+
* heights from the view, and above the transcript's last {@link PARK_KEEP_BOTTOM_VIEWS} view heights.
|
|
83
|
+
*
|
|
84
|
+
* @param rows - The mounted root rows.
|
|
85
|
+
* @param view - The view.
|
|
86
|
+
*/
|
|
87
|
+
function parkCandidates(rows, view) {
|
|
88
|
+
const viewPx = Math.max(1, view.bottom - view.top);
|
|
89
|
+
const far = 12 * viewPx;
|
|
90
|
+
const keepFrom = view.contentBottom - 3 * viewPx;
|
|
91
|
+
const out = [];
|
|
92
|
+
for (const row of rows) {
|
|
93
|
+
if (row.held || row.bottom > keepFrom) continue;
|
|
94
|
+
const distance = row.bottom < view.top ? view.top - row.bottom : row.top > view.bottom ? row.top - view.bottom : 0;
|
|
95
|
+
if (distance > far) out.push({
|
|
96
|
+
key: row.key,
|
|
97
|
+
distance
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
out.sort((a, b) => b.distance - a.distance);
|
|
101
|
+
return out.map((c) => c.key);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Which candidates to park: none while within the budget; past it, the first ones until the transcript is back
|
|
105
|
+
* under {@link PARK_TARGET} of the budget (or the candidates run out).
|
|
106
|
+
*
|
|
107
|
+
* @param candidates - From {@link parkCandidates}, farthest first.
|
|
108
|
+
* @param mounted - Mounted root rows.
|
|
109
|
+
* @param nodes - DOM nodes under the timeline.
|
|
110
|
+
* @param nodesOf - The DOM nodes a row holds (read only for the rows this plan reaches).
|
|
111
|
+
* @param budget - The budget.
|
|
112
|
+
*/
|
|
113
|
+
function parkPlan(candidates, mounted, nodes, nodesOf, budget = PARK_BUDGET) {
|
|
114
|
+
if (!overBudget(mounted, nodes, budget)) return [];
|
|
115
|
+
const rowsTarget = Math.floor(budget.rows * PARK_TARGET);
|
|
116
|
+
const nodesTarget = Math.floor(budget.nodes * PARK_TARGET);
|
|
117
|
+
const out = [];
|
|
118
|
+
for (const key of candidates) {
|
|
119
|
+
if (mounted <= rowsTarget && nodes <= nodesTarget) break;
|
|
120
|
+
out.push(key);
|
|
121
|
+
mounted--;
|
|
122
|
+
nodes -= nodesOf(key);
|
|
123
|
+
}
|
|
124
|
+
return out;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* How long to wait before the reader counts as idle (0: idle now).
|
|
128
|
+
*
|
|
129
|
+
* @param lastActivity - When the reader last scrolled, wheeled, touched or pressed a key (ms).
|
|
130
|
+
* @param now - Now (ms).
|
|
131
|
+
*/
|
|
132
|
+
function idleWait(lastActivity, now) {
|
|
133
|
+
return Math.max(0, lastActivity + PARK_IDLE_MS - now);
|
|
134
|
+
}
|
|
135
|
+
export { PARK_BUDGET, PARK_FAR_VIEWS, PARK_IDLE_MS, PARK_KEEP_BOTTOM_VIEWS, PARK_MAX_NODES, PARK_MAX_ROWS, PARK_SLICE_MS, PARK_TARGET, idleWait, keepsSize, overBudget, parkCandidates, parkPlan, pumpOrder };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a reader did to a row (opened a tool call, a fold's step, a thought
|
|
3
|
+
* group, a worker's block, a diagram's source) outlives the row's
|
|
4
|
+
* component. The transcript parks rows far from the view when it holds too
|
|
5
|
+
* many (`row-mount.ts`): a row coming back must show as it was left. Kept by
|
|
6
|
+
* key in one capped memory per transcript (`RowUiStateContext`, a
|
|
7
|
+
* `createRecentMap`): past the cap the least recently written key goes and
|
|
8
|
+
* reads as its default again. Outside a transcript it is plain state.
|
|
9
|
+
*/
|
|
10
|
+
import { RecentMap } from "./recent-map.js";
|
|
11
|
+
/** The row state of one transcript ({@link createRowUiState}); none outside a transcript. */
|
|
12
|
+
export declare const RowUiStateContext: import("react").Context<RecentMap<unknown> | null>;
|
|
13
|
+
/** A transcript's memory of its rows' state, for {@link RowUiStateContext}. */
|
|
14
|
+
export declare function createRowUiState(): RecentMap<unknown>;
|
|
15
|
+
/** The id of the transcript row around a component (its wrapper's `data-row`), for state that has no id of its own. */
|
|
16
|
+
export declare const RowKeyContext: import("react").Context<string | undefined>;
|
|
17
|
+
/**
|
|
18
|
+
* A key for state of a part of the row around the component: `<row id>:<part>`, or undefined outside a row.
|
|
19
|
+
*
|
|
20
|
+
* @param part - Which part of the row (unique within it).
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRowPartKey(part: string): string | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* A short key for a text (a diagram's source, for the state of one of a reply's diagrams): FNV-1a and the length.
|
|
25
|
+
*
|
|
26
|
+
* @param text - The text.
|
|
27
|
+
*/
|
|
28
|
+
export declare function textKey(text: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* `useState` whose value outlives the component: the next component with the same key starts from it.
|
|
31
|
+
* Without a key, or outside a transcript, it is plain `useState`.
|
|
32
|
+
*
|
|
33
|
+
* @param key - What the state belongs to (a tool call's id, `useRowPartKey`), or undefined.
|
|
34
|
+
* @param initial - The value before anything was written under the key.
|
|
35
|
+
* @returns The value and its setter, as `useState` returns them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function useRowUiState<T>(key: string | undefined, initial: T): [T, (next: T | ((prev: T) => T)) => void];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { createRecentMap } from "./recent-map.js";
|
|
2
|
+
import { createContext, useCallback, useContext, useState } from "react";
|
|
3
|
+
// src/chat/transcript/row-ui-state.ts
|
|
4
|
+
/** Keys held before the least recently written goes: far more than a session's rows a reader touches. */
|
|
5
|
+
const ROW_UI_STATE_MAX = 5e3;
|
|
6
|
+
/** The row state of one transcript ({@link createRowUiState}); none outside a transcript. */
|
|
7
|
+
const RowUiStateContext = createContext(null);
|
|
8
|
+
/** A transcript's memory of its rows' state, for {@link RowUiStateContext}. */
|
|
9
|
+
function createRowUiState() {
|
|
10
|
+
return createRecentMap(ROW_UI_STATE_MAX);
|
|
11
|
+
}
|
|
12
|
+
/** The id of the transcript row around a component (its wrapper's `data-row`), for state that has no id of its own. */
|
|
13
|
+
const RowKeyContext = createContext(void 0);
|
|
14
|
+
/**
|
|
15
|
+
* A key for state of a part of the row around the component: `<row id>:<part>`, or undefined outside a row.
|
|
16
|
+
*
|
|
17
|
+
* @param part - Which part of the row (unique within it).
|
|
18
|
+
*/
|
|
19
|
+
function useRowPartKey(part) {
|
|
20
|
+
const row = useContext(RowKeyContext);
|
|
21
|
+
return row === void 0 ? void 0 : `${row}:${part}`;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A short key for a text (a diagram's source, for the state of one of a reply's diagrams): FNV-1a and the length.
|
|
25
|
+
*
|
|
26
|
+
* @param text - The text.
|
|
27
|
+
*/
|
|
28
|
+
function textKey(text) {
|
|
29
|
+
let h = 2166136261;
|
|
30
|
+
for (let i = 0; i < text.length; i++) h = Math.imul(h ^ text.charCodeAt(i), 16777619);
|
|
31
|
+
return `${(h >>> 0).toString(36)}.${text.length}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `useState` whose value outlives the component: the next component with the same key starts from it.
|
|
35
|
+
* Without a key, or outside a transcript, it is plain `useState`.
|
|
36
|
+
*
|
|
37
|
+
* @param key - What the state belongs to (a tool call's id, `useRowPartKey`), or undefined.
|
|
38
|
+
* @param initial - The value before anything was written under the key.
|
|
39
|
+
* @returns The value and its setter, as `useState` returns them.
|
|
40
|
+
*/
|
|
41
|
+
function useRowUiState(key, initial) {
|
|
42
|
+
const store = useContext(RowUiStateContext);
|
|
43
|
+
const [value, setValue] = useState(() => {
|
|
44
|
+
const kept = key === void 0 ? void 0 : store?.get(key);
|
|
45
|
+
return kept === void 0 ? initial : kept;
|
|
46
|
+
});
|
|
47
|
+
return [value, useCallback((next) => setValue((prev) => {
|
|
48
|
+
const value = typeof next === "function" ? next(prev) : next;
|
|
49
|
+
if (key !== void 0) store?.set(key, value);
|
|
50
|
+
return value;
|
|
51
|
+
}), [key, store])];
|
|
52
|
+
}
|
|
53
|
+
export { RowKeyContext, RowUiStateContext, createRowUiState, textKey, useRowPartKey, useRowUiState };
|
|
@@ -5,7 +5,8 @@ import { useModelName } from "./actions.js";
|
|
|
5
5
|
import { Caret } from "./frame.js";
|
|
6
6
|
import { CompactMeta, RUN_RECEIPT_SEGMENT_TINT, RUN_RECEIPT_TINT, ReceiptValue } from "./receipt-parts.js";
|
|
7
7
|
import { useTranscriptRenderers } from "./renderers.js";
|
|
8
|
-
import {
|
|
8
|
+
import { useRowPartKey, useRowUiState } from "./row-ui-state.js";
|
|
9
|
+
import { memo } from "react";
|
|
9
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
import { formatRunReceiptCells, formatTokenCount } from "zidane/chat/pure";
|
|
11
12
|
// src/chat/transcript/run-rows.tsx
|
|
@@ -81,7 +82,7 @@ const RunSummaryRow = memo(({ event, className, style }) => {
|
|
|
81
82
|
* @param props - Row props: the summary `text` and its `meta`.
|
|
82
83
|
*/
|
|
83
84
|
function CompactSummaryRow({ text, meta, className, style }) {
|
|
84
|
-
const [open, setOpen] =
|
|
85
|
+
const [open, setOpen] = useRowUiState(useRowPartKey("compact-summary"), false);
|
|
85
86
|
const mounted = useStaysMounted(open);
|
|
86
87
|
const labels = useChatLabels();
|
|
87
88
|
const { Markdown } = useTranscriptRenderers();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** What a Codemode script's input panel reads besides its input. Internal to the transcript. */
|
|
2
|
-
import {
|
|
2
|
+
import { aj as ScriptProgress } from "../../dist/index-C6-t1SS9.js";
|
|
3
3
|
import { ToolRowModel } from "../headless/transcript/rows.js";
|
|
4
4
|
import "../headless/transcript/index.js";
|
|
5
5
|
/**
|
|
@@ -2,7 +2,8 @@ import { useStaysMounted } from "../../motion/collapse.js";
|
|
|
2
2
|
import { useChatLabels } from "../useChatLabels.js";
|
|
3
3
|
import { InlineCode } from "./FileChip.js";
|
|
4
4
|
import { FoldHeader } from "./fold.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useRowUiState } from "./row-ui-state.js";
|
|
6
|
+
import { memo } from "react";
|
|
6
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { countTaskOutcomes, formatDuration, formatTaskStatus, previewLine, taskOutcome } from "zidane/chat/pure";
|
|
8
9
|
// src/chat/transcript/tasks.tsx
|
|
@@ -62,7 +63,7 @@ const TaskRow = memo(({ row, className, style }) => /* @__PURE__ */ jsx("div", {
|
|
|
62
63
|
*/
|
|
63
64
|
const TaskBatchRow = memo(({ row, className, style }) => {
|
|
64
65
|
const labels = useChatLabels();
|
|
65
|
-
const [open, setOpen] =
|
|
66
|
+
const [open, setOpen] = useRowUiState(`task-batch:${row.id}`, false);
|
|
66
67
|
const mounted = useStaysMounted(open);
|
|
67
68
|
const counts = countTaskOutcomes(row.tasks.map((t) => t.task));
|
|
68
69
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* each media block as a text stand-in (`[image: image/png, 742500 b64
|
|
4
4
|
* bytes]`, `toolResultToText`); with an app that serves the bytes
|
|
5
5
|
* (`TranscriptActions.toolMediaUrl`) the stand-ins become the media itself.
|
|
6
|
+
* A block the store holds by hash loads by hash (`blobMediaUrl`), where the
|
|
7
|
+
* app serves blobs; one it can serve neither way stays its stand-in.
|
|
6
8
|
*
|
|
7
9
|
* Nothing loads until a result is opened (its panel mounts then), images
|
|
8
10
|
* decode off the main thread, and a video or audio fetches only its first
|
|
@@ -16,10 +18,10 @@ import { CSSProperties } from "react";
|
|
|
16
18
|
/**
|
|
17
19
|
* The media a result shows inline, with the text left around it; `null` when it shows none.
|
|
18
20
|
*
|
|
19
|
-
* @param tool - The tool row; its `callId` addresses the media.
|
|
21
|
+
* @param tool - The tool row; its `callId` addresses the media, and its `mediaRefs` the ones held by hash.
|
|
20
22
|
* @param output - The tool result's text, or `null` before it has one.
|
|
21
23
|
*/
|
|
22
|
-
export declare function useToolMedia(tool: Pick<ToolRowModel, 'callId'>, output: string | null): {
|
|
24
|
+
export declare function useToolMedia(tool: Pick<ToolRowModel, 'callId' | 'mediaRefs'>, output: string | null): {
|
|
23
25
|
media: ToolMediaItem[];
|
|
24
26
|
rest: string;
|
|
25
27
|
url: (index: number) => string;
|
|
@@ -2,7 +2,7 @@ import { useLightbox } from "../../components/Lightbox.js";
|
|
|
2
2
|
import { mediumKey } from "../headless/transcript/exchange-media.js";
|
|
3
3
|
import { parseToolMedia } from "../headless/transcript/tool-media.js";
|
|
4
4
|
import { useChatLabels } from "../useChatLabels.js";
|
|
5
|
-
import { useTranscriptActions } from "./actions.js";
|
|
5
|
+
import { toolMediaSrcOf, useTranscriptActions } from "./actions.js";
|
|
6
6
|
import { useMediaGallery } from "./media-gallery.js";
|
|
7
7
|
import { useMemo, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -10,23 +10,31 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
10
10
|
/**
|
|
11
11
|
* The media a result shows inline, with the text left around it; `null` when it shows none.
|
|
12
12
|
*
|
|
13
|
-
* @param tool - The tool row; its `callId` addresses the media.
|
|
13
|
+
* @param tool - The tool row; its `callId` addresses the media, and its `mediaRefs` the ones held by hash.
|
|
14
14
|
* @param output - The tool result's text, or `null` before it has one.
|
|
15
15
|
*/
|
|
16
16
|
function useToolMedia(tool, output) {
|
|
17
|
-
const { toolMediaUrl } = useTranscriptActions();
|
|
17
|
+
const { toolMediaUrl, blobMediaUrl } = useTranscriptActions();
|
|
18
18
|
const callId = tool.callId;
|
|
19
|
+
const refs = tool.mediaRefs;
|
|
19
20
|
return useMemo(() => {
|
|
20
|
-
if (!toolMediaUrl || !callId || !output || !output.includes("[")) return null;
|
|
21
|
-
const
|
|
21
|
+
if (!toolMediaUrl && !blobMediaUrl || !callId || !output || !output.includes("[")) return null;
|
|
22
|
+
const actions = {
|
|
23
|
+
toolMediaUrl,
|
|
24
|
+
blobMediaUrl
|
|
25
|
+
};
|
|
26
|
+
const parsed = parseToolMedia(output, (item) => toolMediaSrcOf(actions, callId, item) !== void 0, refs);
|
|
27
|
+
const byIndex = new Map(parsed.media.map((item) => [item.index, item]));
|
|
22
28
|
return parsed.media.length > 0 ? {
|
|
23
29
|
...parsed,
|
|
24
|
-
url: (index) =>
|
|
30
|
+
url: (index) => toolMediaSrcOf(actions, callId, byIndex.get(index) ?? { index }) ?? ""
|
|
25
31
|
} : null;
|
|
26
32
|
}, [
|
|
27
33
|
toolMediaUrl,
|
|
34
|
+
blobMediaUrl,
|
|
28
35
|
callId,
|
|
29
|
-
output
|
|
36
|
+
output,
|
|
37
|
+
refs
|
|
30
38
|
]);
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { ToolRowModel } from "../headless/transcript/rows.js";
|
|
8
8
|
import "../headless/transcript/index.js";
|
|
9
9
|
import { CSSProperties, ReactNode } from "react";
|
|
10
|
-
import { ScriptProgress } from "zidane/chat/pure";
|
|
10
|
+
import { ScriptProgress, ToolCallDetail } from "zidane/chat/pure";
|
|
11
11
|
/** Tool input / output panels: set into the row on the code tone (quiet text, the code panel's inset edge). */
|
|
12
12
|
export declare const CODE_PANEL = "zg-code-panel zg-output zg-ansi";
|
|
13
13
|
/** Props for {@link ToolInput}. */
|
|
@@ -63,6 +63,24 @@ export declare function useFullOutput(tool: ToolRowModel): {
|
|
|
63
63
|
available: boolean;
|
|
64
64
|
ready: boolean;
|
|
65
65
|
};
|
|
66
|
+
/**
|
|
67
|
+
* The whole of a tool call whose row went out lean (its input, every hunk of
|
|
68
|
+
* its edit), fetched on demand through `TranscriptActions.toolCall`.
|
|
69
|
+
* `full`: `null` = not fetched, the call once fetched, `'loading'` while
|
|
70
|
+
* the roundtrip runs. `available` is false when the app cannot fetch calls:
|
|
71
|
+
* the row then offers no button.
|
|
72
|
+
*
|
|
73
|
+
* @param tool - The call: its `callId` (and `turnId`, a hint) address it.
|
|
74
|
+
*/
|
|
75
|
+
export declare function useFullToolCall(tool: {
|
|
76
|
+
callId?: string;
|
|
77
|
+
turnId?: string;
|
|
78
|
+
}): {
|
|
79
|
+
full: "loading" | ToolCallDetail | null;
|
|
80
|
+
load: () => void;
|
|
81
|
+
available: boolean;
|
|
82
|
+
ready: boolean;
|
|
83
|
+
};
|
|
66
84
|
/** Props for {@link LoadFullOutputButton}. */
|
|
67
85
|
export interface LoadFullOutputButtonProps {
|
|
68
86
|
/** The full output is being fetched. Disables the button and changes its label. */
|
|
@@ -75,13 +93,18 @@ export interface LoadFullOutputButtonProps {
|
|
|
75
93
|
className: string;
|
|
76
94
|
/** Inline styles on the root element, merged after the component's own. */
|
|
77
95
|
style?: CSSProperties;
|
|
96
|
+
/** What the button loads, in words. Default: the full output. */
|
|
97
|
+
label?: string;
|
|
98
|
+
/** The button's words while it loads. Default: loading the full output. */
|
|
99
|
+
loadingLabel?: string;
|
|
78
100
|
}
|
|
79
101
|
/**
|
|
80
|
-
* "Load full output" under a clipped result
|
|
102
|
+
* "Load full output" under a clipped result (or, with `label`, the rest of
|
|
103
|
+
* any row the host cut for the wire: an input, a diff).
|
|
81
104
|
*
|
|
82
|
-
* @param props - Button props: `loading`, `disabled`, `onClick`, and
|
|
105
|
+
* @param props - Button props: `loading`, `disabled`, `onClick`, `className`, and the labels.
|
|
83
106
|
*/
|
|
84
|
-
export declare function LoadFullOutputButton({ loading, disabled, onClick, className, style }: LoadFullOutputButtonProps): import("react").JSX.Element;
|
|
107
|
+
export declare function LoadFullOutputButton({ loading, disabled, onClick, className, style, label, loadingLabel }: LoadFullOutputButtonProps): import("react").JSX.Element;
|
|
85
108
|
/** Props for {@link ToolTiming}. */
|
|
86
109
|
export interface ToolTimingProps {
|
|
87
110
|
/** Epoch milliseconds the call started. While `running`, the elapsed time counts up from it. */
|
|
@@ -151,11 +151,37 @@ function useFullOutput(tool) {
|
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* The whole of a tool call whose row went out lean (its input, every hunk of
|
|
155
|
+
* its edit), fetched on demand through `TranscriptActions.toolCall`.
|
|
156
|
+
* `full`: `null` = not fetched, the call once fetched, `'loading'` while
|
|
157
|
+
* the roundtrip runs. `available` is false when the app cannot fetch calls:
|
|
158
|
+
* the row then offers no button.
|
|
159
|
+
*
|
|
160
|
+
* @param tool - The call: its `callId` (and `turnId`, a hint) address it.
|
|
161
|
+
*/
|
|
162
|
+
function useFullToolCall(tool) {
|
|
163
|
+
const { sessionId, toolCall } = useTranscriptActions();
|
|
164
|
+
const [full, setFull] = useState(null);
|
|
165
|
+
const ready = Boolean(sessionId && tool.callId);
|
|
166
|
+
const load = () => {
|
|
167
|
+
if (!toolCall || !ready || full !== null) return;
|
|
168
|
+
setFull("loading");
|
|
169
|
+
toolCall(tool.callId, tool.turnId).then((detail) => setFull(detail)).catch(() => setFull(null));
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
full,
|
|
173
|
+
load,
|
|
174
|
+
available: toolCall !== void 0,
|
|
175
|
+
ready
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* "Load full output" under a clipped result (or, with `label`, the rest of
|
|
180
|
+
* any row the host cut for the wire: an input, a diff).
|
|
155
181
|
*
|
|
156
|
-
* @param props - Button props: `loading`, `disabled`, `onClick`, and
|
|
182
|
+
* @param props - Button props: `loading`, `disabled`, `onClick`, `className`, and the labels.
|
|
157
183
|
*/
|
|
158
|
-
function LoadFullOutputButton({ loading, disabled, onClick, className, style }) {
|
|
184
|
+
function LoadFullOutputButton({ loading, disabled, onClick, className, style, label, loadingLabel }) {
|
|
159
185
|
const labels = useChatLabels();
|
|
160
186
|
return /* @__PURE__ */ jsx("button", {
|
|
161
187
|
type: "button",
|
|
@@ -163,7 +189,7 @@ function LoadFullOutputButton({ loading, disabled, onClick, className, style })
|
|
|
163
189
|
onClick,
|
|
164
190
|
className: `zg-press-subtle ${className} text-zg-meta text-[var(--zg-accent)] bg-transparent border-0 cursor-pointer px-0 disabled:opacity-zg-disabled`,
|
|
165
191
|
style,
|
|
166
|
-
children: loading ? labels.loadingFullOutput : labels.loadFullOutput
|
|
192
|
+
children: loading ? loadingLabel ?? labels.loadingFullOutput : label ?? labels.loadFullOutput
|
|
167
193
|
});
|
|
168
194
|
}
|
|
169
195
|
/**
|
|
@@ -251,4 +277,4 @@ function ToolGlyph({ name, className, style }) {
|
|
|
251
277
|
"data-tool": name
|
|
252
278
|
});
|
|
253
279
|
}
|
|
254
|
-
export { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolGlyph, ToolInput, ToolTiming, useFullOutput };
|
|
280
|
+
export { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolGlyph, ToolInput, ToolTiming, useFullOutput, useFullToolCall };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { useChatLabels } from "../useChatLabels.js";
|
|
1
2
|
import { AnsiText } from "./AnsiText.js";
|
|
3
|
+
import { ClippedOutputControls, useClippedOutput } from "./clipped-output.js";
|
|
2
4
|
import { EditDiffBlock } from "./EditDiffBlock.js";
|
|
3
5
|
import { scriptInputProps } from "./script-input.js";
|
|
4
6
|
import { ToolMedia, useToolMedia } from "./tool-media.js";
|
|
5
|
-
import { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolInput,
|
|
7
|
+
import { CODE_PANEL, LoadFullOutputButton, ReadFileBlock, ToolInput, useFullToolCall } from "./tool-parts.js";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
// src/chat/transcript/tool-payload.tsx
|
|
8
10
|
/**
|
|
@@ -11,19 +13,30 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
13
|
* @param props - The tool call, `className` and `style`.
|
|
12
14
|
*/
|
|
13
15
|
function ToolPayload({ tool, className, style }) {
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
+
const labels = useChatLabels();
|
|
17
|
+
const clipped = useClippedOutput(tool);
|
|
18
|
+
const call = useFullToolCall(tool);
|
|
19
|
+
const input = call.full !== "loading" && call.full?.input ? call.full.input : tool.rawInput;
|
|
20
|
+
const loadInputButton = tool.inputClipped && call.available && (call.full === null || call.full === "loading") && /* @__PURE__ */ jsx(LoadFullOutputButton, {
|
|
21
|
+
loading: call.full === "loading",
|
|
22
|
+
disabled: !call.ready,
|
|
23
|
+
onClick: call.load,
|
|
24
|
+
className: "self-start",
|
|
25
|
+
label: labels.loadFullInput,
|
|
26
|
+
loadingLabel: labels.loadingFullInput
|
|
27
|
+
});
|
|
28
|
+
const output = clipped.text ?? tool.result;
|
|
16
29
|
const media = useToolMedia(tool, output);
|
|
17
30
|
const pre = `${CODE_PANEL} m-0 break-words max-h-80 overflow-auto`;
|
|
18
|
-
const loadButton =
|
|
19
|
-
|
|
20
|
-
disabled: !ready,
|
|
21
|
-
onClick: load,
|
|
31
|
+
const loadButton = tool.resultClipped && /* @__PURE__ */ jsx(ClippedOutputControls, {
|
|
32
|
+
output: clipped,
|
|
22
33
|
className: "self-start"
|
|
23
34
|
});
|
|
24
35
|
const root = ["flex flex-col gap-1.5", className].filter(Boolean).join(" ");
|
|
25
36
|
if (tool.edit) return /* @__PURE__ */ jsx(EditDiffBlock, {
|
|
26
37
|
edit: tool.edit,
|
|
38
|
+
...tool.callId ? { callId: tool.callId } : {},
|
|
39
|
+
...tool.turnId ? { turnId: tool.turnId } : {},
|
|
27
40
|
className,
|
|
28
41
|
style
|
|
29
42
|
});
|
|
@@ -31,10 +44,11 @@ function ToolPayload({ tool, className, style }) {
|
|
|
31
44
|
className: root,
|
|
32
45
|
style,
|
|
33
46
|
children: [
|
|
34
|
-
tool.name !== "read_file" &&
|
|
47
|
+
tool.name !== "read_file" && input && Object.keys(input).length > 0 && /* @__PURE__ */ jsx(ToolInput, {
|
|
35
48
|
name: tool.name,
|
|
36
|
-
input
|
|
49
|
+
input
|
|
37
50
|
}),
|
|
51
|
+
tool.name !== "read_file" && loadInputButton,
|
|
38
52
|
/* @__PURE__ */ jsx(ToolMedia, {
|
|
39
53
|
media: media.media,
|
|
40
54
|
url: media.url,
|
|
@@ -59,11 +73,12 @@ function ToolPayload({ tool, className, style }) {
|
|
|
59
73
|
className: root,
|
|
60
74
|
style,
|
|
61
75
|
children: [
|
|
62
|
-
|
|
76
|
+
input && Object.keys(input).length > 0 && /* @__PURE__ */ jsx(ToolInput, {
|
|
63
77
|
name: tool.name,
|
|
64
|
-
input
|
|
78
|
+
input,
|
|
65
79
|
...scriptInputProps(tool)
|
|
66
80
|
}),
|
|
81
|
+
loadInputButton,
|
|
67
82
|
loadButton,
|
|
68
83
|
output !== null && output.trim() !== "" && /* @__PURE__ */ jsx("pre", {
|
|
69
84
|
className: pre,
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* One tool call as a transcript row: a header line (glyph, name, target,
|
|
3
3
|
* edit counts, meta, timing) that opens onto the call's panels: its diff,
|
|
4
4
|
* the app's body for it (the `ToolBody` slot), its input, its output. A
|
|
5
|
-
* clipped output
|
|
5
|
+
* clipped output pages in through `TranscriptActions.toolOutputRange` (or
|
|
6
|
+
* loads whole through `toolOutput`, `clipped-output.tsx`); a
|
|
6
7
|
* session the call addresses is the `SessionTitle` slot.
|
|
7
8
|
*/
|
|
8
9
|
import { ToolRowModel } from "../headless/transcript/rows.js";
|