@theoremjs/react 0.3.5-next.1011.gfbc6c42 → 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 +3 -3
- package/ui/ChatTranscript.d.ts +2 -2
- package/ui/ChatTranscript.js +21 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.5-next.
|
|
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.
|
|
64
|
-
"@theoremjs/web": "^0.3.5-next.
|
|
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": {
|
package/ui/ChatTranscript.d.ts
CHANGED
|
@@ -68,8 +68,8 @@ export type ChatTranscriptProps = {
|
|
|
68
68
|
showWorkStatus?: boolean;
|
|
69
69
|
/**
|
|
70
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
|
|
72
|
-
* left off."). Default: true.
|
|
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
73
|
*/
|
|
74
74
|
showResumedNotice?: boolean;
|
|
75
75
|
/** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
|
package/ui/ChatTranscript.js
CHANGED
|
@@ -93,6 +93,10 @@ function Usage({ tokens }) {
|
|
|
93
93
|
return usageLine(useLabels(), useLocale(), tokens);
|
|
94
94
|
}
|
|
95
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
|
+
}
|
|
96
100
|
function Stopped({ label }) {
|
|
97
101
|
return (_jsxs(HStack, { gap: 1, vAlign: "center", children: [_jsx(Icon, { icon: "stop", size: "xsm", color: "inherit" }), _jsx("span", { children: label })] }));
|
|
98
102
|
}
|
|
@@ -178,19 +182,21 @@ function useFresh(isNewest, status) {
|
|
|
178
182
|
}
|
|
179
183
|
/** A message's copy button (outermost), time and status; a failure says why on hovering its status. */
|
|
180
184
|
function MessageChrome(props) {
|
|
181
|
-
const notice = turnNotice(props.error, props.stopped);
|
|
185
|
+
const notice = turnNotice(props.error, props.stopped, props.resumed);
|
|
182
186
|
return (_jsx(ChatMessageMetadata, { style: { opacity: props.revealed ? 1 : 0, transition: CHROME_FADE },
|
|
183
187
|
// why: The row's first slot is the one nearest the margin.
|
|
184
188
|
timestamp: _jsx(CopyAndTime, { sender: props.sender, at: props.at, copyText: props.copyText }),
|
|
185
189
|
// why: Astryx's statuses are a closed set, so these ride the footer.
|
|
186
190
|
footer: notice ?? (props.usage ? _jsx(Usage, { tokens: props.usage }) : undefined), status: notice === undefined ? props.status : undefined }));
|
|
187
191
|
}
|
|
188
|
-
/** Why a turn failed
|
|
189
|
-
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) {
|
|
190
194
|
if (error !== undefined)
|
|
191
195
|
return _jsx(Failed, { reason: error });
|
|
192
196
|
if (stopped !== undefined)
|
|
193
197
|
return _jsx(Stopped, { label: stopped });
|
|
198
|
+
if (resumed !== undefined)
|
|
199
|
+
return _jsx(Resumed, { label: resumed });
|
|
194
200
|
return undefined;
|
|
195
201
|
}
|
|
196
202
|
function dataUrl(mimeType, data) {
|
|
@@ -439,14 +445,12 @@ function BodyBlock({ block, streaming }) {
|
|
|
439
445
|
return _jsx(ResultBlock, { block: block });
|
|
440
446
|
}
|
|
441
447
|
/**
|
|
442
|
-
* Non-streaming answer rows: structured output
|
|
443
|
-
* its call failed
|
|
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.
|
|
444
450
|
*/
|
|
445
451
|
function ResultBlock({ block }) {
|
|
446
|
-
const showResumed = useContext(ShowResumedNotice);
|
|
447
452
|
switch (block.kind) {
|
|
448
453
|
case 'resumed':
|
|
449
|
-
return showResumed ? (_jsx(Text, { size: "sm", color: "secondary", children: block.message })) : null;
|
|
450
454
|
case 'error':
|
|
451
455
|
case 'citation':
|
|
452
456
|
return null;
|
|
@@ -669,6 +673,8 @@ function AssistantTurn(props) {
|
|
|
669
673
|
const t = useLabels();
|
|
670
674
|
const chrome = useChromeReveal(props.isNewest === true);
|
|
671
675
|
const showUsage = useContext(ShowUsage);
|
|
676
|
+
const showResumed = useContext(ShowResumedNotice);
|
|
677
|
+
const resumed = showResumed ? resumedNotice(props.blocks) : undefined;
|
|
672
678
|
const elapsedMs = useTurnElapsed(props.streaming, props.startedAt, props.workedMs);
|
|
673
679
|
const { trace, gatedTools, body, hasTrace, hasSteps } = composeAssistantTurn(props.blocks, {
|
|
674
680
|
...(props.bodyKindPlacement !== undefined
|
|
@@ -687,13 +693,20 @@ function AssistantTurn(props) {
|
|
|
687
693
|
folds: hasTrace,
|
|
688
694
|
}));
|
|
689
695
|
const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
|
|
690
|
-
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'
|
|
691
697
|
? row.kind
|
|
692
698
|
: row.block.kind).map(({ item: row, index: i, key }) => (_jsx(BodyRowView
|
|
693
699
|
// why: Not the block id: the committed turn re-mints ids, and a
|
|
694
700
|
// remount would cut the text reveal short.
|
|
695
701
|
, { row: row, streaming: props.streaming && i === rows.length - 1, imageOutput: props.imageOutput }, key))), _jsx(PendingImage, { imageOutput: props.imageOutput, streaming: props.streaming, rows: rows })] }) }));
|
|
696
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
|
+
}
|
|
697
710
|
function UserTurn(props) {
|
|
698
711
|
const t = useLabels();
|
|
699
712
|
const reveal = useChromeReveal(props.isNewest === true, props.status);
|