@theoremjs/react 0.3.5-next.1038.gc9db908 → 0.3.5-next.1041.gcd563a8

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 CHANGED
@@ -179,16 +179,16 @@ To draw your own figures like the trace panel does, `@theoremjs/react/ui` also e
179
179
  | `composer` | `false` leaves the composer out. The chat is the transcript alone, and your own control sends through `chatRef`. Default: `true`. |
180
180
  | `composerLayout` | `'stacked'` or `'row'`. In `'row'`, the field, the mic and send share one line, and text that wraps moves the field onto its own line. Above them, a pill shows the reply in progress, with its stop button, and a pill shows each background call. While a reply runs or a step waits, Enter queues a draft and send opens the send menu. Default: `'stacked'`. |
181
181
  | `composerEmptyAction` | Shows in place of the send button while the composer has nothing to send, for example a button that starts a call. It never replaces stop or the send menu. `TheoremChatComposer` and `ChatComposerBar` take it as `emptyAction`. Default: the send button. |
182
- | `renderComposerStatus` | Draws the composer's problem: a send that failed (`type: 'error'`), or files or a voice note it could not take (`type: 'warning'`), with its `message`. Give what you draw its own `role`: `alert` for an error, `status` for a warning. `TheoremChatComposer` and `ChatComposerBar` take it as `renderStatus`. Default: Astryx's status, in the status colour. |
182
+ | `renderComposerStatus` | Draws the composer's problem: a send that failed (`type: 'error'`), or files or a voice note it could not take (`type: 'warning'`), with its `message`. Give what you draw its own `role`: `alert` for an error, `status` for a warning. `TheoremChatComposer` and `ChatComposerBar` take it as `renderStatus`. Default: in `'row'`, Theorem's card over the surface (see [The row composer's look](#the-row-composers-look)); in `'stacked'`, Astryx's status, in the status colour. |
183
183
  | `composerIcons` | The glyphs the `'row'` composer draws: `working`, before the working pill's text; `backgroundJob`, before each background call's name; `stop`, in the working pill's stop button. Each one you leave out keeps Theorem's. See [The row composer's look](#the-row-composers-look). |
184
184
  | `media` | Which media from tools the chat shows. `'sent'` shows only what a tool sent to the person. `'all'` also shows what only the model read, for an evaluation view. Default: `'sent'`. See [Tool media](#tool-media). |
185
185
  | `resolveMedia` | Turns a tool's reference into an address the page can load. See [Tool media](#tool-media). |
186
186
  | `mediaViewer` | The viewer every picture and video opens in. Default: Astryx's Lightbox, with zoom. See [Your own media viewer](#your-own-media-viewer). |
187
- | `transcript` | The options of `TheoremChatTranscript` that the chat does not set itself, given to its transcript as they are: `slots`, `dividers`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, and `showResumedNotice`. Its type is `TheoremChatTranscriptOptions`. See [Draw under a reply](#draw-under-a-reply). |
187
+ | `transcript` | The options of `TheoremChatTranscript` that the chat does not set itself, given to its transcript as they are: `slots`, `turnKeyOf`, `dividers`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, and `showResumedNotice`. Its type is `TheoremChatTranscriptOptions`. See [Draw under a reply](#draw-under-a-reply) and [Draw beside a message's time](#draw-beside-a-messages-time). |
188
188
 
189
189
  ### The row composer's look
190
190
 
191
- The `'row'` composer has three parts: the pill row, the tray of what waits to send, and the surface with the field. The working pill reads "Working for 12s". It counts from the time the reply started and leaves out the time a step waited for approval, the same as the transcript's status line.
191
+ The `'row'` composer has four parts: the pill row, the tray of what waits to send, the composer's problem, and the surface with the field. A problem, such as a refused microphone or a file that cannot be sent, sits on a card above the surface, the same as the tray. The field does not move. The glyph and the words tell a warning from an error; the card has no warning or error colour. `renderComposerStatus` draws your own in its place. The working pill reads "Working for 12s". It counts from the time the reply started and leaves out the time a step waited for approval, the same as the transcript's status line.
192
192
 
193
193
  Each part of the look is a CSS custom property. Set it on any element above the composer, in your stylesheet or in `style`, or in your Astryx theme's `localTokens`. A property you do not set keeps Theorem's value.
194
194
 
@@ -198,11 +198,15 @@ Each part of the look is a CSS custom property. Set it on any element above the
198
198
  | `--theorem-composer-fill` | The fill of the surface and the tray. | `var(--color-background-popover)` |
199
199
  | `--theorem-composer-shadow` | The shadow of the surface and the tray. | `var(--shadow-low)` |
200
200
  | `--theorem-composer-padding` | The space inside the surface. | `var(--spacing-3)` |
201
- | `--theorem-composer-gap` | The space between the pill row, the tray and the surface. | `var(--spacing-2)` |
202
- | `--theorem-composer-inset` | How far the pill row and the tray sit in from the surface's sides. | `0px` |
201
+ | `--theorem-composer-tray-content-gap` | The space between the open tray's header and its content. | `var(--spacing-3)` |
202
+ | `--theorem-composer-gap` | The space between the pill row, the tray, the problem and the surface. | `var(--spacing-2)` |
203
+ | `--theorem-composer-inset` | How far the pill row, the tray and the problem sit in from the surface's sides. | `0px` |
203
204
  | `--theorem-composer-tray-radius` | The open tray's corner radius. | the surface's radius |
204
205
  | `--theorem-composer-tray-folded-radius` | The folded tray's corner radius. | half the folded tray's height, so its ends are round |
205
206
  | `--theorem-composer-tray-padding` | The space inside the tray. | `var(--spacing-3)` |
207
+ | `--theorem-composer-status-fill` | The fill of the problem's card. Set it to give problems a colour of their own. | the surface's fill |
208
+ | `--theorem-composer-status-radius` | The problem card's corner radius. | the open tray's radius |
209
+ | `--theorem-composer-status-padding` | The space inside the problem's card. | the tray's padding |
206
210
  | `--theorem-composer-pill-height` | The height of each pill. | `var(--size-element-lg)` |
207
211
  | `--theorem-composer-pill-radius` | The corner radius of each pill and of the stop button. | `var(--radius-full)` |
208
212
  | `--theorem-composer-pill-fill` | The fill of each pill. | the surface's fill |
@@ -501,7 +505,7 @@ This code opens `wss://<your host>/api/live/relay?profile=<id>`. To send your ow
501
505
 
502
506
  To get the messages your relay sends with `liveHostEnvelope`, give `useLiveCall` an `onHostMessage`. See [Send the page your own messages](https://github.com/masudl-hub/theoremai/blob/main/web/README.md#send-the-page-your-own-messages).
503
507
 
504
- `startCall`, and the start buttons of `LiveRunner`, open the call's audio inside the press, before `connection` is called. When your own press waits before it calls `startCall`, call `call.prepareAudio()` first in that press: the call then uses that audio and does not open another. See [Open the audio in the press](https://github.com/masudl-hub/theoremai/blob/main/web/README.md#open-the-audio-in-the-press).
508
+ `startCall`, and the start buttons of `LiveRunner`, open the call's audio inside the press, before `connection` is called. When your own press waits before it calls `startCall`, call `call.prepareAudio()` first in that press: the call then uses that audio and does not open another. When the press comes before the call exists, for example while the page still loads, call `prepareLiveAudio()` from `@theoremjs/react/live` in the press, and give what it returns to `startCall({ video, audio })` when the call starts. The call plays through that output, opens no other, keeps it across reconnects, and closes it once when the call ends, also when it ends before it connects. See [Open the audio in the press](https://github.com/masudl-hub/theoremai/blob/main/web/README.md#open-the-audio-in-the-press).
505
509
 
506
510
  To know when a call ends, and why, give `useLiveCall` an `onCallEnded`. It is called once for each call the person starts, with a `LiveCallEnd`: `cancelled` when the person ends the call before it connects, `user` after it connects, `agent` when the other side closes it, and `failed` with the error. A call whose component unmounts ends as `user`, or `cancelled` before it connects. See [Know when the call ended](https://github.com/masudl-hub/theoremai/blob/main/web/README.md#know-when-the-call-ended).
507
511
 
@@ -740,7 +744,7 @@ function Dock({ chat, iface }) {
740
744
  }
741
745
  ```
742
746
 
743
- `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, `renderRef`, `emptyAction`, and `renderStatus`. Pass it the `refText` you gave `useTheoremChat`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, `showResumedNotice`, `renderRef`, and `slots`. Its `handle` is the handle of the profile when you leave it out. Put both pieces inside one `TheoremSurface`. It takes what `TheoremChat` takes for the look and the media: `theme`, `mode`, `labels`, `detectCodeLanguage`, `media`, `resolveMedia`, and `mediaViewer`.
747
+ `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, `renderRef`, `emptyAction`, and `renderStatus`. Pass it the `refText` you gave `useTheoremChat`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, `showToolDurations`, `showWorkStatus`, `showResumedNotice`, `renderRef`, `turnKeyOf`, and `slots`. Its `handle` is the handle of the profile when you leave it out. Put both pieces inside one `TheoremSurface`. It takes what `TheoremChat` takes for the look and the media: `theme`, `mode`, `labels`, `detectCodeLanguage`, `media`, `resolveMedia`, and `mediaViewer`.
744
748
 
745
749
  Use `pills` to show your own notice in the pill row of the `row` layout, for example "New from your agent" while the chat is closed. Each pill is `{ id, label, icon?, onSelect? }`. It comes after the working pill and the background calls, and looks like them. The icon goes before the words. A click calls `onSelect`. A pill without `onSelect` only shows.
746
750
 
@@ -823,8 +827,72 @@ These rules apply:
823
827
  - A profile that keeps no conversation (`'stateless'`) saves no reply, so `host` is always empty. Draw from `blocks` there.
824
828
  - With `tools.showData: false`, each tool call in `blocks` has `null` output and `{}` arguments, as the transcript shows it. The `host` values are unchanged.
825
829
 
830
+ ### Draw beside a message's time
831
+
832
+ Each message has a details row: its time and copy button. `slots.details` adds your own part right after the time, on the user's messages and on replies. It receives a `ChatMessageDetails`:
833
+
834
+ | Field | Meaning |
835
+ | --- | --- |
836
+ | `sender` | `'user'` or `'assistant'`. |
837
+ | `blocks` | The message's blocks, as the transcript draws them. |
838
+ | `host` | The `host` value of each of the message's blocks that has one, in order, its `turn-done` blocks too. |
839
+
840
+ Neighbouring blocks from one side share one message. To keep them apart by your own values, pass `turnKeyOf`: it takes a block's `host` value and returns a key.
841
+
842
+ ```tsx
843
+ type Said = { desk: string };
844
+
845
+ <ChatTranscript<Said>
846
+ blocks={blocks}
847
+ handle="Harbor"
848
+ turnKeyOf={(host) => host.desk}
849
+ slots={{ details: ({ host }) => (host[0] ? <Token label={host[0].desk} /> : null) }}
850
+ />;
851
+ ```
852
+
853
+ These rules apply:
854
+
855
+ - Neighbouring blocks share a message only when their keys are equal. A block with no `host` has no key, and shares a message only with a block that has none.
856
+ - A message gets its `host` values once it is saved. Until then, `host` is empty.
857
+ - A reply on its way has no details row yet.
858
+ - Without `slots.details`, the row is unchanged. Without `turnKeyOf`, messages join as before.
859
+
826
860
  `ActionCard` is the frame of the gate cards: their width, a title with an `icon` before it and a `tag` at its end, the body (`children`), and a row of buttons (`actions`) at the end. `ApprovalCard` and `AuthChallengeCard` are built on it. Build your own cards on it so that they look like the gate cards.
827
861
 
862
+ ## Panes, motion and trace charts
863
+
864
+ Set `--theorem-pane-background` on a containing element to change the fill of raised panes within it. The default is `--color-background-card`.
865
+
866
+ Set `--theorem-pane-edge` on a containing element to change the gap its raised panes keep from the page's end and bottom edges, for example `0px` where the page around them is already inset. The default is 12px at the end and 12px or 16px at the bottom.
867
+
868
+ Set `--theorem-pane-divider` to change the line between a wide pane's overview and its detail. The default is `1px solid var(--color-border)`. Set `none` to draw no line.
869
+
870
+ ### The transcript's motion
871
+
872
+ | Property | What it sets | Default |
873
+ | --- | --- | --- |
874
+ | `--theorem-chrome-transition` | How a message's time and copy button fade in. | `opacity 160ms ease` |
875
+ | `--theorem-generating-easing` | The easing of the pulse while an image is made. | `ease-in-out` |
876
+
877
+ ### The trace charts' look
878
+
879
+ Set a property on any element above the trace. A property you do not set keeps Theorem's value.
880
+
881
+ | Property | What it sets | Default |
882
+ | --- | --- | --- |
883
+ | `--theorem-trace-clear` | The first series, and the figure beside a chart's headline. | `light-dark(#0d1e37, #b4c6e2)` |
884
+ | `--theorem-trace-shade-1` | A later series. | `light-dark(#3b5580, #6582ad)` |
885
+ | `--theorem-trace-shade-2` | A later series. | `light-dark(#7f95b7, #3b5078)` |
886
+ | `--theorem-trace-shade-3` | A later series. | `light-dark(#bcc8da, #22345a)` |
887
+ | `--theorem-trace-failed` | Whatever failed. | `light-dark(#8e2a28, #cd5f55)` |
888
+ | `--theorem-trace-hatch-base` | The ground of the hatched series. | `light-dark(#e4e7ec, #2b2f36)` |
889
+ | `--theorem-trace-hatch-stripe` | The stripes of the hatched series. | `light-dark(#9aa3b1, #6b727d)` |
890
+ | `--theorem-trace-tick-size` | The size of axis and row labels. A long row name in the timeline is cut to fit 11px text. | `11px` |
891
+ | `--theorem-trace-tip-padding` | The space inside a chart's hover card. | `6px 8px` |
892
+ | `--theorem-trace-tip-border` | The line around a chart's hover card. | `1px solid var(--color-border)` |
893
+ | `--theorem-trace-nest-indent` | How far a nested step sits in. | `20px` |
894
+ | `--theorem-trace-step-transition` | How a step in the story fades. | `opacity 120ms ease` |
895
+
828
896
  ## Wording
829
897
 
830
898
  Each line of text in the ready-made UI is an Astryx i18n message. Theorem messages use `@theorem.*` keys. `THEOREM_UI_CATALOG` lists them, with a description and the values that each one takes. Astryx messages use `@astryx.*` keys.
@@ -879,7 +947,3 @@ labels={{
879
947
  - [`@theoremjs/agents`](https://www.npmjs.com/package/@theoremjs/agents): profiles, tools, guardrails, and providers.
880
948
 
881
949
  License: MIT.
882
-
883
- Set `--theorem-pane-background` on a containing element to change the fill of raised panes within it. The default is `--color-background-card`.
884
-
885
- Set `--theorem-pane-edge` on a containing element to change the gap its raised panes keep from the page's end and bottom edges, for example `0px` where the page around them is already inset. The default is 12px at the end and 12px or 16px at the bottom.
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { TurnStop } from '@theoremjs/agents';
7
7
  import { type TranscriptBlock } from '@theoremjs/agents/interface';
8
+ import type { JsonObject } from '@theoremjs/agents/kernel';
8
9
  /** What a reply or a called agent used: its tokens, and its cost when the provider gave one. */
9
10
  export type TurnUsage = {
10
11
  total: number;
@@ -19,6 +20,8 @@ export type TranscriptTurnGroup = {
19
20
  blocks: TranscriptBlock[];
20
21
  /** How its turn stopped short before any reply. A message with a stop is closed. */
21
22
  stop?: TurnStop;
23
+ /** The `host` values of the message's blocks that have one, in order. */
24
+ host?: NonNullable<TranscriptBlock['host']>[];
22
25
  } | {
23
26
  kind: 'assistant';
24
27
  key: string;
@@ -81,12 +84,15 @@ export type ComposeAssistantTurnOptions = {
81
84
  /** Where the reply's steps sit. Default: `trace`. */
82
85
  stepLayout?: StepLayout;
83
86
  };
87
+ /** The app's key for the turn a block's `host` value belongs to. */
88
+ export type TurnKeyOf = (host: JsonObject) => string;
84
89
  /**
85
90
  * Blocks as turns: neighbours from the same side share one, unless a block is
86
- * in `breaks`, which always starts its own. A message whose turn stopped short
87
- * is closed: the next message starts its own turn.
91
+ * in `breaks`, which always starts its own, or `keyOf` gives them different
92
+ * keys. A message whose turn stopped short is closed: the next message starts
93
+ * its own turn.
88
94
  */
89
- export declare function groupTranscriptBlocks(blocks: readonly TranscriptBlock[], breaks?: ReadonlySet<string>): TranscriptTurnGroup[];
95
+ export declare function groupTranscriptBlocks(blocks: readonly TranscriptBlock[], breaks?: ReadonlySet<string>, keyOf?: TurnKeyOf): TranscriptTurnGroup[];
90
96
  /** A reply's text to copy; a failure is the message's status, not part of the reply. */
91
97
  export declare function assistantTurnCopyText(blocks: readonly TranscriptBlock[]): string;
92
98
  /** A turn's work, for the status line: running, or done (with its duration when known). */
@@ -74,11 +74,20 @@ function joinsTurn(last, isUser) {
74
74
  return false;
75
75
  return !(last.kind === 'user' && last.stop);
76
76
  }
77
+ /**
78
+ * Whether the app lets two neighbouring blocks share a turn: their keys are equal. A block with no
79
+ * `host` value has no key, and shares a turn only with another that has none.
80
+ */
81
+ function sameTurnKey(a, b, keyOf) {
82
+ return (a.host ? keyOf(a.host) : undefined) === (b.host ? keyOf(b.host) : undefined);
83
+ }
77
84
  /** `block` on the turn before it when it joins that turn, else as a turn of its own. */
78
- function placeBlock(groups, block, breaks) {
85
+ function placeBlock(groups, block, breaks, keyOf) {
79
86
  const isUser = isUserTranscriptBlock(block);
80
87
  const last = groups.at(-1);
81
- if (last && joinsTurn(last, isUser) && !breaks?.has(block.id)) {
88
+ const before = last?.blocks.at(-1);
89
+ const apart = keyOf && before && !sameTurnKey(before, block, keyOf);
90
+ if (last && joinsTurn(last, isUser) && !breaks?.has(block.id) && !apart) {
82
91
  last.blocks.push(block);
83
92
  return;
84
93
  }
@@ -86,18 +95,19 @@ function placeBlock(groups, block, breaks) {
86
95
  }
87
96
  /**
88
97
  * Blocks as turns: neighbours from the same side share one, unless a block is
89
- * in `breaks`, which always starts its own. A message whose turn stopped short
90
- * is closed: the next message starts its own turn.
98
+ * in `breaks`, which always starts its own, or `keyOf` gives them different
99
+ * keys. A message whose turn stopped short is closed: the next message starts
100
+ * its own turn.
91
101
  */
92
- export function groupTranscriptBlocks(blocks, breaks) {
102
+ export function groupTranscriptBlocks(blocks, breaks, keyOf) {
93
103
  const groups = [];
94
104
  for (const block of blocks) {
95
105
  if (block.kind === 'turn-done')
96
106
  closeTurn(groups.at(-1), block);
97
107
  if (!isHiddenTranscriptBlock(block))
98
- placeBlock(groups, block, breaks);
108
+ placeBlock(groups, block, breaks, keyOf);
99
109
  const group = groups.at(-1);
100
- if (block.host && group?.kind === 'assistant')
110
+ if (block.host && group)
101
111
  group.host = [...(group.host ?? []), block.host];
102
112
  }
103
113
  return groups;
@@ -2,6 +2,17 @@ import type { LiveProfileInterface } from '@theoremjs/agents/interface';
2
2
  import type { LiveCallOptions, LiveConnection } from '@theoremjs/web/client';
3
3
  import { type LiveCaptionState, type LiveCaptionTurn } from '../../client/live/live-captions.js';
4
4
  import { type LiveVideoFrame, type LiveVideoOptions } from '../../client/live/live-video.js';
5
+ /** How `startCall` starts a call. */
6
+ export interface LiveStartOptions {
7
+ /** Turn the camera on once the call connects, when the profile takes video. */
8
+ video: boolean;
9
+ /**
10
+ * The audio output the host opened with `prepareLiveAudio` in the person's press, such as one
11
+ * made before this call existed. The call plays through it, opens no other, keeps it across
12
+ * reconnects, and closes it once when the call ends. Default: the call opens its own.
13
+ */
14
+ audio?: AudioContext;
15
+ }
5
16
  /** What `useLiveCall` takes: the profile, what the call opens, and the host's part in the call. */
6
17
  export type LiveCallInput = {
7
18
  iface: LiveProfileInterface;
@@ -61,9 +72,7 @@ export declare function useLiveCall({ iface, connection, video, ...options }: Li
61
72
  setTextDraft: import("react").Dispatch<import("react").SetStateAction<string>>;
62
73
  handleEnd: () => void;
63
74
  prepareAudio: () => void;
64
- startCall: (options: {
65
- video: boolean;
66
- }) => void;
75
+ startCall: (options: LiveStartOptions) => void;
67
76
  handleRestart: () => Promise<void>;
68
77
  handleSendText: (text?: string) => void;
69
78
  handleToggleMic: () => void;
@@ -22,7 +22,7 @@ function useLiveCallLifecycle(controls, captionsRef, sessionActive, videoAvailab
22
22
  videoOnConnectRef.current = options.video && videoAvailable;
23
23
  setCallStarted(true);
24
24
  setEnded(false);
25
- void controls.startSession();
25
+ void controls.startSession(options.audio);
26
26
  }, [controls, videoAvailable]);
27
27
  useEffect(() => {
28
28
  if (sessionActive)
@@ -42,7 +42,7 @@ export declare function useLiveRunnerControls(args: {
42
42
  }): {
43
43
  prepareAudio: () => void;
44
44
  teardownSession: () => void;
45
- startSession: () => Promise<void>;
45
+ startSession: (given?: AudioContext) => Promise<void>;
46
46
  handleSendText: (text?: string) => void;
47
47
  handleToggleVideo: () => Promise<void>;
48
48
  handleFlipCamera: () => Promise<void>;
@@ -40,10 +40,14 @@ export function useLiveRunnerControls(args) {
40
40
  args.setInputLevel(0);
41
41
  args.setOutputLevel(0);
42
42
  }, [args]);
43
- const startSession = useCallback(async () => {
43
+ /** `given` is an audio output the host opened in the press, before the call existed. */
44
+ const startSession = useCallback(async (given) => {
44
45
  // invariant: The audio opens before the first await, inside the press that started the call.
45
- const held = preparedAudioRef.current;
46
+ const prepared = preparedAudioRef.current;
46
47
  preparedAudioRef.current = null;
48
+ if (given && prepared !== given)
49
+ releaseAudio(prepared);
50
+ const held = given ?? prepared;
47
51
  args.clearFailure();
48
52
  args.resetCaptions();
49
53
  const failStart = (err) => {
package/live.d.ts CHANGED
@@ -4,9 +4,10 @@
4
4
  * @module
5
5
  */
6
6
  export type { LiveAudioOptions, LiveCallEnd, LiveCallOptions, LiveClientTuning, LiveConnection, PageTool, PageToolAnswer, PageTools, } from '@theoremjs/web/client';
7
+ export { prepareLiveAudio } from '@theoremjs/web/client';
7
8
  export type { LiveFacingMode, LiveVideoFrame, LiveVideoOptions, } from './client/live/live-video.js';
8
9
  export { type LiveVideoFit, type LiveVideoOverlay, type LiveVideoView, liveFramePointInPreview, } from './client/live/live-video-view.js';
9
- export { type LiveCall, type LiveCallInput, useLiveCall, } from './components/live/use-live-call.js';
10
+ export { type LiveCall, type LiveCallInput, type LiveStartOptions, useLiveCall, } from './components/live/use-live-call.js';
10
11
  export { LiveCallTile, type LiveCallTileProps, type LiveCallTileSlots, } from './ui/LiveCallTile.js';
11
12
  export type { LiveRunnerProps, LiveRunnerSlots } from './ui/LiveRunner.js';
12
13
  export { LiveRunner } from './ui/LiveRunner.js';
package/live.js CHANGED
@@ -7,6 +7,7 @@
7
7
  import '@astryxdesign/core/reset.css';
8
8
  import '@astryxdesign/core/astryx.css';
9
9
  import './ui/built/theme.css';
10
+ export { prepareLiveAudio } from '@theoremjs/web/client';
10
11
  export { liveFramePointInPreview, } from "./client/live/live-video-view.js";
11
12
  export { useLiveCall, } from "./components/live/use-live-call.js";
12
13
  export { LiveCallTile, } from "./ui/LiveCallTile.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1038.gc9db908",
3
+ "version": "0.3.5-next.1041.gcd563a8",
4
4
  "description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -60,8 +60,8 @@
60
60
  "@stylexjs/stylex": "0.19.0",
61
61
  "react": "^19.0.0",
62
62
  "react-dom": "^19.0.0",
63
- "@theoremjs/agents": "^0.3.5-next.1038.gc9db908",
64
- "@theoremjs/web": "^0.3.5-next.1038.gc9db908"
63
+ "@theoremjs/agents": "^0.3.5-next.1041.gcd563a8",
64
+ "@theoremjs/web": "^0.3.5-next.1041.gcd563a8"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -96,7 +96,7 @@ export type ChatComposerBarProps = {
96
96
  /**
97
97
  * Draws the composer's problem: a send that failed (`error`), or files and a voice note it
98
98
  * could not take (`warning`). Give the node its own `role`: `alert` for an error, `status` for
99
- * a warning. Omit to keep Astryx's.
99
+ * a warning. Omit to keep Theorem's: in `row`, a card over the surface; in `stacked`, Astryx's.
100
100
  */
101
101
  renderStatus?: (status: ChatComposerStatus) => ReactNode;
102
102
  };
@@ -57,13 +57,13 @@ export type ComposerRowParts = {
57
57
  /** The send button, or the send menu while a reply runs. */
58
58
  action: ReactNode;
59
59
  status?: ChatComposerStatus;
60
- /** Draws the status in place of Astryx's Banner. */
60
+ /** Draws the status in place of Theorem's card. */
61
61
  renderStatus?: (status: ChatComposerStatus) => ReactNode;
62
62
  };
63
63
  /**
64
64
  * Theorem's one-row composer: the field, then the controls, the mic, and send, on one line.
65
65
  * Text that wraps moves the field onto its own line above them, the stacked layout. Above
66
66
  * it, the pill row: the reply in progress (stop is on its pill), the background jobs, and the
67
- * app's own pills.
67
+ * app's own pills; then the tray, then the composer's problem.
68
68
  */
69
69
  export declare function ChatComposerRow(props: ComposerRowParts): import("react").JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Badge } from '@astryxdesign/core/Badge';
3
- import { Banner } from '@astryxdesign/core/Banner';
4
3
  import { Card } from '@astryxdesign/core/Card';
5
4
  import { useCollapsible } from '@astryxdesign/core/Collapsible';
6
5
  import { HStack } from '@astryxdesign/core/HStack';
6
+ import { Icon } from '@astryxdesign/core/Icon';
7
7
  import { IconButton } from '@astryxdesign/core/IconButton';
8
8
  import { Spinner } from '@astryxdesign/core/Spinner';
9
9
  import { StackItem } from '@astryxdesign/core/Stack';
@@ -30,6 +30,9 @@ const GAP = knob('gap', 'var(--spacing-2)');
30
30
  const INSET = knob('inset', '0px');
31
31
  const TRAY_RADIUS = knob('tray-radius', RADIUS);
32
32
  const TRAY_PADDING = knob('tray-padding', 'var(--spacing-3)');
33
+ const STATUS_FILL = knob('status-fill', FILL);
34
+ const STATUS_RADIUS = knob('status-radius', TRAY_RADIUS);
35
+ const STATUS_PADDING = knob('status-padding', TRAY_PADDING);
33
36
  const TRAY_HEADER_HEIGHT = 'var(--size-element-sm)';
34
37
  /** why: Half the folded height, so the folded tray is round at both ends. */
35
38
  const TRAY_FOLDED_RADIUS = knob('tray-folded-radius', `calc(${TRAY_PADDING} + ${TRAY_HEADER_HEIGHT} / 2)`);
@@ -82,7 +85,9 @@ const trayBody = (open) => ({
82
85
  transition: 'grid-template-rows var(--duration-medium) var(--ease-standard)',
83
86
  });
84
87
  const TRAY_BODY_INNER = { overflow: 'hidden', minHeight: 0 };
85
- const TRAY_CONTENT = { paddingBlockStart: 'var(--spacing-3)' };
88
+ const TRAY_CONTENT = {
89
+ paddingBlockStart: knob('tray-content-gap', 'var(--spacing-3)'),
90
+ };
86
91
  /**
87
92
  * The working pill: what runs and for how long, and its stop button.
88
93
  * why: It counts from the chat's turn clock, the one the transcript's status line reads, so the
@@ -181,20 +186,35 @@ function RowSurface(props) {
181
186
  const attach = props.attach ? _jsx(StackItem, { children: props.attach }) : null;
182
187
  return (_jsx(Card, { elevation: "none", className: "theorem-composer-surface", style: ROW_SURFACE, children: _jsxs(HStack, { gap: 1, wrap: "wrap", vAlign: "end", children: [props.stacked ? null : attach, _jsx(RowField, { input: props.input, stacked: props.stacked }), props.stacked ? attach : null, _jsx(StackItem, { size: props.stacked ? 'fill' : 'static', children: _jsxs(HStack, { gap: 1, vAlign: "center", hAlign: "end", children: [props.controls, props.record, props.action] }) })] }) }));
183
188
  }
189
+ /** A problem: a card over the surface, as the tray is, its glyph and words saying what kind. */
190
+ const STATUS = {
191
+ marginInline: INSET,
192
+ border: 'none',
193
+ borderRadius: STATUS_RADIUS,
194
+ background: STATUS_FILL,
195
+ boxShadow: SHADOW,
196
+ padding: STATUS_PADDING,
197
+ };
198
+ const STATUS_ROLE = { error: 'alert', warning: 'status' };
199
+ /**
200
+ * The composer's problem, over the surface so the field stays where it is.
201
+ * why: It sits in the stack above the surface as the tray does, and grows upward.
202
+ */
184
203
  function RowStatus({ status, renderStatus }) {
185
204
  if (!status)
186
205
  return null;
187
206
  if (renderStatus)
188
207
  return renderStatus(status);
189
- return (_jsx(Banner, { status: status.type, role: status.type === 'error' ? 'alert' : 'status', title: status.message }));
208
+ const kind = status.type;
209
+ return (_jsx(Card, { elevation: "none", className: "theorem-composer-status", "data-status": kind, role: STATUS_ROLE[kind], style: STATUS, children: _jsxs(HStack, { gap: 2, vAlign: "start", children: [_jsx(Icon, { icon: kind, size: "sm", color: "inherit" }), _jsx(StackItem, { size: "fill", children: _jsx(Text, { size: "sm", children: status.message }) })] }) }));
190
210
  }
191
211
  /**
192
212
  * Theorem's one-row composer: the field, then the controls, the mic, and send, on one line.
193
213
  * Text that wraps moves the field onto its own line above them, the stacked layout. Above
194
214
  * it, the pill row: the reply in progress (stop is on its pill), the background jobs, and the
195
- * app's own pills.
215
+ * app's own pills; then the tray, then the composer's problem.
196
216
  */
197
217
  export function ChatComposerRow(props) {
198
218
  const stacked = useWrapped(props.editorRef, props.draftText);
199
- return (_jsxs(VStack, { gap: 0, width: "100%", className: "theorem-composer-row", style: { gap: GAP }, children: [_jsx(PillRow, { isWorking: props.isWorking, workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs, pills: props.pills, onStop: props.onStop, hint: props.hint }), props.tray ? _jsx(RowTray, { tray: props.tray }) : null, _jsx(RowSurface, { stacked: stacked, attach: props.attach, input: props.input, controls: props.controls, record: props.record, action: props.action }), _jsx(RowStatus, { status: props.status, renderStatus: props.renderStatus })] }));
219
+ return (_jsxs(VStack, { gap: 0, width: "100%", className: "theorem-composer-row", style: { gap: GAP }, children: [_jsx(PillRow, { isWorking: props.isWorking, workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs, pills: props.pills, onStop: props.onStop, hint: props.hint }), props.tray ? _jsx(RowTray, { tray: props.tray }) : null, _jsx(RowStatus, { status: props.status, renderStatus: props.renderStatus }), _jsx(RowSurface, { stacked: stacked, attach: props.attach, input: props.input, controls: props.controls, record: props.record, action: props.action })] }));
200
220
  }
@@ -81,6 +81,13 @@ export type ChatTranscriptProps<Host extends JsonObject = JsonObject> = {
81
81
  showResumedNotice?: boolean;
82
82
  /** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
83
83
  labels?: LabelOverrides;
84
+ /**
85
+ * Keeps neighbouring messages apart by the app's own values: given a block's `host`, return a key.
86
+ * Neighbouring blocks from one side share a message only when their keys are equal, and a block
87
+ * with no `host` has no key, so it shares a message only with another that has none. Theorem
88
+ * never reads what a key means. Without it, neighbours from one side share a message.
89
+ */
90
+ turnKeyOf?: (host: Host) => string;
84
91
  };
85
92
  /** Image-profile display: `ratio` is the profile's pinned aspect ratio, if any. */
86
93
  export type ImageOutput = {
@@ -48,6 +48,8 @@ const ShowWorkStatus = createContext(true);
48
48
  const ShowResumedNotice = createContext(true);
49
49
  /** What the app draws under each reply (`ChatTranscriptProps.slots.reply`). */
50
50
  const ReplySlot = createContext(undefined);
51
+ /** What the app draws in each message's details (`ChatTranscriptProps.slots.details`). */
52
+ const DetailsSlot = createContext(undefined);
51
53
  /** What the transcript's props say a tool call's row shows. */
52
54
  function useToolRowShows() {
53
55
  return {
@@ -107,15 +109,23 @@ function Failed({ reason }) {
107
109
  const label = useLabels()('@theorem.transcript.failed');
108
110
  return (_jsx(HoverTip, { content: reason, children: _jsxs(HStack, { gap: 1, vAlign: "center", style: { color: 'var(--color-error)' }, children: [_jsx(Icon, { icon: "error", size: "xsm", color: "inherit" }), _jsx("span", { children: label })] }) }));
109
111
  }
110
- /** A message's copy button and time, the button on the outside: right for the person, left for the agent. */
112
+ /**
113
+ * A message's copy button and time, the button on the outside: right for the person, left for the
114
+ * agent. The app's `details` slot sits right after the time.
115
+ */
111
116
  function CopyAndTime(props) {
112
117
  const copy = _jsx(CopyButton, { text: props.copyText });
113
118
  const time = _jsx(MessageTime, { at: props.at });
114
- return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [props.sender === 'user' ? time : copy, props.sender === 'user' ? copy : time] }));
119
+ const details = useContext(DetailsSlot)?.({
120
+ sender: props.sender,
121
+ blocks: props.blocks,
122
+ host: props.host,
123
+ });
124
+ return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [props.sender === 'user' ? null : copy, time, details, props.sender === 'user' ? copy : null] }));
115
125
  }
116
126
  /** How long the newest message keeps its copy button, time and status in view after it lands or its status changes. */
117
127
  const CHROME_FRESH_MS = 4_000;
118
- const CHROME_FADE = 'opacity 160ms ease';
128
+ const CHROME_FADE = 'var(--theorem-chrome-transition, opacity 160ms ease)';
119
129
  /** A press on a control inside the message, which does its own thing rather than show the details. */
120
130
  function isControl(target) {
121
131
  return (target instanceof Element &&
@@ -187,7 +197,7 @@ function MessageChrome(props) {
187
197
  const notice = turnNotice(props.error, props.stopped, props.resumed);
188
198
  return (_jsx(ChatMessageMetadata, { style: { opacity: props.revealed ? 1 : 0, transition: CHROME_FADE },
189
199
  // why: The row's first slot is the one nearest the margin.
190
- timestamp: _jsx(CopyAndTime, { sender: props.sender, at: props.at, copyText: props.copyText }),
200
+ timestamp: _jsx(CopyAndTime, { sender: props.sender, blocks: props.blocks, host: props.host, at: props.at, copyText: props.copyText }),
191
201
  // why: Astryx's statuses are a closed set, so these ride the footer.
192
202
  footer: notice ?? (props.usage ? _jsx(Usage, { tokens: props.usage }) : undefined), status: notice === undefined ? props.status : undefined }));
193
203
  }
@@ -303,7 +313,7 @@ function GeneratedGallery({ items, ratio }) {
303
313
  /** An image takes seconds: a slow, smooth breath rather than the Skeleton's quick stepped blink. */
304
314
  const GENERATING_PULSE = {
305
315
  animationDuration: '1.8s',
306
- animationTimingFunction: 'ease-in-out',
316
+ animationTimingFunction: 'var(--theorem-generating-easing, ease-in-out)',
307
317
  };
308
318
  /** Placeholder shaped like the image being generated. */
309
319
  function GeneratingImage({ ratio }) {
@@ -709,7 +719,7 @@ function AssistantTurn(props) {
709
719
  folds: hasTrace,
710
720
  }));
711
721
  const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
712
- return (_jsx(ChatMessage, { sender: "assistant", name: props.handle, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, resumed: resumed, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsxs(VStack, { gap: 3, width: "100%", children: [_jsx(TurnStatus, { status: status, trace: trace, hasTrace: hasTrace, streaming: props.streaming }), gatedTools.map((block) => (_jsx(GateCard, { block: block, handle: props.handle, handlers: props.handlers }, block.id))), keyedByContent(rows, (row) => row.kind === 'gallery' || row.kind === 'sources' || row.kind === 'tools'
722
+ return (_jsx(ChatMessage, { sender: "assistant", name: props.handle, ...chrome.handlers, metadata: props.streaming ? undefined : (_jsx(MessageChrome, { sender: "assistant", blocks: props.blocks, host: props.host ?? [], at: props.at, copyText: copyText, error: props.error, stopped: props.stopped, resumed: resumed, usage: showUsage ? props.usage : undefined, revealed: chrome.revealed })), children: _jsxs(VStack, { gap: 3, width: "100%", children: [_jsx(TurnStatus, { status: status, trace: trace, hasTrace: hasTrace, streaming: props.streaming }), gatedTools.map((block) => (_jsx(GateCard, { block: block, handle: props.handle, handlers: props.handlers }, block.id))), keyedByContent(rows, (row) => row.kind === 'gallery' || row.kind === 'sources' || row.kind === 'tools'
713
723
  ? row.kind
714
724
  : row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
715
725
  // why: Not the block id: the committed turn re-mints ids, and a
@@ -730,7 +740,7 @@ function UserTurn(props) {
730
740
  .map((block) => transcriptBlockCopyText(t, block))
731
741
  .filter(Boolean)
732
742
  .join('\n\n');
733
- const chrome = (_jsx(MessageChrome, { sender: "user", at: props.at, copyText: copyText, status: props.status, stopped: props.stopped, error: props.error, revealed: reveal.revealed }));
743
+ const chrome = (_jsx(MessageChrome, { sender: "user", blocks: props.blocks, host: props.host ?? [], at: props.at, copyText: copyText, status: props.status, stopped: props.stopped, error: props.error, revealed: reveal.revealed }));
734
744
  // why: Astryx: metadata goes on the last bubble, or on the message when the last
735
745
  // content is unbubbled (an attachment or voice note).
736
746
  const last = props.blocks.at(-1);
@@ -750,10 +760,16 @@ export function ChatTranscript(props) {
750
760
  const reply = props.slots?.reply;
751
761
  // why: The values are the app's, as its beforeSave wrote them; Theorem never reads them, so their type is the app's to name.
752
762
  const replySlot = reply ? (shown) => reply(shown) : undefined;
753
- return (_jsx(TheoremLabelsProvider, { children: _jsx(ReplySlot.Provider, { value: replySlot, children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(RenderRef.Provider, { value: props.renderRef, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ShowWorkStatus.Provider, { value: props.showWorkStatus !== false, children: _jsx(ShowResumedNotice.Provider, { value: props.showResumedNotice !== false, children: _jsx(ChatTranscriptBody, { ...props }) }) }) }) }) }) }) }) }));
754
- }
755
- function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
756
- const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
763
+ const details = props.slots?.details;
764
+ const detailsSlot = details
765
+ ? (shown) => details(shown)
766
+ : undefined;
767
+ const keyOf = props.turnKeyOf;
768
+ const turnKeyOf = keyOf ? (host) => keyOf(host) : undefined;
769
+ return (_jsx(TheoremLabelsProvider, { children: _jsx(ReplySlot.Provider, { value: replySlot, children: _jsx(DetailsSlot.Provider, { value: detailsSlot, children: _jsx(ShowUsage.Provider, { value: props.usage === true, children: _jsx(RenderRef.Provider, { value: props.renderRef, children: _jsx(ShowToolData.Provider, { value: props.showToolData !== false, children: _jsx(ShowToolDurations.Provider, { value: props.showToolDurations !== false, children: _jsx(ShowWorkStatus.Provider, { value: props.showWorkStatus !== false, children: _jsx(ShowResumedNotice.Provider, { value: props.showResumedNotice !== false, children: _jsx(ChatTranscriptBody, { ...props, turnKeyOf: turnKeyOf }) }) }) }) }) }) }) }) }) }));
770
+ }
771
+ function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, turnKeyOf, }) {
772
+ const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers)), turnKeyOf), [blocks, dividers, turnKeyOf]);
757
773
  const own = useTurnClock(groups, streaming);
758
774
  const { timeOf, replyStart } = clock ?? own;
759
775
  const pendingPrompt = streaming ? pendingPromptOf(groups) : undefined;
@@ -771,7 +787,7 @@ function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToo
771
787
  const next = groups[index + 1];
772
788
  const error = isBareFailure(next) ? failureOf(next) : undefined;
773
789
  const status = index === lastUser ? (delivery ?? undefined) : undefined;
774
- return (_jsx(UserTurn, { blocks: group.blocks, at: promptTime(groups, index, timeOf), status: status, stopped: stopText(group.stop, group.blocks, labels), error: error, isNewest: index === groups.length - 1 }, group.key));
790
+ return (_jsx(UserTurn, { blocks: group.blocks, host: group.host, at: promptTime(groups, index, timeOf), status: status, stopped: stopText(group.stop, group.blocks, labels), error: error, isNewest: index === groups.length - 1 }, group.key));
775
791
  };
776
792
  const turnOf = (group, index) => {
777
793
  if (group.kind === 'user')
package/ui/RankedBars.js CHANGED
@@ -3,7 +3,7 @@ import { Text } from '@astryxdesign/core/Text';
3
3
  import { VStack } from '@astryxdesign/core/VStack';
4
4
  import { Bar, BarChart, Cell, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
5
5
  import { ChartFrame, ChartTip, FIRST_WIDTH_PX } from "./TraceOverview.js";
6
- import { TRACE_GAP, TRACE_RADIUS, traceFill } from "./trace-patterns.js";
6
+ import { TRACE_GAP, TRACE_RADIUS, TRACE_TICK, TRACE_TICK_SIZE, traceFill, } from "./trace-patterns.js";
7
7
  /** A bar's paint: its colour, else its fill. */
8
8
  export function paintOf(row, fill = 'clear') {
9
9
  return row.color ?? traceFill(row.fill ?? fill);
@@ -12,7 +12,6 @@ export function paintOf(row, fill = 'clear') {
12
12
  const ROW_PX = 22;
13
13
  /** Longest name the axis shows whole; the hover card shows the rest. */
14
14
  const NAME_CHARS = 15;
15
- const TICK = { fill: 'var(--color-text-secondary)', fontSize: 11 };
16
15
  /** A bar's hover card: its name, its value, and its detail. */
17
16
  export function RankedTip({ active, payload, format, }) {
18
17
  const row = payload?.[0]?.payload;
@@ -31,13 +30,13 @@ export function RankedBars({ rows, format, max, onSelect, }) {
31
30
  const row = rows[Number(state?.activeIndex)];
32
31
  if (row && onSelect)
33
32
  onSelect(row);
34
- }, style: onSelect ? { cursor: 'pointer' } : undefined, children: [_jsx(XAxis, { type: "number", hide: true, domain: [0, max ?? 'auto'] }), _jsx(YAxis, { type: "category", dataKey: "id", width: 104, tick: TICK, tickLine: false, axisLine: false, interval: 0, tickFormatter: (id) => {
33
+ }, style: onSelect ? { cursor: 'pointer' } : undefined, children: [_jsx(XAxis, { type: "number", hide: true, domain: [0, max ?? 'auto'] }), _jsx(YAxis, { type: "category", dataKey: "id", width: 104, tick: TRACE_TICK, tickLine: false, axisLine: false, interval: 0, tickFormatter: (id) => {
35
34
  const name = rows.find((row) => row.id === id)?.name ?? '';
36
35
  return name.length > NAME_CHARS ? `${name.slice(0, NAME_CHARS - 1)}…` : name;
37
36
  } }), _jsx(Tooltip, { content: (props) => _jsx(RankedTip, { ...props, format: format }), cursor: false, isAnimationActive: false }), _jsx(Bar, { dataKey: "value", radius: TRACE_RADIUS, stroke: TRACE_GAP, strokeWidth: 2, isAnimationActive: false, minPointSize: 2, label: {
38
37
  position: 'right',
39
38
  fill: 'var(--color-text-secondary)',
40
- fontSize: 11,
39
+ fontSize: TRACE_TICK_SIZE,
41
40
  formatter: (value) => format(Number(value)),
42
41
  }, children: rows.map((row) => (_jsx(Cell, { fill: paintOf(row) }, row.id))) })] }) }) }));
43
42
  }
package/ui/SidePanel.js CHANGED
@@ -116,7 +116,7 @@ export function PaneLayout({ isWide, label, detailLabel, lead, overview, detail,
116
116
  width: '48%',
117
117
  flexShrink: 0,
118
118
  height: '100%',
119
- borderInlineStart: '1px solid var(--color-border)',
119
+ borderInlineStart: 'var(--theorem-pane-divider, 1px solid var(--color-border))',
120
120
  }, children: _jsx(PanelScroll, { label: detailLabel, children: detail }) })) : null] }));
121
121
  }
122
122
  /** One titled block of a pane's detail; `doc` says what the title means, on hover. */
@@ -160,12 +160,12 @@ export type TheoremChatProps<Host extends JsonObject = JsonObject> = {
160
160
  renderRef?: (ref: UserRef) => ReactNode;
161
161
  /** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
162
162
  composerEmptyAction?: ReactNode;
163
- /** Draws the composer's problem in place of Astryx's; see `ChatComposerBarProps.renderStatus`. */
163
+ /** Draws the composer's problem in place of Theorem's; see `ChatComposerBarProps.renderStatus`. */
164
164
  renderComposerStatus?: (status: ChatComposerStatus) => ReactNode;
165
165
  /**
166
166
  * The transcript's own options, given to {@link TheoremChatTranscript} as they are: its `slots`,
167
- * such as the `reply` slot, and how it lays out a reply. `Host` is the type of the values your
168
- * server sets on a reply's blocks in `beforeSave`.
167
+ * such as the `reply` slot, its `turnKeyOf`, and how it lays out a reply. `Host` is the type of
168
+ * the values your server sets on blocks in `beforeSave`.
169
169
  */
170
170
  transcript?: TheoremChatTranscriptOptions<Host>;
171
171
  };
@@ -218,7 +218,7 @@ export type TheoremChatComposerProps = {
218
218
  pills?: readonly ComposerPill[];
219
219
  /** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
220
220
  emptyAction?: ReactNode;
221
- /** Draws the composer's problem in place of Astryx's; see `ChatComposerBarProps.renderStatus`. */
221
+ /** Draws the composer's problem in place of Theorem's; see `ChatComposerBarProps.renderStatus`. */
222
222
  renderStatus?: (status: ChatComposerStatus) => ReactNode;
223
223
  };
224
224
  /**
@@ -7,7 +7,7 @@ import { timeFormats, withUnit } from '@theoremjs/web/client';
7
7
  import { useMemo } from 'react';
8
8
  import { Bar, BarChart, Cell, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts';
9
9
  import { ChartFrame, ChartTip, FIRST_WIDTH_PX } from "./TraceOverview.js";
10
- import { ChartCard, TRACE_GAP, TRACE_RADIUS, TraceSwatch, traceFill, } from "./trace-patterns.js";
10
+ import { ChartCard, TRACE_GAP, TRACE_RADIUS, TRACE_TICK, TRACE_TICK_SIZE, TraceSwatch, traceFill, } from "./trace-patterns.js";
11
11
  /**
12
12
  * A tool result's charts, drawn as the trace draws its own: the same card,
13
13
  * fills, ticks, and hover card. Recharts loads with this module, only when a
@@ -19,7 +19,6 @@ import { ChartCard, TRACE_GAP, TRACE_RADIUS, TraceSwatch, traceFill, } from "./t
19
19
  const CHART_PX = 140;
20
20
  /** Height of one row of a ranking, in pixels. */
21
21
  const BAR_ROW_PX = 22;
22
- const TICK = { fill: 'var(--color-text-secondary)', fontSize: 11 };
23
22
  const BAR = {
24
23
  radius: TRACE_RADIUS,
25
24
  stroke: TRACE_GAP,
@@ -68,7 +67,7 @@ function TimeCard({ chart }) {
68
67
  return null;
69
68
  const unit = lead.unit;
70
69
  const range = `${formats.number(Math.min(...values))}–${formats.number(Math.max(...values), unit)}`;
71
- return (_jsxs(ChartCard, { title: chart.title, value: formats.number(first, unit), note: range, children: [_jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: CHART_PX, initialDimension: { width: FIRST_WIDTH_PX, height: CHART_PX }, children: _jsxs(LineChart, { data: chart.rows, margin: { top: 4, right: 4, bottom: 0, left: 0 }, accessibilityLayer: false, children: [_jsx(XAxis, { dataKey: chart.x, tick: TICK, tickLine: false, axisLine: false, tickFormatter: formats.tick, minTickGap: 16 }), _jsx(YAxis, { tick: TICK, tickLine: false, axisLine: false, width: 36, domain: ['auto', 'auto'], tickFormatter: (value) => formats.number(value) }), _jsx(Tooltip, { content: (props) => _jsx(TimeTip, { ...props, chart: chart, formats: formats }), cursor: { stroke: 'var(--color-border-emphasized)' }, isAnimationActive: false }), chart.series.map((series, index) => (_jsx(Line, { type: "monotone", dataKey: series.key, stroke: traceFill(SERIES_FILL[index] ?? 'clear'), strokeWidth: 2, dot: false, activeDot: { r: 3, strokeWidth: 0 }, connectNulls: true, isAnimationActive: false }, series.key)))] }) }) }), chart.series.length > 1 ? (_jsx(HStack, { gap: 3, wrap: "wrap", children: chart.series.map((series, index) => (_jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(TraceSwatch, { fill: SERIES_FILL[index] ?? 'clear' }), _jsx(Text, { type: "supporting", color: "secondary", children: series.label })] }, series.key))) })) : null] }));
70
+ return (_jsxs(ChartCard, { title: chart.title, value: formats.number(first, unit), note: range, children: [_jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: CHART_PX, initialDimension: { width: FIRST_WIDTH_PX, height: CHART_PX }, children: _jsxs(LineChart, { data: chart.rows, margin: { top: 4, right: 4, bottom: 0, left: 0 }, accessibilityLayer: false, children: [_jsx(XAxis, { dataKey: chart.x, tick: TRACE_TICK, tickLine: false, axisLine: false, tickFormatter: formats.tick, minTickGap: 16 }), _jsx(YAxis, { tick: TRACE_TICK, tickLine: false, axisLine: false, width: 36, domain: ['auto', 'auto'], tickFormatter: (value) => formats.number(value) }), _jsx(Tooltip, { content: (props) => _jsx(TimeTip, { ...props, chart: chart, formats: formats }), cursor: { stroke: 'var(--color-border-emphasized)' }, isAnimationActive: false }), chart.series.map((series, index) => (_jsx(Line, { type: "monotone", dataKey: series.key, stroke: traceFill(SERIES_FILL[index] ?? 'clear'), strokeWidth: 2, dot: false, activeDot: { r: 3, strokeWidth: 0 }, connectNulls: true, isAnimationActive: false }, series.key)))] }) }) }), chart.series.length > 1 ? (_jsx(HStack, { gap: 3, wrap: "wrap", children: chart.series.map((series, index) => (_jsxs(HStack, { gap: 2, vAlign: "center", children: [_jsx(TraceSwatch, { fill: SERIES_FILL[index] ?? 'clear' }), _jsx(Text, { type: "supporting", color: "secondary", children: series.label })] }, series.key))) })) : null] }));
72
71
  }
73
72
  function BarTip({ active, payload, chart, formats, }) {
74
73
  const row = payload?.[0]?.payload;
@@ -84,13 +83,13 @@ function CategoryCard({ chart }) {
84
83
  if (!top)
85
84
  return null;
86
85
  const height = rows.length * BAR_ROW_PX;
87
- return (_jsx(ChartCard, { title: chart.title, value: formats.number(top.value, chart.series.unit), note: top.label, children: _jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: height, initialDimension: { width: FIRST_WIDTH_PX, height }, children: _jsxs(BarChart, { data: rows, layout: "vertical", margin: { top: 0, right: 56, bottom: 0, left: 0 }, accessibilityLayer: false, barCategoryGap: 5, children: [_jsx(XAxis, { type: "number", hide: true }), _jsx(YAxis, { type: "category", dataKey: "id", width: 104, tick: TICK, tickLine: false, axisLine: false, interval: 0, tickFormatter: (id) => {
86
+ return (_jsx(ChartCard, { title: chart.title, value: formats.number(top.value, chart.series.unit), note: top.label, children: _jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: height, initialDimension: { width: FIRST_WIDTH_PX, height }, children: _jsxs(BarChart, { data: rows, layout: "vertical", margin: { top: 0, right: 56, bottom: 0, left: 0 }, accessibilityLayer: false, barCategoryGap: 5, children: [_jsx(XAxis, { type: "number", hide: true }), _jsx(YAxis, { type: "category", dataKey: "id", width: 104, tick: TRACE_TICK, tickLine: false, axisLine: false, interval: 0, tickFormatter: (id) => {
88
87
  const label = rows[Number(id)]?.label ?? '';
89
88
  return label.length > 15 ? `${label.slice(0, 14)}…` : label;
90
89
  } }), _jsx(Tooltip, { content: (props) => _jsx(BarTip, { ...props, chart: chart, formats: formats }), cursor: { fill: 'var(--color-overlay-hover)', radius: TRACE_RADIUS }, isAnimationActive: false }), _jsx(Bar, { dataKey: "value", ...BAR, label: {
91
90
  position: 'right',
92
91
  fill: 'var(--color-text-secondary)',
93
- fontSize: 11,
92
+ fontSize: TRACE_TICK_SIZE,
94
93
  formatter: (value) => formats.number(Number(value), chart.series.unit),
95
94
  }, children: rows.map((row, index) => (_jsx(Cell, { fill: traceFill(index === 0 ? 'clear' : 'shade2') }, row.id))) })] }) }) }) }));
96
95
  }
package/ui/TraceCharts.js CHANGED
@@ -10,14 +10,13 @@ import { traceSpans } from "../client/trace-view.js";
10
10
  import { RankedBars } from "./RankedBars.js";
11
11
  import { ChartFrame, ChartTip, FIRST_WIDTH_PX } from "./TraceOverview.js";
12
12
  import { useTraceFormat } from "./TraceValues.js";
13
- import { ACTOR_FILL, ChartCard, TRACE_GAP, TRACE_RADIUS, TraceSwatch, traceFill, } from "./trace-patterns.js";
13
+ import { ACTOR_FILL, ChartCard, TRACE_GAP, TRACE_RADIUS, TRACE_TICK, TraceSwatch, traceFill, } from "./trace-patterns.js";
14
14
  /** Height of each column chart's plot, in pixels. */
15
15
  const CHART_PX = 120;
16
16
  /** Height of a share bar, in pixels. */
17
17
  const SHARE_PX = 12;
18
18
  /** Most steps the slowest-steps chart ranks. */
19
19
  const SLOWEST = 5;
20
- const TICK = { fill: 'var(--color-text-secondary)', fontSize: 11 };
21
20
  /** Every bar: rounded, and parted from its neighbours by the card's background. */
22
21
  const BAR = {
23
22
  radius: TRACE_RADIUS,
@@ -118,7 +117,7 @@ function TokenTip({ active, payload }) {
118
117
  }
119
118
  /** Columns of stacked series, one per row; a column opens its row. */
120
119
  function Columns({ rows, keys, fills, tip, }) {
121
- return (_jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: CHART_PX, initialDimension: { width: FIRST_WIDTH_PX, height: CHART_PX }, children: _jsxs(BarChart, { data: rows, margin: { top: 0, right: 0, bottom: 0, left: 0 }, accessibilityLayer: false, barCategoryGap: "24%", maxBarSize: 24, onClick: (state) => rows[Number(state?.activeIndex)]?.open(), style: { cursor: 'pointer' }, children: [_jsx(XAxis, { dataKey: "index", tick: TICK, tickLine: false, axisLine: false, height: 18 }), _jsx(YAxis, { hide: true }), _jsx(Tooltip, { content: tip, cursor: { fill: 'var(--color-overlay-hover)', radius: TRACE_RADIUS }, isAnimationActive: false }), keys.map((key) => (_jsx(Bar, { dataKey: key, stackId: "stack", fill: traceFill(fills[key] ?? 'clear'), ...BAR }, key)))] }) }) }));
120
+ return (_jsx(ChartFrame, { children: _jsx(ResponsiveContainer, { width: "100%", height: CHART_PX, initialDimension: { width: FIRST_WIDTH_PX, height: CHART_PX }, children: _jsxs(BarChart, { data: rows, margin: { top: 0, right: 0, bottom: 0, left: 0 }, accessibilityLayer: false, barCategoryGap: "24%", maxBarSize: 24, onClick: (state) => rows[Number(state?.activeIndex)]?.open(), style: { cursor: 'pointer' }, children: [_jsx(XAxis, { dataKey: "index", tick: TRACE_TICK, tickLine: false, axisLine: false, height: 18 }), _jsx(YAxis, { hide: true }), _jsx(Tooltip, { content: tip, cursor: { fill: 'var(--color-overlay-hover)', radius: TRACE_RADIUS }, isAnimationActive: false }), keys.map((key) => (_jsx(Bar, { dataKey: key, stackId: "stack", fill: traceFill(fills[key] ?? 'clear'), ...BAR }, key)))] }) }) }));
122
121
  }
123
122
  /** Tokens stacked new, cached, and written per row: the total, the columns, and each series' sum. */
124
123
  function TokensCard({ title, rows }) {
@@ -12,7 +12,7 @@ import { TRACE_FIELDS, traceAttributeMeta } from '@theoremjs/agents';
12
12
  import { useEffect, useRef } from 'react';
13
13
  import { isCallTrace } from "../client/trace-story.js";
14
14
  import { useTraceFormat } from "./TraceValues.js";
15
- import { TRACE_HUE } from "./trace-palette.js";
15
+ import { TRACE_FAILED } from "./trace-patterns.js";
16
16
  /** Width a chart draws at before it has measured its column: the panel's narrowest. */
17
17
  export const FIRST_WIDTH_PX = 280;
18
18
  /**
@@ -35,9 +35,9 @@ export function ChartFrame({ children }) {
35
35
  export function ChartTip({ children }) {
36
36
  return (_jsx("div", { style: {
37
37
  background: 'var(--color-background-popover)',
38
- border: '1px solid var(--color-border)',
38
+ border: 'var(--theorem-trace-tip-border, 1px solid var(--color-border))',
39
39
  borderRadius: 'var(--radius-element)',
40
- padding: '6px 8px',
40
+ padding: 'var(--theorem-trace-tip-padding, 6px 8px)',
41
41
  boxShadow: 'var(--shadow-med)',
42
42
  pointerEvents: 'none',
43
43
  }, children: children }));
@@ -99,7 +99,7 @@ function StepsStat({ totals, tools, format, }) {
99
99
  // why: With no model, every step is a tool call the heading already counts.
100
100
  if (totals.calls === 0 && totals.errors === 0)
101
101
  return null;
102
- return (_jsx(ChartStat, { label: t('@theorem.panel.trace.steps'), value: format.number(totals.calls + tools), detail: totals.errors > 0 ? (_jsx("span", { style: { color: TRACE_HUE.oxblood }, children: t('@theorem.panel.trace.failed', { count: totals.errors }) })) : (t('@theorem.panel.trace.steps.detail', { calls: totals.calls, tools })) }));
102
+ return (_jsx(ChartStat, { label: t('@theorem.panel.trace.steps'), value: format.number(totals.calls + tools), detail: totals.errors > 0 ? (_jsx("span", { style: { color: TRACE_FAILED }, children: t('@theorem.panel.trace.failed', { count: totals.errors }) })) : (t('@theorem.panel.trace.steps.detail', { calls: totals.calls, tools })) }));
103
103
  }
104
104
  function GuardrailsStat({ latency, format, }) {
105
105
  const guardrails = latency?.guardrails;
package/ui/TraceStory.js CHANGED
@@ -93,9 +93,9 @@ function StepBody({ step, isSelected, select, }) {
93
93
  }
94
94
  function StepItem({ step, isSelected, isDimmed, onSelect, }) {
95
95
  return (_jsx(Arrive, { children: _jsx("div", { style: {
96
- paddingInlineStart: step.kind === 'span' && step.nested ? 20 : 0,
96
+ paddingInlineStart: step.kind === 'span' && step.nested ? 'var(--theorem-trace-nest-indent, 20px)' : 0,
97
97
  opacity: isDimmed ? 0.35 : 1,
98
- transition: 'opacity 120ms ease',
98
+ transition: 'var(--theorem-trace-step-transition, opacity 120ms ease)',
99
99
  }, children: _jsx(StepBody, { step: step, isSelected: isSelected, select: () => onSelect(step.node) }) }) }));
100
100
  }
101
101
  /**
@@ -10,8 +10,7 @@ import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, ReferenceArea, Res
10
10
  import { traceActivity, traceActor, traceBars, traceOutcome, } from "../client/trace-story.js";
11
11
  import { ChartFrame, ChartTip, FIRST_WIDTH_PX } from "./TraceOverview.js";
12
12
  import { useTraceFormat } from "./TraceValues.js";
13
- import { TRACE_HUE } from "./trace-palette.js";
14
- import { ACTOR_FILL, TRACE_RADIUS, traceFill } from "./trace-patterns.js";
13
+ import { ACTOR_FILL, TRACE_FAILED, TRACE_RADIUS, TRACE_TICK, TRACE_TICK_SIZE, traceFill, } from "./trace-patterns.js";
15
14
  /** Slices in the activity strip. */
16
15
  const BUCKETS = 120;
17
16
  /** Height of one span's row, in pixels. */
@@ -42,7 +41,7 @@ function BarTip({ active, payload }) {
42
41
  format.t('@theorem.panel.trace.offset', { duration: format.duration(from) }),
43
42
  ...(typeof cost === 'number' ? [format.usd(cost)] : []),
44
43
  ].join(format.t('@theorem.panel.trace.separator')) }), outcome ? (_jsx(Text, { type: "supporting", children: _jsx("span", { style: {
45
- color: outcome.tone === 'error' ? TRACE_HUE.oxblood : 'var(--color-text-secondary)',
44
+ color: outcome.tone === 'error' ? TRACE_FAILED : 'var(--color-text-secondary)',
46
45
  }, children: outcome.label }) })) : null] }) }));
47
46
  }
48
47
  /** A row's name, from the chart's left edge, set in by its depth and cut to the column. */
@@ -54,9 +53,7 @@ function NameTick({ y: rawY, payload, rows, }) {
54
53
  const indent = Math.min(row.bar.depth, 4) * INDENT_PX;
55
54
  const room = Math.floor((NAME_PX - indent - 10) / 6.2);
56
55
  const name = row.name.length > room ? `${row.name.slice(0, Math.max(1, room - 1))}…` : row.name;
57
- return (_jsxs("text", { x: indent, y: y, dy: "0.35em", fontSize: 11, fill: row.bar.node.span.status.code === 'ERROR'
58
- ? TRACE_HUE.oxblood
59
- : 'var(--color-text-secondary)', children: [_jsx("title", { children: row.name }), name] }));
56
+ return (_jsxs("text", { x: indent, y: y, dy: "0.35em", fontSize: TRACE_TICK_SIZE, fill: row.bar.node.span.status.code === 'ERROR' ? TRACE_FAILED : 'var(--color-text-secondary)', children: [_jsx("title", { children: row.name }), name] }));
60
57
  }
61
58
  /** How busy the model and tools were over the turn; a drag across it picks the window to zoom into. */
62
59
  function ActivityStrip({ root, zoom, onZoom, }) {
@@ -119,7 +116,7 @@ function SpanBars({ root, domain, selectedId, matches, onSelect, }) {
119
116
  const row = rows[Number(state?.activeIndex)];
120
117
  if (row)
121
118
  onSelect(row.bar.node);
122
- }, style: { cursor: 'pointer' }, children: [_jsx(CartesianGrid, { horizontal: false, stroke: "var(--color-border)", strokeDasharray: "2 4" }), _jsx(XAxis, { type: "number", domain: domain, allowDataOverflow: true, tickFormatter: (value) => format.duration(value), tick: { fill: 'var(--color-text-secondary)', fontSize: 11 }, axisLine: { stroke: 'var(--color-border)' }, tickLine: false, height: AXIS_PX, tickCount: 5 }), _jsx(YAxis, { type: "category", dataKey: "id", width: NAME_PX, axisLine: false, tickLine: false, interval: 0, tick: (props) => _jsx(NameTick, { ...props, rows: byId }) }), _jsx(Tooltip, { content: (props) => _jsx(BarTip, { ...props }), cursor: { fill: 'var(--color-overlay-hover)' }, isAnimationActive: false }), _jsx(Bar, { dataKey: "range", minPointSize: 2, radius: TRACE_RADIUS, isAnimationActive: false, style: { cursor: 'pointer' }, children: rows.map((row) => (_jsx(Cell, { fill: traceFill(barHatch(row.bar.node)), opacity: barOpacity(row, selectedId, matches) }, row.id))) })] }) }) }));
119
+ }, style: { cursor: 'pointer' }, children: [_jsx(CartesianGrid, { horizontal: false, stroke: "var(--color-border)", strokeDasharray: "2 4" }), _jsx(XAxis, { type: "number", domain: domain, allowDataOverflow: true, tickFormatter: (value) => format.duration(value), tick: TRACE_TICK, axisLine: { stroke: 'var(--color-border)' }, tickLine: false, height: AXIS_PX, tickCount: 5 }), _jsx(YAxis, { type: "category", dataKey: "id", width: NAME_PX, axisLine: false, tickLine: false, interval: 0, tick: (props) => _jsx(NameTick, { ...props, rows: byId }) }), _jsx(Tooltip, { content: (props) => _jsx(BarTip, { ...props }), cursor: { fill: 'var(--color-overlay-hover)' }, isAnimationActive: false }), _jsx(Bar, { dataKey: "range", minPointSize: 2, radius: TRACE_RADIUS, isAnimationActive: false, style: { cursor: 'pointer' }, children: rows.map((row) => (_jsx(Cell, { fill: traceFill(barHatch(row.bar.node)), opacity: barOpacity(row, selectedId, matches) }, row.id))) })] }) }) }));
123
120
  }
