@theoremjs/react 0.3.5-next.987.ge2681d2 → 0.3.5-next.989.g88dcbfc

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
@@ -241,6 +241,8 @@ A tool can also return a **reference**: `{ type, mimeType, uri }`, such as a `gs
241
241
 
242
242
  `resolveMedia` returns a string, `null`, or a promise of either. While it works, and when it returns `null` or throws, the chat shows the file name from the `uri`. `TheoremHost` takes the same `resolveMedia`, and always shows all the media of a call.
243
243
 
244
+ A file the person sent works the same way after your app saves it. When you load a saved conversation, give the person's file as a `user-attachment` or `user-voice` block with `uri` and `type` in place of `data`, and your own values for the file in `metadata` if you need them. The chat shows it on the person's side through `resolveMedia`: a picture, a voice note to play, or the file name.
245
+
244
246
  ### Resume a conversation
245
247
 
246
248
  The server keeps the conversation in its `conversationStore`. The browser never sends the history. It holds only a ref that the store issued.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/react",
3
- "version": "0.3.5-next.987.ge2681d2",
3
+ "version": "0.3.5-next.989.g88dcbfc",
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.987.ge2681d2",
64
- "@theoremjs/web": "^0.3.5-next.987.ge2681d2"
63
+ "@theoremjs/agents": "^0.3.5-next.989.g88dcbfc",
64
+ "@theoremjs/web": "^0.3.5-next.989.g88dcbfc"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@astryxdesign/core": {
@@ -286,8 +286,8 @@ function composerTray(t, props, stagedFiles, onVoiceRemove) {
286
286
  * The text field, with the send menu's shortcuts while it has focus: each acts only when the
287
287
  * menu offers it. `field` wires it up when it stands outside Astryx's composer (the row layout).
288
288
  */
289
- function ComposerTextInput({ editorRef, handleRef, menuActions, onMenuAction, field, }) {
290
- return (_jsx(ChatComposerInput, { ref: editorRef, handleRef: handleRef, ...(field
289
+ function ComposerTextInput({ editorRef, handleRef, menuActions, onMenuAction, onFiles, field, }) {
290
+ return (_jsx(ChatComposerInput, { ref: editorRef, handleRef: handleRef, onFiles: onFiles, ...(field
291
291
  ? {
292
292
  value: field.value,
293
293
  onChange: field.onChange,
@@ -394,6 +394,8 @@ function useComposerParts(props) {
394
394
  placeholder,
395
395
  // why: A profile that takes no text has no text field (false, not null: null gets Astryx's default one).
396
396
  input: inputs.text && (_jsx(ComposerTextInput, { editorRef: editorRef, handleRef: props.inputRef, menuActions: actions.menuActions, onMenuAction: props.onMenuAction,
397
+ // why: A pasted or dropped file goes through the same staging and limits as the attach button.
398
+ onFiles: inputs.attachments ? stageFiles : undefined,
397
399
  // why: The row draws its own surface, outside Astryx's ChatComposer, so the field takes its value here.
398
400
  field: props.layout === 'row'
399
401
  ? {
@@ -199,7 +199,21 @@ function UserBlock({ block, metadata }) {
199
199
  }
200
200
  /** An attached image or voice note inline; any other file as a Token. */
201
201
  function UserFile({ block }) {
202
- const src = dataUrl(block.mimeType, block.data);
202
+ if (block.uri !== undefined)
203
+ return _jsx(SavedUserFile, { block: block, uri: block.uri });
204
+ return _jsx(UserFileView, { block: block, src: dataUrl(block.mimeType, block.data) });
205
+ }
206
+ /** A file the app saved, as its resolver shows it; the named file while it resolves, or when nothing does. */
207
+ function SavedUserFile({ block, uri }) {
208
+ const src = useResolvedMedia({
209
+ type: block.type ?? (block.kind === 'user-voice' ? 'audio' : 'document'),
210
+ mimeType: block.mimeType,
211
+ uri,
212
+ ...(block.metadata ? { metadata: block.metadata } : {}),
213
+ });
214
+ return _jsx(UserFileView, { block: block, src: src ?? undefined });
215
+ }
216
+ function UserFileView({ block, src }) {
203
217
  if (src && block.mimeType.startsWith('image/')) {
204
218
  return _jsx(ImageAttachment, { src: src, name: block.name });
205
219
  }