@theoremjs/react 0.3.5-next.1010.g514118e → 0.3.5-next.1012.g714018f

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1010.g514118e",
3
+ "version": "0.3.5-next.1012.g714018f",
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.1010.g514118e",
64
- "@theoremjs/web": "^0.3.5-next.1010.g514118e"
63
+ "@theoremjs/agents": "^0.3.5-next.1012.g714018f",
64
+ "@theoremjs/web": "^0.3.5-next.1012.g714018f"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -66,6 +66,12 @@ export type ChatTranscriptProps = {
66
66
  * the time ("Worked"); any other reply shows none.
67
67
  */
68
68
  showWorkStatus?: boolean;
69
+ /**
70
+ * Whether a reply whose model call failed part-way, and went on from the words it had shown,
71
+ * shows the profile's notice in its status row, beside its time ("This reply was interrupted and
72
+ * picked up where it left off."). Default: true.
73
+ */
74
+ showResumedNotice?: boolean;
69
75
  /** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
70
76
  labels?: LabelOverrides;
71
77
  };
@@ -44,6 +44,8 @@ const ShowToolData = createContext(true);
44
44
  const ShowToolDurations = createContext(true);
45
45
  /** Whether a reply shows its work status (`ChatTranscriptProps.showWorkStatus`). */
46
46
  const ShowWorkStatus = createContext(true);
47
+ /** Whether a reply that went on after its call failed shows its notice (`ChatTranscriptProps.showResumedNotice`). */
48
+ const ShowResumedNotice = createContext(true);
47
49
  /** What the transcript's props say a tool call's row shows. */
48
50
  function useToolRowShows() {
49
51
  return {
@@ -91,6 +93,10 @@ function Usage({ tokens }) {
91
93
  return usageLine(useLabels(), useLocale(), tokens);
92
94
  }
93
95
  /** Why a turn stopped short, drawn as the delivery statuses are. */
96
+ /** That a reply went on after its model call failed part-way, drawn as a stop is. */
97
+ function Resumed({ label }) {
98
+ return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(Icon, { icon: "info", size: "xsm", color: "inherit" }), _jsx("span", { children: label })] }));
99
+ }
94
100
  function Stopped({ label }) {
95
101
  return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(Icon, { icon: "stop", size: "xsm", color: "inherit" }), _jsx("span", { children: label })] }));
96
102
  }
@@ -176,19 +182,21 @@ function useFresh(isNewest, status) {
176
182
  }
177
183
  /** A message's copy button (outermost), time and status; a failure says why on hovering its status. */
178
184
  function MessageChrome(props) {
179
- const notice = turnNotice(props.error, props.stopped);
185
+ const notice = turnNotice(props.error, props.stopped, props.resumed);
180
186
  return (_jsx(ChatMessageMetadata, { style: { opacity: props.revealed ? 1 : 0, transition: CHROME_FADE },
181
187
  // why: The row's first slot is the one nearest the margin.
182
188
  timestamp: _jsx(CopyAndTime, { sender: props.sender, at: props.at, copyText: props.copyText }),
183
189
  // why: Astryx's statuses are a closed set, so these ride the footer.
184
190
  footer: notice ?? (props.usage ? _jsx(Usage, { tokens: props.usage }) : undefined), status: notice === undefined ? props.status : undefined }));
185
191
  }
186
- /** Why a turn failed or stopped short, said where its status goes. */
187
- function turnNotice(error, stopped) {
192
+ /** Why a turn failed, stopped short, or went on after a failed call, said where its status goes. */
193
+ function turnNotice(error, stopped, resumed) {
188
194
  if (error !== undefined)
189
195
  return _jsx(Failed, { reason: error });
190
196
  if (stopped !== undefined)
191
197
  return _jsx(Stopped, { label: stopped });
198
+ if (resumed !== undefined)
199
+ return _jsx(Resumed, { label: resumed });
192
200
  return undefined;
193
201
  }
194
202
  function dataUrl(mimeType, data) {
@@ -436,9 +444,13 @@ function BodyBlock({ block, streaming }) {
436
444
  return _jsx(ThoughtLine, { text: block.text, streaming: streaming });
437
445
  return _jsx(ResultBlock, { block: block });
438
446
  }
439
- /** Non-streaming answer rows: errors, structured output, and media. Citations coalesce in bodyRows. */
447
+ /**
448
+ * Non-streaming answer rows: structured output and media. Errors, and the notice of a reply that
449
+ * went on after its call failed, show on the message's status; citations coalesce in bodyRows.
450
+ */
440
451
  function ResultBlock({ block }) {
441
452
  switch (block.kind) {
453
+ case 'resumed':
442
454
  case 'error':
443
455
  case 'citation':
444
456
  return null;
@@ -661,6 +673,8 @@ function AssistantTurn(props) {
661
673
  const t = useLabels();
662
674
  const chrome = useChromeReveal(props.isNewest === true);
663
675
  const showUsage = useContext(ShowUsage);
676
+ const showResumed = useContext(ShowResumedNotice);
677
+ const resumed = showResumed ? resumedNotice(props.blocks) : undefined;
664
678
  const elapsedMs = useTurnElapsed(props.streaming, props.startedAt, props.workedMs);
665
679
  const { trace, gatedTools, body, hasTrace, hasSteps } = composeAssistantTurn(props.blocks, {
666
680
  ...(props.bodyKindPlacement !== undefined
@@ -679,13 +693,20 @@ function AssistantTurn(props) {
679
693
  folds: hasTrace,
680
694
  }));
681
695
  const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
682
- 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, 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'
696
+ 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'
683
697
  ? row.kind
684
698
  : row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
685
699
  // why: Not the block id: the committed turn re-mints ids, and a
686
700
  // remount would cut the text reveal short.
687
701
  , { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows })] }) }));
688
702
  }
703
+ /** The notice of a reply that went on after its model call failed part-way, if it did. */
704
+ function resumedNotice(blocks) {
705
+ for (const block of blocks)
706
+ if (block.kind === 'resumed')
707
+ return block.message;
708
+ return undefined;
709
+ }
689
710
  function UserTurn(props) {
690
711
  const t = useLabels();
691
712
  const reveal = useChromeReveal(props.isNewest === true, props.status);
@@ -710,7 +731,7 @@ function isBareFailure(group) {
710
731
  }
711
732
  /** Theorem transcript blocks rendered as Astryx chat messages. */
712
733
  export function ChatTranscript(props) {
713
- return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, 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(ChatTranscriptBody, { ...props }) }) }) }) }) }));
734
+ return (_jsx(TheoremLabelsProvider, { children: _jsx(ShowUsage.Provider, { value: props.usage === true, 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 }) }) }) }) }) }) }));
714
735
  }
715
736
  function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
716
737
  const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
@@ -34,6 +34,7 @@ export function transcriptBlockCopyText(t, block) {
34
34
  case 'error':
35
35
  return block.message;
36
36
  case 'guardrail':
37
+ case 'resumed':
37
38
  case 'late-results':
38
39
  case 'turn-done':
39
40
  return '';