meowtail 0.4.0-alpha.4 → 0.4.0-alpha.6

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 (49) hide show
  1. package/ASSISTANT.md +1 -1
  2. package/CHANGELOG.md +37 -0
  3. package/COMPONENTS.md +3 -2
  4. package/README.md +77 -2
  5. package/dist/src/chat/assistant-composer.js +1 -10
  6. package/dist/src/chat/assistant-types.d.ts +6 -0
  7. package/dist/src/chat/composer-triggers.d.ts +70 -0
  8. package/dist/src/chat/composer-triggers.js +35 -0
  9. package/dist/src/chat/composer.d.ts +24 -4
  10. package/dist/src/chat/composer.js +288 -8
  11. package/dist/src/chat/index.d.ts +1 -0
  12. package/dist/src/chat/index.js +1 -0
  13. package/dist/src/components/button.d.ts +3 -1
  14. package/dist/src/components/button.js +16 -1
  15. package/dist/src/components/choice-select.d.ts +5 -2
  16. package/dist/src/components/choice-select.js +7 -3
  17. package/dist/src/components/index.d.ts +1 -0
  18. package/dist/src/components/index.js +1 -0
  19. package/dist/src/components/item.d.ts +7 -2
  20. package/dist/src/components/item.js +4 -4
  21. package/dist/src/components/stat.d.ts +24 -0
  22. package/dist/src/components/stat.js +15 -0
  23. package/dist/src/registry/index.d.ts +5 -1
  24. package/dist/src/registry/index.js +2 -0
  25. package/dist/src/theme/base.styles.js +5 -0
  26. package/dist/src/theme/chat/composer.styles.js +98 -0
  27. package/dist/src/theme/components/button.styles.js +25 -11
  28. package/dist/src/theme/components/choice-select.styles.js +19 -4
  29. package/dist/src/theme/components/item.styles.js +13 -5
  30. package/dist/src/theme/components/nav-list.styles.js +2 -0
  31. package/dist/src/theme/components/output-block.styles.js +35 -10
  32. package/dist/src/theme/components/stat.styles.d.ts +1 -0
  33. package/dist/src/theme/components/stat.styles.js +54 -0
  34. package/dist/src/theme/doodle.tokens.d.ts +120 -58
  35. package/dist/src/theme/doodle.tokens.js +50 -27
  36. package/dist/src/theme/index.d.ts +428 -30
  37. package/dist/src/theme/index.js +18 -0
  38. package/dist/src/theme/journal.tokens.d.ts +62 -0
  39. package/dist/src/theme/journal.tokens.js +2 -0
  40. package/dist/src/theme/meow.tokens.d.ts +62 -0
  41. package/dist/src/theme/meow.tokens.js +2 -0
  42. package/dist/src/theme/ottr.tokens.d.ts +62 -0
  43. package/dist/src/theme/ottr.tokens.js +1 -0
  44. package/dist/src/theme/pine.tokens.d.ts +426 -0
  45. package/dist/src/theme/pine.tokens.js +126 -0
  46. package/dist/src/theme/tokens.d.ts +70 -0
  47. package/dist/src/theme/tokens.js +35 -0
  48. package/dist/src/theme/utilities.js +1 -1
  49. package/package.json +2 -2
