@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.
Files changed (71) hide show
  1. package/README.md +60 -0
  2. package/build/{SessionPanel-J2U8v88q.d.mts → SessionPanel-CnNYEX80.d.mts} +170 -21
  3. package/build/{SessionPanel-DI1NO4l8.mjs → SessionPanel-DMPhsNlW.mjs} +4759 -1483
  4. package/build/SessionPanel-DMPhsNlW.mjs.map +1 -0
  5. package/build/{format-ljc3lKpA.d.mts → format-DfI_je9S.d.mts} +1 -1
  6. package/build/format.d.mts +39 -4
  7. package/build/format.mjs +2 -118
  8. package/build/index.d.mts +493 -45
  9. package/build/index.mjs +343 -17
  10. package/build/index.mjs.map +1 -1
  11. package/build/status-Ydzi7n6j.mjs +143 -0
  12. package/build/status-Ydzi7n6j.mjs.map +1 -0
  13. package/build/workspace.d.mts +9 -1
  14. package/build/workspace.mjs +108 -5
  15. package/build/workspace.mjs.map +1 -1
  16. package/package.json +16 -7
  17. package/src/components/agent/Composer.tsx +189 -89
  18. package/src/components/agent/Conversation.tsx +12 -12
  19. package/src/components/agent/FileCard.tsx +0 -26
  20. package/src/components/agent/FileTree.tsx +9 -8
  21. package/src/components/agent/Loader.tsx +22 -72
  22. package/src/components/agent/Message.tsx +11 -46
  23. package/src/components/agent/PermissionPrompt.tsx +0 -92
  24. package/src/components/agent/ProjectIcon.tsx +119 -0
  25. package/src/components/agent/QuestionPrompt.tsx +0 -122
  26. package/src/components/agent/Reasoning.tsx +5 -19
  27. package/src/components/agent/Response.tsx +1 -132
  28. package/src/components/agent/SessionBrowser.tsx +84 -3
  29. package/src/components/agent/SessionPanel.tsx +249 -28
  30. package/src/components/agent/SessionWorkspace.tsx +29 -0
  31. package/src/components/agent/StatusBar.tsx +20 -4
  32. package/src/components/agent/ToolCallCard.tsx +85 -112
  33. package/src/components/agent/Transcript.tsx +780 -203
  34. package/src/components/agent/UsageDialog.tsx +20 -106
  35. package/src/components/agent/UsageMeters.tsx +133 -0
  36. package/src/components/agent/pulse.tsx +3 -2
  37. package/src/components/agent/tool-result-fetch.tsx +36 -0
  38. package/src/components/agent/tool-result-image.tsx +209 -0
  39. package/src/components/agent/transcript-rows.ts +173 -0
  40. package/src/components/agent/transcript-variant.tsx +29 -51
  41. package/src/components/agent/use-height-epoch.ts +60 -0
  42. package/src/components/agent/use-path-links.ts +147 -0
  43. package/src/components/agent/use-transcript-jumps.ts +190 -0
  44. package/src/components/prompt-area/cursor-helpers.ts +65 -0
  45. package/src/components/prompt-area/use-prompt-area.ts +16 -10
  46. package/src/components/terminal/PermissionPrompt.tsx +119 -0
  47. package/src/components/terminal/QuestionPrompt.tsx +322 -0
  48. package/src/components/terminal/StatusLine.tsx +159 -0
  49. package/src/components/terminal/TerminalTranscript.tsx +225 -0
  50. package/src/components/terminal/affordances.tsx +118 -0
  51. package/src/components/terminal/blocks.ts +232 -0
  52. package/src/components/terminal/diff.tsx +130 -0
  53. package/src/components/terminal/height.ts +770 -0
  54. package/src/components/terminal/image-box.ts +53 -0
  55. package/src/components/terminal/items.tsx +486 -0
  56. package/src/components/terminal/markdown.tsx +191 -0
  57. package/src/components/terminal/press.tsx +120 -0
  58. package/src/components/terminal/prompt.tsx +343 -0
  59. package/src/components/terminal/result-preview.ts +86 -0
  60. package/src/components/terminal/row.tsx +132 -0
  61. package/src/components/terminal/scrubber.tsx +784 -0
  62. package/src/components/terminal/surface.tsx +80 -0
  63. package/src/components/terminal/tool-run.ts +224 -0
  64. package/src/index.ts +36 -1
  65. package/src/lib/status.ts +59 -3
  66. package/src/lib/tool-icon.ts +14 -0
  67. package/src/styles/terminal.css +1081 -0
  68. package/src/styles/theme.css +41 -0
  69. package/build/SessionPanel-DI1NO4l8.mjs.map +0 -1
  70. package/build/format.mjs.map +0 -1
  71. package/src/components/agent/line-prompt.tsx +0 -249