124
121
  /**
125
122
  * Every span of the turn on one time axis, nested by depth and coloured by
package/ui/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { AstryxMediaViewer, type MediaViewer, type MediaViewerItem, type MediaVi
31
31
  export { PaneFailure, PaneLoading, PaneState } from './PaneState.js';
32
32
  export { RadialBars, Sunburst, type SunburstNode } from './RadialCharts.js';
33
33
  export { type RankedBar, RankedBars } from './RankedBars.js';
34
- export type { ChatReply, ChatReplySlot, ChatTranscriptSlots } from './reply-slot.js';
34
+ export type { ChatDetailsSlot, ChatMessageDetails, ChatReply, ChatReplySlot, ChatTranscriptSlots, } from './reply-slot.js';
35
35
  export { InPlace, PaneLayout, PanePanel, Prose, RaisedPane } from './SidePanel.js';
36
36
  export { DEFAULT_CHAT_MAX_WIDTH, TheoremChat, TheoremChatComposer, type TheoremChatComposerProps, type TheoremChatHandle, type TheoremChatProps, TheoremChatTranscript, type TheoremChatTranscriptOptions, type TheoremChatTranscriptProps, } from './TheoremChat.js';
37
37
  export { TheoremDecision, type TheoremDecisionProps } from './TheoremDecision.js';
@@ -16,8 +16,27 @@ export type ChatReply<Host extends JsonObject = JsonObject> = {
16
16
  };
17
17
  /** Drawn under each reply. Unset or `null` draws nothing. */