package/ASSISTANT.md CHANGED
@@ -49,7 +49,7 @@ A finished reply carries a quiet action row: Copy (built in; it copies the reply
49
49
 
50
50
  Message `parts` include `text`, `code`, `process`, `attachments`, `tool`, and `task`. `text` is safe Markdown by default: raw HTML and images are shown as text, and only explicit HTTP, HTTPS, and mailto links navigate; code parts use the shared `CodeBlock`. Text renders through the shared `Markdown` blocks: while a message has `status: "streaming"`, its last text part completes half-typed markers in its open tail, and finished blocks are never rewritten, so a reader's selection in them survives. Fenced code in text is drawn with the same `CodeBlock` as code parts, with highlighting and copy. Processes use native disclosure, and process steps take only normalized titles, descriptions, status text, and visual tone. A process may also carry `state` (the same execution states as tool and task parts): its header then shows the shared state badge after the title, with `statusText` as a quiet fact beside it. Whether the badge exists is fixed by the part's first value; later states update its tone and word in place. Without `state` the header shows the title and `statusText` alone.
51
51
 
52
- `renderPart` can replace just one part, and returning `undefined` uses the default implementation; `renderWorkDetail` replaces only the detail body. `composerTrailing` and `headerActions` hold local controls without replacing the whole page. Custom components still consume ancestor Context in the original render tree and do not create another renderer root.
52
+ `renderPart` can replace just one part, and returning `undefined` uses the default implementation; `renderWorkDetail` replaces only the detail body. `composerTrailing` and `headerActions` hold local controls without replacing the whole page; `composerTriggers` adds `@` mentions or `/` commands to the composer with the shared trigger contract described in the README. Custom components still consume ancestor Context in the original render tree and do not create another renderer root.
53
53
 
54
54
  New default copy is centralized in `assistantCopy`; hosts can override local text with `labels={{ latest: "Back to latest", send: "Send" }}` without installing a separate internationalization runtime. Titles, statuses, and descriptions in the data are still provided by the host.
55
55
 
package/CHANGELOG.md CHANGED
@@ -116,6 +116,43 @@
116
116
  - Add `journalFonts` and the `ThemeFont` type: the Fontsource packages that carry the faces Journal
117
117
  names. Meowtail ships no font files. The gallery paints Journal stories with those faces.
118
118
 
119
+ ## 0.4.0-alpha.6
120
+
121
+ Requires `meowjsx@^0.3.0-alpha.1` and `meowcss@^0.3.0-alpha.2`. Released together with
122
+ `meowjsx@0.3.0-alpha.3`, which adds the `meowjsx/router` entry.
123
+
124
+ - `ChatComposer` is the one place to extend a draft ([design](../../docs/designs/2026-11-27-composer-extensions.md)):
125
+ - `defaultValue` and `onValueChange` give it the Autocomplete ownership shape; without `value` it
126
+ keeps a local draft.
127
+ - `submitOn` (`"none"`, `"enter"`, `"mod-enter"`) submits through the form's submit button, so a
128
+ blocked composer swallows the key and IME composition never submits. `AssistantComposer` uses
129
+ it instead of its own Enter handler.
130
+ - `triggers` turn characters into host suggestions (`@` mentions, `/` commands, `#` paths) with
131
+ one keyboard order, a surface-anchored listbox, async lookups with an `AbortSignal`, removable
132
+ or drill-down inserts and a live region. New parts: `suggestions`, `suggestionList`,
133
+ `suggestion`, `suggestionLeading`, `suggestionCopy`, `suggestionLabel`,
134
+ `suggestionDescription`, `suggestionMeta`, `suggestionStatus` and `announcement`.
135
+ - `findComposerTrigger` and `insertComposerSuggestion` are exported for hosts and tests.
136
+ - `AssistantView` accepts `composerTriggers`.
137
+ - `ChoiceSelect` takes a Signal for `disabled`, and `ChoiceOption` an optional `description` line
138
+ (new parts `optionLabel` and `description`).
139
+ - `Item` accepts an `href`: the whole item becomes a link with the button item's hover and focus
140
+ treatment, and a selected link item carries `aria-current="page"`. The leading slot now centers on
141
+ the first text line (`1lh`), so a state dot and an icon sit level with the title.
142
+ - Add `Stat`, one summary figure with a label, the figure in the page-title size, an optional
143
+ supporting fact and an optional `href`. It joins `meowUIComponents` and `standardThemeStyles`.
144
+ - `NavList` packs its rows at the top when a sidebar gives it spare height.
145
+ - Button accepts an `href` for navigation with native link semantics and the same theme styling as
146
+ button actions. The documentation's home entry uses it instead of a separately styled link.
147
+ - Doodle dark uses quieter ink edges and a darker blue and rust action palette.
148
+
149
+ ## 0.4.0-alpha.5
150
+
151
+ - Improve Doodle with a paper wash, independent decorative marker colors, physical ink borders
152
+ and a press state that collapses the shadow without hiding the border.
153
+ - Add Pine, a cool paper-and-pine theme with a fixed-dark terminal palette, available in the docs
154
+ and component gallery.
155
+
119
156
  ## 0.4.0-alpha.4
120
157
 
121
158
  - Add `doodleTheme`, an editorial paper-and-ink theme with crisp outlines and optional Geist.
package/COMPONENTS.md CHANGED
@@ -178,7 +178,8 @@ reason or review before it is added.
178
178
  | [Card](src/components/card.tsx) | [`Card`](src/components/card.tsx) | [`CardHeader`](src/components/card-header.tsx), [`CardTitle`](src/components/card-title.tsx), [`CardDescription`](src/components/card-description.tsx), [`CardContent`](src/components/card-content.tsx), [`CardFooter`](src/components/card-footer.tsx), [`CardAction`](src/components/card-action.tsx) | Card is the surface; CardHeader groups identity/actions; CardTitle provides its heading; CardDescription supplies context; CardContent holds its body; CardFooter holds closing content/actions; CardAction is the header action slot. | Gives one related object a coherent structure. Use a plain section for ordinary document flow and avoid adding a card around every nested block. |
179
179
  | [Resource card](src/components/resource-card.tsx) | [`ResourceCard`](src/components/resource-card.tsx) | — | Presents a capability/resource's identity, status, description, and actions. | Fits service or resource overviews where users must identify what is available and what they can do next. Status facts come from the host. |
180
180
  | [List](src/components/list-group.tsx) | [`ListGroup`](src/components/list-group.tsx) | `ListRow` | ListGroup groups records; ListRow arranges an individual record's content, state, and actions. | Supports repeated records without table columns. Navigation-specific lists use destination semantics instead. |
181
- | [Item](src/components/item.tsx) | [`Item`](src/components/item.tsx) | — | Arranges one readable item with leading/trailing content, description, and metadata, optionally as a button. | Provides a smaller content unit than a full record row. A button item must not contain nested controls. |
181
+ | [Item](src/components/item.tsx) | [`Item`](src/components/item.tsx) | — | Arranges one readable item with leading/trailing content, description, and metadata, optionally as a button or, with `href`, a link. | Provides a smaller content unit than a full record row. A button item must not contain nested controls. |
182
+ | [Stat](src/components/stat.tsx) | [`Stat`](src/components/stat.tsx) | — | One summary figure: a short label, the uncolored figure and an optional supporting fact, optionally linking to the records it counts. | Gives overview strips one figure hierarchy instead of card titles over small numbers. State stays in a Status; the host owns the value and its unknown wording. |
182
183
  | [Description list](src/components/description-list.tsx) | [`DescriptionList`](src/components/description-list.tsx) | `DescriptionItem` | DescriptionList groups named facts; DescriptionItem supplies a term and its value. | Preserves name/value semantics for inspectors and details instead of using a table solely for alignment. |
183
184
  | [Timeline](src/components/timeline.tsx) | [`Timeline`](src/components/timeline.tsx) | `TimelineItem` | Timeline groups an ordered event history; TimelineItem presents one event. | Makes chronology readable without interpreting events as live execution or scheduling tasks. |
184
185
  | [Entries](src/components/entry.tsx) | [`EntryList`](src/components/entry.tsx), `Entry` | — | Entry summarizes one piece of content: a kicker, a heading that can link to it, a standfirst and its facts; EntryList runs entries on the surrounding surface, opening each with a hairline. | Fits blog indexes, notes, release lists and search results, where each item is a titled document rather than a row in a box. An Entry is a list item in an EntryList and an article alone; its heading level follows the region. |
@@ -234,7 +235,7 @@ from `meowtail/components`; they are not chat-subpath exports. All are re-export
234
235
  | [Message](src/chat/message.tsx) | [`ChatMessage`](src/chat/message.tsx) | [`ChatBubble`](src/chat/bubble.tsx), [`ChatMessageActions`](src/chat/message-actions.tsx) | ChatMessage arranges role/author/status and content; ChatBubble provides bubble presentation; ChatMessageActions groups actions associated with one message. | Preserves identity and action scope while allowing either document-like messages or bubbles. |
235
236
  | [Message list](src/chat/message-list.tsx) | [`ChatMessageList`](src/chat/message-list.tsx) | `ChatMessageListContent`, `ChatMessageListItem`, `ChatMessageListDate` | ChatMessageList is the accessible log; ChatMessageListContent is its independently rendered message target; ChatMessageListItem hosts one message and continuity marker; ChatMessageListDate separates dates. | Makes custom logs composable without treating a date separator as a message. The caller supplies stable identities and continuity facts. |
236
237
  | [Conversation scrolling](src/chat/conversation.tsx) | [`ChatConversation`](src/chat/conversation.tsx), `ChatConversationLatest` | — | ChatConversation owns scrolling for an append-only transcript; ChatConversationLatest is a normal-flow latest-message action for a host that already owns scrolling. | Choose one scroll owner. The standalone action leaves visibility, navigation, and focus restoration to the host. |
237
- | [Composer](src/chat/composer.tsx) | [`ChatComposer`](src/chat/composer.tsx), [`ComposerPanel`](src/chat/composer-panel.tsx) | — | ChatComposer provides the writing/submit surface; ComposerPanel composes it with a page-level metadata region. | Reuses input interactions without a second writing surface. Sending, stopping, draft persistence, and submission acceptance remain explicit host responsibilities. |
238
+ | [Composer](src/chat/composer.tsx) | [`ChatComposer`](src/chat/composer.tsx), [`ComposerPanel`](src/chat/composer-panel.tsx) | — | ChatComposer provides the writing/submit surface with keyboard submit and host-suggested triggers (mentions, commands, paths); ComposerPanel composes it with a page-level metadata region. | Reuses input interactions without a second writing surface. Sending, stopping, draft persistence, and submission acceptance remain explicit host responsibilities. |
238
239
  | [Attachments](src/chat/attachments.tsx) | [`ChatAttachments`](src/chat/attachments.tsx) | — | Presents message or draft attachments. | Keeps attachments recognizable while their upload, access, and persistence remain host facts. |
239
240
  | [Chat status](src/chat/status.tsx) | [`ChatStatus`](src/chat/status.tsx) | — | Presents compact conversation status text and tone. | Fits chat chrome; it does not calculate the execution state of every background task. |
240
241
  | [Tool call](src/chat/tool-call.tsx) | [`ChatToolCall`](src/chat/tool-call.tsx) | — | Presents an action/target, explicit execution state, expandable input/output, and retry/cancel intent. | Keeps long results and actions in their tool context. Missing output is not failure, and callbacks do not execute or change the tool state automatically. |
package/README.md CHANGED
@@ -184,7 +184,7 @@ focus into a 256px drawer over the content, and a collapsed group folds into one
184
184
  `Button`'s `outline` is the secondary level, plus `accent` (a soft background related to current activity) and `stop` (to interrupt running work).
185
185
  Details and page structures added in the second stage: `DetailSection` (a block with a hairline; its title is a small label rather than a page title), `Timeline` and
186
186
  `TimelineItem` (events threaded on one line, with markers following `StatusDot` semantics), `ResourceLink` (a whole-row reference to an openable object:
187
- a link when href is present, otherwise a button); `PageHeader` (page name, one-sentence purpose, an optional `leading` mark before the title, and page-level actions; `Page` forwards `leading` into that header), `ListGroup` and `ListRow` (sibling entries share one
187
+ a link when href is present, otherwise a button); `Item` takes the same `href` and marks a selected link `aria-current="page"`, which suits master-detail lists; `Stat` is one summary figure (label, figure, optional fact, optional `href`) for overview strips; `PageHeader` (page name, one-sentence purpose, an optional `leading` mark before the title, and page-level actions; `Page` forwards `leading` into that header), `ListGroup` and `ListRow` (sibling entries share one
188
188
  outline, an editing area can expand below a row, and a standalone row with `tone="accent"` is a summary row), `ResourceCard` (a capability on an overview page, with a dashed
189
189
  low-contrast disabled state); `Drawer` is a narrow-screen native modal panel that slides in from the start edge, with backdrop clicks and Escape handed to the host to update `open`. `SegmentedControl`
190
190
  tightens its track and selected state to match the design draft. The narrow-screen `ChatComposer` stacked layout puts "add, input, send" on one row and keeps model selection below.
@@ -464,6 +464,60 @@ the Composer inside uses its natural width within that container and is no longe
464
464
  Request state, submitted snapshots, and the latest draft are managed by the caller. `attachments` holds materials to send, and `inputLabel` provides the input name.
465
465
  The form groups a writing `surface` and its supporting `hint`. Attachments, input and actions stay inside the surface; the hint follows outside its rounded edge and focus outline, associated with the textarea by `hintId`. Page-level metadata follows the whole composer.
466
466
  `surface="none"` removes only the internal writing surface's chrome and padding for explicit bare embedding; it does not move the hint back inside a surface.
467
+
468
+ #### Extending the composer: choices, triggers and keyboard submit
469
+
470
+ One `ChatComposer` takes every extension, so model choice, project choice, mentions and commands
471
+ share one keyboard order and one place for state. The design record is
472
+ [Composer extensions](../../docs/designs/2026-11-27-composer-extensions.md).
473
+
474
+ - **Text.** `value` (a Signal stays live) is controlled; without it a local draft starts at
475
+ `defaultValue`. `onValueChange` reports every edit and every text change the composer makes
476
+ itself, such as an accepted suggestion or a form reset.
477
+ - **Keyboard submit.** `submitOn="enter"` submits on Enter (Shift+Enter for a newline);
478
+ `"mod-enter"` on Cmd or Ctrl+Enter; the default `"none"` leaves Enter to the textarea. The key
479
+ goes through the form's submit button, so a `submitDisabled` composer swallows it, and IME
480
+ composition never submits. State the key in `hint`.
481
+ - **Choices** are values the whole draft is sent with: model, reasoning, project, priority. Put
482
+ host-controlled `ChoiceSelect`s in `trailing`, `searchable` when the list can grow; option
483
+ `description` carries a supporting line and `disabled` accepts a Signal for a pending send.
484
+ One-off actions (save as draft) are a `MenuButton` beside them.
485
+ - **Triggers** are characters that turn into text: `@` mentions, `/` commands, `#` paths. Each
486
+ `ComposerTrigger` names its `char`, `label` and a `suggest(query, { signal })` that returns
487
+ host-filtered `ComposerSuggestion`s, synchronously or as a Promise; `position: "start"` limits
488
+ commands to the start of the draft. The composer detects the caret's word, shows one listbox
489
+ under or over the surface, owns ArrowUp/ArrowDown, Enter and Tab (only while an option is
490
+ active) and Escape, writes `insert` (default `char + id`, `""` to remove the trigger text) and
491
+ then calls `onAccept`. Focus stays in the textarea, pastes never open a list, and a live region
492
+ announces counts. `triggers` is fixed for the mount; turn one off with its `disabled` Signal.
493
+ - **References stay with the host.** The draft holds plain text (`@t-105`). Record structured
494
+ references in `onAccept`, show them in `attachments`, and drop one when its token leaves the text.
495
+
496
+ ```tsx
497
+ <ChatComposer
498
+ value={draft}
499
+ onValueChange={(text) => (draft.value = text)}
500
+ submitOn="enter"
501
+ hint="Enter to send · Shift+Enter for a new line"
502
+ hintId="draft-hint"
503
+ triggers={[
504
+ {
505
+ char: "@",
506
+ label: "Tasks",
507
+ suggest: (query) =>
508
+ tasks.value
509
+ .filter((task) => task.title.includes(query))
510
+ .map((task) => ({ id: task.id, label: task.title, meta: task.id })),
511
+ onAccept: (suggestion) => (refs.value = [...refs.value, suggestion.id]),
512
+ },
513
+ ]}
514
+ trailing={<ChoiceSelect aria-label="Model" options={models} value={model} searchable />}
515
+ onSubmit={send}
516
+ />
517
+ ```
518
+
519
+ `AssistantView` passes `composerTriggers` to its composer and submits on Enter through the same
520
+ `submitOn` path.
467
521
  `layout="inline"` puts short drafts and actions on the same row, and long drafts keep growing; its external hint appears on focus. The default `stacked` keeps the tool row at the bottom of the writing surface. On narrow screens, attach/input/send share the writing row and model selection sits below it; the supporting hint remains outside the surface and wraps. The `hero` hint retains its visually hidden presentation.
468
522
  `layout="hero"` uses the input height of the desktop master blank conversation. `trailing` composes selection entry points such as provider and model to the left of the send button;
469
523
  a controlled `ChoiceSelect` can be passed, expanding grouped options upward with `placement="top"`, `align="end"`, and `matchTriggerWidth={false}`.
@@ -571,7 +625,10 @@ applyTheme(document.documentElement, meowTheme);
571
625
  mint actions and selected rows, compact system typography, quiet borders, and softly rounded panels.
572
626
  It supports light, dark and system appearance, with no additional fonts or business-specific markup.
573
627
  It shares the standard component styles; the theme supplies `ottrUiTokenValues` (compiled as
574
- `ottrUiTokens`) and keeps the large control size available for touch layouts.
628
+ `ottrUiTokens`) and keeps the large control size available for touch layouts. A workbench built on
629
+ it composes `NavList` and `AppBar` for the shell, `Item` links with a leading `StatusDot` for
630
+ master-detail lists, `Status` beside detail titles, `Stat` in `Card`s for overview figures and
631
+ `ComposerPanel` with `MenuButton` choices for record creation.
575
632
 
