@theoremjs/react 0.3.5-next.1002.g355bde0 → 0.3.5-next.1004.gd674e6b
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
|
@@ -590,9 +590,9 @@ function Dock({ chat, iface }) {
|
|
|
590
590
|
}
|
|
591
591
|
```
|
|
592
592
|
|
|
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 `
|
|
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`, `showToolDurations`, and `showWorkStatus`. 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
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.
|
|
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, 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.
|
|
596
596
|
|
|
597
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`.
|
|
598
598
|
|
|
@@ -615,6 +615,8 @@ A failed tool call in `ChatTranscript` shows its failure once: the row shows the
|
|
|
615
615
|
|
|
616
616
|
Pass `showToolDurations={false}` to leave out how long each call ran.
|
|
617
617
|
|
|
618
|
+
Pass `showWorkStatus={false}` to leave out a reply's work status ("Working for 12s", "Worked for 3.5s"). A reply whose steps fold under the status keeps it as the fold's trigger, without the time ("Worked"). Any other reply shows none.
|
|
619
|
+
|
|
618
620
|
The hooks and the client write no English text. They return kinds, codes, and states. You write the words.
|
|
619
621
|
|
|
620
622
|
- A failure is a `ClientFailure`: `{ error, errorKind, errorInternal? }`. Show `error` to the user. It is the wording of the profile. `errorKind` and `errorInternal` are for your code.
|
|
@@ -92,11 +92,17 @@ export type WorkStatus = {
|
|
|
92
92
|
phase: 'working' | 'worked';
|
|
93
93
|
elapsedMs?: number;
|
|
94
94
|
};
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Working while streaming; worked after, when it has a duration or steps; else nothing to show.
|
|
97
|
+
* With `shown: false` (`ChatTranscriptProps.showWorkStatus`), only a reply whose steps fold under
|
|
98
|
+
* the status (`folds`) has one, as the fold's trigger, without its time.
|
|
99
|
+
*/
|
|
96
100
|
export declare function workStatus(args: {
|
|
97
101
|
streaming: boolean;
|
|
98
102
|
hasSteps: boolean;
|
|
99
103
|
elapsedMs?: number;
|
|
104
|
+
shown?: boolean;
|
|
105
|
+
folds?: boolean;
|
|
100
106
|
}): WorkStatus | null;
|
|
101
107
|
/**
|
|
102
108
|
* Split an assistant turn into Seance-style trace + final body.
|
|
@@ -108,8 +108,16 @@ export function assistantTurnCopyText(blocks) {
|
|
|
108
108
|
.filter(Boolean)
|
|
109
109
|
.join('\n\n');
|
|
110
110
|
}
|
|
111
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* Working while streaming; worked after, when it has a duration or steps; else nothing to show.
|
|
113
|
+
* With `shown: false` (`ChatTranscriptProps.showWorkStatus`), only a reply whose steps fold under
|
|
114
|
+
* the status (`folds`) has one, as the fold's trigger, without its time.
|
|
115
|
+
*/
|
|
112
116
|
export function workStatus(args) {
|
|
117
|
+
if (args.shown === false) {
|
|
118
|
+
const work = workStatus({ streaming: args.streaming, hasSteps: args.hasSteps });
|
|
119
|
+
return args.folds && work ? { phase: work.phase } : null;
|
|
120
|
+
}
|
|
113
121
|
const elapsed = args.elapsedMs !== undefined ? { elapsedMs: args.elapsedMs } : {};
|
|
114
122
|
if (args.streaming)
|
|
115
123
|
return { phase: 'working', ...elapsed };
|
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.1004.gd674e6b",
|
|
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.1004.gd674e6b",
|
|
64
|
+
"@theoremjs/web": "^0.3.5-next.1004.gd674e6b"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatComposerRow.d.ts
CHANGED
|
@@ -15,12 +15,13 @@ export type ComposerRowIcons = {
|
|
|
15
15
|
stop?: ReactNode;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* A pill the app puts in the pill row after Theorem's own, drawn as they are: its
|
|
19
|
-
* a click does. One without `onSelect` only shows.
|
|
18
|
+
* A pill the app puts in the pill row after Theorem's own, drawn as they are: its icon, its words,
|
|
19
|
+
* and what a click does. One without `icon` has words only; one without `onSelect` only shows.
|
|
20
20
|
*/
|
|
21
21
|
export type ComposerPill = {
|
|
22
22
|
id: string;
|
|
23
23
|
label: string;
|
|
24
|
+
icon?: ReactNode;
|
|
24
25
|
onSelect?: () => void;
|
|
25
26
|
};
|
|
26
27
|
/** What waits to send: the count and label for the tray's header, and the content it folds. */
|
package/ui/ChatComposerRow.js
CHANGED
|
@@ -106,7 +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
|
+
...(props.pills ?? []).map((pill) => (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "app", style: PILL, label: pill.label, icon: pill.icon, onClick: pill.onSelect }, pill.id))),
|
|
110
110
|
].filter(Boolean);
|
|
111
111
|
if (pills.length === 0 && !props.hint)
|
|
112
112
|
return null;
|
package/ui/ChatTranscript.d.ts
CHANGED
|
@@ -60,6 +60,12 @@ export type ChatTranscriptProps = {
|
|
|
60
60
|
stepLayout?: StepLayout;
|
|
61
61
|
/** Whether a finished tool call's row shows how long it ran. Default: true. */
|
|
62
62
|
showToolDurations?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Whether a reply shows its work status ("Working for 12s", "Worked for 3.5s"). Default: true.
|
|
65
|
+
* With `false`, a reply whose steps fold under the status keeps it as the fold's trigger, without
|
|
66
|
+
* the time ("Worked"); any other reply shows none.
|
|
67
|
+
*/
|
|
68
|
+
showWorkStatus?: boolean;
|
|
63
69
|
/** The profile's labels (`iface.labels`): a stopped turn says why in its words. */
|
|
64
70
|
labels?: LabelOverrides;
|
|
65
71
|
};
|
package/ui/ChatTranscript.js
CHANGED
|
@@ -42,6 +42,8 @@ const ShowUsage = createContext(false);
|
|
|
42
42
|
const ShowToolData = createContext(true);
|
|
43
43
|
/** Whether a finished tool call's row shows how long it ran (`ChatTranscriptProps.showToolDurations`). */
|
|
44
44
|
const ShowToolDurations = createContext(true);
|
|
45
|
+
/** Whether a reply shows its work status (`ChatTranscriptProps.showWorkStatus`). */
|
|
46
|
+
const ShowWorkStatus = createContext(true);
|
|
45
47
|
/** What the transcript's props say a tool call's row shows. */
|
|
46
48
|
function useToolRowShows() {
|
|
47
49
|
return {
|
|
@@ -660,7 +662,14 @@ function AssistantTurn(props) {
|
|
|
660
662
|
});
|
|
661
663
|
const { shown } = useToolMedia();
|
|
662
664
|
const rows = bodyRows(t, body, shown);
|
|
663
|
-
const
|
|
665
|
+
const statusShown = useContext(ShowWorkStatus);
|
|
666
|
+
const status = workStatusLabel(t, workStatus({
|
|
667
|
+
streaming: props.streaming,
|
|
668
|
+
hasSteps,
|
|
669
|
+
elapsedMs,
|
|
670
|
+
shown: statusShown,
|
|
671
|
+
folds: hasTrace,
|
|
672
|
+
}));
|
|
664
673
|
const copyText = assistantTurnCopyText(body.length > 0 ? body : props.blocks);
|
|
665
674
|
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'
|
|
666
675
|
? row.kind
|
|
@@ -693,7 +702,7 @@ function isBareFailure(group) {
|
|
|
693
702
|
}
|
|
694
703
|
/** Theorem transcript blocks rendered as Astryx chat messages. */
|
|
695
704
|
export function ChatTranscript(props) {
|
|
696
|
-
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(ChatTranscriptBody, { ...props }) }) }) }) }));
|
|
705
|
+
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 }) }) }) }) }) }));
|
|
697
706
|
}
|
|
698
707
|
function ChatTranscriptBody({ blocks, handle, streaming = false, delivery, onToolDecision, answering = null, onAuthenticated, emptyState, dividers, imageOutput, bodyKindPlacement, stepLayout, labels, clock, }) {
|
|
699
708
|
const groups = useMemo(() => groupTranscriptBlocks(blocks, dividers && new Set(Object.keys(dividers))), [blocks, dividers]);
|