@particle-academy/react-fancy 5.65.0 → 5.67.0

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.
Files changed (106) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/{PastePills.types-CDyotkUb.d.cts → PastePills.types-CpXzsuwJ.d.cts} +2 -0
  3. package/dist/{PastePills.types-CDyotkUb.d.ts → PastePills.types-CpXzsuwJ.d.ts} +2 -0
  4. package/dist/{PastedFilesInput-CrgNoEBd.d.ts → PastedFilesInput-Bt3KSTVN.d.ts} +1 -1
  5. package/dist/{PastedFilesInput-DQ1eZaHk.d.cts → PastedFilesInput-CUQeOeOA.d.cts} +1 -1
  6. package/dist/button.cjs +3 -4
  7. package/dist/button.js +1 -2
  8. package/dist/{chunk-COXHFZR6.js → chunk-23AVEYUP.js} +14 -8
  9. package/dist/chunk-23AVEYUP.js.map +1 -0
  10. package/dist/{chunk-C5YX5XVL.cjs → chunk-3U7PUZLI.cjs} +214 -4
  11. package/dist/chunk-3U7PUZLI.cjs.map +1 -0
  12. package/dist/{chunk-ATIDUWY6.cjs → chunk-4S5DFN5N.cjs} +12 -12
  13. package/dist/{chunk-ATIDUWY6.cjs.map → chunk-4S5DFN5N.cjs.map} +1 -1
  14. package/dist/{chunk-CMC2TOEQ.cjs → chunk-6CAXLP7D.cjs} +6 -6
  15. package/dist/{chunk-CMC2TOEQ.cjs.map → chunk-6CAXLP7D.cjs.map} +1 -1
  16. package/dist/{chunk-TQGRXJ74.cjs → chunk-7FYRFNPX.cjs} +9 -9
  17. package/dist/{chunk-TQGRXJ74.cjs.map → chunk-7FYRFNPX.cjs.map} +1 -1
  18. package/dist/{chunk-MVVHUTXA.js → chunk-B4LVQ4QI.js} +3 -3
  19. package/dist/{chunk-MVVHUTXA.js.map → chunk-B4LVQ4QI.js.map} +1 -1
  20. package/dist/{chunk-QP35Z2WB.js → chunk-BL5IKSB3.js} +3 -3
  21. package/dist/{chunk-QP35Z2WB.js.map → chunk-BL5IKSB3.js.map} +1 -1
  22. package/dist/{chunk-SZH7TFME.js → chunk-DCAD2JPP.js} +4 -4
  23. package/dist/{chunk-SZH7TFME.js.map → chunk-DCAD2JPP.js.map} +1 -1
  24. package/dist/{chunk-MCQJFMDP.cjs → chunk-E5UU666U.cjs} +478 -36
  25. package/dist/chunk-E5UU666U.cjs.map +1 -0
  26. package/dist/{chunk-L24LUSEE.js → chunk-FXOT4P4P.js} +478 -36
  27. package/dist/chunk-FXOT4P4P.js.map +1 -0
  28. package/dist/{chunk-CAUEKGMR.js → chunk-HEY4SMS2.js} +4 -4
  29. package/dist/{chunk-CAUEKGMR.js.map → chunk-HEY4SMS2.js.map} +1 -1
  30. package/dist/{chunk-QNQNGARW.cjs → chunk-HFK5SBNM.cjs} +27 -9
  31. package/dist/chunk-HFK5SBNM.cjs.map +1 -0
  32. package/dist/{chunk-TLRRMYNV.js → chunk-OXERDFFF.js} +212 -4
  33. package/dist/chunk-OXERDFFF.js.map +1 -0
  34. package/dist/{chunk-ELFTEJBT.js → chunk-QSGAFKK2.js} +3 -3
  35. package/dist/{chunk-ELFTEJBT.js.map → chunk-QSGAFKK2.js.map} +1 -1
  36. package/dist/{chunk-SYEHWUM5.cjs → chunk-RALJMI7C.cjs} +4 -4
  37. package/dist/{chunk-SYEHWUM5.cjs.map → chunk-RALJMI7C.cjs.map} +1 -1
  38. package/dist/{chunk-UM4JXBRZ.cjs → chunk-S3NB6LDV.cjs} +4 -4
  39. package/dist/{chunk-UM4JXBRZ.cjs.map → chunk-S3NB6LDV.cjs.map} +1 -1
  40. package/dist/{chunk-C463C4MM.cjs → chunk-SAG6DHQK.cjs} +22 -16
  41. package/dist/chunk-SAG6DHQK.cjs.map +1 -0
  42. package/dist/{chunk-4XHG6Q42.cjs → chunk-U5LKNGHU.cjs} +21 -21
  43. package/dist/{chunk-4XHG6Q42.cjs.map → chunk-U5LKNGHU.cjs.map} +1 -1
  44. package/dist/{chunk-M52S3TFI.js → chunk-WFR7HKJL.js} +3 -3
  45. package/dist/{chunk-M52S3TFI.js.map → chunk-WFR7HKJL.js.map} +1 -1
  46. package/dist/{chunk-NILA2LZY.js → chunk-YIKXJWO4.js} +27 -9
  47. package/dist/chunk-YIKXJWO4.js.map +1 -0
  48. package/dist/composer.cjs +4 -4
  49. package/dist/composer.d.cts +2 -2
  50. package/dist/composer.d.ts +2 -2
  51. package/dist/composer.js +2 -2
  52. package/dist/content-renderer.cjs +7 -5
  53. package/dist/content-renderer.d.cts +56 -4
  54. package/dist/content-renderer.d.ts +56 -4
  55. package/dist/content-renderer.js +4 -2
  56. package/dist/editor.cjs +6 -5
  57. package/dist/editor.d.cts +1 -1
  58. package/dist/editor.d.ts +1 -1
  59. package/dist/editor.js +4 -3
  60. package/dist/{extensions-6PVd3-vB.d.cts → extensions-DiByZIpD.d.cts} +26 -3
  61. package/dist/{extensions-6PVd3-vB.d.ts → extensions-DiByZIpD.d.ts} +26 -3
  62. package/dist/{index-CCJVT9Hu.d.cts → index-DWtSViJ3.d.cts} +7 -1
  63. package/dist/{index-DRlltbdV.d.ts → index-XR5t8bTq.d.ts} +7 -1
  64. package/dist/index.cjs +47 -48
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.cts +5 -5
  67. package/dist/index.d.ts +5 -5
  68. package/dist/index.js +10 -11
  69. package/dist/index.js.map +1 -1
  70. package/dist/input.cjs +3 -3
  71. package/dist/input.d.cts +1 -1
  72. package/dist/input.d.ts +1 -1
  73. package/dist/input.js +2 -2
  74. package/dist/inputs.cjs +3 -3
  75. package/dist/inputs.d.cts +1 -1
  76. package/dist/inputs.d.ts +1 -1
  77. package/dist/inputs.js +2 -2
  78. package/dist/json-editor.cjs +15 -16
  79. package/dist/json-editor.js +4 -5
  80. package/dist/magic-wand.cjs +3 -4
  81. package/dist/magic-wand.js +2 -3
  82. package/dist/paste-pills.cjs +14 -14
  83. package/dist/paste-pills.d.cts +3 -3
  84. package/dist/paste-pills.d.ts +3 -3
  85. package/dist/paste-pills.js +1 -1
  86. package/dist/prompt-input.cjs +6 -7
  87. package/dist/prompt-input.d.cts +2 -2
  88. package/dist/prompt-input.d.ts +2 -2
  89. package/dist/prompt-input.js +3 -4
  90. package/dist/reason-tag.cjs +3 -4
  91. package/dist/reason-tag.js +2 -3
  92. package/docs/ContentRenderer.md +138 -3
  93. package/docs/PromptInput.md +24 -1
  94. package/package.json +1 -1
  95. package/dist/chunk-6TBRBN7H.js +0 -212
  96. package/dist/chunk-6TBRBN7H.js.map +0 -1
  97. package/dist/chunk-C463C4MM.cjs.map +0 -1
  98. package/dist/chunk-C5YX5XVL.cjs.map +0 -1
  99. package/dist/chunk-COXHFZR6.js.map +0 -1
  100. package/dist/chunk-L24LUSEE.js.map +0 -1
  101. package/dist/chunk-MCQJFMDP.cjs.map +0 -1
  102. package/dist/chunk-NILA2LZY.js.map +0 -1
  103. package/dist/chunk-QNQNGARW.cjs.map +0 -1
  104. package/dist/chunk-TLRRMYNV.js.map +0 -1
  105. package/dist/chunk-X2FC7ODX.cjs +0 -215
  106. package/dist/chunk-X2FC7ODX.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -11,6 +11,80 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [5.67.0] - 2026-10-27