576
633
  ```ts
577
634
  import { ottrTheme } from "meowtail/theme";
@@ -595,6 +652,24 @@ import { createMeowUITheme } from "meowtail/web";
595
652
  const theme = createMeowUITheme({ theme: doodleTheme });
596
653
  ```
597
654
 
655
+ Doodle uses independent control stroke, resting lift, and press roles, so the ink border stays
656
+ visible as the button sinks. The canvas wash and marker colors are decorative; status colors remain
657
+ separate. Compare the same form and metric cards in the gallery's Theme Workbench.
658
+
659
+ ### Pine theme
660
+
661
+ `pineTheme` uses cool paper and deep pine green in light mode, and blue-black with mint in dark
662
+ mode. Its TerminalBlock stays dark in either scheme. Command and prompt ink use mint, ANSI
663
+ magenta maps to lavender, and exit status has a separate color. `pineFonts` names the optional
664
+ Inter web font. The monospace stack prefers IBM Plex Mono when supplied by the host.
665
+
666
+ ```ts
667
+ import { pineTheme } from "meowtail/theme";
668
+ import { createMeowUITheme } from "meowtail/web";
669
+
670
+ const theme = createMeowUITheme({ theme: pineTheme });
671
+ ```
672
+
598
673
  All built-in themes share one theme root name and one set of `--ui-*` variables, so mount one theme per document. `standardUiTokenValues` and the `UiTokenValues` type let a host value the same roles for its own
