@theoremjs/react 0.3.5-next.1035.g7656c60 → 0.3.5-next.1036.g513f336

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,6 +179,7 @@ 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
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). |
183
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). |
184
185
  | `resolveMedia` | Turns a tool's reference into an address the page can load. See [Tool media](#tool-media). |
@@ -734,7 +735,7 @@ function Dock({ chat, iface }) {
734
735
  }
735
736
  ```
736
737
 
737
- `TheoremChatComposer` takes `layout`, `icons`, `pills`, `placeholder`, `inputRef`, `inputComponent`, `triggers`, `refText`, and `renderRef`. 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`.
738
+ `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`.
738
739
 
739
740
  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.
740
741
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1035.g7656c60",
3
+ "version": "0.3.5-next.1036.g513f336",
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.1035.g7656c60",
64
- "@theoremjs/web": "^0.3.5-next.1035.g7656c60"
63
+ "@theoremjs/agents": "^0.3.5-next.1036.g513f336",
64
+ "@theoremjs/web": "^0.3.5-next.1036.g513f336"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -1,4 +1,4 @@
1
- import { ChatComposerInput, type ChatComposerInputHandle, type ChatComposerTrigger } from '@astryxdesign/core/Chat';
1
+ import { ChatComposerInput, type ChatComposerInputHandle, type ChatComposerStatus, type ChatComposerTrigger } from '@astryxdesign/core/Chat';
2
2
  import type { RefText, UserPart, UserRef } from '@theoremjs/agents/interface';
3
3
  import { type AttachmentValidationIssue, type ComposerMenuAction, type ComposerPendingMessage, type ComposerProfileInterface, type ComposerRunPhase, type LiveProfileInterface } from '@theoremjs/agents/interface';
4
4
  import type { ClientFailure } from '@theoremjs/web/client';
@@ -93,6 +93,12 @@ export type ChatComposerBarProps = {
93
93
  * starts a call. Never replaces stop or the send menu. Omit to keep the send button.
94
94
  */
95
95
  emptyAction?: ReactNode;
96
+ /**
97
+ * Draws the composer's problem: a send that failed (`error`), or files and a voice note it
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.
100
+ */
101
+ renderStatus?: (status: ChatComposerStatus) => ReactNode;
96
102
  };
97
103
  /** A Live call's text line: it is sent as typed, so there is nothing to attach, queue, or stop. */
98
104
  export type LiveComposerBarProps = Omit<Pick<ChatComposerBarProps, 'draftText' | 'placeholder' | 'inputRef' | 'inputComponent' | 'triggers' | 'draftParts' | 'onDraftPartsChange' | 'refText' | 'renderRef' | 'onDraftTextChange' | 'onSubmit' | 'emptyAction'>, 'onSubmit'> & {
@@ -453,12 +453,13 @@ function RowComposerBar({ props, parts, }) {
453
453
  hasPayload: parts.hasPayload,
454
454
  primary: parts.primary,
455
455
  opensMenu,
456
- }) ? (props.emptyAction) : 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 }));
456
+ }) ? (props.emptyAction) : 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, renderStatus: props.renderStatus }));
457
457
  }
458
458
  /** Today's layout: Astryx's ChatComposer. */
459
459
  function StackedComposerBar({ props, parts, }) {
460
460
  const isStopShown = parts.primary === 'stop';
461
- return (_jsx(ChatComposer
461
+ const hostStatus = parts.status && props.renderStatus?.(parts.status);
462
+ const composer = (_jsx(ChatComposer
462
463
  // why: No keyboard focus ring on the composer (product choice): zero Astryx's
463
464
  // focus-outline token for this subtree. The editor still shows its caret.
464
465
  , {
@@ -471,5 +472,9 @@ function StackedComposerBar({ props, parts, }) {
471
472
  hasPayload: parts.hasPayload,
472
473
  primary: parts.primary,
473
474
  opensMenu: false,
474
- }) ? (props.emptyAction) : (_jsx(ChatSendButton, { isStopShown: isStopShown, isDisabled: parts.primaryDisabled, onSend: parts.runPrimary, onStop: props.onStop })), status: parts.status }));
475
+ }) ? (props.emptyAction) : (_jsx(ChatSendButton, { isStopShown: isStopShown, isDisabled: parts.primaryDisabled, onSend: parts.runPrimary, onStop: props.onStop })), status: props.renderStatus ? undefined : parts.status }));
476
+ // why: Astryx's composer draws only its own status, so the host's goes under it, where Astryx's sits.
477
+ if (!hostStatus)
478
+ return composer;
479
+ return (_jsxs(VStack, { gap: 2, width: "100%", children: [composer, hostStatus] }));
475
480
  }
@@ -57,6 +57,8 @@ 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. */
61
+ renderStatus?: (status: ChatComposerStatus) => ReactNode;
60
62
  };