18
18
  export type ChatReplySlot<Host extends JsonObject = JsonObject> = null | ((reply: ChatReply<Host>) => ReactNode);
19
+ /** A message as the transcript's `details` slot is given it. `Host` is the type of the app's own values. */
20
+ export type ChatMessageDetails<Host extends JsonObject = JsonObject> = {
21
+ /** Whose message it is: the person's, or a reply. */
22
+ sender: 'user' | 'assistant';
23
+ /** The message's blocks as the transcript draws them. */
24
+ blocks: readonly TranscriptBlock[];
25
+ /**
26
+ * The `host` value of each of the message's blocks that has one, in order, its `turn-done` blocks
27
+ * too. Empty when none has one. Theorem never reads them and does not check their shape.
28
+ */
29
+ host: readonly Host[];
30
+ };
31
+ /** Drawn in each message's details, right after its time. Unset or `null` draws nothing. */
32
+ export type ChatDetailsSlot<Host extends JsonObject = JsonObject> = null | ((message: ChatMessageDetails<Host>) => ReactNode);
19
33
  /** What the app draws in the transcript's slots. */
20
34
  export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
21
35
  /** Under each reply, inside its message. */
22
36
  reply?: ChatReplySlot<Host>;
37
+ /**
38
+ * In each message's details, right after its time, on the person's messages and on replies. The
39
+ * details show with the message's time and copy button; a reply on its way has none yet.
40
+ */
41
+ details?: ChatDetailsSlot<Host>;
23
42
  };
