@theoremjs/react 0.3.5-next.1000.g569f044 → 0.3.5-next.1001.g68d8dcf

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
@@ -222,7 +222,7 @@ Each part of the look is a CSS custom property. Set it on any element above the
222
222
  }
223
223
  ```
224
224
 
225
- The words are labels: `@theorem.composer.pill.working_for`, `@theorem.composer.pill.working` (before the start is known), `@theorem.composer.pill.stop`, `@theorem.composer.pill.background`, `@theorem.composer.tray.expand` and `@theorem.composer.tray.collapse`. See [Wording](#wording). For a rule that no property covers, each part has a class: `theorem-composer-row`, `theorem-composer-pills`, `theorem-composer-pill` (with `data-pill="working"` or `"background"`), `theorem-composer-tray` (with `data-open`) and `theorem-composer-surface`.
225
+ The words are labels: `@theorem.composer.pill.working_for`, `@theorem.composer.pill.working` (before the start is known), `@theorem.composer.pill.stop`, `@theorem.composer.pill.background`, `@theorem.composer.tray.expand` and `@theorem.composer.tray.collapse`. See [Wording](#wording). For a rule that no property covers, each part has a class: `theorem-composer-row`, `theorem-composer-pills`, `theorem-composer-pill` (with `data-pill="working"`, `"background"` or `"app"`), `theorem-composer-tray` (with `data-open`) and `theorem-composer-surface`.
226
226
 
227
227
  ### Tool media
228
228
 
@@ -590,7 +590,9 @@ function Dock({ chat, iface }) {
590
590
  }
591
591
  ```
592
592
 
593
- `TheoremChatComposer` takes `layout`, `icons`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, and `showToolDurations`. 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`.
593
+ `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, and `inputRef`. `TheoremChatTranscript` takes the props of `ChatTranscript` that the chat does not give: `handle`, `emptyState`, `dividers`, `usage`, `bodyKindPlacement`, `stepLayout`, and `showToolDurations`. 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`.
594
+
595
+ 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, onSelect? }`. It comes after the working pill and the background calls, and looks like them. A click calls `onSelect`. A pill without `onSelect` only shows.
594
596
 
595
597
  The two pieces read one clock: `chat.turnClock`. So the working pill of the composer and the status line of the transcript show the same time. `chat.workingSince` is when the reply in progress started, less its waits for approval. For a reply that runs elsewhere, it is `chat.runningElsewhere.since`. `chat.shownBlocks` is what the transcript shows: `chat.blocks`, then `chat.streamBlocks`.
596
598
 
@@ -598,6 +600,8 @@ To draw one piece in your own way, use `ChatTranscript` and `ChatComposerBar` fr
598
600
 
599
601
  The composer bar has a selector for the model, its effort, and each option. When their values do not fit the bar, each selector shows only its icon, and a tooltip gives its name and value. When the icons do not fit either, the row scrolls inside the composer. A control you pass as `generationSelect` keeps its own look and scrolls with the row.
600
602
 
603
+ A tool call that runs on in the background after its reply ends shows as running, with a "Background task" badge (`@theorem.transcript.tool_background`). The badge goes when the call's end reaches the transcript.
604
+
601
605
  A failed tool call in `ChatTranscript` shows its failure once: the row shows the message the model read, and the details show its `code`, `kind`, and `details`.
602
606
 
603
607
  `ChatTranscript` places `citation` blocks after the answer text by default (the Sources strip under the prose). Pass `bodyKindPlacement={{}}` when citations must stay in stream order between text segments (inline citations).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1000.g569f044",
