@workerdeck/ui 0.15.0 → 0.17.0
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 +60 -0
- package/build/{SessionPanel-J2U8v88q.d.mts → SessionPanel-CnNYEX80.d.mts} +170 -21
- package/build/{SessionPanel-DI1NO4l8.mjs → SessionPanel-DMPhsNlW.mjs} +4759 -1483
- package/build/SessionPanel-DMPhsNlW.mjs.map +1 -0
- package/build/{format-ljc3lKpA.d.mts → format-DfI_je9S.d.mts} +1 -1
- package/build/format.d.mts +39 -4
- package/build/format.mjs +2 -118
- package/build/index.d.mts +493 -45
- package/build/index.mjs +343 -17
- package/build/index.mjs.map +1 -1
- package/build/status-Ydzi7n6j.mjs +143 -0
- package/build/status-Ydzi7n6j.mjs.map +1 -0
- package/build/workspace.d.mts +9 -1
- package/build/workspace.mjs +108 -5
- package/build/workspace.mjs.map +1 -1
- package/package.json +16 -7
- package/src/components/agent/Composer.tsx +189 -89
- package/src/components/agent/Conversation.tsx +12 -12
- package/src/components/agent/FileCard.tsx +0 -26
- package/src/components/agent/FileTree.tsx +9 -8
- package/src/components/agent/Loader.tsx +22 -72
- package/src/components/agent/Message.tsx +11 -46
- package/src/components/agent/PermissionPrompt.tsx +0 -92
- package/src/components/agent/ProjectIcon.tsx +119 -0
- package/src/components/agent/QuestionPrompt.tsx +0 -122
- package/src/components/agent/Reasoning.tsx +5 -19
- package/src/components/agent/Response.tsx +1 -132
- package/src/components/agent/SessionBrowser.tsx +84 -3
- package/src/components/agent/SessionPanel.tsx +249 -28
- package/src/components/agent/SessionWorkspace.tsx +29 -0
- package/src/components/agent/StatusBar.tsx +20 -4
- package/src/components/agent/ToolCallCard.tsx +85 -112
- package/src/components/agent/Transcript.tsx +780 -203
- package/src/components/agent/UsageDialog.tsx +20 -106
- package/src/components/agent/UsageMeters.tsx +133 -0
- package/src/components/agent/pulse.tsx +3 -2
- package/src/components/agent/tool-result-fetch.tsx +36 -0
- package/src/components/agent/tool-result-image.tsx +209 -0
- package/src/components/agent/transcript-rows.ts +173 -0
- package/src/components/agent/transcript-variant.tsx +29 -51
- package/src/components/agent/use-height-epoch.ts +60 -0
- package/src/components/agent/use-path-links.ts +147 -0
- package/src/components/agent/use-transcript-jumps.ts +190 -0
- package/src/components/prompt-area/cursor-helpers.ts +65 -0
- package/src/components/prompt-area/use-prompt-area.ts +16 -10
- package/src/components/terminal/PermissionPrompt.tsx +119 -0
- package/src/components/terminal/QuestionPrompt.tsx +322 -0
- package/src/components/terminal/StatusLine.tsx +159 -0
- package/src/components/terminal/TerminalTranscript.tsx +225 -0
- package/src/components/terminal/affordances.tsx +118 -0
- package/src/components/terminal/blocks.ts +232 -0
- package/src/components/terminal/diff.tsx +130 -0
- package/src/components/terminal/height.ts +770 -0
- package/src/components/terminal/image-box.ts +53 -0
- package/src/components/terminal/items.tsx +486 -0
- package/src/components/terminal/markdown.tsx +191 -0
- package/src/components/terminal/press.tsx +120 -0
- package/src/components/terminal/prompt.tsx +343 -0
- package/src/components/terminal/result-preview.ts +86 -0
- package/src/components/terminal/row.tsx +132 -0
- package/src/components/terminal/scrubber.tsx +784 -0
- package/src/components/terminal/surface.tsx +80 -0
- package/src/components/terminal/tool-run.ts +224 -0
- package/src/index.ts +36 -1
- package/src/lib/status.ts +59 -3
- package/src/lib/tool-icon.ts +14 -0
- package/src/styles/terminal.css +1081 -0
- package/src/styles/theme.css +41 -0
- package/build/SessionPanel-DI1NO4l8.mjs.map +0 -1
- package/build/format.mjs.map +0 -1
- package/src/components/agent/line-prompt.tsx +0 -249
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useEffect,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
type RefObject,
|
|
10
|
+
} from 'react'
|
|
11
|
+
import { createPortal } from 'react-dom'
|
|
12
|
+
import { defaultRangeExtractor, useVirtualizer, type Range } from '@tanstack/react-virtual'
|
|
3
13
|
import { useStickToBottomContext } from 'use-stick-to-bottom'
|
|
4
|
-
import type { MessageAttachment } from '@workerdeck/protocol'
|
|
14
|
+
import type { MessageAttachment, PermissionRequest } from '@workerdeck/protocol'
|
|
5
15
|
import { recapLine, summarizeSince, type TranscriptItem, type TranscriptState } from '@workerdeck/react'
|
|
6
16
|
import { cn } from '../../lib/utils.ts'
|
|
7
17
|
import { formatCost, formatDuration, formatRelativeTime } from '../../lib/format.ts'
|
|
@@ -14,41 +24,24 @@ import { Reasoning } from './Reasoning.tsx'
|
|
|
14
24
|
import { Response } from './Response.tsx'
|
|
15
25
|
import { SessionEmptyState } from './SessionEmptyState.tsx'
|
|
16
26
|
import { ToolCallCard } from './ToolCallCard.tsx'
|
|
27
|
+
import { resolveAffordances, type TerminalAffordances } from '../terminal/affordances.tsx'
|
|
28
|
+
import { ToolRunRow, WorkingRow, parentOf, terminalBlocks } from '../terminal/items.tsx'
|
|
29
|
+
import { estimateBlockPx } from '../terminal/height.ts'
|
|
30
|
+
import { TerminalScrubber } from '../terminal/scrubber.tsx'
|
|
31
|
+
import { gapBefore, positionInRow, rowIndexForItem, type TranscriptRow } from './transcript-rows.ts'
|
|
32
|
+
import { useHeightEpoch } from './use-height-epoch.ts'
|
|
33
|
+
import { useTranscriptJumps } from './use-transcript-jumps.ts'
|
|
34
|
+
import { Row } from '../terminal/row.tsx'
|
|
35
|
+
import { TerminalSurface } from '../terminal/surface.tsx'
|
|
36
|
+
import { TaskRow, TerminalItemView } from '../terminal/TerminalTranscript.tsx'
|
|
17
37
|
import {
|
|
18
|
-
LineGlyph,
|
|
19
38
|
ROW_GAP,
|
|
20
39
|
TranscriptVariantProvider,
|
|
21
|
-
useLines,
|
|
22
40
|
type TranscriptDensity,
|
|
23
41
|
type TranscriptVariant,
|
|
24
42
|
} from './transcript-variant.tsx'
|
|
25
43
|
|
|
26
44
|
function TurnResultRow({ item }: { item: Extract<TranscriptItem, { kind: 'turn_result' }> }) {
|
|
27
|
-
const lines = useLines()
|
|
28
|
-
if (lines) {
|
|
29
|
-
// One dim line, no rules: the turn's end is a footnote, not a divider that
|
|
30
|
-
// costs three rows of vertical space.
|
|
31
|
-
return (
|
|
32
|
-
<div data-slot='turn-result' className='flex items-baseline gap-2'>
|
|
33
|
-
<LineGlyph className='text-fg-4'>·</LineGlyph>
|
|
34
|
-
<div className='min-w-0 flex-1'>
|
|
35
|
-
<span className={cn('text-label leading-5', item.isError ? 'text-danger' : 'text-fg-4')}>
|
|
36
|
-
{item.isError ? item.subtype : 'turn done'} · {formatDuration(item.durationMs)} ·{' '}
|
|
37
|
-
{formatCost(item.totalCostUsd)}
|
|
38
|
-
</span>
|
|
39
|
-
{item.errors?.length ? (
|
|
40
|
-
<ul className='flex flex-col'>
|
|
41
|
-
{item.errors.map((message, index) => (
|
|
42
|
-
<li key={index} className='text-label leading-5 break-words text-danger'>
|
|
43
|
-
{message}
|
|
44
|
-
</li>
|
|
45
|
-
))}
|
|
46
|
-
</ul>
|
|
47
|
-
) : null}
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
45
|
return (
|
|
53
46
|
<div data-slot='turn-result' className='py-1'>
|
|
54
47
|
<div className='flex items-center gap-2'>
|
|
@@ -75,21 +68,6 @@ function TurnResultRow({ item }: { item: Extract<TranscriptItem, { kind: 'turn_r
|
|
|
75
68
|
}
|
|
76
69
|
|
|
77
70
|
function NoticeRow({ item }: { item: Extract<TranscriptItem, { kind: 'notice' }> }) {
|
|
78
|
-
const lines = useLines()
|
|
79
|
-
if (lines) {
|
|
80
|
-
return (
|
|
81
|
-
<div data-slot='notice' className='flex items-baseline gap-2'>
|
|
82
|
-
<LineGlyph className={item.level === 'error' ? 'text-danger' : 'text-fg-4'}>!</LineGlyph>
|
|
83
|
-
<span
|
|
84
|
-
className={cn(
|
|
85
|
-
'min-w-0 flex-1 text-body-sm leading-5',
|
|
86
|
-
item.level === 'error' ? 'text-danger' : 'text-fg-3',
|
|
87
|
-
)}>
|
|
88
|
-
{item.text}
|
|
89
|
-
</span>
|
|
90
|
-
</div>
|
|
91
|
-
)
|
|
92
|
-
}
|
|
93
71
|
return (
|
|
94
72
|
<div
|
|
95
73
|
data-slot='notice'
|
|
@@ -109,12 +87,17 @@ function TranscriptItemView({
|
|
|
109
87
|
fileUrl,
|
|
110
88
|
attachmentUrl,
|
|
111
89
|
hostImage,
|
|
90
|
+
terminal,
|
|
112
91
|
}: {
|
|
113
92
|
item: TranscriptItem
|
|
114
93
|
fileUrl?: (path: string) => string
|
|
115
94
|
attachmentUrl?: (attachmentId: string) => string
|
|
116
95
|
hostImage?: (path: string) => Promise<string | undefined>
|
|
96
|
+
terminal?: boolean
|
|
117
97
|
}) {
|
|
98
|
+
// The terminal theme is a renderer, not a branch: it draws every kind itself,
|
|
99
|
+
// so the switch below is never reached under it.
|
|
100
|
+
if (terminal) return <TerminalItemView item={item} fileUrl={fileUrl} />
|
|
118
101
|
switch (item.kind) {
|
|
119
102
|
case 'user':
|
|
120
103
|
return (
|
|
@@ -163,21 +146,27 @@ function TranscriptItemView({
|
|
|
163
146
|
* the virtual list, and a boundary with nothing to say must contribute no row
|
|
164
147
|
* at all rather than an empty slot that still costs its gap.
|
|
165
148
|
*/
|
|
166
|
-
function RecapRow({ line, since }: { line: string; since?: number }) {
|
|
167
|
-
const lines = useLines()
|
|
149
|
+
function RecapRow({ line, since, terminal }: { line: string; since?: number; terminal?: boolean }) {
|
|
168
150
|
const away = since === undefined ? undefined : formatRelativeTime(since)
|
|
169
151
|
const text = away ? `${line} · last here ${away}` : line
|
|
170
152
|
|
|
171
|
-
|
|
153
|
+
// Under the terminal theme it is a Row like everything else, and that is not
|
|
154
|
+
// cosmetic: the cards markup measures 42px against an 18px line, so it was the
|
|
155
|
+
// one row in the transcript sitting off the grid — and it shifted *every row
|
|
156
|
+
// below it* by the remainder, which is precisely the failure the whole-multiple
|
|
157
|
+
// rule exists to prevent. It was invisible until a fixture carried a recap
|
|
158
|
+
// splice. Being a real row also makes it exactly computable, so the height
|
|
159
|
+
// calculator loses its last estimated constant.
|
|
160
|
+
if (terminal) {
|
|
172
161
|
return (
|
|
173
|
-
<div data-slot='recap'
|
|
174
|
-
<
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
</span>
|
|
162
|
+
<div data-slot='recap'>
|
|
163
|
+
<Row glyph='※' glyphTone='faint' tone='faint'>
|
|
164
|
+
recap: {text}
|
|
165
|
+
</Row>
|
|
178
166
|
</div>
|
|
179
167
|
)
|
|
180
168
|
}
|
|
169
|
+
|
|
181
170
|
return (
|
|
182
171
|
<div data-slot='recap' className='flex items-center gap-2 py-1'>
|
|
183
172
|
<div className='h-px flex-1 bg-border' />
|
|
@@ -188,39 +177,24 @@ function RecapRow({ line, since }: { line: string; since?: number }) {
|
|
|
188
177
|
}
|
|
189
178
|
|
|
190
179
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
* the right behaviour for a live turn — turns opening a session into a
|
|
196
|
-
* several-second scroll from its first row to its last, which is precisely wrong
|
|
197
|
-
* when you are skimming sessions to see where each agent got to.
|
|
180
|
+
* **Nothing on this surface animates its scroll position.** VS Code does not —
|
|
181
|
+
* click its editor scrollbar and it jumps — and neither does a terminal, which
|
|
182
|
+
* is the article this transcript is drawing. Every travel a reader ever
|
|
183
|
+
* complained about here was an animation we asked for.
|
|
198
184
|
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
185
|
+
* What used to be here was `useSettled`: a latch deciding smooth-vs-instant for
|
|
186
|
+
* the follow spring, with a quiet window, a "silence before the first row does
|
|
187
|
+
* not count" guard and a live-status gate — all of it apparatus for a
|
|
188
|
+
* smooth-scroll bug (the attach replays hundreds of rows, and animating that
|
|
189
|
+
* turned opening a session into a several-second journey). With no smooth mode
|
|
190
|
+
* left there is nothing for it to decide, so the whole thing is gone rather
|
|
191
|
+
* than pinned to `false`.
|
|
202
192
|
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
* webview → extension host → gateway and back — so the first replayed row can
|
|
208
|
-
* land well after the quiet window. A timer started at mount then latches
|
|
209
|
-
* *before the transcript exists*, and the whole replay animates: exactly the
|
|
210
|
-
* symptom the latch was added to prevent.
|
|
211
|
-
* - **Only a live turn earns smooth.** An idle session has nothing to animate.
|
|
212
|
-
* Skimming finished sessions is therefore instant no matter what the timing
|
|
213
|
-
* did, which is the case that has to be right.
|
|
193
|
+
* The two remaining writers of `scrollTop` — the follow spring and the
|
|
194
|
+
* virtualizer's size-change correction — are unchanged and still split by
|
|
195
|
+
* regime; `Conversation` itself is now hardwired to `instant` on both `initial`
|
|
196
|
+
* and `resize`.
|
|
214
197
|
*/
|
|
215
|
-
function useSettled(count: number, status: TranscriptState['status'], quietMs = 400): boolean {
|
|
216
|
-
const [settled, setSettled] = useState(false)
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
if (settled || count === 0) return
|
|
219
|
-
const timer = setTimeout(() => setSettled(true), quietMs)
|
|
220
|
-
return () => clearTimeout(timer)
|
|
221
|
-
}, [count, settled, quietMs])
|
|
222
|
-
return settled && (status === 'running' || status === 'starting')
|
|
223
|
-
}
|
|
224
198
|
|
|
225
199
|
/**
|
|
226
200
|
* When the current run began — the clock the working line counts from.
|
|
@@ -283,23 +257,137 @@ function SentAttachments({
|
|
|
283
257
|
)
|
|
284
258
|
}
|
|
285
259
|
|
|
260
|
+
/**
|
|
261
|
+
* The terminal theme's root, when that is the variant, and a passthrough when it
|
|
262
|
+
* is not.
|
|
263
|
+
*
|
|
264
|
+
* It has to live *inside* the scroller's content element rather than around the
|
|
265
|
+
* whole `Conversation`: `--term-line` and `1ch` are inherited, and the rows are
|
|
266
|
+
* rendered by the virtualizer several levels down. Wrapping the scroller instead
|
|
267
|
+
* would work identically for the cells and break the full-bleed bands, whose
|
|
268
|
+
* negative margins are measured against this element's padding.
|
|
269
|
+
*/
|
|
270
|
+
function TerminalShell({
|
|
271
|
+
active,
|
|
272
|
+
fontSize,
|
|
273
|
+
lineHeight,
|
|
274
|
+
affordances,
|
|
275
|
+
children,
|
|
276
|
+
}: {
|
|
277
|
+
active: boolean
|
|
278
|
+
fontSize?: number
|
|
279
|
+
lineHeight?: number
|
|
280
|
+
affordances?: TerminalAffordances | boolean
|
|
281
|
+
children: ReactNode
|
|
282
|
+
}) {
|
|
283
|
+
if (!active) return <>{children}</>
|
|
284
|
+
return (
|
|
285
|
+
<TerminalSurface
|
|
286
|
+
fontSize={fontSize}
|
|
287
|
+
lineHeight={lineHeight}
|
|
288
|
+
affordances={affordances}
|
|
289
|
+
bleed='1ch'
|
|
290
|
+
className='term-transcript'>
|
|
291
|
+
{children}
|
|
292
|
+
</TerminalSurface>
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Already read: present, legible, and visibly behind you. */
|
|
297
|
+
function read(boundary: number | undefined, index: number): boolean {
|
|
298
|
+
return boundary !== undefined && index < boundary
|
|
299
|
+
}
|
|
300
|
+
|
|
286
301
|
/** Rows produced inside a subagent (`parentToolUseId != null`) are stepped in
|
|
287
302
|
* behind a rule, so a Task's own output reads as belonging to the tool call
|
|
288
303
|
* above it rather than as the main thread carrying on. */
|
|
289
|
-
function nestedClass(item: TranscriptItem
|
|
304
|
+
function nestedClass(item: TranscriptItem): string | undefined {
|
|
290
305
|
const nested = 'parentToolUseId' in item && item.parentToolUseId != null
|
|
291
|
-
|
|
292
|
-
return lines ? 'ml-3.5 border-l border-border pl-2' : 'border-l-2 border-border pl-3'
|
|
306
|
+
return nested ? 'border-l-2 border-border pl-3' : undefined
|
|
293
307
|
}
|
|
294
308
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
309
|
+
// The virtual row model — what a row *is*, the spacing rule, and the
|
|
310
|
+
// item-index → row-index mapping — lives in `transcript-rows.ts`; re-exported
|
|
311
|
+
// here because this file is where consumers have always found them.
|
|
312
|
+
export { rowIndexForItem, type TranscriptRow } from './transcript-rows.ts'
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* A prompt row's sticky lane — the strip spanning its turn, leading with the
|
|
316
|
+
* one-line pinned **head** (see the pinned-prompt comment in
|
|
317
|
+
* {@link TranscriptRows}).
|
|
318
|
+
*
|
|
319
|
+
* The head starts `visibility: hidden` and shows only while actually stuck —
|
|
320
|
+
* an overlay that is visible in flow would sit on the real row's first line
|
|
321
|
+
* and swallow its selection highlight, which reads as "the first line cannot
|
|
322
|
+
* be selected". CSS cannot ask "am I stuck?", so a 1px sentinel at the head's
|
|
323
|
+
* engage threshold (the line's own y) feeds an IntersectionObserver: sentinel
|
|
324
|
+
* above the scrollport top → stuck. Transition-only callbacks — this adds no
|
|
325
|
+
* per-scroll work, and the pin itself is still the compositor's.
|
|
326
|
+
*/
|
|
327
|
+
function StickyPromptLane({
|
|
328
|
+
top,
|
|
329
|
+
height,
|
|
330
|
+
gapClass,
|
|
331
|
+
scrollRoot,
|
|
332
|
+
index,
|
|
333
|
+
measureRef,
|
|
334
|
+
content,
|
|
335
|
+
}: {
|
|
336
|
+
top: number
|
|
337
|
+
height: number
|
|
338
|
+
gapClass?: string | false
|
|
339
|
+
scrollRoot: HTMLElement | null
|
|
340
|
+
index: number
|
|
341
|
+
measureRef: (element: HTMLDivElement | null) => void
|
|
342
|
+
content: ReactNode
|
|
343
|
+
}) {
|
|
344
|
+
const headRef = useRef<HTMLDivElement | null>(null)
|
|
345
|
+
const sentinelRef = useRef<HTMLDivElement | null>(null)
|
|
346
|
+
useEffect(() => {
|
|
347
|
+
const head = headRef.current
|
|
348
|
+
const sentinel = sentinelRef.current
|
|
349
|
+
if (!head || !sentinel || !scrollRoot) return
|
|
350
|
+
const observer = new IntersectionObserver(
|
|
351
|
+
([entry]) => {
|
|
352
|
+
if (!entry) return
|
|
353
|
+
// Above the scrollport, not merely out of it — a lane still below the
|
|
354
|
+
// viewport has its sentinel non-intersecting too.
|
|
355
|
+
const stuck =
|
|
356
|
+
!entry.isIntersecting &&
|
|
357
|
+
entry.boundingClientRect.top < (entry.rootBounds?.top ?? 0)
|
|
358
|
+
head.toggleAttribute('data-stuck', stuck)
|
|
359
|
+
},
|
|
360
|
+
{ root: scrollRoot },
|
|
361
|
+
)
|
|
362
|
+
observer.observe(sentinel)
|
|
363
|
+
return () => observer.disconnect()
|
|
364
|
+
}, [scrollRoot])
|
|
365
|
+
return (
|
|
366
|
+
<div data-sticky-lane='' className='absolute inset-x-0' style={{ top, height }}>
|
|
367
|
+
{/* The head rides in its own absolutely positioned sub-lane rather than
|
|
368
|
+
in flow with a cancelled footprint: sticky confinement clamps the
|
|
369
|
+
*margin* box, and a negative bottom margin shrinks that box to zero
|
|
370
|
+
height — the head then overshoots the lane's end by its own height,
|
|
371
|
+
which put two pinned prompts on screen at once during the handoff.
|
|
372
|
+
Out of flow, the border box is what gets clamped, and the push-off
|
|
373
|
+
lands exactly at the lane's bottom edge. */}
|
|
374
|
+
<div data-sticky-headlane='' aria-hidden>
|
|
375
|
+
<div ref={headRef} data-sticky-head='' className={gapClass || undefined}>
|
|
376
|
+
{content}
|
|
377
|
+
</div>
|
|
378
|
+
</div>
|
|
379
|
+
<div
|
|
380
|
+
ref={sentinelRef}
|
|
381
|
+
aria-hidden
|
|
382
|
+
className='absolute left-0 w-px'
|
|
383
|
+
style={{ top: gapClass ? 'var(--term-line)' : 0, height: 1 }}
|
|
384
|
+
/>
|
|
385
|
+
<div ref={measureRef} data-index={index} className={gapClass || undefined}>
|
|
386
|
+
{content}
|
|
387
|
+
</div>
|
|
388
|
+
</div>
|
|
389
|
+
)
|
|
390
|
+
}
|
|
303
391
|
|
|
304
392
|
/**
|
|
305
393
|
* The virtualized row window. Only rows near the viewport are mounted, so
|
|
@@ -339,23 +427,54 @@ function TranscriptRows({
|
|
|
339
427
|
rows,
|
|
340
428
|
boundary,
|
|
341
429
|
since,
|
|
342
|
-
|
|
430
|
+
terminal,
|
|
431
|
+
replaying,
|
|
432
|
+
stickyPrompt,
|
|
343
433
|
gap,
|
|
434
|
+
fontSize,
|
|
435
|
+
lineHeight,
|
|
436
|
+
items,
|
|
437
|
+
pendingApprovals,
|
|
438
|
+
scrubber,
|
|
439
|
+
scrubberMarks,
|
|
440
|
+
affordances,
|
|
344
441
|
fileUrl,
|
|
345
442
|
attachmentUrl,
|
|
346
443
|
hostImage,
|
|
347
444
|
jumpToRecapRef,
|
|
445
|
+
repinRef,
|
|
446
|
+
reveal,
|
|
348
447
|
}: {
|
|
349
448
|
rows: TranscriptRow[]
|
|
350
449
|
boundary: number | undefined
|
|
351
450
|
since: number | undefined
|
|
352
|
-
|
|
451
|
+
/** The terminal theme draws its own rows; see {@link TranscriptItemView}. */
|
|
452
|
+
terminal: boolean
|
|
453
|
+
/** The replay hold (see {@link TranscriptProps.replaying}) — read here only
|
|
454
|
+
* for its falling edge, which needs a pre-paint pin. */
|
|
455
|
+
replaying: boolean
|
|
456
|
+
/** Pin the prompt of the turn being read to the top of the scroller. */
|
|
457
|
+
stickyPrompt: boolean
|
|
353
458
|
/** The inter-row gap for this variant and density (`ROW_GAP`). */
|
|
354
459
|
gap: { className?: string; px: number }
|
|
460
|
+
/** The terminal cell, when the host set one — only read as a signal that the
|
|
461
|
+
* height epoch below must re-measure; the epoch's numbers come from the DOM. */
|
|
462
|
+
fontSize?: number
|
|
463
|
+
lineHeight?: number
|
|
464
|
+
/** The transcript items — the scrubber's marks and peeks render from these,
|
|
465
|
+
* never from the DOM (the row a mark points at is usually unmounted). */
|
|
466
|
+
items: readonly TranscriptItem[]
|
|
467
|
+
pendingApprovals: readonly PermissionRequest[]
|
|
468
|
+
/** Mount the overview-ruler rail (terminal theme only). */
|
|
469
|
+
scrubber?: boolean
|
|
470
|
+
scrubberMarks?: readonly number[]
|
|
471
|
+
affordances?: TerminalAffordances | boolean
|
|
355
472
|
fileUrl?: (path: string) => string
|
|
356
473
|
attachmentUrl?: (attachmentId: string) => string
|
|
357
474
|
hostImage?: (path: string) => Promise<string | undefined>
|
|
358
475
|
jumpToRecapRef?: RefObject<(() => void) | null>
|
|
476
|
+
repinRef?: RefObject<(() => void) | null>
|
|
477
|
+
reveal?: { toolUseId: string; nonce: number }
|
|
359
478
|
}) {
|
|
360
479
|
const stick = useStickToBottomContext()
|
|
361
480
|
// The scroll element belongs to an ancestor — `StickToBottom.Content`
|
|
@@ -366,9 +485,98 @@ function TranscriptRows({
|
|
|
366
485
|
// virtualizer adopt it promptly: without one, a transcript short enough to
|
|
367
486
|
// never fire a scroll event could sit renderless indefinitely.
|
|
368
487
|
const [scrollElement, setScrollElement] = useState<HTMLElement | null>(null)
|
|
488
|
+
// Which rows *could* be the pinned prompt. Recomputed only when the row list
|
|
489
|
+
// changes, so the per-scroll work below is a walk over prompts rather than
|
|
490
|
+
// over the transcript.
|
|
491
|
+
const promptRows = useMemo(
|
|
492
|
+
// Top-level prompts only: a subagent's brief is a `user` item too, and one
|
|
493
|
+
// that escaped absorption (an orphan) must not become the pinned prompt —
|
|
494
|
+
// it is not what the answer on screen belongs to.
|
|
495
|
+
() =>
|
|
496
|
+
rows.flatMap((row, index) =>
|
|
497
|
+
'item' in row && row.item.kind === 'user' && parentOf(row.item) === undefined
|
|
498
|
+
? [index]
|
|
499
|
+
: [],
|
|
500
|
+
),
|
|
501
|
+
[rows],
|
|
502
|
+
)
|
|
503
|
+
// The pinned row must stay mounted even when it is far above the window, so
|
|
504
|
+
// it is forced into the virtual range — see `rangeExtractor` below, which
|
|
505
|
+
// reads these refs rather than closing over render values: it is called from
|
|
506
|
+
// inside the virtualizer's own range pass, where a closure would be a stale
|
|
507
|
+
// render's.
|
|
508
|
+
const pinRef = useRef<{ enabled: boolean; promptRows: readonly number[] }>({
|
|
509
|
+
enabled: false,
|
|
510
|
+
promptRows: [],
|
|
511
|
+
})
|
|
512
|
+
pinRef.current = { enabled: terminal && stickyPrompt, promptRows }
|
|
369
513
|
useEffect(() => {
|
|
370
514
|
setScrollElement(stick.scrollRef.current)
|
|
371
515
|
}, [stick.scrollRef])
|
|
516
|
+
|
|
517
|
+
// A composer that grows steals a line from the transcript.
|
|
518
|
+
//
|
|
519
|
+
// The composer and the transcript are siblings in the panel's flex column, so
|
|
520
|
+
// typing a newline shrinks this scroller by one line. "At the bottom" is a
|
|
521
|
+
// `scrollTop`, and that number stops meaning the bottom the moment the
|
|
522
|
+
// viewport changes height — so the last row, the one you were reading, slides
|
|
523
|
+
// under the fold as you type.
|
|
524
|
+
//
|
|
525
|
+
// `use-stick-to-bottom` cannot catch this: its ResizeObserver observes the
|
|
526
|
+
// **content** element (`.observe(content)` in its `useStickToBottom`), and
|
|
527
|
+
// here the content is unchanged and the *scroller* moved. Nor does the browser
|
|
528
|
+
// help — scrollTop is untouched, so no scroll event fires and nothing
|
|
529
|
+
// recomputes. Hence an observer of our own, on the scroller's own box.
|
|
530
|
+
//
|
|
531
|
+
// The guard is the whole feature: re-pin **only when already pinned**, or
|
|
532
|
+
// every newline yanks a reader who had deliberately scrolled up. That state
|
|
533
|
+
// lives in here, which is why this is in `Transcript` and not `SessionPanel`.
|
|
534
|
+
// Reading `stick.state.isAtBottom` (the library's live object, not the
|
|
535
|
+
// rendered boolean) is safe precisely because of the paragraph above: no
|
|
536
|
+
// scroll event fired, so the flag still holds the pre-resize answer.
|
|
537
|
+
//
|
|
538
|
+
// This is not a third writer of `scrollTop` — it presses the follow spring's
|
|
539
|
+
// own button, instantly, which is what the spring would have done had it
|
|
540
|
+
// noticed. The pinned-suppresses-corrections regime below is untouched.
|
|
541
|
+
useEffect(() => {
|
|
542
|
+
if (!scrollElement) return
|
|
543
|
+
let last = scrollElement.clientHeight
|
|
544
|
+
const observer = new ResizeObserver(() => {
|
|
545
|
+
const height = scrollElement.clientHeight
|
|
546
|
+
if (height === last) return
|
|
547
|
+
last = height
|
|
548
|
+
if (stick.state.isAtBottom) void stick.scrollToBottom('instant')
|
|
549
|
+
})
|
|
550
|
+
observer.observe(scrollElement)
|
|
551
|
+
return () => observer.disconnect()
|
|
552
|
+
}, [scrollElement, stick])
|
|
553
|
+
|
|
554
|
+
// The replay hold's reveal must paint already at the bottom, and the follow
|
|
555
|
+
// spring cannot make that true: even `scrollToBottom('instant')` defers its
|
|
556
|
+
// write behind a `requestAnimationFrame`, one frame after the reveal's paint
|
|
557
|
+
// — so the first visible frame showed the tail a burst shy of the bottom and
|
|
558
|
+
// then hopped (measured: revealTop 33037 against final 34459 on the 600-row
|
|
559
|
+
// fixture). A layout effect runs after the commit that removed the hold's
|
|
560
|
+
// visibility and before its paint, so this write lands in the very frame the
|
|
561
|
+
// transcript appears. It presses the library's own `state.scrollTop` setter
|
|
562
|
+
// — which records the write in `ignoreScrollToTop`, so the scroll handler
|
|
563
|
+
// knows it for its own — not a raw `scrollTop`, and only on the hold's
|
|
564
|
+
// falling edge, only while pinned; it is the pin's own move made a frame
|
|
565
|
+
// early, not a third writer.
|
|
566
|
+
const wasReplaying = useRef(replaying)
|
|
567
|
+
useLayoutEffect(() => {
|
|
568
|
+
const was = wasReplaying.current
|
|
569
|
+
wasReplaying.current = replaying
|
|
570
|
+
if (!was || replaying) return
|
|
571
|
+
if (!stick.state.isAtBottom) return
|
|
572
|
+
stick.state.scrollTop = stick.state.calculatedTargetScrollTop
|
|
573
|
+
}, [replaying, stick])
|
|
574
|
+
|
|
575
|
+
// The height epoch — see `use-height-epoch.ts`. Owned here because this
|
|
576
|
+
// component owns the virtualizer the heights feed.
|
|
577
|
+
const rowsRef = useRef<HTMLDivElement | null>(null)
|
|
578
|
+
const epoch = useHeightEpoch({ terminal, fontSize, lineHeight, rowsRef })
|
|
579
|
+
|
|
372
580
|
const virtualizer = useVirtualizer<HTMLElement, HTMLDivElement>({
|
|
373
581
|
count: rows.length,
|
|
374
582
|
// On adopting a scroll element the virtualizer *replays* its remembered
|
|
@@ -387,16 +595,56 @@ function TranscriptRows({
|
|
|
387
595
|
}
|
|
388
596
|
return scrollElement
|
|
389
597
|
},
|
|
390
|
-
// Estimates only shape the scrollbar and the span of never-mounted rows;
|
|
391
|
-
//
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
//
|
|
397
|
-
|
|
598
|
+
// Estimates only shape the scrollbar and the span of never-mounted rows; a
|
|
599
|
+
// measurement replaces them the moment a row mounts. Under the terminal
|
|
600
|
+
// theme they are *computed* (`terminal/height.ts`): the theme's one line
|
|
601
|
+
// height and one cell make a row's height derivable from its item, so the
|
|
602
|
+
// scrollbar is honest before rows mount and `scrollToIndex` sums real
|
|
603
|
+
// sizes instead of accumulating error over unmeasured spans. The gap rides
|
|
604
|
+
// the same estimate because it is real height on the same measured element
|
|
605
|
+
// — one line, decided per pair by `gapBefore`, exactly as the renderer
|
|
606
|
+
// applies the class. The recap row is a Row here too, so it is one line and
|
|
607
|
+
// exact — it used to be the cards markup, which measured 42px against an
|
|
608
|
+
// 18px line and pushed every row below it off the grid.
|
|
609
|
+
// Cards keep the flat constant: they vary too much for any constant to be
|
|
610
|
+
// right, so it is merely the order of magnitude — and the calculator has
|
|
611
|
+
// no claim there (padding scales, borders, a proportional face).
|
|
612
|
+
estimateSize: (index) => {
|
|
613
|
+
if (terminal && epoch) {
|
|
614
|
+
const row = rows[index]
|
|
615
|
+
const gapPx = index > 0 && gapBefore(rows, index) ? epoch.line : 0
|
|
616
|
+
if (row && !('line' in row))
|
|
617
|
+
return estimateBlockPx(row, epoch) + gapPx
|
|
618
|
+
return epoch.line + gapPx // recap: one Row, one line
|
|
619
|
+
}
|
|
620
|
+
return (terminal ? 36 : 100) + gap.px
|
|
621
|
+
},
|
|
398
622
|
overscan: 8,
|
|
399
623
|
getItemKey: (index) => rows[index].key,
|
|
624
|
+
// The sticky row, forced into the range. This is the virtualizer's own
|
|
625
|
+
// sticky-header seam: without it the pinned prompt's lane unmounts the
|
|
626
|
+
// moment it leaves the window, which is exactly when it is doing its job.
|
|
627
|
+
// The active prompt — the last one starting at or above the fold — is
|
|
628
|
+
// computed *here*, from the instance's own offset, rather than in the
|
|
629
|
+
// render body: the range pass runs before the render that would refresh a
|
|
630
|
+
// ref, so a value computed outside this callback is one scroll event
|
|
631
|
+
// stale, and a long programmatic jump would leave the pinned row unmounted
|
|
632
|
+
// until the next scroll. (`virtualizer` is safe to close over: the hook
|
|
633
|
+
// returns one stable instance for the component's lifetime.)
|
|
634
|
+
rangeExtractor: useCallback((range: Range) => {
|
|
635
|
+
const indexes = new Set(defaultRangeExtractor(range))
|
|
636
|
+
const { enabled, promptRows: prompts } = pinRef.current
|
|
637
|
+
if (enabled) {
|
|
638
|
+
const offset = virtualizer.scrollOffset ?? 0
|
|
639
|
+
let pinned = -1
|
|
640
|
+
for (const index of prompts) {
|
|
641
|
+
if ((virtualizer.measurementsCache[index]?.start ?? Infinity) <= offset) pinned = index
|
|
642
|
+
else break
|
|
643
|
+
}
|
|
644
|
+
if (pinned >= 0) indexes.add(pinned)
|
|
645
|
+
}
|
|
646
|
+
return [...indexes].sort((a, b) => a - b)
|
|
647
|
+
}, []),
|
|
400
648
|
// Explicit, and left at the default, because the obvious cleanup here is
|
|
401
649
|
// wrong. A correction fires from `measureElement`'s ref callback — inside
|
|
402
650
|
// React's commit — so the core's synchronous flush draws a "flushSync was
|
|
@@ -426,104 +674,273 @@ function TranscriptRows({
|
|
|
426
674
|
: item.start < fold
|
|
427
675
|
}
|
|
428
676
|
|
|
429
|
-
//
|
|
430
|
-
//
|
|
431
|
-
//
|
|
432
|
-
//
|
|
433
|
-
// is what tells you how far back the boundary was. `stopScroll()` first,
|
|
434
|
-
// because the pin spring is the other `scrollTop` writer and this is the
|
|
435
|
-
// library's own switch for "the user is leaving the bottom".
|
|
436
|
-
//
|
|
437
|
-
// And it has to *re-aim*. Every row between here and the boundary is
|
|
438
|
-
// unmeasured, so the offset the virtualizer scrolls to is the sum of a few
|
|
439
|
-
// hundred estimates; the real one only exists once those rows mount. A
|
|
440
|
-
// single smooth scroll therefore lands a screen or two short — measured at
|
|
441
|
-
// ~3300px off over 600 rows — and it cannot self-correct, because the core
|
|
442
|
-
// suppresses size-change adjustments outright while a smooth scroll is in
|
|
443
|
-
// flight. So: aim, let the rows it crossed measure, aim again from the
|
|
444
|
-
// better estimate. Each pass overshoots by less, and the moment the row is
|
|
445
|
-
// actually mounted the DOM can finish the job exactly.
|
|
677
|
+
// A new epoch means every remembered size is against the wrong metrics —
|
|
678
|
+
// the *measurements* included, which were taken at the old width. Dropping
|
|
679
|
+
// both together is the whole point: better estimates layered under
|
|
680
|
+
// stale-width measurements would be worse than either alone.
|
|
446
681
|
//
|
|
447
|
-
// The
|
|
448
|
-
//
|
|
449
|
-
//
|
|
450
|
-
//
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
|
|
682
|
+
// The second half is not optional: `measure()` clears the size cache and a
|
|
683
|
+
// row re-enters it only when its ResizeObserver fires — which needs a *size
|
|
684
|
+
// change*. A mounted row whose height happens to survive the width change
|
|
685
|
+
// (short lines that never rewrap) would keep its estimate forever, and
|
|
686
|
+
// wherever the estimate is off the transcript grows a phantom tail — 2,052px
|
|
687
|
+
// of scrollable nothing after one sidebar toggle, on a real session. So the
|
|
688
|
+
// mounted rows are fed straight back in.
|
|
454
689
|
useEffect(() => {
|
|
455
|
-
if (!
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
aim(0)
|
|
474
|
-
}
|
|
475
|
-
return () => {
|
|
476
|
-
jumpToRecapRef.current = null
|
|
690
|
+
if (!terminal || !epoch) return
|
|
691
|
+
virtualizer.measure()
|
|
692
|
+
const container = rowsRef.current
|
|
693
|
+
if (!container) return
|
|
694
|
+
// Two sharp edges in the re-feed, both learned the hard way. Order:
|
|
695
|
+
// `resizeItem` diffs a measure against `measurementsCache`, and straight
|
|
696
|
+
// after `measure()` that array is still the pre-wipe one — an unchanged
|
|
697
|
+
// row diffs to zero against its own old measurement and the write is
|
|
698
|
+
// skipped; recomputing first (any measurement read does it) rebuilds the
|
|
699
|
+
// array from estimates, so the diff is real again. And `resizeItem`
|
|
700
|
+
// directly, not `measureElement(element)`: the latter is gated on the
|
|
701
|
+
// scroll state and silently drops a measure that lands while a scroll is
|
|
702
|
+
// still hot — which a resize's own scroll anchoring makes routine.
|
|
703
|
+
virtualizer.getTotalSize()
|
|
704
|
+
for (const element of container.querySelectorAll<HTMLElement>('[data-index]')) {
|
|
705
|
+
const index = Number(element.getAttribute('data-index'))
|
|
706
|
+
if (Number.isInteger(index) && index >= 0)
|
|
707
|
+
virtualizer.resizeItem(index, element.getBoundingClientRect().height)
|
|
477
708
|
}
|
|
709
|
+
}, [terminal, epoch, virtualizer])
|
|
710
|
+
|
|
711
|
+
// The jump machinery — the aim loop, the catch-up strip's jump, the re-pin
|
|
712
|
+
// — lives in `use-transcript-jumps.ts`; every jump on this surface comes
|
|
713
|
+
// through the one function it returns.
|
|
714
|
+
const jumpToRow = useTranscriptJumps({
|
|
715
|
+
rows,
|
|
716
|
+
terminal,
|
|
717
|
+
stickyPrompt,
|
|
718
|
+
epoch,
|
|
719
|
+
promptRows,
|
|
720
|
+
scrollElement,
|
|
721
|
+
rowsRef,
|
|
722
|
+
virtualizer,
|
|
723
|
+
stick,
|
|
724
|
+
jumpToRecapRef,
|
|
725
|
+
repinRef,
|
|
478
726
|
})
|
|
479
727
|
|
|
728
|
+
// Reveal a tool call from outside the transcript — a sub-agent picked in a
|
|
729
|
+
// sessions list, whose `Task` row is the thing the reader asked for.
|
|
730
|
+
//
|
|
731
|
+
// Keyed on the **nonce**, never on the id: asking for the same sub-agent twice
|
|
732
|
+
// is a second request, and a props-equal effect would answer only the first.
|
|
733
|
+
// The lookup goes through `rowIndexForItem` for the reason that function
|
|
734
|
+
// exists — a row covers a *membership*, not a contiguous span, so a Task's id
|
|
735
|
+
// resolves to the folded row that absorbed it rather than to a position. That
|
|
736
|
+
// also makes a nested child's id work, which is what a client holding only a
|
|
737
|
+
// `parentToolUseId` can offer.
|
|
738
|
+
//
|
|
739
|
+
// `'start'`, like the recap seam and the scrubber's marks: the sub-agent's
|
|
740
|
+
// work runs *downward* from its row, so the reader wants the screen below it.
|
|
741
|
+
const revealNonce = reveal?.nonce
|
|
742
|
+
const revealId = reveal?.toolUseId
|
|
743
|
+
useEffect(() => {
|
|
744
|
+
if (revealId === undefined) return
|
|
745
|
+
const itemIndex = items.findIndex(
|
|
746
|
+
(item) => item.kind === 'tool_call' && item.id === revealId,
|
|
747
|
+
)
|
|
748
|
+
// Not here: a compaction, a `/clear`, or simply a client whose list knows
|
|
749
|
+
// about a Task this transcript has not replayed yet. Staying put beats
|
|
750
|
+
// jumping somewhere arbitrary.
|
|
751
|
+
if (itemIndex < 0) return
|
|
752
|
+
jumpToRow(rowIndexForItem(rows, itemIndex), 'start')
|
|
753
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- the nonce IS the trigger
|
|
754
|
+
}, [revealNonce])
|
|
755
|
+
|
|
756
|
+
// The scrubber. Interactivity follows the hover affordance — with
|
|
757
|
+
// `affordances={false}` the rail is passive paint (pointer-events off) and
|
|
758
|
+
// the native scrollbar stays; interactive, the rail IS the scrollbar, so the
|
|
759
|
+
// native one is hidden via an attribute on the scroll element.
|
|
760
|
+
const scrubInteractive = resolveAffordances(affordances).hover
|
|
761
|
+
const recapIndex = rows.findIndex((row) => row.key === 'recap')
|
|
762
|
+
const recapRow =
|
|
763
|
+
recapIndex >= 0
|
|
764
|
+
? { rowIndex: recapIndex, label: (rows[recapIndex] as { line: string }).line }
|
|
765
|
+
: undefined
|
|
766
|
+
useEffect(() => {
|
|
767
|
+
if (!terminal || !scrubber || !scrubInteractive || !scrollElement) return
|
|
768
|
+
scrollElement.setAttribute('data-term-scrubber-host', '')
|
|
769
|
+
return () => scrollElement.removeAttribute('data-term-scrubber-host')
|
|
770
|
+
}, [terminal, scrubber, scrubInteractive, scrollElement])
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* The pinned prompt: the prompt's **first line**, held at the top of the
|
|
774
|
+
* scroller.
|
|
775
|
+
*
|
|
776
|
+
* One line, not the row: a pasted twenty-line prompt pinned whole covers the
|
|
777
|
+
* viewport and buries the very answer being read under it. So what pins is a
|
|
778
|
+
* **head** — one line tall, `overflow: hidden` — whose content is the same
|
|
779
|
+
* row rendered again, laid exactly over the real row's first line. It is a
|
|
780
|
+
* duplicate, which an earlier design here rejected — but that rejection was
|
|
781
|
+
* of a *separate header* with its own padding and its own idea of the
|
|
782
|
+
* gutter. This copy is the same component in the same column at the same
|
|
783
|
+
* width, so it aligns with the row beneath by construction, and while the
|
|
784
|
+
* row is in flow the overlay is pixel-identical and invisible. It takes no
|
|
785
|
+
* pointer events and is `aria-hidden`: the real row owns interaction and
|
|
786
|
+
* the accessibility tree; the head is paint.
|
|
787
|
+
*
|
|
788
|
+
* The pin itself is the browser's, not ours. Each prompt row renders inside a
|
|
789
|
+
* **lane**: an absolutely positioned strip spanning from the prompt's start to
|
|
790
|
+
* the next prompt's (its turn), with the head `position: sticky` inside it
|
|
791
|
+
* (its flow footprint cancelled by a negative bottom margin, so the real row
|
|
792
|
+
* sits at the lane's top as if the head were not there). The compositor does
|
|
793
|
+
* the pinning and the lane's bottom edge does the push-off — `sticky` is
|
|
794
|
+
* inert on an absolutely positioned element, but works unchanged on a child
|
|
795
|
+
* *of* one, confined to the lane's box. An earlier version clamped the row's
|
|
796
|
+
* transform from render instead, and paid for it every frame: any JS-written
|
|
797
|
+
* pin — React render or a raw scroll handler — runs behind the compositor
|
|
798
|
+
* thread, so the row wobbled under momentum scroll. With the lane there is
|
|
799
|
+
* no per-scroll JS and no lag.
|
|
800
|
+
*
|
|
801
|
+
* Which row — the last prompt at or above the fold, the question the answer
|
|
802
|
+
* on screen belongs to — falls out of the geometry: only the lane spanning
|
|
803
|
+
* the viewport top has its child stuck; every earlier lane has pushed its row
|
|
804
|
+
* off its bottom edge, every later one hasn't reached the top.
|
|
805
|
+
*
|
|
806
|
+
* The one job left to JS is keeping that row *mounted* once it scrolls far
|
|
807
|
+
* above the virtual window — which is exactly when it is working. That lives
|
|
808
|
+
* in the `rangeExtractor` above.
|
|
809
|
+
*/
|
|
810
|
+
const measurements = virtualizer.measurementsCache
|
|
811
|
+
|
|
480
812
|
return (
|
|
481
813
|
<div
|
|
814
|
+
ref={rowsRef}
|
|
482
815
|
data-slot='transcript-rows'
|
|
483
816
|
className='relative w-full'
|
|
484
817
|
style={{ height: virtualizer.getTotalSize() }}>
|
|
485
818
|
{virtualizer.getVirtualItems().map((virtualRow) => {
|
|
486
819
|
const row = rows[virtualRow.index]
|
|
820
|
+
// The inter-row gap, folded into each row so the measured height
|
|
821
|
+
// carries it: flex `gap` cannot reach absolutely positioned rows,
|
|
822
|
+
// and a pixel constant for the virtualizer's `gap` option would
|
|
823
|
+
// drift from the rem the layout is set in. On the measured wrapper,
|
|
824
|
+
// not the row div, so a nested row's left border still breaks
|
|
825
|
+
// across the gap as it did under flex. Skipped for the first row —
|
|
826
|
+
// a gap above it would be padding, not spacing.
|
|
827
|
+
// Every variant but terminal spaces every row alike. Terminal
|
|
828
|
+
// asks whether the pair belongs together — a tool call and its
|
|
829
|
+
// output get no blank line, exactly as the CLI leaves none.
|
|
830
|
+
const gapClass =
|
|
831
|
+
virtualRow.index > 0 && (!terminal || gapBefore(rows, virtualRow.index))
|
|
832
|
+
? gap.className
|
|
833
|
+
: undefined
|
|
834
|
+
const content =
|
|
835
|
+
'run' in row ? (
|
|
836
|
+
<div className={cn(read(boundary, row.index) && 'opacity-45')}>
|
|
837
|
+
<ToolRunRow items={row.run} />
|
|
838
|
+
</div>
|
|
839
|
+
) : 'item' in row ? (
|
|
840
|
+
<div className={cn(read(boundary, row.index) && 'opacity-45', nestedClass(row.item))}>
|
|
841
|
+
<TranscriptItemView
|
|
842
|
+
item={row.item}
|
|
843
|
+
fileUrl={fileUrl}
|
|
844
|
+
attachmentUrl={attachmentUrl}
|
|
845
|
+
hostImage={hostImage}
|
|
846
|
+
terminal={terminal}
|
|
847
|
+
/>
|
|
848
|
+
</div>
|
|
849
|
+
) : 'line' in row ? (
|
|
850
|
+
<RecapRow line={row.line} since={since} terminal={terminal} />
|
|
851
|
+
) : (
|
|
852
|
+
// A task block. No `nestedClass` here: the rule belongs *inside*
|
|
853
|
+
// the row, around the children it opens onto — the collapsed line
|
|
854
|
+
// is the main thread's, and stepping it in would say a `Task` call
|
|
855
|
+
// happened somewhere else.
|
|
856
|
+
<div className={cn(read(boundary, row.index) && 'opacity-45')}>
|
|
857
|
+
<TaskRow block={row} fileUrl={fileUrl} />
|
|
858
|
+
</div>
|
|
859
|
+
)
|
|
860
|
+
// A prompt row's sticky lane — see the pinned-prompt comment above.
|
|
861
|
+
// The lane is sized to the turn; the sticky **head** (one clipped
|
|
862
|
+
// line, the same content again) comes first with its flow footprint
|
|
863
|
+
// cancelled, and the *measured* element is the real row after it, so
|
|
864
|
+
// the virtualizer's heights are untouched by either. Both carry the
|
|
865
|
+
// gap class: the row because the gap is part of its measured height,
|
|
866
|
+
// the head so its one visible line sits on the same y while in flow —
|
|
867
|
+
// the pin parks that padding above the viewport edge when stuck.
|
|
868
|
+
// Positioned with `top`, NOT the translate every other row gets:
|
|
869
|
+
// `position: sticky` is resolved at layout time and a transform is
|
|
870
|
+
// paint-only, so under a translate the head would stick against the
|
|
871
|
+
// lane's un-translated box at the top of the list — observed as the
|
|
872
|
+
// row clamped to its lane's bottom edge, never pinning at all.
|
|
873
|
+
// Same predicate as `promptRows` above — the lane and the forced range
|
|
874
|
+
// must agree on which rows are prompts.
|
|
875
|
+
if (
|
|
876
|
+
terminal &&
|
|
877
|
+
stickyPrompt &&
|
|
878
|
+
'item' in row &&
|
|
879
|
+
row.item.kind === 'user' &&
|
|
880
|
+
parentOf(row.item) === undefined
|
|
881
|
+
) {
|
|
882
|
+
const next = promptRows.find((index) => index > virtualRow.index)
|
|
883
|
+
const laneEnd =
|
|
884
|
+
next === undefined
|
|
885
|
+
? virtualizer.getTotalSize()
|
|
886
|
+
: (measurements[next]?.start ?? virtualRow.start)
|
|
887
|
+
return (
|
|
888
|
+
<StickyPromptLane
|
|
889
|
+
key={row.key}
|
|
890
|
+
top={virtualRow.start}
|
|
891
|
+
height={Math.max(laneEnd - virtualRow.start, 0)}
|
|
892
|
+
gapClass={gapClass}
|
|
893
|
+
scrollRoot={scrollElement}
|
|
894
|
+
index={virtualRow.index}
|
|
895
|
+
measureRef={virtualizer.measureElement}
|
|
896
|
+
content={content}
|
|
897
|
+
/>
|
|
898
|
+
)
|
|
899
|
+
}
|
|
487
900
|
return (
|
|
488
901
|
<div
|
|
489
902
|
key={row.key}
|
|
490
903
|
ref={virtualizer.measureElement}
|
|
491
904
|
data-index={virtualRow.index}
|
|
492
|
-
className={cn(
|
|
493
|
-
'absolute inset-x-0 top-0',
|
|
494
|
-
// The inter-row gap, folded into each row so the measured height
|
|
495
|
-
// carries it: flex `gap` cannot reach absolutely positioned rows,
|
|
496
|
-
// and a pixel constant for the virtualizer's `gap` option would
|
|
497
|
-
// drift from the rem the layout is set in. On this outer wrapper,
|
|
498
|
-
// not the row div, so a nested row's left border still breaks
|
|
499
|
-
// across the gap as it did under flex. Skipped for the first row —
|
|
500
|
-
// a gap above it would be padding, not spacing.
|
|
501
|
-
virtualRow.index > 0 && gap.className,
|
|
502
|
-
)}
|
|
905
|
+
className={cn('absolute inset-x-0 top-0', gapClass)}
|
|
503
906
|
style={{ transform: `translateY(${virtualRow.start}px)` }}>
|
|
504
|
-
{
|
|
505
|
-
<div
|
|
506
|
-
className={cn(
|
|
507
|
-
// Full-bleed hover: the row IS the affordance, so the
|
|
508
|
-
// highlight has to reach past the content gutter.
|
|
509
|
-
lines && '-mx-1 rounded-sm px-1 py-0.5 transition-colors hover:bg-surface-hover',
|
|
510
|
-
// Already read: present, legible, and visibly behind you.
|
|
511
|
-
boundary !== undefined && row.index < boundary && 'opacity-45',
|
|
512
|
-
nestedClass(row.item, lines),
|
|
513
|
-
)}>
|
|
514
|
-
<TranscriptItemView
|
|
515
|
-
item={row.item}
|
|
516
|
-
fileUrl={fileUrl}
|
|
517
|
-
attachmentUrl={attachmentUrl}
|
|
518
|
-
hostImage={hostImage}
|
|
519
|
-
/>
|
|
520
|
-
</div>
|
|
521
|
-
) : (
|
|
522
|
-
<RecapRow line={row.line} since={since} />
|
|
523
|
-
)}
|
|
907
|
+
{content}
|
|
524
908
|
</div>
|
|
525
909
|
)
|
|
526
910
|
})}
|
|
911
|
+
{/* The overview ruler, portalled beside the scroll element rather than
|
|
912
|
+
rendered as content: it must not scroll with the rows it maps. It
|
|
913
|
+
lives here, not in the shell above, because everything it draws from
|
|
914
|
+
— the virtualizer's offsets, the epoch, the row list, the jump — is
|
|
915
|
+
this component's. The portal target is the Conversation root
|
|
916
|
+
(`relative`), the same containing block the scroll button uses. */}
|
|
917
|
+
{terminal && scrubber && scrollElement?.parentElement
|
|
918
|
+
? createPortal(
|
|
919
|
+
<TerminalScrubber
|
|
920
|
+
items={items}
|
|
921
|
+
pendingApprovals={pendingApprovals}
|
|
922
|
+
recapRow={recapRow}
|
|
923
|
+
bookmarks={scrubberMarks ?? []}
|
|
924
|
+
rowIndexFor={(itemIndex) => rowIndexForItem(rows, itemIndex)}
|
|
925
|
+
positionInRow={(itemIndex) => positionInRow(rows, itemIndex)}
|
|
926
|
+
// The public memoized measurements array — `getTotalSize()` just
|
|
927
|
+
// above refreshed it, and with the calculator feeding
|
|
928
|
+
// `estimateSize` these starts are honest for unmounted rows too.
|
|
929
|
+
offsetOfRow={(rowIndex) => virtualizer.measurementsCache[rowIndex]?.start ?? 0}
|
|
930
|
+
sizeOfRow={(rowIndex) => virtualizer.measurementsCache[rowIndex]?.size ?? 0}
|
|
931
|
+
totalSize={virtualizer.getTotalSize()}
|
|
932
|
+
scrollOffset={virtualizer.scrollOffset ?? 0}
|
|
933
|
+
viewportH={virtualizer.scrollRect?.height ?? 0}
|
|
934
|
+
// To the top: a mark is where you start reading, not the middle of
|
|
935
|
+
// what you want to see.
|
|
936
|
+
onJumpToRow={(rowIndex) => jumpToRow(rowIndex, 'start')}
|
|
937
|
+
interactive={scrubInteractive}
|
|
938
|
+
fontSize={fontSize}
|
|
939
|
+
lineHeight={lineHeight}
|
|
940
|
+
/>,
|
|
941
|
+
scrollElement.parentElement,
|
|
942
|
+
)
|
|
943
|
+
: null}
|
|
527
944
|
</div>
|
|
528
945
|
)
|
|
529
946
|
}
|
|
@@ -544,9 +961,9 @@ export interface TranscriptProps {
|
|
|
544
961
|
* on the host (codex's `image_gen`). Omit and those cards name the path. */
|
|
545
962
|
hostImage?: (path: string) => Promise<string | undefined>
|
|
546
963
|
/**
|
|
547
|
-
* How a turn is drawn: `cards` (default, the chat convention) or `
|
|
548
|
-
*
|
|
549
|
-
*
|
|
964
|
+
* How a turn is drawn: `cards` (default, the chat convention) or `terminal`,
|
|
965
|
+
* which is not a set of branches in these components but its own renderer.
|
|
966
|
+
* See {@link TranscriptVariant}.
|
|
550
967
|
*/
|
|
551
968
|
variant?: TranscriptVariant
|
|
552
969
|
/**
|
|
@@ -555,6 +972,42 @@ export interface TranscriptProps {
|
|
|
555
972
|
* {@link TranscriptVariant}. See {@link TranscriptDensity}.
|
|
556
973
|
*/
|
|
557
974
|
density?: TranscriptDensity
|
|
975
|
+
/** Terminal theme only: the character cell, in whole pixels. See
|
|
976
|
+
* {@link TerminalSurface}. */
|
|
977
|
+
fontSize?: number
|
|
978
|
+
lineHeight?: number
|
|
979
|
+
/** Terminal theme only: the pointer affordances a real terminal cannot offer.
|
|
980
|
+
* `false` for none. See {@link TerminalAffordances}. */
|
|
981
|
+
affordances?: TerminalAffordances | boolean
|
|
982
|
+
/** Terminal theme only: hold the prompt of the turn being read at the top of
|
|
983
|
+
* the scroller. The *real* row is pinned, not a copy — see `TranscriptRows`. */
|
|
984
|
+
stickyPrompt?: boolean
|
|
985
|
+
/**
|
|
986
|
+
* Terminal theme only: mount the overview-ruler scrubber — a 2ch rail of
|
|
987
|
+
* marks (your prompts, each turn's response and result as one mark, errors,
|
|
988
|
+
* the pending approval, the catch-up boundary) that replaces the native
|
|
989
|
+
* scrollbar. Ignored under `cards`: the rail's positions ride the height
|
|
990
|
+
* calculator, which has no claim there. With `affordances={false}` the rail
|
|
991
|
+
* degrades to passive paint — no drag, peek or click — and the native
|
|
992
|
+
* scrollbar stays. See {@link TerminalScrubber}.
|
|
993
|
+
*/
|
|
994
|
+
scrubber?: boolean
|
|
995
|
+
/**
|
|
996
|
+
* Bookmarked item indices, painted as full-width marks on the rail. Paint
|
|
997
|
+
* only, deliberately: the store — and the affordance that writes it — is
|
|
998
|
+
* the client's, the way the unread watermarks are, not the panel's.
|
|
999
|
+
*/
|
|
1000
|
+
scrubberMarks?: readonly number[]
|
|
1001
|
+
/**
|
|
1002
|
+
* The attach replay is still landing (`useClaudeSession().replaying`): rows
|
|
1003
|
+
* render, measure and pin exactly as normal but nothing paints, and a loading
|
|
1004
|
+
* line shows in their place; when it flips false the settled tail appears in
|
|
1005
|
+
* one frame. Hiding is by *visibility*, never by not mounting — see the
|
|
1006
|
+
* comment at the render site. Optional: an embedder that never passes it
|
|
1007
|
+
* gets today's behaviour, and a short or empty session holds for no visible
|
|
1008
|
+
* time at all (the frame between attach and replay-complete).
|
|
1009
|
+
*/
|
|
1010
|
+
replaying?: boolean
|
|
558
1011
|
/**
|
|
559
1012
|
* Catch-up: `from` is how many items had been seen last time, `since` when
|
|
560
1013
|
* that was. A recap row is drawn at that boundary and everything above it is
|
|
@@ -570,6 +1023,27 @@ export interface TranscriptProps {
|
|
|
570
1023
|
* catch-up strip never touch it. `null` while no transcript is mounted.
|
|
571
1024
|
*/
|
|
572
1025
|
jumpToRecapRef?: RefObject<(() => void) | null>
|
|
1026
|
+
/**
|
|
1027
|
+
* Filled with a closure that re-pins the transcript to the bottom, so a host
|
|
1028
|
+
* can resume following after the reader has scrolled away. The panel presses
|
|
1029
|
+
* it on send: choosing to say something is choosing to watch what happens
|
|
1030
|
+
* next, and a transcript left parked where you were reading makes a sent
|
|
1031
|
+
* message look like it did nothing at all.
|
|
1032
|
+
*/
|
|
1033
|
+
repinRef?: RefObject<(() => void) | null>
|
|
1034
|
+
/**
|
|
1035
|
+
* Scroll a tool call into view — bump `nonce` to ask again for the same one.
|
|
1036
|
+
*
|
|
1037
|
+
* The seam a *list* needs: sub-agent work is nested inside the `Task` call
|
|
1038
|
+
* that spawned it, so "open that sub-agent" can only ever mean "take me to its
|
|
1039
|
+
* row". A `parentToolUseId` works here as well as the Task's own id, since the
|
|
1040
|
+
* lookup resolves an absorbed child to the row that folded it.
|
|
1041
|
+
*
|
|
1042
|
+
* A prop rather than a ref (the shape `jumpToRecapRef` uses) because the asker
|
|
1043
|
+
* is outside this webview entirely and the request travels as data; a ref
|
|
1044
|
+
* would need a live closure at the other end of a postMessage bridge.
|
|
1045
|
+
*/
|
|
1046
|
+
reveal?: { toolUseId: string; nonce: number }
|
|
573
1047
|
className?: string
|
|
574
1048
|
}
|
|
575
1049
|
|
|
@@ -581,33 +1055,72 @@ export function Transcript({
|
|
|
581
1055
|
hostImage,
|
|
582
1056
|
variant = 'cards',
|
|
583
1057
|
density = 'comfortable',
|
|
1058
|
+
fontSize,
|
|
1059
|
+
lineHeight,
|
|
1060
|
+
affordances,
|
|
1061
|
+
stickyPrompt = false,
|
|
1062
|
+
scrubber,
|
|
1063
|
+
scrubberMarks,
|
|
1064
|
+
replaying = false,
|
|
584
1065
|
catchUp,
|
|
585
1066
|
jumpToRecapRef,
|
|
1067
|
+
repinRef,
|
|
1068
|
+
reveal,
|
|
586
1069
|
className,
|
|
587
1070
|
}: TranscriptProps) {
|
|
588
|
-
const
|
|
1071
|
+
const terminal = variant === 'terminal'
|
|
589
1072
|
const gap = ROW_GAP[variant][density]
|
|
590
1073
|
const runStartedAt = useRunStart(state.status)
|
|
591
|
-
const following = useSettled(state.items.length, state.status)
|
|
592
1074
|
// A boundary at (or past) the end means nothing is new — no row, no dimming.
|
|
1075
|
+
//
|
|
1076
|
+
// That "past the end" arm now also covers a `/clear`. The mark a client
|
|
1077
|
+
// stored is an item index, and `conversation_reset` empties `items` while
|
|
1078
|
+
// `activityCount` stays monotonic (it is an unread cursor, not an item count
|
|
1079
|
+
// — a count that went backwards would silence the badge for good against a
|
|
1080
|
+
// monotonic watermark store). So a session returned to after a clear has a
|
|
1081
|
+
// boundary well past its few fresh rows and gets **no recap row**, which is
|
|
1082
|
+
// the honest answer: an index into a conversation that no longer exists
|
|
1083
|
+
// cannot say what you missed. Clamping it would land on `items.length` and
|
|
1084
|
+
// read as "nothing is new" — the same outcome, told less truthfully.
|
|
593
1085
|
const boundary =
|
|
594
1086
|
catchUp && catchUp.from > 0 && catchUp.from < state.items.length ? catchUp.from : undefined
|
|
595
1087
|
const recap = useMemo(
|
|
596
1088
|
() => (boundary === undefined ? undefined : recapLine(summarizeSince(state, boundary))),
|
|
597
1089
|
[state, boundary],
|
|
598
1090
|
)
|
|
599
|
-
const rows = useMemo(() => {
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
1091
|
+
const rows = useMemo<TranscriptRow[]>(() => {
|
|
1092
|
+
const fold = (from: number, to: number) =>
|
|
1093
|
+
terminalBlocks(state.items.slice(from, to), from, terminal)
|
|
1094
|
+
if (boundary === undefined || !recap) return fold(0, state.items.length)
|
|
1095
|
+
// Each side of the boundary folds separately, so a shell run never spans it:
|
|
1096
|
+
// "what happened while you were away" must not hide inside a count that also
|
|
1097
|
+
// covers what you have already read.
|
|
1098
|
+
return [
|
|
1099
|
+
...fold(0, boundary),
|
|
1100
|
+
{ key: 'recap' as const, line: recap },
|
|
1101
|
+
...fold(boundary, state.items.length),
|
|
1102
|
+
]
|
|
1103
|
+
}, [state.items, boundary, recap, terminal])
|
|
607
1104
|
return (
|
|
608
1105
|
<TranscriptVariantProvider value={variant}>
|
|
609
|
-
|
|
610
|
-
|
|
1106
|
+
{/* The replay hold hides by VISIBILITY, never by not mounting. The rows
|
|
1107
|
+
must exist and lay out while hidden: the virtualizer measures them,
|
|
1108
|
+
the height epoch builds, and the follow pin settles on the real
|
|
1109
|
+
bottom — so the reveal is the removal of one style, a single paint of
|
|
1110
|
+
an already-settled tail, and the catch-up jump always fires against a
|
|
1111
|
+
measured list. (Unmounting instead would replay the entire
|
|
1112
|
+
mount-measure-correct churn, visibly, at reveal time.) `visibility`
|
|
1113
|
+
is the one hiding property a descendant can turn back ON, which is
|
|
1114
|
+
how the loading line below stays visible inside a hidden root — and
|
|
1115
|
+
the root is the right scope because the scrubber and the scroll
|
|
1116
|
+
button portal/position into it, not into the scroller. */}
|
|
1117
|
+
<Conversation className={cn(replaying && 'invisible', className)}>
|
|
1118
|
+
<ConversationContent className={cn(terminal && 'gap-0 p-0')}>
|
|
1119
|
+
<TerminalShell
|
|
1120
|
+
active={terminal}
|
|
1121
|
+
fontSize={fontSize}
|
|
1122
|
+
lineHeight={lineHeight}
|
|
1123
|
+
affordances={affordances}>
|
|
611
1124
|
{state.items.length === 0 && state.status !== 'starting' ? (
|
|
612
1125
|
<SessionEmptyState
|
|
613
1126
|
cwd={state.cwd}
|
|
@@ -620,24 +1133,88 @@ export function Transcript({
|
|
|
620
1133
|
rows={rows}
|
|
621
1134
|
boundary={boundary}
|
|
622
1135
|
since={catchUp?.since}
|
|
623
|
-
|
|
1136
|
+
terminal={terminal}
|
|
1137
|
+
replaying={replaying}
|
|
1138
|
+
stickyPrompt={stickyPrompt}
|
|
624
1139
|
gap={gap}
|
|
1140
|
+
fontSize={fontSize}
|
|
1141
|
+
lineHeight={lineHeight}
|
|
1142
|
+
items={state.items}
|
|
1143
|
+
pendingApprovals={state.pendingApprovals}
|
|
1144
|
+
scrubber={scrubber}
|
|
1145
|
+
scrubberMarks={scrubberMarks}
|
|
1146
|
+
affordances={affordances}
|
|
625
1147
|
fileUrl={fileUrl}
|
|
626
1148
|
attachmentUrl={attachmentUrl}
|
|
627
1149
|
hostImage={hostImage}
|
|
628
1150
|
jumpToRecapRef={jumpToRecapRef}
|
|
1151
|
+
repinRef={repinRef}
|
|
1152
|
+
reveal={reveal}
|
|
629
1153
|
/>
|
|
630
1154
|
)}
|
|
631
1155
|
{showLoader(state) ? (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
1156
|
+
terminal ? (
|
|
1157
|
+
// The CLI's own working line, and it is a *row of the transcript*
|
|
1158
|
+
// rather than a spinner floating over it — one blank line down,
|
|
1159
|
+
// like every other block.
|
|
1160
|
+
<>
|
|
1161
|
+
{state.items.length > 0 ? <div className='term-blank' aria-hidden /> : null}
|
|
1162
|
+
<WorkingRow
|
|
1163
|
+
label={state.status === 'starting' ? 'Starting…' : 'Working…'}
|
|
1164
|
+
startedAt={runStartedAt}
|
|
1165
|
+
tokens={state.contextUsage?.totalTokens}
|
|
1166
|
+
/>
|
|
1167
|
+
</>
|
|
1168
|
+
) : (
|
|
1169
|
+
<Loader
|
|
1170
|
+
label={state.status === 'starting' ? 'Starting session…' : undefined}
|
|
1171
|
+
startedAt={runStartedAt}
|
|
1172
|
+
tokens={state.contextUsage?.totalTokens}
|
|
1173
|
+
/>
|
|
1174
|
+
)
|
|
638
1175
|
) : null}
|
|
1176
|
+
</TerminalShell>
|
|
639
1177
|
</ConversationContent>
|
|
640
1178
|
<ConversationScrollButton />
|
|
1179
|
+
{/* What shows while the hold is on — and for a normal attach that is
|
|
1180
|
+
*nothing*. `wd-hold-appear` (theme.css) keeps it at `opacity: 0`
|
|
1181
|
+
and fades it in only after 600ms, so a healthy ~0.5s hold unmounts
|
|
1182
|
+
it before it ever paints. An unconditional line here was worse than
|
|
1183
|
+
no hold at all: it appeared and vanished inside half a second, which
|
|
1184
|
+
is the flicker the hold exists to remove, relocated to the top of
|
|
1185
|
+
the panel. Only a genuinely slow attach earns a placeholder, which
|
|
1186
|
+
is the case where a reader would otherwise think the panel is dead.
|
|
1187
|
+
An overlay rather than a flow row
|
|
1188
|
+
because the hidden content is at full height and pinned to its
|
|
1189
|
+
bottom; a row in flow would sit at the bottom edge. It mirrors
|
|
1190
|
+
`ConversationContent`'s wrapper (not the component itself — a
|
|
1191
|
+
second `StickToBottom.Content` would steal the library's content
|
|
1192
|
+
ref) so the paddings line up with the real rows'. */}
|
|
1193
|
+
{replaying ? (
|
|
1194
|
+
<div
|
|
1195
|
+
data-slot='transcript-hold'
|
|
1196
|
+
aria-hidden
|
|
1197
|
+
className='wd-hold-appear visible pointer-events-none absolute inset-0 overflow-hidden'>
|
|
1198
|
+
<div
|
|
1199
|
+
className={cn(
|
|
1200
|
+
'mx-auto w-full max-w-[var(--wd-content-max-w,48rem)]',
|
|
1201
|
+
!terminal && 'px-4 py-4',
|
|
1202
|
+
)}>
|
|
1203
|
+
{terminal ? (
|
|
1204
|
+
<TerminalSurface
|
|
1205
|
+
fontSize={fontSize}
|
|
1206
|
+
lineHeight={lineHeight}
|
|
1207
|
+
affordances={false}
|
|
1208
|
+
bleed='1ch'
|
|
1209
|
+
className='term-transcript'>
|
|
1210
|
+
<WorkingRow label='Loading…' />
|
|
1211
|
+
</TerminalSurface>
|
|
1212
|
+
) : (
|
|
1213
|
+
<Loader label='Loading session…' />
|
|
1214
|
+
)}
|
|
1215
|
+
</div>
|
|
1216
|
+
</div>
|
|
1217
|
+
) : null}
|
|
641
1218
|
</Conversation>
|
|
642
1219
|
</TranscriptVariantProvider>
|
|
643
1220
|
)
|