@@ -9,6 +9,15 @@ import type { TraceActor } from '../client/trace-story.js';
9
9
  * @module
10
10
  */
11
11
  export type TraceFill = 'clear' | 'hatch' | 'shade1' | 'shade2' | 'shade3' | 'failed';
12
+ /** Whatever failed: oxblood, deep in light mode and softened in dark. */
13
+ export declare const TRACE_FAILED = "var(--theorem-trace-failed, light-dark(#8e2a28, #cd5f55))";
14
+ /** The size of a chart's axis and row labels. */
15
+ export declare const TRACE_TICK_SIZE = "var(--theorem-trace-tick-size, 11px)";
16
+ /** How a chart's axis labels are drawn. */
17
+ export declare const TRACE_TICK: {
18
+ readonly fill: "var(--color-text-secondary)";
19
+ readonly fontSize: "var(--theorem-trace-tick-size, 11px)";
20
+ };
12
21
  /** Corner radius of every bar, in pixels. */
13
22
  export declare const TRACE_RADIUS = 4;
14
23
  /** Paints the gap between stacked segments: the chart card's own background. */
@@ -4,17 +4,30 @@ import { HStack } from '@astryxdesign/core/HStack';
4
4
  import { StackItem } from '@astryxdesign/core/Stack';
5
5
  import { Text } from '@astryxdesign/core/Text';