3
+ "version": "0.3.5-next.1001.g68d8dcf",
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.1000.g569f044",
64
- "@theoremjs/web": "^0.3.5-next.1000.g569f044"
63
+ "@theoremjs/agents": "^0.3.5-next.1001.g68d8dcf",
64
+ "@theoremjs/web": "^0.3.5-next.1001.g68d8dcf"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -3,7 +3,7 @@ import { type AttachmentValidationIssue, type ComposerMenuAction, type ComposerP
3
3
  import type { ClientFailure } from '@theoremjs/web/client';
4
4
  import { type ReactNode } from 'react';
5
5
  import type { BackgroundJob } from '../client/transcript-groups.js';
6
- import { type ComposerRowIcons } from './ChatComposerRow.js';
6
+ import { type ComposerPill, type ComposerRowIcons } from './ChatComposerRow.js';
7
7
  /** An option the profile declares: its allowed values, the one chosen, and how to choose another. */
8
8
  /** The effort selector's icon. The studio's Agents list shows the same one. */
9
9
  export declare const EFFORT_ICON: import("react").ForwardRefExoticComponent<import("@tabler/icons-react").IconProps & import("react").RefAttributes<SVGSVGElement>>;
@@ -33,6 +33,8 @@ export type ChatComposerBarProps = {
33
33
  layout?: ComposerLayout;
34
34
  /** The tool calls running in the background; the `row` layout shows each as a pill. */
35
35
  backgroundJobs?: readonly BackgroundJob[];
36
+ /** The app's own pills; the `row` layout shows them after the background jobs. */
37
+ pills?: readonly ComposerPill[];
36
38
  /** When the reply in progress started, its approval waits skipped; the `row` layout's working pill counts from it. */
37
39
  workingSince?: number;
38
40
  /** Glyphs the `row` layout draws; each one left out keeps Theorem's. See {@link ComposerRowIcons}. */
@@ -19,7 +19,7 @@ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
19
19
  import { stageComposerFiles } from "../client/composer-attachments.js";
20
20
  import { useComposerVoice } from "../components/use-composer-voice.js";
21
21
  import { useEditorSelection } from "../components/use-editor-selection.js";
22
- import { ChatComposerRow } from "./ChatComposerRow.js";
22
+ import { ChatComposerRow, } from "./ChatComposerRow.js";
23
23
  import { ComposerControls, ComposerSelector } from "./ComposerControls.js";
24
24
  import { composerDrawerLabel } from "./labels.js";
25
25
  import { TheoremLabelsProvider, useLabels } from "./labels-provider.js";
@@ -423,7 +423,7 @@ function RowComposerBar({ props, parts, }) {
423
423
  // why: Stop lives on the working pill, so the button only sends; while a reply runs or a
424
424
  // step waits, a draft opens the send menu instead (Enter still queues).
425
425
  const opensMenu = props.phase !== 'idle' && parts.menuActions.length > 0;
426
- return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action: opensMenu ? (_jsx(SendMenu, { actions: parts.menuActions, phase: props.phase, onAction: props.onMenuAction, trigger: "send" })) : (_jsx(ChatSendButton, { isDisabled: parts.primaryDisabled || parts.primary === 'stop', onSend: parts.runPrimary })), status: parts.status }));
426
+ return (_jsx(ChatComposerRow, { isWorking: props.phase === 'streaming', workingSince: props.workingSince, icons: props.icons, backgroundJobs: props.backgroundJobs ?? [], pills: props.pills, onStop: props.onStop, hint: parts.hintNode, tray: parts.tray, attach: parts.attach, input: parts.input, editorRef: parts.editorRef, draftText: props.draftText, controls: parts.controls, record: parts.record, action: opensMenu ? (_jsx(SendMenu, { actions: parts.menuActions, phase: props.phase, onAction: props.onMenuAction, trigger: "send" })) : (_jsx(ChatSendButton, { isDisabled: parts.primaryDisabled || parts.primary === 'stop', onSend: parts.runPrimary })), status: parts.status }));
427
427
  }
428
428
  /** Today's layout: Astryx's ChatComposer. */
