@theoremjs/react 0.3.5-next.1045.gcc305fe → 0.3.5-next.1047.gb68ee87

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
@@ -213,7 +213,8 @@ Each part of the look is a CSS custom property. Set it on any element above the
213
213
  | `--theorem-composer-pill-fill` | The fill of each pill. | the surface's fill |
214
214
  | `--theorem-composer-pill-shadow` | The shadow of each pill. | the surface's shadow |
215
215
  | `--theorem-composer-pill-end-padding` | The space between the working pill's stop button and the pill's end. | half the pill's height less the stop button's, so the same ring of space goes round the button |
216
- | `--theorem-composer-pill-align` | Where one pill sits in the row, as `justify-content`. Two or more pills start at the row's start, and scroll once they do not fit. | `center` |
216
+ | `--theorem-composer-pill-align` | Where the pills sit in the row, as `justify-content`. Pills that do not fit start at the row's start and scroll. | `center` |
217
+ | `--theorem-composer-pill-shadow-room` | How far the pill shadow reaches past a pill. The row keeps that much room, so the shadow is not cut. Raise it with a larger `pill-shadow`. | `var(--spacing-3)` |
217
218
 
218
219
  ```tsx
219
220
  <TheoremChat
@@ -865,16 +866,19 @@ These rules apply:
865
866
 
866
867
  ### Draw the name, the calls, and the words yourself
867
868
 
868
- Three more `slots` stand in for parts the transcript draws. Use them to change how a part looks or moves. Each one you leave out keeps the transcript's own.
869
+ Four more `slots` stand in for parts the transcript draws. Use them to change how a part looks or moves. Each one you leave out keeps the transcript's own.
869
870
 
870
871
  | Slot | Stands in for | Receives |
871
872
  | --- | --- | --- |
872
873
  | `name` | A reply's name, where the name shows (`nameAppears`). | `{ handle, streaming }` |
873
874
  | `toolCalls` | Each list of tool calls: in a reply, in its trace, and in an agent call's detail. | `{ list, streaming }`. `list` is what the transcript gives Astryx's `ChatToolCalls`. |
874
875
  | `markdown` | The Markdown of a reply's words and thoughts. | What the transcript gives Astryx's `Markdown`, its `children` and `isStreaming` among them. |
876
+ | `status` | The words of a reply's work status ("Working for 12s", then "Worked for 22s"). With a trace, they are the trigger that opens it. | `{ words, streaming }`. Its type is `ChatTurnStatus`. |
875
877
 
876
878
  `streaming` is `true` while the reply is on its way. A call's `key` is its operation id, or its call id. It stays the same from the live reply to the saved one.
877
879
 
880
+ What `status` returns stays mounted from "Working" to "Worked", so you can animate the change. It mounts again in two cases: the reply gets its first thought or call while it runs, so its words move into the trace's trigger; or the reply has no status to show, as when it ends with no time and no trace.
881
+
878
882
  ```tsx
879
883
  <ChatTranscript
880
884
  blocks={blocks}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.1045.gcc305fe",
3
+ "version": "0.3.5-next.1047.gb68ee87",
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.1045.gcc305fe",
64
- "@theoremjs/web": "^0.3.5-next.1045.gcc305fe"
63
+ "@theoremjs/agents": "^0.3.5-next.1047.gb68ee87",
64
+ "@theoremjs/web": "^0.3.5-next.1047.gb68ee87"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -55,6 +55,7 @@ const PILL_RADIUS = knob('pill-radius', 'var(--radius-full)');
55
55
  const PILL_FILL = knob('pill-fill', FILL);
56
56
  const PILL_SHADOW = knob('pill-shadow', SHADOW);
57
57
  const PILL_ALIGN = knob('pill-align', 'center');
58
+ const PILL_SHADOW_ROOM = knob('pill-shadow-room', 'var(--spacing-3)');
58
59
  /** The pill shape, kept whole when the row scrolls. */