61
63
  /**
62
64
  * Theorem's one-row composer: the field, then the controls, the mic, and send, on one line.
@@ -181,9 +181,11 @@ function RowSurface(props) {
181
181
  const attach = props.attach ? _jsx(StackItem, { children: props.attach }) : null;
182
182
  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
183
  }
184
- function RowStatus({ status }) {
184
+ function RowStatus({ status, renderStatus }) {
185
185
  if (!status)
186
186
  return null;
187
+ if (renderStatus)
188
+ return renderStatus(status);
187
189
  return (_jsx(Banner, { status: status.type, role: status.type === 'error' ? 'alert' : 'status', title: status.message }));
188
190
  }
189
191
  /**
@@ -194,5 +196,5 @@ function RowStatus({ status }) {
194
196
  */
195
197
  export function ChatComposerRow(props) {
196
198
  const stacked = useWrapped(props.editorRef, props.draftText);
197
- 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 })] }));
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 })] }));
198
200
  }
@@ -1,4 +1,4 @@
1
- import { type ChatComposerInputHandle, type ChatComposerTrigger } from '@astryxdesign/core/Chat';
1
+ import { type ChatComposerInputHandle, type ChatComposerStatus, type ChatComposerTrigger } from '@astryxdesign/core/Chat';
2
2
  import type { DefinedTheme } from '@astryxdesign/core/theme';
3
3
  import type { RefText, UserRef } from '@theoremjs/agents/interface';
4
4
  import { type ComposerPendingMessage, type ComposerProfileInterface } from '@theoremjs/agents/interface';
@@ -160,6 +160,8 @@ 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`. */
164
+ renderComposerStatus?: (status: ChatComposerStatus) => ReactNode;
163
165
  /**
164
166
  * The transcript's own options, given to {@link TheoremChatTranscript} as they are: its `slots`,
165
167
  * such as the `reply` slot, and how it lays out a reply. `Host` is the type of the values your
@@ -216,13 +218,15 @@ export type TheoremChatComposerProps = {
216
218
  pills?: readonly ComposerPill[];
217
219
  /** Stands in for the send button while the composer is empty; see `ChatComposerBarProps.emptyAction`. */
218
220
  emptyAction?: ReactNode;
221
+ /** Draws the composer's problem in place of Astryx's; see `ChatComposerBarProps.renderStatus`. */
222
+ renderStatus?: (status: ChatComposerStatus) => ReactNode;
219
223
  };
220
224
  /**
221
225
  * The composer bound to a chat: drafts, files, voice, the pending queue, send and stop, and the
222
226
  * working pill on the chat's turn clock. Place it anywhere; `TheoremChat` is built from it and
223
227
  * `TheoremChatTranscript`.
224
228
  */
225
- export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, }: TheoremChatComposerProps): import("react").JSX.Element;
229
+ export declare function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, }: TheoremChatComposerProps): import("react").JSX.Element;
226
230
  export type TheoremChatTranscriptProps<Host extends JsonObject = JsonObject> = Omit<ChatTranscriptProps<Host>, 'blocks' | 'handle' | 'streaming' | 'delivery' | 'answering' | 'clock' | 'onToolDecision' | 'onAuthenticated' | 'imageOutput' | 'labels' | 'showToolData'> & {
227
231
  /** The chat it shows (`useTheoremChat`). */
228
232
  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, pills, inputComponent, triggers, refText, renderRef, emptyAction, }) {
37
- return (_jsx(ChatComposerBar, { emptyAction: emptyAction, 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, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
36
+ export function TheoremChatComposer({ chat, iface, placeholder, inputRef, layout, icons, pills, inputComponent, triggers, refText, renderRef, emptyAction, renderStatus, }) {
37
+ return (_jsx(ChatComposerBar, { emptyAction: emptyAction, renderStatus: renderStatus, 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, inputComponent: inputComponent, triggers: triggers, refText: refText, renderRef: renderRef, draftParts: chat.draftParts, onDraftPartsChange: chat.setDraftParts, onDraftTextChange: chat.setDraftText, onFilesSelected: (files) => {
38
38
  chat.setPendingFiles((prev) => [...prev, ...files]);
39
39
  chat.setIssues([]);
40
40
  }, onAttachmentRemove: (index) => {
@@ -71,7 +71,7 @@ function useChatHandle(chatRef, chat) {
71
71
  /** The composer, or, with none, the failed turn's error where the composer was. */
72
72
  function ChatBodyComposer({ body, chat, inputRef, }) {
73
73
  if (body.composer ?? true)
74
- return (_jsx(TheoremChatComposer, { chat: chat, iface: body.iface, placeholder: body.placeholder, inputRef: inputRef, layout: body.composerLayout, icons: body.composerIcons, inputComponent: body.composerInput, triggers: body.composerTriggers, refText: body.refText, renderRef: body.renderRef, emptyAction: body.composerEmptyAction }));
74
+ return (_jsx(TheoremChatComposer, { chat: chat, iface: body.iface, placeholder: body.placeholder, inputRef: inputRef, layout: body.composerLayout, icons: body.composerIcons, inputComponent: body.composerInput, triggers: body.composerTriggers, refText: body.refText, renderRef: body.renderRef, emptyAction: body.composerEmptyAction, renderStatus: body.renderComposerStatus }));
75
75
  const failure = chat.failure;
76
76
  return failure ? _jsx(Banner, { status: "error", role: "alert", title: failure.error }) : null;
77
77
  }