429
429
  function StackedComposerBar({ props, parts, }) {
@@ -14,6 +14,15 @@ export type ComposerRowIcons = {
14
14
  /** In the working pill's stop button. Default: a filled square. */
15
15
  stop?: ReactNode;
16
16
  };
17
+ /**
18
+ * A pill the app puts in the pill row after Theorem's own, drawn as they are: its words, and what
19
+ * a click does. One without `onSelect` only shows.
20
+ */
21
+ export type ComposerPill = {
22
+ id: string;
23
+ label: string;
24
+ onSelect?: () => void;
25
+ };
17
26
  /** What waits to send: the count and label for the tray's header, and the content it folds. */
18
27
  export type ComposerTray = {
19
28
  count: number;
@@ -22,12 +31,14 @@ export type ComposerTray = {
22
31
  };
23
32
  /** What the row composer draws; the bar works each piece out, so both layouts share it. */
24
33
  export type ComposerRowParts = {
25
- /** The pill row: the working pill while a reply runs, then the background jobs. */
34
+ /** The pill row: the working pill while a reply runs, then the background jobs, then `pills`. */
26
35
  isWorking: boolean;
27
36
  /** When the reply in progress started; the working pill counts from it. */
28
37
  workingSince?: number;
29
38
  icons?: ComposerRowIcons;
30
39
  backgroundJobs: readonly BackgroundJob[];
40
+ /** The app's own pills, after the background jobs. */
41
+ pills?: readonly ComposerPill[];
31
42
  onStop: () => void;
32
43
  /** Contextual hint, at the end of the pill row. */
33
44
  hint?: ReactNode;
@@ -49,6 +60,7 @@ export type ComposerRowParts = {
49
60
  /**
50
61
  * Theorem's one-row composer: the field, then the controls, the mic, and send, on one line.
51
62
  * Text that wraps moves the field onto its own line above them, the stacked layout. Above
52
- * it, the pill row: the reply in progress (stop is on its pill) and the background jobs.
63
+ * it, the pill row: the reply in progress (stop is on its pill), the background jobs, and the
64
+ * app's own pills.
53
65
  */
54
66
  export declare function ChatComposerRow(props: ComposerRowParts): import("react").JSX.Element;
@@ -106,6 +106,7 @@ function PillRow(props) {
106
106
  const pills = [
107
107
  props.isWorking ? (_jsx(WorkingPill, { since: props.workingSince, icons: props.icons, onStop: props.onStop }, "working")) : null,
108
108
  ...props.backgroundJobs.map((job) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "background", style: PILL, label: job.label, description: t('@theorem.composer.pill.background'), icon: props.icons?.backgroundJob ?? (_jsx(Spinner, { size: "sm", shade: "inherit", "aria-label": t('@theorem.composer.pill.background') })) }, job.callId))),
109
+ ...(props.pills ?? []).map((pill) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "app", style: PILL, label: pill.label, onClick: pill.onSelect }, pill.id))),
109
110
  ].filter(Boolean);
110
111
  if (pills.length === 0 && !props.hint)
111
112
  return null;
@@ -186,9 +187,10 @@ function RowStatus({ status }) {
186
187
  /**
187
188
  * Theorem's one-row composer: the field, then the controls, the mic, and send, on one line.
188
189
  * Text that wraps moves the field onto its own line above them, the stacked layout. Above
189
- * it, the pill row: the reply in progress (stop is on its pill) and the background jobs.
190
+ * it, the pill row: the reply in progress (stop is on its pill), the background jobs, and the
191
+ * app's own pills.
190
192
  */
191
193
  export function ChatComposerRow(props) {
192
194
  const stacked = useWrapped(props.editorRef, props.draftText);
193
- 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, 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 })] }));
195
+ 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 })] }));
194
196
  }
@@ -510,8 +510,15 @@ function toolCallItem(t, id, tool, shows) {
510
510
  ...rowDetail(t, tool, shows, state.output === undefined ? undefined : (_jsx(ShapedData, { value: state.output, title: t('@theorem.transcript.tool_output') }))),
511
511
  };
512
512
  case 'running':
513
- case 'background':
514
513
  return { ...base, status: 'running', ...rowDetail(t, tool, shows) };
514
+ // why: The reply ended and the call goes on; the row says so until its end comes back.
515
+ case 'background':
516
+ return {
517
+ ...base,
518
+ status: 'running',
519
+ node: t('@theorem.transcript.tool_background'),
520
+ ...rowDetail(t, tool, shows),
521
+ };
515
522
  default:
516
523
  return { ...base, status: 'pending', ...rowDetail(t, tool, shows) };
517
524
  }
@@ -6,7 +6,7 @@ import { type ConversationView, type HttpTransportOptions, type TheoremTransport
6
6
  import { type ReactNode, type Ref } from 'react';
7
7
  import { type SendTextOptions, type SentTurn, type TheoremChatState, type UseTheoremChatOptions } from '../hooks/use-theorem-chat.js';
8
8
  import { type ComposerLayout } from './ChatComposerBar.js';
9
- import type { ComposerRowIcons } from './ChatComposerRow.js';
9
+ import type { ComposerPill, ComposerRowIcons } from './ChatComposerRow.js';
10
10
  import { type ChatTranscriptProps } from './ChatTranscript.js';
11
11
  import type { TheoremLabels } from './labels.js';
12
12
  import type { MediaViewer } from './media-viewer.js';
@@ -180,13 +180,15 @@ export type TheoremChatComposerProps = {
180
180
  inputRef?: Ref<ChatComposerInputHandle>;
181
181
  layout?: ComposerLayout;
182
182
  icons?: ComposerRowIcons;
183
+ /** The app's own pills, in the `row` layout's pill row after the background jobs. */
184
+ pills?: readonly ComposerPill[];
183
185
  };
184
186
  /**
185
187
  * The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
186
188
  * working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
187
189
  * `TheoremChatTranscript`.
188
190
  */
189
- export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, }: TheoremChatComposerProps): import("react").JSX.Element;
191
+ export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, }: TheoremChatComposerProps): import("react").JSX.Element;
190
192
  export type TheoremChatTranscriptProps = Omit<ChatTranscriptProps, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