59
60
  const PILL = {
60
61
  height: PILL_HEIGHT,
@@ -72,11 +73,22 @@ const WORKING_PILL = {
72
73
  };
73
74
  /** invariant: The pill row keeps one pill's height whatever it holds, so the composer never moves. */
74
75
  const PILL_ROW = { paddingInline: INSET, minHeight: PILL_HEIGHT };
75
- /** why: One pill sits where `pill-align` puts it; more start at the edge and scroll sideways. */
76
- const PILLS_ONE = { display: 'flex', justifyContent: PILL_ALIGN };
77
- const PILLS_MANY = {
76
+ /**
77
+ * why: The pills sit where `pill-align` puts them, however many there are; once they outgrow the
78
+ * row they scroll sideways from its start (`safe`), so none is out of reach.
79
+ * why: A scroller clips what its children paint outside it, so it reaches past the row by the pill
80
+ * shadow's room, above, below and at its start, and pads it back: the pills stay where they were and
81
+ * their shadows round off whole. The end needs none: the mask fades it.
82
+ */
83
+ const PILLS = {
84
+ display: 'flex',
85
+ justifyContent: `safe ${PILL_ALIGN}`,
78
86
  overflowX: 'auto',
79
87
  scrollbarWidth: 'none',
88
+ paddingBlock: PILL_SHADOW_ROOM,
89
+ marginBlock: `calc(-1 * ${PILL_SHADOW_ROOM})`,
90
+ paddingInlineStart: PILL_SHADOW_ROOM,
91
+ marginInlineStart: `calc(-1 * ${PILL_SHADOW_ROOM})`,
80
92
  // why: Pills that scroll fade out at the end instead of being cut against the hint.
81
93
  maskImage: 'linear-gradient(to right, black calc(100% - var(--spacing-6)), transparent)',
82
94
  };
@@ -117,8 +129,8 @@ function WorkingPill({ since, icons, renderPillWords, onStop, }) {
117
129
  return (_jsx(Token, { size: "lg", className: "theorem-composer-pill", "data-pill": "working", style: WORKING_PILL, ...pillWords({ pill: 'working', words: label }, renderPillWords, _jsx(IconButton, { label: stop, tooltip: stop, size: "sm", variant: "secondary", icon: icons?.stop ?? _jsx(IconPlayerStopFilled, { size: 12 }), onClick: onStop })), icon: pillIcon(icons?.working, _jsx(Spinner, { size: "sm", shade: "inherit", "aria-label": label })) }));
118
130
  }
119
131
  /**
120
- * The pill row. One pill sits centred over the composer (see `pill-align`); with more, the working
121
- * pill leads and the rest follow it, scrolling sideways once they outgrow the row.
132
+ * The pill row. The pills sit centred over the composer (see `pill-align`): the working pill leads
133
+ * and the rest follow it, scrolling sideways once they outgrow the row.
122
134
  */
123
135
  function PillRow(props) {
124
136
  const t = useLabels();
@@ -134,7 +146,7 @@ function PillRow(props) {
134
146
  ].filter(Boolean);
135
147
  if (pills.length === 0 && !props.hint)
136
148
  return null;
137
- return (_jsxs(HStack, { gap: 2, vAlign: "center", className: "theorem-composer-pills", style: PILL_ROW, children: [_jsx(StackItem, { size: "fill", style: pills.length > 1 ? PILLS_MANY : PILLS_ONE, children: _jsx(HStack, { gap: 1, vAlign: "center", children: pills }) }), props.hint] }));
149
+ return (_jsxs(HStack, { gap: 2, vAlign: "center", className: "theorem-composer-pills", style: PILL_ROW, children: [_jsx(StackItem, { size: "fill", style: PILLS, children: _jsx(HStack, { gap: 1, vAlign: "center", children: pills }) }), props.hint] }));
138
150
  }
139
151
  /**
140
152
  * What waits to send, on a card of its own above the surface: a header with the count, then the
@@ -680,6 +680,7 @@ function useTurnElapsed(streaming, startedAt, workedMs) {
680
680
  */
681
681
  function TurnStatus(props) {
682
682
  const { status, streaming } = props;
683
+ const drawStatus = useContext(AppSlots).status;
683
684
  const [traceOpen, setTraceOpen] = useState(streaming);
684
685
  const [wasStreaming, setWasStreaming] = useState(streaming);
685
686
  const [openBefore, setOpenBefore] = useState(false);
@@ -691,7 +692,7 @@ function TurnStatus(props) {
691
692
  }
692
693
  if (!status)
693
694
  return null;
694
- const label = (_jsx(Text, { size: "sm", color: "secondary", children: status }));
695
+ const label = drawStatus ? (drawStatus({ words: status, streaming })) : (_jsx(Text, { size: "sm", color: "secondary", children: status }));
695
696
  if (!props.hasTrace)
696
697
  return label;
697
698
  return (_jsx(Collapsible, { trigger: label, isOpen: traceOpen, onOpenChange: setTraceOpen, children: _jsx(TraceList, { items: props.trace, streaming: streaming }) }));
package/ui/index.d.ts CHANGED
@@ -31,7 +31,7 @@ export { AstryxMediaViewer, type MediaViewer, type MediaViewerItem, type MediaVi
31
31
  export { PaneFailure, PaneLoading, PaneState } from './PaneState.js';
32
32
  export { RadialBars, Sunburst, type SunburstNode } from './RadialCharts.js';
33
33
  export { type RankedBar, RankedBars } from './RankedBars.js';
34
- export type { ChatDetailsSlot, ChatMarkdownSlot, ChatMessageDetails, ChatNameSlot, ChatReply, ChatReplyName, ChatReplySlot, ChatToolCallList, ChatToolCallsSlot, ChatTranscriptSlots, } from './reply-slot.js';
34
+ export type { ChatDetailsSlot, ChatMarkdownSlot, ChatMessageDetails, ChatNameSlot, ChatReply, ChatReplyName, ChatReplySlot, ChatStatusSlot, ChatToolCallList, ChatToolCallsSlot, ChatTranscriptSlots, ChatTurnStatus, } from './reply-slot.js';
35
35
  export { InPlace, PaneLayout, PanePanel, Prose, RaisedPane } from './SidePanel.js';
36
36
  export { DEFAULT_CHAT_MAX_WIDTH, TheoremChat, TheoremChatComposer, type TheoremChatComposerProps, type TheoremChatHandle, type TheoremChatProps, TheoremChatTranscript, type TheoremChatTranscriptOptions, type TheoremChatTranscriptProps, } from './TheoremChat.js';
37
37
  export { TheoremDecision, type TheoremDecisionProps } from './TheoremDecision.js';
@@ -58,6 +58,18 @@ export type ChatToolCallsSlot = (calls: ChatToolCallList) => ReactNode;
58
58
  * `Markdown`. Unset draws Astryx's `Markdown`.
59
59
  */
60
60
  export type ChatMarkdownSlot = (markdown: MarkdownProps<readonly MarkdownPluginEntry[]>) => ReactNode;
61
+ /** A reply's work status as the transcript's `status` slot is given it. */
62
+ export type ChatTurnStatus = {
63
+ /** The status's words: "Working for 12s" while the reply is on its way, then "Worked for 22s" or "Worked". */
64
+ words: string;
65
+ /** `true` while the reply is on its way. */
66
+ streaming: boolean;
67
+ };
68
+ /**
69
+ * Draws the words of a reply's work status. Unset draws them as Astryx's `Text`. What it returns
70
+ * stays mounted from "Working" to "Worked", so it can animate the change.
71
+ */
72
+ export type ChatStatusSlot = (status: ChatTurnStatus) => ReactNode;
61
73
  /** What the app draws in the transcript's slots. */
62
74
  export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
63
75
  /** Under each reply, inside its message. */
@@ -73,4 +85,8 @@ export type ChatTranscriptSlots<Host extends JsonObject = JsonObject> = {
73
85
  toolCalls?: ChatToolCallsSlot;
74
86
  /** In place of the Markdown of a reply's words and thoughts. */
75
87
  markdown?: ChatMarkdownSlot;
88
+ /**
89
+ * In place of the words of a reply's work status. With a trace, they are the trigger that opens it.
90
+ */
91
+ status?: ChatStatusSlot;
76
92
  };