6
6
  import { VStack } from '@astryxdesign/core/VStack';
7
+ // why: Each paint is a `--theorem-trace-*` property with Theorem's colour behind it, so a host
8
+ // sets its own in CSS. Plain string literals, so a style checker can follow an import to them.
9
+ const TRACE_CLEAR = 'var(--theorem-trace-clear, light-dark(#0d1e37, #b4c6e2))';
10
+ const TRACE_SHADE_1 = 'var(--theorem-trace-shade-1, light-dark(#3b5580, #6582ad))';
11
+ const TRACE_SHADE_2 = 'var(--theorem-trace-shade-2, light-dark(#7f95b7, #3b5078))';
12
+ const TRACE_SHADE_3 = 'var(--theorem-trace-shade-3, light-dark(#bcc8da, #22345a))';
13
+ const HATCH_BASE = 'var(--theorem-trace-hatch-base, light-dark(#e4e7ec, #2b2f36))';
14
+ const HATCH_STRIPE = 'var(--theorem-trace-hatch-stripe, light-dark(#9aa3b1, #6b727d))';
15
+ /** Whatever failed: oxblood, deep in light mode and softened in dark. */
16
+ export const TRACE_FAILED = 'var(--theorem-trace-failed, light-dark(#8e2a28, #cd5f55))';
7
17
  const SOLID = {
8
- clear: 'light-dark(#0d1e37, #b4c6e2)',
9
- shade1: 'light-dark(#3b5580, #6582ad)',
10
- shade2: 'light-dark(#7f95b7, #3b5078)',
11
- shade3: 'light-dark(#bcc8da, #22345a)',
12
- failed: 'light-dark(#8e2a28, #cd5f55)',
18
+ clear: TRACE_CLEAR,
19
+ shade1: TRACE_SHADE_1,
20
+ shade2: TRACE_SHADE_2,
21
+ shade3: TRACE_SHADE_3,
22
+ failed: TRACE_FAILED,
23
+ };
24
+ /** The size of a chart's axis and row labels. */
25
+ export const TRACE_TICK_SIZE = 'var(--theorem-trace-tick-size, 11px)';
26
+ /** How a chart's axis labels are drawn. */
27
+ export const TRACE_TICK = {
28
+ fill: 'var(--color-text-secondary)',
29
+ fontSize: TRACE_TICK_SIZE,
13
30
  };