191
193
  /** The chat it shows (`useTheoremChat`). */
192
194
  chat: TheoremChatState;
package/ui/TheoremChat.js CHANGED
@@ -33,8 +33,8 @@ function ChatColumn({ maxWidth, ref, children, }) {
33
33
  * working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
34
34
  * `TheoremChatTranscript`.
35
35
  */
36
- export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, }) {
37
- return (_jsx(ChatComposerBar, { iface: iface, layout: layout, icons: icons, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
36
+ export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, }) {
37
+ return (_jsx(ChatComposerBar, { iface: iface, layout: layout, icons: icons, pills: pills, workingSince: chat.workingSince, backgroundJobs: chat.backgroundJobs, draftText: chat.draftText, pendingFiles: chat.pendingFiles, pendingVoice: chat.pendingVoice, pendingMessages: chat.pendingMessages, issues: chat.issues, phase: chat.phase, failure: chat.failure, selectedModel: chat.session.selectedModel, selectedEffort: chat.session.selectedEffort, placeholder: placeholder, inputRef: inputRef, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
38
38
  chat.setPendingFiles((prev) => [...prev, ...files]);
39
39
  chat.setIssues([]);
40
40
  }, onAttachmentRemove: (index) => {
package/ui/index.d.ts CHANGED
@@ -16,7 +16,7 @@ export { InkWaveform, type InkWaveformProps, type InkWaveLevels, } from '../comp
16
16
  export { type LiveCall, type LiveCallInput, useLiveCall, } from '../components/live/use-live-call.js';
17
17
  export { theoremTheme } from './built/theorem.js';
18
18
  export { ChatComposerBar, type ChatComposerBarProps, type ComposerLayout, EFFORT_ICON, generationOptions, type LiveComposerBarProps, } from './ChatComposerBar.js';
19
- export type { ComposerRowIcons } from './ChatComposerRow.js';
19
+ export type { ComposerPill, ComposerRowIcons } from './ChatComposerRow.js';
20
20
  export { ChatTranscript, type ChatTranscriptProps } from './ChatTranscript.js';
21
21
  export { ConsoleFrame, type ConsoleFrameProps, type ConsolePageProps, RequestCard, ResponseColumn, RunBar, useBytes, } from './ConsoleFrame.js';
22
22
  export { TheoremDecisionAnswers, type TheoremDecisionAnswersProps } from './DecisionAnswers.js';
package/ui/labels.d.ts CHANGED
@@ -285,6 +285,10 @@ export declare const THEOREM_UI_CATALOG: {
285
285
  readonly defaultMessage: "Calls";
286
286
  readonly description: "The calls the agent an agent tool ran made, in its detail.";
287
287
  };
288
+ readonly '@theorem.transcript.tool_background': {
289
+ readonly defaultMessage: "Background task";
290
+ readonly description: "The badge on a tool call's row while it runs on in the background.";
291
+ };
288
292
  readonly '@theorem.transcript.tool_output': {
289
293
  readonly defaultMessage: "Output";
290
294
  readonly description: "A tool call's result, in its detail.";
package/ui/labels.js CHANGED
@@ -269,6 +269,10 @@ export const THEOREM_UI_CATALOG = {
269
269
  defaultMessage: 'Calls',
270
270
  description: 'The calls the agent an agent tool ran made, in its detail.',
271
271
  },
272
+ '@theorem.transcript.tool_background': {
273
+ defaultMessage: 'Background task',
274
+ description: "The badge on a tool call's row while it runs on in the background.",
275
+ },
272
276
  '@theorem.transcript.tool_output': {
273
277
  defaultMessage: 'Output',
274
278
  description: "A tool call's result, in its detail.",