599
674
  theme; a value tree that misses or adds a role does not typecheck. In Meowbook, the gallery's Theme
600
675
  control paints every story with any of them, and a query such as `?theme=doodle` selects one in a link.
@@ -141,16 +141,7 @@ export function AssistantComposer({ options, trailing }, context) {
141
141
  }))) }), hint: derived(() => unwrap(options.disabledReason ?? "")), onSubmit: send, onInput: (event) => {
142
142
  textVersion++;
143
143
  change({ ...draft.value, text: event.target.value });
144
- }, onKeyDown: (event) => {
145
- const target = event.target;
146
- if (target instanceof HTMLTextAreaElement &&
147
- target.dataset.chatInput !== undefined &&
148
- event.key === "Enter" &&
149
- !event.shiftKey &&
150
- !event.isComposing &&
151
- event.keyCode !== 229)
152
- void send(event);
153
- } }, options.allowAttachments === false ? null : (h(Fragment, null,
144
+ }, submitOn: "enter", triggers: options.composerTriggers }, options.allowAttachments === false ? null : (h(Fragment, null,
154
145
  h(IconButton, { label: assistantCopy.attach, disabled: derived(() => disabled.value || attaching.value), onClick: () => fileInput?.click() },
155
146
  h(Icon, { name: "paperclip" })),
156
147
  h("input", { type: "file", multiple: true, hidden: true, onChange: attach, ref: [
@@ -1,3 +1,4 @@
1
+ import type { ComposerTrigger } from "./composer-triggers.js";
1
2
  import type { IconName } from "../icons/icon.js";
2
3
  import type { Child, Props } from "meowjsx";
3
4
  import type { MaybeSignal } from "meowjsx/signal";
@@ -179,6 +180,11 @@ export interface AssistantViewProps extends Props {
179
180
  renderPart?: (part: AssistantMessagePart, message: AssistantMessage) => Child | undefined;
180
181
  renderWorkDetail?: (work: AssistantWork) => Child | undefined;
181
182
  composerTrailing?: Child;
183
+ /**
184
+ * Characters that open host suggestions in the composer (`@` mentions, `/` commands). Fixed for
185
+ * the mount. Accepted suggestions become draft text; structured references stay with the host.
186
+ */
187
+ composerTriggers?: readonly ComposerTrigger[];
182
188
  headerActions?: Child;
183
189
  labels?: Partial<AssistantLabels>;
184
190
  }
@@ -0,0 +1,70 @@
1
+ import type { Child } from "meowjsx";
2
+ import type { MaybeSignal } from "meowjsx/signal";
3
+ /** One entry in a trigger's suggestion list. */
4
+ export interface ComposerSuggestion {
5
+ /** Stable identity, unique in one list. */
6
+ id: string;
7
+ label: string;
8
+ description?: string;
9
+ /** A decorative mark before the label, such as a state dot or a type icon. */
10
+ leading?: Child;
11
+ /** A short fact after the label, such as an id or a shortcut. */
12
+ meta?: string;
13
+ /**
14
+ * Text that replaces the trigger character and query. Default: the character followed by `id`.
15
+ * `""` removes the trigger text, which is how a command that acts leaves the draft clean.
16
+ */
17
+ insert?: string;
18
+ /**
19
+ * Add one space after a non-empty insert unless whitespace already follows. Default true; false
20
+ * keeps the list open on the inserted text, so a path can be drilled into.
21
+ */
22
+ trailingSpace?: boolean;
23
+ disabled?: boolean;
24
+ }
25
+ export interface ComposerSuggestContext {
26
+ /** Aborted when the query changes or the list closes before the lookup settles. */
27
+ signal: AbortSignal;
28
+ }
29
+ /** A character that opens host suggestions while the reader writes: `@` mentions, `/` commands. */
30
+ export interface ComposerTrigger {
31
+ /** One character, unique within one composer. */
32
+ char: string;
33
+ /**
34
+ * `anywhere`: the word under the caret starts with the character. `start`: and only whitespace
35
+ * precedes that word in the whole draft, as for commands.
36
+ */
37
+ position?: "anywhere" | "start";
38
+ /** Accessible name of the suggestion list, such as "Tasks" or "Commands". */
39
+ label: string;
40
+ /**
41
+ * Host-filtered suggestions for the text typed after the character; the composer never filters.
42
+ * A synchronous call runs inside an effect, so Signals it reads keep an open list current.
43
+ */
44
+ suggest: (query: string, context: ComposerSuggestContext) => readonly ComposerSuggestion[] | PromiseLike<readonly ComposerSuggestion[]>;
45
+ /** Shown when a finished lookup returns nothing. Omitted: the list stays closed. */
46
+ emptyMessage?: string;
47
+ /** Turns this trigger off, for example while a command runs. A Signal stays live. */
48
+ disabled?: MaybeSignal<boolean>;
49
+ /** Called after the composer has written the accepted suggestion into the text. */
50
+ onAccept?: (suggestion: ComposerSuggestion) => void;
51
+ }
52
+ /** The trigger occurrence under the caret. */
53
+ export interface ComposerTriggerMatch {
54
+ /** Index of the trigger character in the text. */
55
+ index: number;
56
+ char: string;
57
+ query: string;
58
+ }
59
+ /** Longest query that still opens a list; longer words are prose, not a lookup. */
60
+ export declare const composerQueryLimit = 64;
61
+ /**
62
+ * Finds the trigger occurrence for the word that ends at the caret: the word must start with a
63
+ * declared character, and a `start` trigger also needs only whitespace before the word.
64
+ */
65
+ export declare function findComposerTrigger(text: string, caret: number, triggers: readonly Pick<ComposerTrigger, "char" | "position">[]): ComposerTriggerMatch | null;
66
+ /** The text and caret after accepting a suggestion for a match. */
67
+ export declare function insertComposerSuggestion(text: string, match: ComposerTriggerMatch, suggestion: ComposerSuggestion): {
68
+ text: string;
69
+ caret: number;
70
+ };
@@ -0,0 +1,35 @@
1
+ /** Longest query that still opens a list; longer words are prose, not a lookup. */
2
+ export const composerQueryLimit = 64;
3
+ /**
4
+ * Finds the trigger occurrence for the word that ends at the caret: the word must start with a
5
+ * declared character, and a `start` trigger also needs only whitespace before the word.
6
+ */
7
+ export function findComposerTrigger(text, caret, triggers) {
8
+ const before = text.slice(0, caret);
9
+ const index = before.search(/\S*$/);
10
+ const char = before[index];
11
+ if (char === undefined)
12
+ return null;
13
+ const trigger = triggers.find((candidate) => candidate.char === char);
14
+ if (!trigger)
15
+ return null;
16
+ if (trigger.position === "start" && before.slice(0, index).trim() !== "")
17
+ return null;
18
+ const query = before.slice(index + 1);
19
+ if (query.length > composerQueryLimit)
20
+ return null;
21
+ return { index, char, query };
22
+ }
23
+ /** The text and caret after accepting a suggestion for a match. */
24
+ export function insertComposerSuggestion(text, match, suggestion) {
25
+ const end = match.index + 1 + match.query.length;
26
+ const insert = suggestion.insert ?? match.char + suggestion.id;
27
+ const after = text.slice(end);
28
+ const space = insert !== "" && suggestion.trailingSpace !== false && !/^\s/.test(after) ? " " : "";
29
+ // Removing a command's text also drops the space that separated it from what followed.
30
+ const rest = insert === "" ? after.replace(/^ /, "") : after;
31
+ return {
32
+ text: text.slice(0, match.index) + insert + space + rest,
33
+ caret: match.index + insert.length + space.length,
34
+ };
35
+ }
@@ -1,16 +1,24 @@
1
1
  import { type Child, type Context, type Props } from "meowjsx";
2
2
  import { type MaybeSignal } from "meowjsx/signal";
3
+ import { type ComposerTrigger } from "./composer-triggers.js";
3
4
  export type ChatComposerSubmit = (event: SubmitEvent) => void;
4
5
  export type ChatComposerInput = (event: Event) => void;
5
6
  export interface ChatComposerProps extends Props {
7
+ /** Controlled text; a Signal stays live. Omit it to keep a local draft that starts at defaultValue. */
6
8
  value?: MaybeSignal<string>;
9
+ defaultValue?: string;
10
+ /** Called for every edit and for text the composer writes itself (an accepted suggestion, a reset). */
11
+ onValueChange?: (value: string) => void;
7
12
  placeholder?: string;
8
13
  inputLabel?: string;
9
14
  /** Inline keeps a short draft and its actions on one row; long drafts still grow.
10
15
  * Bar is one rounded row: attach, text, trailing choices, send. */
11
16
  /** Draft attachments belong to the same writing surface; upload ownership stays with the host. */
12
17
  attachments?: Child;
13
- /** Model/provider selection beside the send action; options and state belong to the host. */
18
+ /**
19
+ * Choices the draft is submitted with (model, project, priority) beside the send action, usually
20
+ * host-controlled ChoiceSelects; options and state belong to the host.
21
+ */
14
22
  trailing?: Child;
15
23
  /** Supporting instructions below the writing surface, associated through hintId. */
16
24
  hint?: Child;
@@ -22,15 +30,27 @@ export interface ChatComposerProps extends Props {
22
30
  readOnly?: MaybeSignal<boolean>;
23
31
  /** Prevent another submission while keeping the draft editable. */
24
32
  submitDisabled?: MaybeSignal<boolean>;
33
+ /**
34
+ * Which key submits: "none" (Enter inserts a newline), "enter" (Shift+Enter for a newline) or
35
+ * "mod-enter" (Cmd+Enter or Ctrl+Enter). A blocked composer swallows the key; IME composition never
36
+ * submits. Fixed for the mount.
37
+ */
38
+ submitOn?: "none" | "enter" | "mod-enter";
39
+ /** Characters that open host suggestions while writing. Fixed for the mount; use `disabled` on one. */
40
+ triggers?: readonly ComposerTrigger[];
41
+ /** Where the suggestion list opens relative to the writing surface; it flips when there is no room. */
42
+ suggestionPlacement?: "top" | "bottom";
43
+ /** Status shown while a trigger's lookup is pending. */
44
+ loadingMessage?: string;
25
45
  onSubmit?: ChatComposerSubmit;
26
46
  onInput?: ChatComposerInput;
27
47
  }
28
- /** The message input of a conversation, with attachments, model choice and send. */
29
- export declare function ChatComposer({ value, placeholder, inputLabel, attachments, trailing, hint, hintId, submitLabel, submitContent, disabled, readOnly, submitDisabled, onSubmit, onInput, children, className, ref, ...props }: ChatComposerProps, context: Context<typeof ChatComposer>): import("meowjsx").VNode;
48
+ /** The message input of a conversation, with attachments, choices, suggestions and send. */
49
+ export declare function ChatComposer({ value, defaultValue, onValueChange, placeholder, inputLabel, attachments, trailing, hint, hintId, submitLabel, submitContent, disabled, readOnly, submitDisabled, submitOn, triggers, suggestionPlacement, loadingMessage, onSubmit, onInput, children, className, ref, ...props }: ChatComposerProps, context: Context<typeof ChatComposer>): import("meowjsx").VNode;
30
50
  export declare namespace ChatComposer {
31
51
  var meta: {
32
52
  readonly name: "chat-composer";
33
- readonly parts: readonly ["root", "surface", "attachments", "field", "input", "hint", "actions", "trailing", "submit"];
53
+ readonly parts: readonly ["root", "surface", "attachments", "field", "input", "hint", "actions", "trailing", "submit", "suggestions", "suggestionList", "suggestion", "suggestionLeading", "suggestionCopy", "suggestionLabel", "suggestionDescription", "suggestionMeta", "suggestionStatus", "announcement"];
34
54
  readonly style: import("meowcss/meowjsx").StylePropsBinding<import("meowcss").Options<{
35
55
  readonly layout: readonly ["stacked", "inline", "hero", "bar"];
36
56
  readonly surface: readonly ["default", "none"];