14
- const HATCH_BASE = 'light-dark(#e4e7ec, #2b2f36)';
15
- const HATCH_STRIPE = 'light-dark(#9aa3b1, #6b727d)';
16
- /** Text that leads a chart's headline, in the clear series' colour. */
17
- const TRACE_ACCENT = SOLID.clear;
18
31
  /** Corner radius of every bar, in pixels. */
19
32
  export const TRACE_RADIUS = 4;
20
33
  /** Paints the gap between stacked segments: the chart card's own background. */
@@ -49,7 +62,7 @@ export const CONSOLE_CARD = {
49
62
  export function ChartBody({ title, value, note, aside, detail, children, }) {
50
63
  const titled = (_jsx(Text, { type: "supporting", color: "secondary", children: title }));
51
64
  const heading = detail ? (_jsxs(VStack, { gap: 1, children: [titled, _jsx(Text, { type: "supporting", maxLines: 2, children: detail })] })) : (titled);
52
- return (_jsxs(VStack, { gap: 3, children: [aside ? (_jsxs(HStack, { gap: 3, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: heading }), aside] })) : (heading), _jsxs("div", { style: { display: 'flex', alignItems: 'baseline', flexWrap: 'wrap', columnGap: 8 }, children: [_jsx(Text, { size: "2xl", weight: "medium", hasTabularNumbers: true, children: value }), note ? (_jsx(Text, { type: "supporting", hasTabularNumbers: true, children: _jsx("span", { style: { color: TRACE_ACCENT }, children: note }) })) : null] }), children] }));
65
+ return (_jsxs(VStack, { gap: 3, children: [aside ? (_jsxs(HStack, { gap: 3, vAlign: "center", children: [_jsx(StackItem, { size: "fill", children: heading }), aside] })) : (heading), _jsxs("div", { style: { display: 'flex', alignItems: 'baseline', flexWrap: 'wrap', columnGap: 8 }, children: [_jsx(Text, { size: "2xl", weight: "medium", hasTabularNumbers: true, children: value }), note ? (_jsx(Text, { type: "supporting", hasTabularNumbers: true, children: _jsx("span", { style: { color: TRACE_CLEAR }, children: note }) })) : null] }), children] }));
53
66
  }
54
67
  /** A chart as a card. */
55
68
  export function ChartCard(props) {
@@ -1,10 +0,0 @@
1
- /**
2
- * The trace panel's colour for a failed step: oxblood, a light-dark pair that is deep in light
3
- * mode and softened, not brightened, in dark.
4
- *
5
- * @module
6
- */
7
- export declare const TRACE_HUE: {
8
- /** Oxblood: whatever failed. */
9
- readonly oxblood: "light-dark(#8e2a28, #cd5f55)";
10
- };
@@ -1,10 +0,0 @@
1
- /**
2
- * The trace panel's colour for a failed step: oxblood, a light-dark pair that is deep in light
3
- * mode and softened, not brightened, in dark.
4
- *
5
- * @module
6
- */
7
- export const TRACE_HUE = {
8
- /** Oxblood: whatever failed. */
9
- oxblood: 'light-dark(#8e2a28, #cd5f55)',
10
- };