@@ -8,12 +8,20 @@ import {
8
8
  type ReactNode,
9
9
  } from 'react'
10
10
  import type { WorkerDeckClient } from '@workerdeck/client'
11
- import { PROTOCOL_VERSION, type ModelOption, type PermissionMode } from '@workerdeck/protocol'
12
11
  import {
13
- rateLimitWindows,
12
+ PROTOCOL_VERSION,
13
+ mergeUsage,
14
+ orderUsageWindows,
15
+ usageInfos,
16
+ type ModelOption,
17
+ type PermissionMode,
18
+ type RateLimitInfo,
19
+ } from '@workerdeck/protocol'
20
+ import {
14
21
  useAttachments,
15
22
  useClaudeSession,
16
23
  useHostFileSearch,
24
+ useProfileUsage,
17
25
  useToolCallHost,
18
26
  type ConnectionState,
19
27
  type ProducedFileRef,
@@ -47,9 +55,16 @@ import {
47
55
  } from './PermissionModeSelect.tsx'
48
56
  import { PermissionPrompt } from './PermissionPrompt.tsx'
49
57
  import { QuestionPrompt, parseUserQuestions } from './QuestionPrompt.tsx'
58
+ import { TerminalPermissionPrompt } from '../terminal/PermissionPrompt.tsx'
59
+ import { TerminalQuestionPrompt } from '../terminal/QuestionPrompt.tsx'
60
+ import { TerminalSurface } from '../terminal/surface.tsx'
61
+ import type { TerminalAffordances } from '../terminal/affordances.tsx'
62
+
50
63
  import { SessionInfoDialog } from './SessionInfoDialog.tsx'
51
64
  import { StatusBar } from './StatusBar.tsx'
52
65
  import { Transcript } from './Transcript.tsx'
66
+ import { ToolResultFetchProvider } from './tool-result-fetch.tsx'
67
+ import { ToolResultImageProvider, useToolResultImages } from './tool-result-image.tsx'
53
68
  import {
54
69
  TranscriptDensityProvider,
55
70
  TranscriptVariantProvider,
@@ -59,6 +74,59 @@ import {
59
74
  } from './transcript-variant.tsx'
60
75
  import { UsageDialog } from './UsageDialog.tsx'
61
76
 
77
+ /**
78
+ * The box the pending prompts sit in.
79
+ *
80
+ * Under the terminal theme they are rows of the same run as the transcript, so
81
+ * they need that theme's cell — and its `--term-bleed`, so an approval's diff
82
+ * bands reach the same edges the transcript's do. Every other variant keeps the
83
+ * centred content column the panel uses everywhere else.
84
+ */
85
+ function PromptSurface({
86
+ terminal,
87
+ metrics,
88
+ affordances,
89
+ children,
90
+ }: {
91
+ terminal: boolean
92
+ metrics?: TerminalMetrics
93
+ affordances?: TerminalAffordances | boolean
94
+ children: ReactNode
95
+ }) {
96
+ if (!terminal) {
97
+ return (
98
+ <div className='mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] flex-col gap-2'>
99
+ {children}
100
+ </div>
101
+ )
102
+ }
103
+ return (
104
+ <TerminalSurface
105
+ fontSize={metrics?.fontSize}
106
+ lineHeight={metrics?.lineHeight}
107
+ affordances={affordances}
108
+ bleed='1ch'
109
+ className='term-transcript'>
110
+ {children}
111
+ </TerminalSurface>
112
+ )
113
+ }
114
+
115
+ /**
116
+ * The character cell the terminal theme draws on, in **whole pixels**.
117
+ *
118
+ * One object rather than two props because the panel mounts three separate
119
+ * `TerminalSurface`s — the transcript, the pending prompts, the composer — and
120
+ * they must agree: a prompt drawn at a different line height from the rows above
121
+ * it is three surfaces on three grids, which is the failure this theme is built
122
+ * to make impossible. Passing one value through one prop is what keeps them from
123
+ * drifting.
124
+ *
125
+ * Absent means the CLI's own 13/18. A host that follows an editor font size
126
+ * (VS Code) hands that down instead.
127
+ */
128
+ export type TerminalMetrics = { fontSize?: number; lineHeight?: number }
129
+
62
130
  export interface SessionPanelProps {
63
131
  client: WorkerDeckClient
64
132
  sessionId: string | undefined
@@ -119,12 +187,63 @@ export interface SessionPanelProps {
119
187
  * internal ref, so an inline closure is fine). */
120
188
  onVitals?: (vitals: SessionVitals) => void
121
189
  /**
122
- * How the transcript draws a turn — `'cards'` (default) or `'lines'`, the
123
- * space-efficient terminal treatment: no boxes, no bubbles, one full-width
124
- * hover-highlit row per event behind a gutter glyph. An embedder in a dock
125
- * (the VS Code panel) wants `'lines'`; a full-width dashboard usually doesn't.
190
+ * How the transcript draws a turn — `'cards'` (default, the chat convention)
191
+ * or `'terminal'`, the CLI's own form: every row on a character cell, no boxes
192
+ * anywhere, diffs as full-width bands. An embedder in a dock (the VS Code
193
+ * panel) wants `'terminal'`; a full-width dashboard may prefer cards.
126
194
  */
127
195
  transcriptVariant?: TranscriptVariant
196
+ /**
197
+ * Terminal theme only: the pointer affordances a real terminal cannot offer —
198
+ * the hover fill, the hover-revealed copy. `false` for none. None of them
199
+ * costs layout, so turning them off changes no glyph's position. See
200
+ * {@link TerminalAffordances}.
201
+ */
202
+ affordances?: TerminalAffordances | boolean
203
+ /**
204
+ * Terminal theme only: the character cell, in whole pixels. See
205
+ * {@link TerminalMetrics} — it reaches all three of the panel's terminal
206
+ * surfaces, which is why it is one prop and not two per surface.
207
+ */
208
+ terminalMetrics?: TerminalMetrics
209
+ /**
210
+ * Terminal theme only: replace the scrollbar with the **overview ruler** — a
211
+ * `2ch` rail of coloured marks in three lanes (what you typed, the answer and
212
+ * its turn end, errors and a waiting approval), which you can hover to peek,
213
+ * click to jump, and drag to scrub.
214
+ *
215
+ * Its premise is the terminal theme's own: one line height and one cell make
216
+ * every row's height derivable, so a mark's position is *computed* rather than
217
+ * guessed from rows that have not mounted. That is why it is not offered under
218
+ * `cards` — there the flag is inert.
219
+ *
220
+ * `false` keeps the native scrollbar. So does `affordances={false}`, which
221
+ * leaves the marks painted but inert rather than removing a reader's only way
222
+ * to scroll.
223
+ */
224
+ scrubber?: boolean
225
+ /**
226
+ * Bookmarked **item indices**, painted full-width on the rail. Paint only —
227
+ * the panel neither stores bookmarks nor offers a way to set one, because who
228
+ * owns that store is the embedder's question (a private pin belongs with the
229
+ * client's watermarks; a shared one is session metadata on the gateway).
230
+ */
231
+ scrubberMarks?: readonly number[]
232
+ /**
233
+ * Scroll a tool call into view; bump `nonce` to ask again for the same one.
234
+ * See {@link TranscriptProps.reveal} — this is the panel's pass-through, and
235
+ * exists so a surface *outside* the panel (a sessions list showing a session's
236
+ * running sub-agents) can say "take me to that one" without opening a second
237
+ * attach to find out where it is.
238
+ */
239
+ reveal?: { toolUseId: string; nonce: number }
240
+ /**
241
+ * Terminal theme only: hold the prompt of the turn you are reading at the top
242
+ * of the transcript, as the Claude Code CLI does. The **real row** is pinned
243
+ * rather than a copy drawn above it, so it lines up with the rows beneath by
244
+ * construction — see `TranscriptRows`.
245
+ */
246
+ stickyPrompt?: boolean
128
247
  /**
129
248
  * How much air the transcript gives each row — `'comfortable'` (default: a
130
249
  * blank line between messages, as the Claude Code CLI leaves) or `'compact'`
@@ -224,6 +343,14 @@ export interface SessionPanelProps {
224
343
  * a wildcard.
225
344
  */
226
345
  toolHost?: UseToolCallHostOptions | false
346
+ /**
347
+ * Keep this session's transcript warm across remounts (default true), so
348
+ * switching back to a recently viewed session paints instantly and replays
349
+ * only what it missed — `UseClaudeSessionOptions.cacheTranscript`. Set
350
+ * `false` for an embedder whose principal varies on one gateway URL by means
351
+ * the client cannot see.
352
+ */
353
+ cacheTranscript?: boolean
227
354
  className?: string
228
355
  }
229
356
 
@@ -320,12 +447,19 @@ export function SessionPanel({
320
447
  transcriptVariant = 'cards',
321
448
  transcriptDensity = 'comfortable',
322
449
  transcriptFont = 'sans',
450
+ affordances,
451
+ terminalMetrics,
452
+ scrubber = false,
453
+ scrubberMarks,
454
+ reveal,
455
+ stickyPrompt = false,
323
456
  controlsSurface = 'internal',
324
457
  onControls,
325
458
  focusComposerOnClick = false,
326
459
  unseen,
327
460
  readOnly = false,
328
461
  toolHost,
462
+ cacheTranscript,
329
463
  className,
330
464
  }: SessionPanelProps) {
331
465
  const external = panelSurface === 'external'
@@ -344,6 +478,7 @@ export function SessionPanel({
344
478
  const {
345
479
  state,
346
480
  connection,
481
+ replaying,
347
482
  protocolMismatch,
348
483
  models,
349
484
  effectiveModel,
@@ -355,7 +490,8 @@ export function SessionPanel({
355
490
  setModel,
356
491
  setPermissionMode,
357
492
  reconnectNow,
358
- } = useClaudeSession(client, sessionId, { onProtocolError: setProtocolError })
493
+ loadFullResult,
494
+ } = useClaudeSession(client, sessionId, { onProtocolError: setProtocolError, cacheTranscript })
359
495
  // Callers are told to remount on a session switch, but a changed prop must not leave
360
496
  // the previous session's failure on screen.
361
497
  useEffect(() => setProtocolError(undefined), [sessionId])
@@ -398,8 +534,39 @@ export function SessionPanel({
398
534
  // client. Free for Claude sessions: the guest loads lazily on the first call,
399
535
  // which for them never comes.
400
536
  useToolCallHost(handle, toolHost === false ? { enabled: false } : toolHost)
537
+ const terminal = transcriptVariant === 'terminal'
401
538
  const capabilities = state.capabilities
402
539
 
540
+ // Plan usage as the *gateway* knows it, merged over this session's own
541
+ // reading — one derivation, feeding the bar, the terminal status line, the
542
+ // Usage panel and the vitals an external chrome renders from, because four
543
+ // surfaces disagreeing about the same percentage is worse than any of them
544
+ // being stale. A session's own `rate_limit` readings land only at a turn's
545
+ // edges, so an idle session's numbers age silently and a sibling session's
546
+ // spend never shows up here at all; `mergeUsage` is where that rule is
547
+ // written down. Skipped entirely for an engine that reports no windows.
548
+ const { usage: profileUsage } = useProfileUsage(client, state.session?.profile, {
549
+ enabled: capabilities.rateLimits,
550
+ })
551
+ const usage = useMemo(
552
+ () =>
553
+ mergeUsage(
554
+ { rateLimits: state.rateLimits, updatedAt: state.rateLimitsUpdatedAt },
555
+ profileUsage,
556
+ ),
557
+ [state.rateLimits, state.rateLimitsUpdatedAt, profileUsage],
558
+ )
559
+ // Undefined rather than an empty map when nothing has been reported: absent is
560
+ // *unknown*, and a surface that can't tell the two apart draws 0%.
561
+ const rateLimits: Record<string, RateLimitInfo> | undefined = useMemo(
562
+ () => (Object.keys(usage).length > 0 ? usageInfos(usage) : undefined),
563
+ [usage],
564
+ )
565
+ const usageUpdatedAt = useMemo(() => {
566
+ const stamps = Object.values(usage).map((w) => w.updatedAt)
567
+ return stamps.length > 0 ? Math.max(...stamps) : undefined
568
+ }, [usage])
569
+
403
570
  // Vitals out to the embedder, keyed on the readings themselves so an inline
404
571
  // closure prop doesn't retrigger it every render.
405
572
  const onVitalsRef = useRef(onVitals)
@@ -423,7 +590,7 @@ export function SessionPanel({
423
590
  permissionModes,
424
591
  cwd: state.cwd,
425
592
  contextUsage: state.contextUsage,
426
- rateLimits: state.rateLimits,
593
+ rateLimits,
427
594
  itemCount: state.items.length,
428
595
  })
429
596
  }, [
@@ -437,7 +604,7 @@ export function SessionPanel({
437
604
  permissionModes,
438
605
  state.cwd,
439
606
  state.contextUsage,
440
- state.rateLimits,
607
+ rateLimits,
441
608
  state.items.length,
442
609
  ])
443
610
 
@@ -468,15 +635,23 @@ export function SessionPanel({
468
635
  // inert for the moment before it does, and stays inert on a gateway that
469
636
  // serves no host files.
470
637
  const hostFiles = useHostFileSearch(client, state.cwd)
471
- const windows = useMemo(() => rateLimitWindows(state), [state])
638
+ // Protocol's ordering, over the merged readings — each row keeping its own
639
+ // date, since they no longer share one clock.
640
+ const windows = useMemo(() => orderUsageWindows(usage), [usage])
472
641
  // Reads a picture the engine left on the host (codex's `image_gen` reports a
473
642
  // path, never bytes). Stable and memoized per path: transcript rows re-render
474
643
  // on every delta, and a fresh function would re-fetch each time.
475
644
  const hostImage = useHostImage(client, sessionId, state.producedFiles)
645
+ // The other picture route, and the other store: an image *part* of a tool
646
+ // result, which an opted-in replay delivered as a reference rather than half a
647
+ // megabyte of base64. Bounded, unlike `useHostImage` — see the module.
648
+ const resultImages = useToolResultImages(client, sessionId)
476
649
  const composerRef = useRef<ComposerHandle>(null)
477
650
  // The catch-up strip's way of scrolling the (virtualized, usually unmounted)
478
651
  // recap row into view — the transcript fills it in. See TranscriptProps.
479
652
  const jumpToRecap = useRef<(() => void) | null>(null)
653
+ // Filled by the transcript; pressed on send. See `handleSend`.
654
+ const repinTranscript = useRef<(() => void) | null>(null)
480
655
 
481
656
  // "/model" is handled panel-side (see handleSend) — surface it in the autocomplete
482
657
  // even though the CLI's command list doesn't include it.
@@ -510,6 +685,13 @@ export function SessionPanel({
510
685
  // Typing into a session is the clearest possible statement that you have
511
686
  // read it — nothing left to catch up on.
512
687
  setCaughtUp(true)
688
+ // ...and sending is the statement that you want to watch what happens next,
689
+ // so following resumes here too. Scrolling up escapes the bottom lock, and
690
+ // without this the reply streams in off screen: the transcript stays parked
691
+ // where you were reading and sending looks like it did nothing. Ordered
692
+ // before `send` only for readability — the re-pin is instant and the first
693
+ // row is a round trip away either way.
694
+ repinTranscript.current?.()
513
695
  send(text, attachmentIds)
514
696
  }
515
697
 
@@ -613,6 +795,7 @@ export function SessionPanel({
613
795
  const statusBar = statusExternal ? null : (
614
796
  <StatusBar
615
797
  state={state}
798
+ rateLimits={rateLimits}
616
799
  connection={connection}
617
800
  placement={statusPlacement}
618
801
  controls={controlsInStatus && !readOnly ? sessionControls : undefined}
@@ -635,11 +818,17 @@ export function SessionPanel({
635
818
  }
636
819
 
637
820
  return (
638
- // The variant is a panel-wide fact, not a transcript-only one: the approval
639
- // and question prompts live outside the scroller but are line items in the
640
- // same run, and they read `useLines()` like every other row.
821
+ // The variant is a panel-wide fact, not a transcript-only one: the composer
822
+ // and the pending prompts live outside the scroller but belong to the same
823
+ // run, and they read it from this context rather than a prop chain.
641
824
  <TranscriptVariantProvider value={transcriptVariant}>
642
825
  <TranscriptDensityProvider value={transcriptDensity}>
826
+ {/* The panel owns the session's one attach, so it is the only thing that
827
+ can answer a row asking for the rest of a truncated tool result. Rows
828
+ rendered anywhere else fall back to the context's no-op, which is
829
+ correct for them: nothing truncates a replay they never asked for. */}
830
+ <ToolResultFetchProvider value={loadFullResult}>
831
+ <ToolResultImageProvider value={resultImages}>
643
832
  <div
644
833
  data-slot='session-panel'
645
834
  // The typeface is a cascade fact, not a React one — one attribute here,
@@ -669,27 +858,35 @@ export function SessionPanel({
669
858
  hostImage={hostImage}
670
859
  variant={transcriptVariant}
671
860
  density={transcriptDensity}
861
+ fontSize={terminalMetrics?.fontSize}
862
+ lineHeight={terminalMetrics?.lineHeight}
863
+ affordances={affordances}
864
+ stickyPrompt={stickyPrompt}
865
+ scrubber={scrubber}
866
+ scrubberMarks={scrubberMarks}
867
+ replaying={replaying}
672
868
  catchUp={
673
869
  catchUp && newCount > 0
674
870
  ? { from: catchUp.itemCount, since: catchUp.since }
675
871
  : undefined
676
872
  }
873
+ reveal={reveal}
677
874
  jumpToRecapRef={jumpToRecap}
875
+ repinRef={repinTranscript}
678
876
  />
679
877
  {/* The way back into what you missed. Above the composer because that is
680
878
  where the eye already is on returning, and because the transcript
681
- itself opens pinned to the newest row. */}
682
- {catchUp && newCount > 0 ? (
879
+ itself opens pinned to the newest row. Held with the transcript
880
+ while the replay lands its count is `state.items.length`, which
881
+ during the replay is a number visibly climbing toward its answer. */}
882
+ {catchUp && newCount > 0 && !replaying ? (
683
883
  <div className='px-3 pb-1'>
684
884
  <div
685
885
  data-slot='catch-up'
686
886
  className='mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] items-center gap-2 text-label text-fg-3'>
687
887
  <span
688
888
  aria-hidden
689
- className={cn(
690
- 'select-none',
691
- transcriptVariant === 'lines' ? 'text-fg-3' : 'text-accent',
692
- )}>
889
+ className={cn('select-none', terminal ? 'text-fg-3' : 'text-accent')}>
693
890
 
694
891
  </span>
695
892
  <span className='min-w-0 flex-1 truncate'>
@@ -718,11 +915,30 @@ export function SessionPanel({
718
915
  `awaiting approval`, and the place that can act on it is wherever the
719
916
  session is actually driven. */}
720
917
  {!readOnly && capabilities.interactiveApprovals && state.pendingApprovals.length > 0 ? (
721
- <div className='px-3 pb-2'>
722
- <div className='mx-auto flex w-full max-w-[var(--wd-content-max-w,48rem)] flex-col gap-2'>
723
- {state.pendingApprovals.map((request) =>
724
- request.toolName === 'AskUserQuestion' &&
725
- parseUserQuestions(request.input).length > 0 ? (
918
+ <div className={cn(terminal ? 'pb-2' : 'px-3 pb-2')}>
919
+ <PromptSurface terminal={terminal} metrics={terminalMetrics} affordances={affordances}>
920
+ {state.pendingApprovals.map((request) => {
921
+ const isQuestion =
922
+ request.toolName === 'AskUserQuestion' &&
923
+ parseUserQuestions(request.input).length > 0
924
+ if (terminal) {
925
+ return isQuestion ? (
926
+ <TerminalQuestionPrompt
927
+ key={request.id}
928
+ request={request}
929
+ onAnswer={approve}
930
+ onDismiss={(id) => deny(id, 'Question dismissed by user')}
931
+ />
932
+ ) : (
933
+ <TerminalPermissionPrompt
934
+ key={request.id}
935
+ request={request}
936
+ onApprove={approve}
937
+ onDeny={deny}
938
+ />
939
+ )
940
+ }
941
+ return isQuestion ? (
726
942
  <QuestionPrompt
727
943
  key={request.id}
728
944
  request={request}
@@ -736,9 +952,9 @@ export function SessionPanel({
736
952
  onApprove={approve}
737
953
  onDeny={deny}
738
954
  />
739
- ),
740
- )}
741
- </div>
955
+ )
956
+ })}
957
+ </PromptSurface>
742
958
  </div>
743
959
  ) : null}
744
960
  {readOnly ? null : (
@@ -758,6 +974,9 @@ export function SessionPanel({
758
974
  }
759
975
  layout={controlsExternal ? 'inline' : 'stacked'}
760
976
  toolbar={controlsExternal ? undefined : sessionControls}
977
+ fontSize={terminalMetrics?.fontSize}
978
+ lineHeight={terminalMetrics?.lineHeight}
979
+ affordances={affordances}
761
980
  />
762
981
  )}
763
982
  {/* Below the composer, along the foot of the panel — the editor
@@ -785,7 +1004,7 @@ export function SessionPanel({
785
1004
  subscriptionType={state.subscriptionType}
786
1005
  engine={state.engine ?? 'claude'}
787
1006
  totalCostUsd={state.totalCostUsd}
788
- updatedAt={state.rateLimitsUpdatedAt}
1007
+ updatedAt={usageUpdatedAt}
789
1008
  open={panel === 'usage'}
790
1009
  onOpenChange={(next) => setPanel(next ? 'usage' : undefined)}
791
1010
  />
@@ -813,6 +1032,8 @@ export function SessionPanel({
813
1032
  </>
814
1033
  ) : null}
815
1034
  </div>
1035
+ </ToolResultImageProvider>
1036
+ </ToolResultFetchProvider>
816
1037
  </TranscriptDensityProvider>
817
1038
  </TranscriptVariantProvider>
818
1039
  )
@@ -17,6 +17,7 @@ import { EditorTabs } from './EditorTabs.tsx'
17
17
  import { FileTree } from './FileTree.tsx'
18
18
  import { FileViewer } from './FileViewer.tsx'
19
19
  import { SessionPanel, type SessionPanelProps } from './SessionPanel.tsx'
20
+ import { resolveAgainstCwd, usePathLinks } from './use-path-links.ts'
20
21
 
21
22
  export interface SessionWorkspaceProps {
22
23
  client: WorkerDeckClient
@@ -35,6 +36,11 @@ export interface SessionWorkspaceProps {
35
36
  transcriptVariant?: SessionPanelProps['transcriptVariant']
36
37
  transcriptDensity?: SessionPanelProps['transcriptDensity']
37
38
  transcriptFont?: SessionPanelProps['transcriptFont']
39
+ /** The overview ruler in place of the scrollbar — see `SessionPanel`. */
40
+ scrubber?: SessionPanelProps['scrubber']
41
+ scrubberMarks?: SessionPanelProps['scrubberMarks']
42
+ /** The last prompt pinned above the transcript — see `SessionPanel`. */
43
+ stickyPrompt?: SessionPanelProps['stickyPrompt']
38
44
  /** Which end of the panel the status bar sits at — see `SessionPanel`. */
39
45
  statusPlacement?: SessionPanelProps['statusPlacement']
40
46
  controlsSurface?: SessionPanelProps['controlsSurface']
@@ -94,6 +100,9 @@ export function SessionWorkspace({
94
100
  transcriptVariant,
95
101
  transcriptDensity,
96
102
  transcriptFont,
103
+ scrubber,
104
+ scrubberMarks,
105
+ stickyPrompt,
97
106
  statusPlacement,
98
107
  controlsSurface,
99
108
  unseen,
@@ -118,6 +127,7 @@ export function SessionWorkspace({
118
127
  // editor asks before it offers to save anything.
119
128
  const { canWrite } = useHostFileRoots(client)
120
129
 
130
+
121
131
  // Nothing here can save on the user's behalf when the tab is going away, so
122
132
  // the browser's own guard is the last line. Registered only while there is
123
133
  // something to lose — an unconditional handler makes every navigation prompt.
@@ -172,6 +182,22 @@ export function SessionWorkspace({
172
182
 
173
183
  const column = useRef<HTMLDivElement>(null)
174
184
  const columnHeight = useElementHeight(column)
185
+ // Cmd/Ctrl+click a file the agent named and it opens in the editor above —
186
+ // the workspace is the only surface that *has* an editor, which is why this
187
+ // lives here and not in the panel. Gated on the tree being available: without
188
+ // a host filesystem there is nothing to open, and a link that cannot resolve
189
+ // is worse than plain text. Monaco is excluded because Cmd+click already
190
+ // means go-to-definition in there, and every identifier would match.
191
+ const openPath = useCallback(
192
+ ({ path }: { path: string }) => files.open(resolveAgainstCwd(path, cwd)),
193
+ [files.open, cwd],
194
+ )
195
+ usePathLinks({
196
+ container: column,
197
+ onOpen: openPath,
198
+ enabled: tree.available,
199
+ ignore: '.monaco-editor',
200
+ })
175
201
  const editorMax = Math.max(EDITOR_MIN, columnHeight - AGENT_MIN)
176
202
 
177
203
  // The embedder's header is app chrome and belongs above everything — but only
@@ -278,6 +304,9 @@ export function SessionWorkspace({
278
304
  transcriptVariant={transcriptVariant}
279
305
  transcriptDensity={transcriptDensity}
280
306
  transcriptFont={transcriptFont}
307
+ scrubber={scrubber}
308
+ scrubberMarks={scrubberMarks}
309
+ stickyPrompt={stickyPrompt}
281
310
  controlsSurface={controlsSurface}
282
311
  statusPlacement={statusPlacement}
283
312
  unseen={unseen}
@@ -9,9 +9,19 @@ import { Tip } from '../ui/Tooltip.tsx'
9
9
  import { cn } from '../../lib/utils.ts'
10
10
  import { formatCost, formatCountdown, formatTokens } from '../../lib/format.ts'
11
11
  import { STATUS_META } from './status.ts'
12
+ import { useTranscriptVariant } from './transcript-variant.tsx'
12
13
 
13
14
  export interface StatusBarProps {
14
15
  state: TranscriptState
16
+ /**
17
+ * Plan windows to draw, when they should not be the session's own. The panel
18
+ * hands over the gateway's per-profile state merged over this transcript's
19
+ * reading (`mergeUsage`): a session's own `rate_limit` readings arrive only at
20
+ * a turn's edges, so one idle since yesterday would otherwise render
21
+ * yesterday's number as current. Absent = `state.rateLimits`, which is what a
22
+ * bar composed by hand outside the panel gets.
23
+ */
24
+ rateLimits?: Record<string, RateLimitInfo>
15
25
  /** @deprecated Pass {@link StatusBarProps.connection}; kept so an embedder
16
26
  * still handing over a boolean keeps working. */
17
27
  connected?: boolean
@@ -167,6 +177,7 @@ function Slot({ onClick, hint, children }: { onClick?: () => void; hint: string;
167
177
 
168
178
  export function StatusBar({
169
179
  state,
180
+ rateLimits,
170
181
  connected,
171
182
  connection,
172
183
  onOpenStatus,
@@ -179,9 +190,11 @@ export function StatusBar({
179
190
  }: StatusBarProps) {
180
191
  const meta = STATUS_META[state.status]
181
192
  const now = useNow()
182
- const session = state.rateLimits?.five_hour
183
- const weekly = state.rateLimits?.seven_day
193
+ const windows = rateLimits ?? state.rateLimits
194
+ const session = windows?.five_hour
195
+ const weekly = windows?.seven_day
184
196
  const link: ConnectionState = connection ?? (connected === false ? 'reconnecting' : 'live')
197
+ const terminal = useTranscriptVariant() === 'terminal'
185
198
  return (
186
199
  <div
187
200
  data-slot='status-bar'
@@ -198,8 +211,11 @@ export function StatusBar({
198
211
  // one piece of chrome, and a pixel of drift between them shows.
199
212
  'flex h-[38px] items-baseline gap-2 border-border bg-surface p-1.5',
200
213
  // The rule goes between the bar and the content, so which edge it sits
201
- // on follows the placement.
202
- placement === 'bottom' ? 'border-t' : 'border-b',
214
+ // on follows the placement — except under the terminal theme at the
215
+ // foot, where the composer directly above already closes itself with a
216
+ // rule of its own. Two adjacent 1px rules is a 2px rule with a seam in
217
+ // it, and it is off the line grid besides.
218
+ placement === 'bottom' ? (terminal ? undefined : 'border-t') : 'border-b',
203
219
  className,
204
220
  )}>
205
221
  {/* One slot, two meanings: connection trouble wins it, because a session