15
+
16
+ ### Added
17
+
18
+ - **`ContentRenderer`: copy buttons, markdown-body tags, streaming, and a
19
+ clipboard writer** (genie#1263). Genie and MOIC render chat markup with this.
20
+ Until now Genie split replies into blocks itself, because custom tags were
21
+ only found after the markdown had become HTML.
22
+ - **Copy buttons** on every code block and table. They are react-fancy
23
+ `Button`s with `copy`/`check` icons and the handle
24
+ `data-react-fancy-content-copy="code" | "table"`, plus `data-copy-state`.
25
+ Code copies exactly what is between the fences: no language label and no
26
+ added trailing newline. A table copies as TSV. Every copy is announced as
27
+ `Copied` or `Copy failed` in a polite live region
28
+ (`[data-react-fancy-content-renderer-live]`). Opt out with
29
+ `copyButtons={false}`, or per kind with `copyButtons={{ table: false }}`.
30
+ `onCopy` reports `{ kind, index, text, html, ok }`.
31
+ - **`markdown: true` on a `RenderExtension`.** A tag that starts a line is
32
+ lifted out of the markdown source before conversion. The component gets
33
+ the raw markdown body as `content`, and the body rendered as `children`.
34
+ The rendered body is sanitised, and it gets nested extensions and copy
35
+ buttons. Same-name nesting is balanced. Tags inside code are left alone.
36
+ Nesting stops at depth 8.
37
+ - **`streaming`** holds back an unfinished trailing tag of a registered
38
+ extension (`<res`, `<result title="x`, an opened tag with no close yet,
39
+ `</res`) and an open code fence, so none of it flashes as raw text. A `<`
40
+ that cannot become a registered tag still renders (`a < b`). When
41
+ `streaming` turns off, everything renders. While streaming, the root
42
+ carries `data-streaming="true"`.
43
+ - **`clipboardWriter`** lets a host supply its own clipboard write, for a
44
+ sandboxed Electron window where `navigator.clipboard` can fail silently.
45
+ The default writes text/html plus text/plain through `ClipboardItem`. If
46
+ that is missing or refused, it falls back to `writeText`. A writer fails if
47
+ it throws, rejects, returns `false`, or has not settled after 5 s. A failure
48
+ is never silent.
49
+ - New types: `ContentCopyKind`, `ContentCopyEvent`, `ContentClipboardPayload`,
50
+ `ContentClipboardWriter`. `RenderExtensionProps` gains an optional
51
+ `children`.
52
+
53
+ ### Changed
54
+
55
+ - **`ContentRenderer` (and `Editor`'s view mode, which renders through it) now
56
+ shows copy buttons by default.** Each `<pre>` and `<table>` is wrapped in a
57
+ `div[data-react-fancy-content-copy-block]`. A live-region `<span>` sits at
58
+ the end of the root. Pass `copyButtons={false}` to get the old markup back.
59
+ If you style or select `pre`/`table` by direct-child position, check it. If
60
+ you do not, do nothing.
61
+ - **Attributes of a lifted `markdown` tag are cleaned before the component sees
62
+ them.** `on*`, `srcdoc` and unsafe URLs are removed. This matches what the
63
+ HTML sanitiser already did to tags matched in HTML, so nothing an existing
64
+ extension received changes.
65
+
66
+ ## [5.66.0] - 2026-10-27
67
+
68
+ ### Added
69
+
70
+ - **`PromptInput`: text paste pills take an optional `label`** (genie#1280).
71
+ A text pill (`{ kind: "text", id, text, label? }` in `PromptDraft`) shows its
72
+ `label` in place of `Pasted text · N characters`. This mirrors the label image
73
+ pills already have. It lets a host that inserts a pill itself, such as Genie
74
+ sending a plan step into the chat, show which step it is.
75
+ - The label is display only. The submitted value still expands the pill to
76
+ the full `text`.
77
+ - The accessible name becomes `Insert this pasted text: <label>, N characters`,
78
+ so it still says the pill is pasted text.
79
+ - The label is drawn as plain text, never HTML. Whitespace, control characters
80
+ and U+FFFC are flattened to single spaces, and the label is capped at 80
81
+ characters with `…`. If it is blank or not a string, the generic text is
82
+ shown. A non-string `label` is dropped when a draft is read.
83
+ - It round-trips through `getDraft` / `setDraft`, `defaultDraft`, a controlled
84
+ `draft` and `onDraftChange`. `HeldPaste` (the `Composer` / `usePastePills`
85
+ shape) gains the same optional `label`.
86
+ - Additive. With no `label` the markup is unchanged, so you need do nothing.
87
+
14
88
  ## [5.65.0] - 2026-10-27
15
89
 
16
90
  ### Added
@@ -9,6 +9,8 @@
9
9
  interface HeldPaste {
10
10
  id: string;
11
11
  text: string;
12
+ /** Shown on the pill instead of `Pasted text · N characters`. Display only. */
13
+ label?: string;
12
14
  }
13
15
  /**
14
16
  * The minimum of a clipboard event this hook touches.
@@ -9,6 +9,8 @@
9
9
  interface HeldPaste {
10
10
  id: string;
11
11
  text: string;
12
+ /** Shown on the pill instead of `Pasted text · N characters`. Display only. */
13
+ label?: string;
12
14
  }
13
15
  /**
14
16
  * The minimum of a clipboard event this hook touches.
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject } from 'react';
3
- import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CDyotkUb.js';
3
+ import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CpXzsuwJ.js';
4
4
 
5
5
  /** The attribute on the placeholder span a pill is portalled into. */
6
6
  declare const HOST_ATTR = "data-react-fancy-composer-paste-host";
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, RefObject } from 'react';
3
- import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CDyotkUb.cjs';
3
+ import { C as ComposerPastePreview, a as ComposerPasteClassNames, b as HeldPaste, H as HeldImage, f as UsePastePillsResult } from './PastePills.types-CpXzsuwJ.cjs';
4
4
 
5
5
  /** The attribute on the placeholder span a pill is portalled into. */
6
6
  declare const HOST_ATTR = "data-react-fancy-composer-paste-host";
package/dist/button.cjs CHANGED
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('./chunk-M5MUGSON.cjs');
4
- var chunkC5YX5XVL_cjs = require('./chunk-C5YX5XVL.cjs');
5
- require('./chunk-X2FC7ODX.cjs');
4
+ var chunk3U7PUZLI_cjs = require('./chunk-3U7PUZLI.cjs');
6
5
  require('./chunk-XCZZVRBY.cjs');
7
6
  require('./chunk-MXWR3T3N.cjs');
8
7
  require('./chunk-ZU5Q77OT.cjs');
@@ -11,11 +10,11 @@ require('./chunk-ZU5Q77OT.cjs');
11
10
 
12
11
  Object.defineProperty(exports, "Action", {
13
12
  enumerable: true,
14
- get: function () { return chunkC5YX5XVL_cjs.Action; }
13
+ get: function () { return chunk3U7PUZLI_cjs.Action; }
15
14
  });
16
15
  Object.defineProperty(exports, "Button", {
17
16
  enumerable: true,
18
- get: function () { return chunkC5YX5XVL_cjs.Button; }
17
+ get: function () { return chunk3U7PUZLI_cjs.Button; }
19
18
  });
20
19
  //# sourceMappingURL=button.cjs.map
21
20
  //# sourceMappingURL=button.cjs.map
package/dist/button.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import './chunk-LQ4ICCN2.js';
2
- export { Action, Button } from './chunk-TLRRMYNV.js';
3
- import './chunk-6TBRBN7H.js';
2
+ export { Action, Button } from './chunk-OXERDFFF.js';
4
3
  import './chunk-45BBNJQD.js';
5
4
  import './chunk-J3A4Z2P7.js';
6
5
  import './chunk-MMW2JGKZ.js';
@@ -1,6 +1,6 @@
1
1
  import { Tooltip } from './chunk-GR2WKBER.js';
2
- import { useInlinePaste, InlinePasteEditor, PastedFilesInput, markedIds, expandMarkers } from './chunk-NILA2LZY.js';
3
- import { Button } from './chunk-TLRRMYNV.js';
2
+ import { useInlinePaste, InlinePasteEditor, PastedFilesInput, markedIds, expandMarkers } from './chunk-YIKXJWO4.js';
3
+ import { Button } from './chunk-OXERDFFF.js';
4
4
  import { Icon } from './chunk-J3A4Z2P7.js';
5
5
  import { cn } from './chunk-MMW2JGKZ.js';
6
6
  import { forwardRef, useState, useRef, useCallback, useReducer, useMemo, useEffect, useLayoutEffect, useImperativeHandle } from 'react';
@@ -27,7 +27,7 @@ function readPill(raw) {
27
27
  const p = raw;
28
28
  if (typeof p.id !== "string") return null;
29
29
  if (p.kind === "text" && typeof p.text === "string") {
30
- return { kind: "text", id: p.id, text: p.text };
30
+ return typeof p.label === "string" ? { kind: "text", id: p.id, text: p.text, label: p.label } : { kind: "text", id: p.id, text: p.text };
31
31
  }
32
32
  if (p.kind === "image" && typeof p.label === "string") {
33
33
  const file = readFile(p.file, p.id);
@@ -245,7 +245,9 @@ var PromptInput = forwardRef(function PromptInput2({
245
245
  return stand;
246
246
  }, []);
247
247
  const heldPastes = useMemo(
248
- () => model.pills.flatMap((p) => p.kind === "text" ? [{ id: p.id, text: p.text }] : []),
248
+ () => model.pills.flatMap(
249
+ (p) => p.kind === "text" ? [p.label !== void 0 ? { id: p.id, text: p.text, label: p.label } : { id: p.id, text: p.text }] : []
250
+ ),
249
251
  [model.pills]
250
252
  );
251
253
  const heldImages = useMemo(
@@ -259,13 +261,17 @@ var PromptInput = forwardRef(function PromptInput2({
259
261
  const onHeldPastesChange = useCallback(
260
262
  (next) => commit((m) => {
261
263
  const current = m.pills.filter((p) => p.kind === "text");
262
- if (current.length === next.length && current.every((p, i) => p.id === next[i].id && p.kind === "text" && p.text === next[i].text)) {
264
+ if (current.length === next.length && current.every(
265
+ (p, i) => p.id === next[i].id && p.kind === "text" && p.text === next[i].text && p.label === next[i].label
266
+ )) {
263
267
  return m;
264
268
  }
265
269
  return {
266
270
  ...m,
267
271
  pills: [
268
- ...next.map((p) => ({ kind: "text", id: p.id, text: p.text })),
272
+ ...next.map(
273
+ (p) => p.label !== void 0 ? { kind: "text", id: p.id, text: p.text, label: p.label } : { kind: "text", id: p.id, text: p.text }
274
+ ),
269
275
  ...m.pills.filter((p) => p.kind === "image")
270
276
  ]
271
277
  };
@@ -809,5 +815,5 @@ function fmtSize(b) {
809
815
  }
810
816
 
811
817
  export { PromptInput, browserPlatformHints, detectPlatform, modifierKeyLabel, promptDataUrlToFile, promptFileToDataUrl };
812
- //# sourceMappingURL=chunk-COXHFZR6.js.map
813
- //# sourceMappingURL=chunk-COXHFZR6.js.map
818
+ //# sourceMappingURL=chunk-23AVEYUP.js.map
819
+ //# sourceMappingURL=chunk-23AVEYUP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/PromptInput/prompt-draft.ts","../src/utils/platform.ts","../src/components/PromptInput/PromptInput.tsx"],"names":["PromptInput","fileRef"],"mappings":";;;;;;;;;AAoFO,IAAM,WAAA,GAA2B,EAAE,CAAA,EAAG,CAAA,EAAG,IAAA,EAAM,EAAA,EAAI,KAAA,EAAO,EAAC,EAAG,WAAA,EAAa,EAAC,EAAE;AAErF,SAAS,QAAA,CAAS,KAAc,EAAA,EAAqC;AACnE,EAAA,IAAI,CAAC,GAAA,IAAO,OAAO,GAAA,KAAQ,UAAU,OAAO,IAAA;AAC5C,EAAA,MAAM,CAAA,GAAI,GAAA;AACV,EAAA,MAAM,MAAA,GAAS,MAAM,CAAA,CAAE,EAAA;AACvB,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,IAAY,OAAO,CAAA,CAAE,IAAA,KAAS,UAAU,OAAO,IAAA;AACrE,EA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GAAI,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACpD,EAAA,OAAO,IAAI,CAAA,GAAI,IAAA,GAAO,IAAA,EAAM,OAAA,CAAQ,CAAC,CAAC,CAAA,GAAA,CAAA;AACxC","file":"chunk-23AVEYUP.js","sourcesContent":["import { expandMarkers, markedIds, type HeldImage } from \"../PastePills/paste-markers\";\n\n/**\n * A file in a saved draft — an attachment chip, or the image behind an image\n * pill — described by data alone, so the draft survives `JSON.stringify`.\n *\n * The bytes are deliberately NOT in here. A `File` does not survive JSON, and\n * putting base64 in the draft by default would make every saved draft as large\n * as everything attached to it: a 6 MB screenshot becomes 8 MB of string written\n * on every keystroke by a host that saves on change. Instead the host decides\n * where bytes live, through `persistAttachment` (save) and `restoreAttachment`\n * (load), and the draft carries only the host's handle for them in `ref`.\n *\n * A host that WANTS the bytes inline passes `promptFileToDataUrl` as\n * `persistAttachment`, and `ref` is then a `data:` URL.\n */\nexport interface PromptDraftFile {\n /** Stable for the life of the draft. For an image pill, the pill's own id. */\n id: string;\n name: string;\n /** MIME type, `\"\"` when the browser did not know it. */\n type: string;\n bytes: number;\n /**\n * The host's handle for the stored bytes — whatever `persistAttachment`\n * returned: a storage key, an upload URL, a `data:` URL. Absent when the host\n * keeps nothing, in which case a restored attachment has no `File`.\n */\n ref?: string;\n}\n\n/** A paste held as a pill inside the message. Its marker sits in `text`. */\nexport type PromptDraftPill =\n | {\n kind: \"text\";\n id: string;\n text: string;\n /**\n * Shown on the pill in place of `Pasted text · N characters`. Display only:\n * sending still expands the pill to the full `text`. Plain text, flattened\n * to one line and capped at 80 characters when drawn. Optional.\n */\n label?: string;\n }\n | { kind: \"image\"; id: string; label: string; file: PromptDraftFile };\n\n/**\n * Everything a PromptInput holds, as JSON. Versioned, so a draft saved by one\n * release and read by a later one is recognised or refused, never guessed at.\n *\n * `text` is the raw value: with paste pills on, each pill is a marker in it\n * (`pasteMarker(id)`), because the message itself is the record of what is\n * attached and where. Mentions and slash commands are plain text in it.\n */\nexport interface PromptDraft {\n v: 1;\n text: string;\n pills: PromptDraftPill[];\n attachments: PromptDraftFile[];\n}\n\nexport interface PromptSetDraftOptions {\n /**\n * Focus the composer after restoring, caret at the end. Default `false`:\n * restoring a draft never moves focus or anybody's caret on its own\n * (genie#1235 was exactly that).\n */\n focus?: boolean;\n}\n\n/** The imperative handle a `ref` on `PromptInput` receives. */\nexport interface PromptInputHandle {\n /** The current draft. A fresh JSON-safe copy; mutating it changes nothing. */\n getDraft(): PromptDraft;\n /**\n * Replace the whole draft. Does NOT call `onChange` / `onDraftChange` (the\n * host is the one setting it), does NOT focus unless `{ focus: true }`.\n * A draft whose `v` this release does not know is refused with a warning.\n */\n setDraft(draft: PromptDraft, options?: PromptSetDraftOptions): void;\n /** Focus the composer, caret at the end. */\n focus(): void;\n}\n\nexport const EMPTY_DRAFT: PromptDraft = { v: 1, text: \"\", pills: [], attachments: [] };\n\nfunction readFile(raw: unknown, id?: string): PromptDraftFile | null {\n if (!raw || typeof raw !== \"object\") return null;\n const f = raw as Record<string, unknown>;\n const fileId = id ?? f.id;\n if (typeof fileId !== \"string\" || typeof f.name !== \"string\") return null;\n const out: PromptDraftFile = {\n id: fileId,\n name: f.name,\n type: typeof f.type === \"string\" ? f.type : \"\",\n bytes: typeof f.bytes === \"number\" && Number.isFinite(f.bytes) ? f.bytes : 0,\n };\n if (typeof f.ref === \"string\") out.ref = f.ref;\n return out;\n}\n\nfunction readPill(raw: unknown): PromptDraftPill | null {\n if (!raw || typeof raw !== \"object\") return null;\n const p = raw as Record<string, unknown>;\n if (typeof p.id !== \"string\") return null;\n if (p.kind === \"text\" && typeof p.text === \"string\") {\n return typeof p.label === \"string\"\n ? { kind: \"text\", id: p.id, text: p.text, label: p.label }\n : { kind: \"text\", id: p.id, text: p.text };\n }\n if (p.kind === \"image\" && typeof p.label === \"string\") {\n const file = readFile(p.file, p.id);\n return file ? { kind: \"image\", id: p.id, label: p.label, file } : null;\n }\n return null;\n}\n\n/**\n * Validate a draft from storage. `null` for anything that is not a v1 draft.\n *\n * `inline` is whether the composer can show pills. Without them (no\n * `pasteThreshold` / `pasteImages`) a pill would surface as raw marker\n * characters, so text pills are expanded in place and image pills become `[label]`\n * in the text plus an ordinary attachment — what the message would have sent.\n */\nexport function readPromptDraft(raw: unknown, inline: boolean): PromptDraft | null {\n if (!raw || typeof raw !== \"object\" || (raw as { v?: unknown }).v !== 1) return null;\n const d = raw as Record<string, unknown>;\n\n let text = typeof d.text === \"string\" ? d.text : \"\";\n let pills = (Array.isArray(d.pills) ? d.pills : [])\n .map(readPill)\n .filter((p): p is PromptDraftPill => p !== null);\n let attachments = (Array.isArray(d.attachments) ? d.attachments : [])\n .map((a) => readFile(a))\n .filter((a): a is PromptDraftFile => a !== null);\n\n // The message is the record: a pill the text no longer marks is not attached.\n const marked = new Set(markedIds(text));\n pills = pills.filter((p) => marked.has(p.id));\n\n if (!inline && pills.length > 0) {\n const texts = pills.flatMap((p) => (p.kind === \"text\" ? [{ id: p.id, text: p.text }] : []));\n const images = pills.flatMap((p) => (p.kind === \"image\" ? [p] : []));\n text = expandMarkers(\n text,\n texts,\n images.map((p) => ({ id: p.id, label: p.label }) as HeldImage),\n );\n attachments = [...attachments, ...images.map((p) => p.file)];\n pills = [];\n }\n\n return { v: 1, text, pills, attachments };\n}\n\n/** A deep, JSON-safe copy, so a host cannot mutate the component's state through it. */\nexport function clonePromptDraft(draft: PromptDraft): PromptDraft {\n return JSON.parse(JSON.stringify(draft)) as PromptDraft;\n}\n\n/** Every file a draft refers to: attachments, then image pills. */\nexport function promptDraftFiles(draft: PromptDraft): PromptDraftFile[] {\n return [\n ...draft.attachments,\n ...draft.pills.flatMap((p) => (p.kind === \"image\" ? [p.file] : [])),\n ];\n}\n\n/**\n * Read a File as a `data:` URL. Pass it as `persistAttachment` to keep the bytes\n * IN the draft — simple, and fine for small files; every saved draft then carries\n * every attached byte, base64-inflated by a third.\n */\nexport function promptFileToDataUrl(file: Blob): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(String(reader.result));\n reader.onerror = () => reject(reader.error);\n reader.readAsDataURL(file);\n });\n}\n\n/**\n * Turn a `data:` URL back into a File — the other half of `promptFileToDataUrl`:\n *\n * restoreAttachment={(f) => f.ref ? promptDataUrlToFile(f.ref, f.name, f.type) : undefined}\n *\n * Synchronous, so the restored draft has its Files on the first render.\n * `undefined` for anything that is not a `data:` URL.\n */\nexport function promptDataUrlToFile(dataUrl: string, name: string, type?: string): File | undefined {\n if (!dataUrl.startsWith(\"data:\")) return undefined;\n const comma = dataUrl.indexOf(\",\");\n if (comma < 0) return undefined;\n\n const meta = dataUrl.slice(5, comma);\n const body = dataUrl.slice(comma + 1);\n const mime = type || meta.split(\";\")[0] || \"application/octet-stream\";\n\n try {\n let bytes: Uint8Array<ArrayBuffer>;\n if (meta.endsWith(\";base64\")) {\n const bin = atob(body);\n bytes = new Uint8Array(bin.length);\n for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);\n } else {\n bytes = new TextEncoder().encode(decodeURIComponent(body));\n }\n return new File([bytes], name, { type: mime });\n } catch {\n return undefined;\n }\n}\n","/**\n * Which modifier key the user actually has.\n *\n * This exists because a keyboard hint is a CLAIM about the reader's hardware.\n * `⌘ + Enter to send` on Windows or Linux names a key that is not on the\n * keyboard, and a reader who cannot act on a hint learns to ignore hints — so\n * the cost is not one wrong glyph, it is the credibility of every hint beside\n * it. (Reported from a real Electron app running on Linux, where the glyph had\n * no font behind it either and rendered as tofu.)\n *\n * Two deliberate choices:\n *\n * 1. **The platform is an ARGUMENT, never a global read.** `detectPlatform`\n * takes the hints; `modifierKeyLabel` takes the verdict. Both branches are\n * therefore reachable from one machine, which is the only way a test can\n * cover the platform you are not sitting at. A function that reads\n * `navigator` internally can only ever be tested on the developer's own OS.\n * 2. **`generic` is the fallback, and that is not arbitrary.** Every Fancy\n * surface that submits on a modifier accepts `metaKey || ctrlKey`, so\n * `Ctrl` is a TRUE label on an Apple keyboard while `⌘` is a FALSE one\n * everywhere else. The honest default is the one that is pressable on all\n * of them.\n */\nexport type FancyPlatform = \"apple\" | \"generic\";\n\n/**\n * The parts of `navigator` the detection reads — nothing more, so a caller can\n * hand it a literal (a test, an Electron main process forwarding `process.platform`,\n * a server with a stored preference).\n */\nexport interface PlatformHints {\n /** `navigator.userAgentData` — the modern, non-spoofed answer where it exists. */\n userAgentData?: { platform?: string } | null;\n /** `navigator.platform` — deprecated, still the most reliable legacy signal. */\n platform?: string | null;\n /** `navigator.userAgent` — last resort. */\n userAgent?: string | null;\n}\n\n/**\n * `userAgentData.platform` is a short enumerated token (\"macOS\", \"Windows\",\n * \"Linux\", \"Android\", \"iOS\"), so it is matched exactly rather than by substring.\n */\nconst APPLE_UA_DATA_PLATFORMS = new Set([\"macos\", \"ios\", \"ipados\"]);\n\n/**\n * Legacy `platform` / `userAgent` are free text. iPadOS reports `MacIntel`, and\n * iOS user agents say \"like Mac OS X\" — both are Apple, so a Mac match is\n * correct for them too.\n */\nconst APPLE_FREE_TEXT = /\\b(mac|macintosh|iphone|ipad|ipod|darwin)/i;\n\n/** Resolve a platform from navigator-shaped hints. Unknown or absent ⇒ `generic`. */\nexport function detectPlatform(hints?: PlatformHints | null): FancyPlatform {\n if (!hints) return \"generic\";\n\n const uaData = hints.userAgentData?.platform;\n if (typeof uaData === \"string\" && uaData.length > 0) {\n // When the browser gives an enumerated answer, TRUST IT and stop. Falling\n // through to the free-text test would let a Windows UA string containing\n // the word \"Mac\" (a font name, a device model) overturn it.\n return APPLE_UA_DATA_PLATFORMS.has(uaData.trim().toLowerCase()) ? \"apple\" : \"generic\";\n }\n\n for (const value of [hints.platform, hints.userAgent]) {\n if (typeof value === \"string\" && APPLE_FREE_TEXT.test(value)) return \"apple\";\n }\n\n return \"generic\";\n}\n\n/**\n * The modifier key to NAME for a platform.\n *\n * `⌘` is emitted for `apple` and nothing else. A test enumerates the platform\n * values and counts that no other one can produce it, because a hint that names\n * the wrong key is worse than no hint.\n */\nexport function modifierKeyLabel(platform: FancyPlatform): \"⌘\" | \"Ctrl\" {\n return platform === \"apple\" ? \"⌘\" : \"Ctrl\";\n}\n\n/** SSR-safe read of the live browser hints. `null` off a browser. */\nexport function browserPlatformHints(): PlatformHints | null {\n if (typeof navigator === \"undefined\") return null;\n return navigator as PlatformHints;\n}\n","import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { Button } from \"../Button\";\nimport { Icon } from \"../Icon\";\nimport { Tooltip } from \"../Tooltip\";\nimport {\n InlinePasteEditor,\n PastedFilesInput,\n useInlinePaste,\n type ComposerPasteClassNames,\n type ComposerPastePreview,\n type InlinePasteEditorHandle,\n type HeldImage,\n type HeldPaste,\n} from \"../PastePills\";\nimport {\n EMPTY_DRAFT,\n clonePromptDraft,\n promptDraftFiles,\n readPromptDraft,\n type PromptDraft,\n type PromptDraftFile,\n type PromptDraftPill,\n type PromptInputHandle,\n type PromptSetDraftOptions,\n} from \"./prompt-draft\";\n\nexport {\n promptDataUrlToFile,\n promptFileToDataUrl,\n} from \"./prompt-draft\";\nexport type {\n PromptDraft,\n PromptDraftFile,\n PromptDraftPill,\n PromptInputHandle,\n PromptSetDraftOptions,\n} from \"./prompt-draft\";\nimport {\n browserPlatformHints,\n detectPlatform,\n modifierKeyLabel,\n type FancyPlatform,\n} from \"../../utils/platform\";\n\n/**\n * PromptInput — the chat composer every AI app rebuilds. Auto-growing\n * multi-line input with:\n *\n * • slash-command picker (`/` triggers a filtered command palette,\n * ↑/↓ navigate, Enter inserts)\n * • mention picker (`@` triggers, filtered against `mentions`)\n * • drop-to-attach (drag files anywhere on the surface), paste-to-attach\n * (a pasted screenshot becomes an attachment) + chip bar\n * • submit on ⌘/Ctrl+Enter (plain Enter inserts a newline)\n * • live token-budget meter (green → amber → red as headroom drops)\n *\n * Wire it up:\n *\n * <PromptInput\n * budgetTokens={32000}\n * commands={[{ name: \"/rewrite\", hint: \"rewrite the selection\" }]}\n * mentions={[{ id: \"ada\", name: \"Ada\", kind: \"person\" }]}\n * onSubmit={(text, attachments) => sendToAgent(text, attachments)}\n * />\n */\nexport type PromptCmd = { name: string; hint: string };\nexport type PromptMention = {\n id: string;\n name: string;\n kind: \"agent\" | \"file\" | \"person\" | string;\n};\nexport type PromptAttachment = {\n id: string;\n name: string;\n bytes: number;\n /**\n * The file the user actually attached.\n *\n * Optional because an attachment restored from a server has no File — but for\n * anything the user dropped or picked it is always present. Without it a host\n * can render a chip and nothing else: no POST, no FormData, no send-to-model.\n */\n file?: File;\n /** MIME type. Hosts branch on this to decide whether a file can be sent as-is. */\n type?: string;\n /**\n * The host's handle for the stored bytes, from `persistAttachment`. On an\n * attachment restored from a draft WITHOUT a File, this is how the host finds\n * the bytes to send.\n */\n ref?: string;\n};\n\n/**\n * `...rest` reaches the root surface, so a consumer or a bridge can tag the\n * composer with its own `data-*` handle. The component named every prop it\n * used and had no rest spread, which means a `data-handle` put on it was\n * DROPPED — silently, since React discards unknown props and the component\n * still renders perfectly. That is issue #22 all over again, and the contract\n * calls it out: \"Each interactive element has a stable identity. Agents never\n * guess DOM.\"\n */\nexport interface PromptInputProps\n extends Omit<\n HTMLAttributes<HTMLDivElement>,\n \"onSubmit\" | \"className\" | \"onChange\" | \"defaultValue\"\n > {\n /** Extra classes on the root surface. MERGED, never replaced. */\n className?: string;\n /**\n * The text, controlled. With paste pills on it carries a marker per pill\n * (`pasteMarker(id)`), exactly as `Composer`'s `value` does. Pills and\n * attachments stay internal; use `draft` to control those too.\n */\n value?: string;\n /** The starting text, uncontrolled. Ignored when `value` or `draft` is given. */\n defaultValue?: string;\n /**\n * Called with the new text when the PERSON edits it, and with `\"\"` after a\n * send. Not called by `setDraft` or a prop change: the host made those.\n */\n onChange?: (value: string) => void;\n /**\n * The whole draft, controlled: text, paste pills and attachments, as JSON.\n * Wins over `value`. Pair with `onDraftChange`.\n */\n draft?: PromptDraft;\n /** The starting draft, uncontrolled. Wins over `defaultValue`. */\n defaultDraft?: PromptDraft;\n /**\n * Called with the whole draft whenever the person changes any part of it —\n * typing, a paste, an attach, a removal, a send (which empties it) — and when\n * `persistAttachment` resolves a `ref`. Not called by `setDraft`.\n */\n onDraftChange?: (draft: PromptDraft) => void;\n /**\n * Keep an attached file somewhere and return a handle for it (a storage key, an\n * upload URL — or a `data:` URL via `promptFileToDataUrl`). Called once per\n * attached or pasted file; the result becomes the file's `ref` in the draft.\n * May return a Promise; the draft is updated (and `onDraftChange` fires) when it\n * resolves. Omit it and a draft carries file metadata only.\n */\n persistAttachment?: (\n file: File,\n entry: PromptDraftFile,\n ) => string | undefined | Promise<string | undefined>;\n /**\n * Get a File back for a draft entry restored without one (from `setDraft`,\n * `defaultDraft` or a controlled `draft`). May return a Promise. Return\n * `undefined` when there is none: the chip or pill still shows, and the\n * attachment reaches `onSubmit` with its `ref` and no `file`.\n */\n restoreAttachment?: (\n entry: PromptDraftFile,\n ) => File | undefined | Promise<File | undefined>;\n /** Token budget for the meter. */\n budgetTokens: number;\n /** Slash-commands. Names must start with `/`. */\n commands?: PromptCmd[];\n /** @-mentions. */\n mentions?: PromptMention[];\n /** Show the keyboard hint (\"Ctrl + Enter to send\", \"⌘ + Enter\" on a Mac). */\n showHint?: boolean;\n /**\n * Which modifier the hint and the default placeholder NAME. Omit it and the\n * component reads the platform after mount, which is the right answer for an\n * ordinary web app.\n *\n * Pass it when the host knows better than `navigator` does — an Electron\n * renderer forwarding `process.platform`, a remote session where the\n * keyboard is not the one running the browser, or a test that needs the\n * branch it is not sitting on. The pressed keys are unaffected either way:\n * submit is `⌘/Ctrl+Enter` on every platform, so this only decides which\n * true key gets named.\n */\n platform?: FancyPlatform;\n /** Called on ⌘/Ctrl+Enter or send button. */\n onSubmit: (text: string, attachments: PromptAttachment[]) => void;\n /**\n * Placeholder text. Defaults to a hint naming the modifier THIS platform\n * actually has, so leaving it unset is the better option — a hardcoded\n * placeholder is the other place a `⌘` ends up in front of a Windows user.\n */\n placeholder?: string;\n /** Rough estimator: chars-per-token. Defaults to 4. */\n charsPerToken?: number;\n /** Color → CSS chip mapping for mention kinds. */\n mentionColor?: Record<string, string>;\n /** Optional max textarea height in px. Defaults to 280. */\n maxHeight?: number;\n /**\n * Rendered INSIDE the rounded shell, ABOVE the attachments bar and\n * textarea. Use this slot for a drawer of tools/files/prompts/etc. so\n * the drawer and composer share one visual panel. See {@link ChatDrawer}.\n */\n aboveInput?: ReactNode;\n /**\n * Hold a paste of at least this many characters as a pill IN the message,\n * where it was pasted: on a line of its own, its full text put back in place\n * when clicked, and expanded where it sits when sent. Omit it and paste is\n * unchanged. Setting this (or `pasteImages`) swaps the textarea for an inline\n * editor that keeps the `/` and `@` pickers and the send key.\n */\n pasteThreshold?: number;\n /**\n * A pasted image becomes an inline `Pasted image N` pill AND reaches\n * `onSubmit`'s attachments, with its File, in message order; the text marks\n * where it sat as `[Pasted image N]`. Without it a pasted image is an\n * ordinary attachment chip, as before.\n */\n pasteImages?: boolean;\n /** Characters of a held paste shown at EACH end of its hover preview. Default 20. */\n previewChars?: number;\n /** Replace the paste pills' hover popover content. */\n renderPastePreview?: (preview: ComposerPastePreview) => ReactNode;\n /** Restyle the paste pills, their popover and the inline editor. Merged onto the defaults. */\n pasteClassNames?: ComposerPasteClassNames;\n /**\n * Submit pasted images with an enclosing `<form>`, under this field name: a\n * hidden `<input type=\"file\" multiple>` holds the images still in the message,\n * in message order. Needs `pasteImages`. They reach `onSubmit` either way.\n */\n pasteFilesName?: string;\n /** `\"icon\"`: an icon-only attach button whose tooltip says what it does. Default `\"label\"`. */\n attachButton?: \"label\" | \"icon\";\n /**\n * `\"icon\"`: a compact icon send button whose tooltip carries the shortcut —\n * replacing the inline `Ctrl + Enter to send` hint. Default `\"label\"`.\n */\n sendButton?: \"label\" | \"icon\";\n /**\n * Tokens already used — the caller's REAL value, e.g. an agent's context\n * usage. The meter shows this plus the estimate for the draft. Without it the\n * meter estimates the draft alone, as before.\n */\n usedTokens?: number;\n /**\n * `\"always\"` (default) — as before. `\"near-limit\"` — hidden until usage passes\n * `meterShowAt`, muted until `meterWarnAt`, warning colour past that.\n * `\"hidden\"` — never shown.\n */\n meter?: \"always\" | \"near-limit\" | \"hidden\";\n /** Fraction of `budgetTokens` at which a `\"near-limit\"` meter appears. Default 0.75. */\n meterShowAt?: number;\n /** Fraction of `budgetTokens` past which a `\"near-limit\"` meter takes the warning colour. Default 0.9. */\n meterWarnAt?: number;\n}\n\nconst DEFAULT_MENTION_COLOR: Record<string, string> = {\n agent: \"#a855f7\",\n file: \"#10b981\",\n person: \"#3b82f6\",\n};\n\nexport const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(function PromptInput({\n value: controlledValue,\n defaultValue,\n onChange,\n draft: controlledDraft,\n defaultDraft,\n onDraftChange,\n persistAttachment,\n restoreAttachment,\n budgetTokens,\n commands = [],\n mentions = [],\n showHint = true,\n platform,\n onSubmit,\n placeholder,\n charsPerToken = 4,\n mentionColor,\n maxHeight = 280,\n aboveInput,\n className,\n pasteThreshold,\n pasteImages = false,\n previewChars = 20,\n renderPastePreview,\n pasteClassNames,\n pasteFilesName,\n attachButton = \"label\",\n sendButton = \"label\",\n usedTokens,\n meter = \"always\",\n meterShowAt = 0.75,\n meterWarnAt = 0.9,\n ...rest\n}: PromptInputProps, ref) {\n /** Inline pills need an editor that can hold them; a textarea cannot. */\n const inline = pasteThreshold !== undefined || pasteImages;\n\n /*\n * ONE model for everything a draft is — text, pills, attachments — so a draft\n * read back is never a text from one moment and a list from another. Pills used\n * to live in `useInlinePaste` and attachments in their own state, which is why\n * nothing outside could read or restore them. They are now owned here and handed\n * to `useInlinePaste` controlled.\n *\n * Files cannot be JSON, so they live beside the model in `filesRef`, keyed by the\n * model's ids. `filesVersion` re-renders when a restored File arrives; that is\n * not a draft change, so nobody is told about it.\n */\n const draftControlled = controlledDraft !== undefined;\n const [innerDraft, setInnerDraft] = useState<PromptDraft>(\n () =>\n (defaultDraft && readPromptDraft(defaultDraft, inline)) || {\n ...EMPTY_DRAFT,\n text: defaultValue ?? \"\",\n },\n );\n const baseDraft = draftControlled ? controlledDraft : innerDraft;\n const model: PromptDraft =\n !draftControlled && controlledValue !== undefined && controlledValue !== baseDraft.text\n ? { ...baseDraft, text: controlledValue }\n : baseDraft;\n const modelRef = useRef(model);\n modelRef.current = model;\n const text = model.text;\n\n const onChangeRef = useRef(onChange);\n onChangeRef.current = onChange;\n const onDraftChangeRef = useRef(onDraftChange);\n onDraftChangeRef.current = onDraftChange;\n const persistRef = useRef(persistAttachment);\n persistRef.current = persistAttachment;\n\n /**\n * Apply a change to the draft. `notify` is false only for `setDraft`: a host\n * restoring a draft already knows what it set, and telling it would make every\n * restore look like the person typed — a \"dirty\" flag, a typing indicator, a\n * save that overwrites what was just loaded.\n */\n const commit = useCallback(\n (update: (current: PromptDraft) => PromptDraft, notify = true) => {\n const prev = modelRef.current;\n const next = update(prev);\n if (next === prev) return;\n modelRef.current = next;\n setInnerDraft(next);\n if (!notify) return;\n if (next.text !== prev.text) onChangeRef.current?.(next.text);\n onDraftChangeRef.current?.(next);\n },\n [],\n );\n\n const filesRef = useRef(new Map<string, File>());\n const placeholdersRef = useRef(new Map<string, File>());\n const requestedRef = useRef(new Set<string>());\n const [filesVersion, bumpFiles] = useReducer((n: number) => n + 1, 0);\n\n /** Record a ref from `persistAttachment` against whichever entry has `id`. */\n const setFileRef = useCallback(\n (id: string, fileRef: string) =>\n commit((m) => {\n const withRef = (f: PromptDraftFile) => (f.id === id ? { ...f, ref: fileRef } : f);\n if (!promptDraftFiles(m).some((f) => f.id === id)) return m;\n return {\n ...m,\n attachments: m.attachments.map(withRef),\n pills: m.pills.map((p) => (p.kind === \"image\" ? { ...p, file: withRef(p.file) } : p)),\n };\n }),\n [commit],\n );\n\n /**\n * Hand a newly attached file to the host's store. A synchronous handle is\n * returned so it lands in the same draft as the file; an async one updates the\n * draft when it arrives. A failing store loses the handle, never the attachment.\n */\n const persist = useCallback(\n (file: File, entry: PromptDraftFile): string | undefined => {\n const store = persistRef.current;\n if (!store) return undefined;\n let out: ReturnType<typeof store>;\n try {\n out = store(file, entry);\n } catch (error) {\n console.error(\"PromptInput: persistAttachment threw\", error);\n return undefined;\n }\n if (typeof out === \"string\") return out;\n if (out && typeof (out as Promise<unknown>).then === \"function\") {\n (out as Promise<string | undefined>).then(\n (fileRef) => {\n if (typeof fileRef === \"string\") setFileRef(entry.id, fileRef);\n },\n (error) => console.error(\"PromptInput: persistAttachment rejected\", error),\n );\n }\n return undefined;\n },\n [setFileRef],\n );\n\n const fileMeta = (id: string, file: File): PromptDraftFile => ({\n id,\n name: file.name,\n type: file.type,\n bytes: file.size,\n });\n\n /** A held image needs a File to show; a restored one without its bytes gets an empty stand-in. */\n const fileFor = useCallback((entry: PromptDraftFile): File => {\n const real = filesRef.current.get(entry.id);\n if (real) return real;\n let stand = placeholdersRef.current.get(entry.id);\n if (!stand) {\n stand = new File([], entry.name, { type: entry.type });\n placeholdersRef.current.set(entry.id, stand);\n }\n return stand;\n }, []);\n\n const heldPastes = useMemo<HeldPaste[]>(\n () =>\n model.pills.flatMap((p) =>\n p.kind === \"text\"\n ? [p.label !== undefined ? { id: p.id, text: p.text, label: p.label } : { id: p.id, text: p.text }]\n : [],\n ),\n [model.pills],\n );\n const heldImages = useMemo<HeldImage[]>(\n () =>\n model.pills.flatMap((p) =>\n p.kind === \"image\" ? [{ id: p.id, label: p.label, file: fileFor(p.file) }] : [],\n ),\n // filesVersion: a restored File arrived, so the stand-in can be swapped out.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [model.pills, fileFor, filesVersion],\n );\n\n const onHeldPastesChange = useCallback(\n (next: HeldPaste[]) =>\n commit((m) => {\n const current = m.pills.filter((p) => p.kind === \"text\");\n if (\n current.length === next.length &&\n current.every(\n (p, i) =>\n p.id === next[i]!.id &&\n p.kind === \"text\" &&\n p.text === next[i]!.text &&\n p.label === next[i]!.label,\n )\n ) {\n return m;\n }\n return {\n ...m,\n pills: [\n ...next.map(\n (p): PromptDraftPill =>\n p.label !== undefined\n ? { kind: \"text\", id: p.id, text: p.text, label: p.label }\n : { kind: \"text\", id: p.id, text: p.text },\n ),\n ...m.pills.filter((p) => p.kind === \"image\"),\n ],\n };\n }),\n [commit],\n );\n\n const onHeldImagesChange = useCallback(\n (next: HeldImage[]) =>\n commit((m) => {\n const before = new Map(\n m.pills.flatMap((p) => (p.kind === \"image\" ? [[p.id, p] as const] : [])),\n );\n if (before.size === next.length && next.every((i) => before.has(i.id))) return m;\n const images = next.map((image): PromptDraftPill => {\n const known = before.get(image.id);\n if (known && known.kind === \"image\") return known;\n // A new paste: its File is real, so keep it and offer it to the host.\n filesRef.current.set(image.id, image.file);\n const entry = fileMeta(image.id, image.file);\n const fileRef = persist(image.file, entry);\n return {\n kind: \"image\",\n id: image.id,\n label: image.label,\n file: fileRef === undefined ? entry : { ...entry, ref: fileRef },\n };\n });\n return { ...m, pills: [...m.pills.filter((p) => p.kind === \"text\"), ...images] };\n }),\n [commit, persist],\n );\n\n const editorRef = useRef<InlinePasteEditorHandle>(null);\n const paste = useInlinePaste({\n pasteThreshold,\n pasteImages,\n previewChars,\n renderPastePreview,\n classNames: pasteClassNames,\n disabled: false,\n heldPastes,\n onHeldPastesChange,\n heldImages,\n onHeldImagesChange,\n editorRef,\n });\n\n const attachments = useMemo<PromptAttachment[]>(\n () =>\n model.attachments.map((a) => ({\n id: a.id,\n name: a.name,\n bytes: a.bytes,\n file: filesRef.current.get(a.id),\n type: a.type,\n ...(a.ref !== undefined ? { ref: a.ref } : {}),\n })),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [model.attachments, filesVersion],\n );\n\n /*\n * Get Files back for entries that arrived without one — a restored draft, a\n * default draft, a controlled draft from storage. Each id is asked for once.\n */\n const restoreRef = useRef(restoreAttachment);\n restoreRef.current = restoreAttachment;\n useEffect(() => {\n const restore = restoreRef.current;\n if (!restore) return;\n for (const entry of promptDraftFiles(model)) {\n if (filesRef.current.has(entry.id) || requestedRef.current.has(entry.id)) continue;\n requestedRef.current.add(entry.id);\n const accept = (file: File | undefined) => {\n if (!(file instanceof Blob)) return;\n filesRef.current.set(entry.id, file as File);\n bumpFiles();\n };\n let out: ReturnType<typeof restore>;\n try {\n out = restore(entry);\n } catch (error) {\n console.error(\"PromptInput: restoreAttachment threw\", error);\n continue;\n }\n if (out && typeof (out as Promise<unknown>).then === \"function\") {\n (out as Promise<File | undefined>).then(accept, (error) =>\n console.error(\"PromptInput: restoreAttachment rejected\", error),\n );\n } else {\n accept(out as File | undefined);\n }\n }\n }, [model]);\n\n const setText = (next: string) => commit((m) => (m.text === next ? m : { ...m, text: next }));\n const [picker, setPicker] = useState<null | {\n kind: \"cmd\" | \"mention\";\n start: number;\n query: string;\n cursor: number;\n }>(null);\n const taRef = useRef<HTMLTextAreaElement>(null);\n const fileRef = useRef<HTMLInputElement>(null);\n const [dragOver, setDragOver] = useState(false);\n\n const colors = mentionColor ?? DEFAULT_MENTION_COLOR;\n\n /**\n * Resolved AFTER mount, never during render.\n *\n * `navigator` read during render disagrees with the server's HTML and\n * hydration patches it — so the fix for a wrong label would have introduced a\n * hydration mismatch instead. The first paint names `Ctrl`, which is\n * pressable on every platform including a Mac, and an Apple client swaps to\n * `⌘` on the next tick. A prop, when given, wins outright and no detection\n * runs at all.\n */\n const [detected, setDetected] = useState<FancyPlatform>(\"generic\");\n useEffect(() => {\n if (platform) return;\n setDetected(detectPlatform(browserPlatformHints()));\n }, [platform]);\n const modKey = modifierKeyLabel(platform ?? detected);\n\n const resolvedPlaceholder =\n placeholder ??\n `Ask anything. Type / for commands, @ for mentions. ${modKey}+Enter to send.`;\n\n // Estimated from what will actually be SENT — pills expanded — so a held\n // paste counts for its text, not for the few characters of its marker.\n const draftTokens = useMemo(\n () =>\n Math.ceil((inline ? paste.expand(text) : text).length / Math.max(1, charsPerToken)),\n [text, inline, paste, charsPerToken],\n );\n const tokens = (usedTokens ?? 0) + draftTokens;\n const ratio = Math.min(1, tokens / budgetTokens);\n const meterLevel: \"ok\" | \"caution\" | \"warn\" | \"muted\" | null =\n meter === \"hidden\"\n ? null\n : meter === \"near-limit\"\n ? ratio < meterShowAt\n ? null\n : ratio >= meterWarnAt\n ? \"warn\"\n : \"muted\"\n : ratio < 0.6\n ? \"ok\"\n : ratio < 0.85\n ? \"caution\"\n : \"warn\";\n const meterColor =\n meterLevel === \"ok\"\n ? \"#10b981\"\n : meterLevel === \"caution\"\n ? \"#f59e0b\"\n : meterLevel === \"warn\"\n ? \"#ef4444\"\n : \"#a1a1aa\";\n\n const filteredCmds = useMemo(\n () =>\n picker?.kind === \"cmd\"\n ? commands.filter((c) =>\n c.name.slice(1).toLowerCase().startsWith(picker.query.toLowerCase()),\n )\n : [],\n [picker, commands],\n );\n const filteredMentions = useMemo(\n () =>\n picker?.kind === \"mention\"\n ? mentions.filter((m) =>\n m.name.toLowerCase().includes(picker.query.toLowerCase()),\n )\n : [],\n [picker, mentions],\n );\n const items: Array<PromptCmd | PromptMention> =\n picker?.kind === \"cmd\"\n ? filteredCmds\n : picker?.kind === \"mention\"\n ? filteredMentions\n : [];\n\n useEffect(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.style.height = \"auto\";\n ta.style.height = Math.min(maxHeight, ta.scrollHeight) + \"px\";\n }, [text, maxHeight]);\n\n const updateText = (next: string, caret: number) => {\n setText(next);\n let triggerIdx = -1;\n let triggerKind: \"cmd\" | \"mention\" | null = null;\n for (let i = caret - 1; i >= 0; i--) {\n const ch = next[i];\n if (ch === \"@\") {\n triggerKind = \"mention\";\n triggerIdx = i;\n break;\n }\n if (ch === \"/\" && (i === 0 || /\\s/.test(next[i - 1] ?? \"\"))) {\n triggerKind = \"cmd\";\n triggerIdx = i;\n break;\n }\n if (/\\s/.test(ch)) break;\n }\n if (triggerKind !== null && triggerIdx >= 0) {\n const query = next.slice(triggerIdx + 1, caret);\n setPicker({ kind: triggerKind, start: triggerIdx, query, cursor: 0 });\n } else {\n setPicker(null);\n }\n };\n\n const insertChoice = (i: number) => {\n if (!picker || items.length === 0) return;\n const choice = items[i] ?? items[0];\n const insert =\n picker.kind === \"cmd\"\n ? (choice as PromptCmd).name + \" \"\n : `@${(choice as PromptMention).id} `;\n const before = text.slice(0, picker.start);\n const after = text.slice(picker.start + 1 + picker.query.length);\n const next = before + insert + after;\n setText(next);\n setPicker(null);\n if (inline) {\n // The editor rebuilds from the value and puts the caret back itself.\n editorRef.current?.setValue(next, before.length + insert.length);\n return;\n }\n requestAnimationFrame(() => {\n const ta = taRef.current;\n if (!ta) return;\n ta.focus();\n const pos = before.length + insert.length;\n ta.setSelectionRange(pos, pos);\n });\n };\n\n const submit = () => {\n // A message that is only a paste counts: its marker is in `text`.\n if (!text.trim() && attachments.length === 0) return;\n\n if (inline) {\n // Every pill goes out where it sits; pasted images join the attachments\n // in message order, with their Files, so a host sends them like any other.\n // A restored image without its bytes goes out with its `ref` and no `file`,\n // never with the empty stand-in that only exists so the pill can render.\n const pastedImages: PromptAttachment[] = paste.imagesIn(text).map((image) => {\n const entry = model.pills.find((p) => p.id === image.id);\n const meta = entry?.kind === \"image\" ? entry.file : fileMeta(image.id, image.file);\n return {\n id: image.id,\n name: meta.name,\n bytes: meta.bytes,\n file: filesRef.current.get(image.id),\n type: meta.type,\n ...(meta.ref !== undefined ? { ref: meta.ref } : {}),\n };\n });\n onSubmit(paste.expand(text), [...attachments, ...pastedImages]);\n } else {\n onSubmit(text, attachments);\n }\n // One commit for the whole reset, so a host saving on change sees one empty\n // draft rather than three half-empty ones.\n commit(() => EMPTY_DRAFT);\n filesRef.current.clear();\n placeholdersRef.current.clear();\n requestedRef.current.clear();\n setPicker(null);\n };\n\n /**\n * Focus requested by `setDraft(..., { focus: true })` waits for the render that\n * shows the draft: the inline editor rebuilds its DOM from the new value, which\n * would discard a caret placed before it. Children's layout effects run first,\n * so by the time this one runs the editor already holds the draft.\n */\n const pendingFocus = useRef(false);\n const focusInput = useCallback(() => {\n if (inline) {\n editorRef.current?.focus();\n return;\n }\n const ta = taRef.current;\n if (!ta) return;\n ta.focus();\n ta.setSelectionRange(ta.value.length, ta.value.length);\n }, [inline]);\n useLayoutEffect(() => {\n if (!pendingFocus.current) return;\n pendingFocus.current = false;\n focusInput();\n });\n\n useImperativeHandle(\n ref,\n () => ({\n getDraft: () => clonePromptDraft(modelRef.current),\n setDraft(next: PromptDraft, options?: PromptSetDraftOptions) {\n const read = readPromptDraft(next, inline);\n if (!read) {\n console.warn(\n \"PromptInput: setDraft ignored a draft it does not recognise (expected { v: 1, ... }).\",\n next,\n );\n return;\n }\n // Ask again for any File this draft needs that is not already held.\n for (const entry of promptDraftFiles(read)) {\n if (!filesRef.current.has(entry.id)) requestedRef.current.delete(entry.id);\n }\n setPicker(null);\n commit(() => read, false);\n // `commit` always sets state here (`read` is a new object), so a render\n // follows and the layout effect below picks the focus up.\n if (options?.focus) pendingFocus.current = true;\n },\n focus: focusInput,\n }),\n [inline, commit, focusInput],\n );\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLElement>) => {\n if (picker) {\n if (e.key === \"ArrowDown\") {\n e.preventDefault();\n setPicker((p) =>\n p ? { ...p, cursor: Math.min(items.length - 1, p.cursor + 1) } : p,\n );\n return;\n }\n if (e.key === \"ArrowUp\") {\n e.preventDefault();\n setPicker((p) => (p ? { ...p, cursor: Math.max(0, p.cursor - 1) } : p));\n return;\n }\n // Tab completes, as Enter does: the autocomplete key people expect from a\n // shell or Claude Code. Only while a menu is open; otherwise Tab moves\n // focus as usual.\n if (((e.key === \"Enter\" && !e.metaKey && !e.ctrlKey) || (e.key === \"Tab\" && !e.shiftKey)) && items.length > 0) {\n e.preventDefault();\n insertChoice(picker.cursor);\n return;\n }\n if (e.key === \"Escape\") {\n e.preventDefault();\n setPicker(null);\n return;\n }\n }\n if (e.key === \"Enter\" && (e.metaKey || e.ctrlKey)) {\n e.preventDefault();\n submit();\n }\n };\n\n /**\n * Build attachments from a FileList, KEEPING the File.\n *\n * Shared by the drop handler and the picker so the two cannot drift — the\n * picker being a second, subtly different copy of this is exactly how one of\n * them would end up dropping the File again.\n */\n const attach = (list: FileList | File[] | null) => {\n const files = Array.from(list ?? []);\n if (files.length === 0) return;\n\n const added = files.map((f) => {\n const id = crypto.randomUUID();\n filesRef.current.set(id, f);\n const entry = fileMeta(id, f);\n const fileRef = persist(f, entry);\n return fileRef === undefined ? entry : { ...entry, ref: fileRef };\n });\n commit((m) => ({ ...m, attachments: [...m.attachments, ...added] }));\n };\n\n const onDrop = (e: React.DragEvent<HTMLDivElement>) => {\n e.preventDefault();\n setDragOver(false);\n attach(e.dataTransfer.files);\n };\n\n /**\n * Paste a screenshot, get an attachment.\n *\n * There was no paste handler at all, so a pasted image did nothing — no chip,\n * no error — and a host that had swapped its own paste-capable textarea for\n * this component lost the feature without noticing.\n *\n * Files attach only when the clipboard carries NO plain text. Word, Excel and\n * most editors put a picture of the selection beside the text; attaching that\n * would turn every pasted sentence into a screenshot of the sentence. A pure\n * image paste has nothing for the browser to insert, so the default is\n * prevented only then, and a text paste is never touched.\n */\n const onPaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n const data = e.clipboardData;\n const files = Array.from(data?.files ?? []);\n\n if (files.length === 0 || (data?.getData(\"text/plain\") ?? \"\") !== \"\") return;\n\n e.preventDefault();\n attach(files);\n };\n\n return (\n <div\n // Spread FIRST so an internal handler or data attribute cannot be\n // clobbered from outside, and so a missing one fails loudly here rather\n // than at a consumer's selector. `className` is merged below instead.\n {...rest}\n // The component had no root handle at all, so an agent reading the\n // composer had to guess at classes. The drag state is on it too: a bridge\n // that wants to know whether a drop is in flight should not have to infer\n // it from Tailwind colours.\n data-react-fancy-prompt-input=\"\"\n data-react-fancy-prompt-input-drag={dragOver ? \"over\" : \"idle\"}\n onDragOver={(e) => {\n e.preventDefault();\n setDragOver(true);\n }}\n onDragLeave={() => setDragOver(false)}\n onDrop={onDrop}\n className={cn(\n \"relative rounded-md border bg-[color:var(--fancy-surface,var(--color-white))] transition dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\",\n dragOver\n ? \"border-violet-400 bg-violet-50/50 dark:border-violet-600 dark:bg-violet-950/30\"\n : \"border-zinc-200 dark:border-zinc-800\",\n className,\n )}\n >\n {aboveInput && (\n <div className=\"border-b border-zinc-200 dark:border-zinc-800\">\n {aboveInput}\n </div>\n )}\n {attachments.length > 0 && (\n <div className=\"flex flex-wrap gap-1.5 border-b border-zinc-200 px-3 py-2 dark:border-zinc-800\">\n {attachments.map((a) => (\n <span\n key={a.id}\n // Stable handle per chip, so a host or agent can address one\n // attachment without guessing at markup.\n data-react-fancy-prompt-input-attachment={a.id}\n className=\"inline-flex items-center gap-1.5 rounded-md bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] px-2 py-0.5 text-[11px] dark:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\"\n >\n <Icon name=\"paperclip\" size=\"xs\" className=\"text-zinc-400\" />\n <span className=\"font-mono\">{a.name}</span>\n <span className=\"text-zinc-400\">{fmtSize(a.bytes)}</span>\n <button\n onClick={() =>\n commit((m) => ({\n ...m,\n attachments: m.attachments.filter((x) => x.id !== a.id),\n }))\n }\n className=\"opacity-50 hover:opacity-100\"\n aria-label=\"Remove attachment\"\n >\n ×\n </button>\n </span>\n ))}\n </div>\n )}\n\n <div className=\"relative\">\n {inline ? (\n <>\n <InlinePasteEditor\n ref={editorRef}\n value={text}\n known={paste.known}\n onChange={(next, caret) => {\n updateText(next, caret);\n paste.prune(next);\n }}\n onSubmit={submit}\n submitKey=\"mod-enter\"\n onKeyDown={onKeyDown}\n onPaste={paste.decidePaste}\n onHostsChange={paste.onHostsChange}\n placeholder={resolvedPlaceholder}\n disabled={false}\n maxHeight={maxHeight}\n placeholderClassName=\"left-3 top-2.5 text-[14px] leading-relaxed\"\n className={cn(\n \"block min-h-[5.5rem] px-3 py-2.5 text-[14px] leading-relaxed\",\n pasteClassNames?.input,\n )}\n />\n {paste.portals}\n {pasteImages && pasteFilesName && (\n <PastedFilesInput\n name={pasteFilesName}\n files={paste\n .imagesIn(text)\n .flatMap((i) => (filesRef.current.has(i.id) ? [i.file] : []))}\n />\n )}\n </>\n ) : (\n <textarea\n ref={taRef}\n value={text}\n onChange={(e) => updateText(e.target.value, e.target.selectionStart)}\n onKeyDown={onKeyDown}\n onPaste={onPaste}\n placeholder={resolvedPlaceholder}\n spellCheck={false}\n className=\"block w-full resize-none bg-transparent px-3 py-2.5 text-[14px] leading-relaxed outline-none placeholder:text-zinc-400\"\n rows={3}\n />\n )}\n\n {picker && items.length > 0 && (\n <div className=\"absolute bottom-full left-2 z-10 mb-1 w-72 overflow-hidden rounded-md border border-[color:var(--fancy-border,var(--color-zinc-200))] bg-[color:var(--fancy-surface,var(--color-white))] shadow-lg dark:border-[color:var(--fancy-border-dark,var(--color-zinc-700))] dark:bg-[color:var(--fancy-surface-dark,var(--color-zinc-900))]\">\n <div className=\"border-b border-zinc-100 bg-zinc-50 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-zinc-500 dark:border-zinc-800 dark:bg-zinc-950\">\n {picker.kind === \"cmd\" ? \"Commands\" : \"Mention\"} · {items.length}\n </div>\n <ul className=\"max-h-56 overflow-y-auto\">\n {items.map((item, i) => {\n const active = i === picker.cursor;\n if (picker.kind === \"cmd\") {\n const c = item as PromptCmd;\n return (\n <li\n key={c.name}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`cursor-pointer px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <div className=\"font-mono font-medium text-violet-700 dark:text-violet-300\">\n {c.name}\n </div>\n <div className=\"text-[11px] text-zinc-500\">{c.hint}</div>\n </li>\n );\n }\n const m = item as PromptMention;\n return (\n <li\n key={m.id}\n onMouseDown={(e) => {\n e.preventDefault();\n insertChoice(i);\n }}\n onMouseEnter={() =>\n setPicker((p) => (p ? { ...p, cursor: i } : p))\n }\n className={`flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[12px] ${\n active\n ? \"bg-violet-100 dark:bg-violet-900/30\"\n : \"hover:bg-zinc-50 dark:hover:bg-zinc-800\"\n }`}\n >\n <span\n className=\"h-2 w-2 rounded-full\"\n style={{ backgroundColor: colors[m.kind] ?? \"#71717a\" }}\n />\n <span className=\"font-medium\">{m.name}</span>\n <span className=\"ml-auto text-[10px] uppercase tracking-wider text-zinc-400\">\n {m.kind}\n </span>\n </li>\n );\n })}\n </ul>\n </div>\n )}\n </div>\n\n <div className=\"flex items-center gap-2 border-t border-zinc-200 bg-zinc-50/60 px-3 py-2 dark:border-zinc-800 dark:bg-zinc-900/40\">\n <Tooltip content={attachButton === \"icon\" ? \"Attach files — or drop them here\" : \"Drop files here, or click\"}>\n <Button\n variant=\"ghost\"\n size=\"sm\"\n icon=\"paperclip\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-attach=\"\"\n // An icon alone has no name; the tooltip is not one a screen reader reads.\n aria-label={attachButton === \"icon\" ? \"Attach files\" : undefined}\n onClick={() => fileRef.current?.click()}\n >\n {attachButton === \"icon\" ? null : \"attach\"}\n </Button>\n </Tooltip>\n {/*\n The button above shipped with a no-op onClick and a tooltip reading\n \"Drop files here, or click\" — an affordance that lied. Drop-only also\n meant keyboard and touch users could not attach at all.\n\n It then shipped with a literal paperclip EMOJI as its icon, which\n needs a COLOUR\n EMOJI FONT — not merely broad coverage — so a lean container renders a\n tofu box where the affordance should be. `icon=\"paperclip\"` draws an\n SVG from the kit's own icon layer, which is the same reason the rest of\n the suite does not hand-roll iconography.\n */}\n <input\n ref={fileRef}\n type=\"file\"\n multiple\n className=\"hidden\"\n onChange={(e) => {\n attach(e.target.files);\n // Let the same file be picked twice in a row.\n e.target.value = \"\";\n }}\n />\n {meterLevel !== null && (\n <div\n data-react-fancy-prompt-input-meter=\"\"\n data-level={meterLevel}\n className=\"ml-2 flex min-w-0 items-center gap-1.5 overflow-hidden\"\n >\n <div className=\"h-1.5 w-24 shrink overflow-hidden rounded-full bg-[color:var(--fancy-border,var(--color-zinc-200))] dark:bg-[color:var(--fancy-border-dark,var(--color-zinc-700))]\">\n <div\n className=\"h-full rounded-full transition-all\"\n style={{ width: `${ratio * 100}%`, backgroundColor: meterColor }}\n />\n </div>\n <span className=\"font-mono text-[11px]\" style={{ color: meterColor }}>\n {fmtTokens(tokens)} / {fmtTokens(budgetTokens)}\n </span>\n </div>\n )}\n <div className=\"ml-auto flex shrink-0 items-center gap-2\">\n {/* With an icon send button the shortcut lives in its tooltip instead. */}\n {showHint && sendButton !== \"icon\" && (\n <span\n className=\"hidden text-[10px] text-zinc-500 sm:inline\"\n data-react-fancy-prompt-input-hint={modKey === \"⌘\" ? \"apple\" : \"generic\"}\n >\n <kbd className=\"rounded border border-[color:var(--fancy-border-strong,var(--color-zinc-300))] bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\">\n {modKey}\n </kbd>{\" \"}\n +{\" \"}\n <kbd className=\"rounded border border-[color:var(--fancy-border-strong,var(--color-zinc-300))] bg-zinc-50 px-1 py-0.5 font-mono text-[9px] text-[color:var(--fancy-text-soft,var(--color-zinc-700))] dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-700))] dark:bg-zinc-800 dark:text-[color:var(--fancy-text-soft-dark,var(--color-zinc-300))]\">\n Enter\n </kbd>{\" \"}\n to send\n </span>\n )}\n {sendButton === \"icon\" ? (\n <Tooltip content={`Send · ${modKey}+Enter`}>\n <Button\n color=\"violet\"\n size=\"sm\"\n icon=\"arrow-up\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n aria-label=\"Send\"\n onClick={submit}\n />\n </Tooltip>\n ) : (\n <Button\n color=\"violet\"\n size=\"sm\"\n iconTrailing=\"arrow-right\"\n className=\"shrink-0\"\n data-react-fancy-prompt-input-send=\"\"\n onClick={submit}\n >\n send\n </Button>\n )}\n </div>\n </div>\n </div>\n );\n});\n\nfunction fmtTokens(n: number): string {\n if (n < 1000) return `${n}`;\n return `${(n / 1000).toFixed(1)}k`;\n}\n\nfunction fmtSize(b: number): string {\n if (b < 1024) return `${b} B`;\n if (b < 1024 * 1024) return `${(b / 1024).toFixed(0)} KB`;\n return `${(b / 1024 / 1024).toFixed(1)} MB`;\n}\n"]}