@justanarthur/modo-ui-ai 0.0.0-stage → 0.3.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.
- package/LICENSE +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/README.md +105 -2
- package/blocks/conversation/agent-prompt/examples.mdx +44 -0
- package/blocks/conversation/agent-prompt/index.tsx +114 -0
- package/blocks/conversation/composer/draft.css +25 -0
- package/blocks/conversation/composer/draft.tsx +589 -0
- package/blocks/conversation/composer/examples.mdx +164 -0
- package/blocks/conversation/composer/file-preview-tile.tsx +59 -0
- package/blocks/conversation/composer/file-thumbnail.tsx +146 -0
- package/blocks/conversation/composer/index.tsx +651 -0
- package/blocks/conversation/composer/queued-row.tsx +102 -0
- package/blocks/conversation/composer/shared.ts +38 -0
- package/blocks/conversation/composer/suggestion-row.tsx +64 -0
- package/blocks/conversation/composer/use-composer-files.ts +142 -0
- package/blocks/conversation/composer/use-history-nav.ts +60 -0
- package/blocks/conversation/composer/use-message-queue.ts +108 -0
- package/blocks/conversation/composer/use-region-height.ts +34 -0
- package/blocks/conversation/failure-states/examples.mdx +58 -0
- package/blocks/conversation/failure-states/index.tsx +274 -0
- package/blocks/conversation/transcript/examples.mdx +43 -0
- package/blocks/conversation/transcript/index.tsx +206 -0
- package/blocks/conversation/transcript-search/examples.mdx +50 -0
- package/blocks/conversation/transcript-search/index.tsx +469 -0
- package/blocks/dialogs/command-palette/examples.mdx +50 -0
- package/blocks/dialogs/command-palette/index.tsx +239 -0
- package/blocks/dialogs/hook-dialog/examples.mdx +44 -0
- package/blocks/dialogs/hook-dialog/index.tsx +286 -0
- package/blocks/dialogs/mcp-server-dialog/examples.mdx +57 -0
- package/blocks/dialogs/mcp-server-dialog/index.tsx +415 -0
- package/blocks/dialogs/shortcuts-sheet/examples.mdx +36 -0
- package/blocks/dialogs/shortcuts-sheet/index.tsx +186 -0
- package/blocks/panes/artifacts-pane/examples.mdx +23 -0
- package/blocks/panes/artifacts-pane/index.tsx +82 -0
- package/blocks/panes/changes-pane/examples.mdx +23 -0
- package/blocks/panes/changes-pane/index.tsx +248 -0
- package/blocks/panes/file-pane/examples.mdx +13 -0
- package/blocks/panes/file-pane/index.tsx +102 -0
- package/blocks/panes/pr-pane/examples.mdx +13 -0
- package/blocks/panes/pr-pane/index.tsx +191 -0
- package/blocks/panes/side-pane/examples.mdx +58 -0
- package/blocks/panes/side-pane/index.tsx +187 -0
- package/blocks/panes/tasks-pane/examples.mdx +23 -0
- package/blocks/panes/tasks-pane/index.tsx +127 -0
- package/blocks/panes/terminal-pane/examples.mdx +13 -0
- package/blocks/panes/terminal-pane/index.tsx +99 -0
- package/blocks/panes/usage-pane/examples.mdx +23 -0
- package/blocks/panes/usage-pane/index.tsx +78 -0
- package/blocks/profiles/profile-onboarding/examples.mdx +80 -0
- package/blocks/profiles/profile-onboarding/index.tsx +580 -0
- package/blocks/profiles/profile-switcher/examples.mdx +29 -0
- package/blocks/profiles/profile-switcher/index.tsx +212 -0
- package/blocks/profiles/profile-usage/examples.mdx +41 -0
- package/blocks/profiles/profile-usage/index.tsx +141 -0
- package/blocks/sessions/inbox/examples.mdx +35 -0
- package/blocks/sessions/inbox/index.tsx +372 -0
- package/blocks/sessions/session-board/examples.mdx +34 -0
- package/blocks/sessions/session-board/index.tsx +570 -0
- package/blocks/sessions/session-sidebar/examples.mdx +93 -0
- package/blocks/sessions/session-sidebar/index.tsx +497 -0
- package/blocks/settings/extensions/examples.mdx +10 -0
- package/blocks/settings/extensions/index.tsx +72 -0
- package/blocks/settings/hooks/examples.mdx +16 -0
- package/blocks/settings/hooks/index.tsx +127 -0
- package/blocks/settings/mcp-servers/examples.mdx +26 -0
- package/blocks/settings/mcp-servers/index.tsx +204 -0
- package/blocks/settings/memory/examples.mdx +22 -0
- package/blocks/settings/memory/index.tsx +113 -0
- package/blocks/settings/notifications/examples.mdx +8 -0
- package/blocks/settings/notifications/index.tsx +63 -0
- package/blocks/settings/permission-rules/examples.mdx +37 -0
- package/blocks/settings/permission-rules/index.tsx +317 -0
- package/blocks/settings/plugin-catalog/examples.mdx +52 -0
- package/blocks/settings/plugin-catalog/index.tsx +407 -0
- package/blocks/settings/plugins/examples.mdx +10 -0
- package/blocks/settings/plugins/index.tsx +72 -0
- package/blocks/settings/settings-window/examples.mdx +40 -0
- package/blocks/settings/settings-window/index.tsx +188 -0
- package/blocks/settings/worktrees/examples.mdx +17 -0
- package/blocks/settings/worktrees/index.tsx +145 -0
- package/components/conversation/agent-run/examples.mdx +38 -0
- package/components/conversation/agent-run/index.tsx +83 -0
- package/components/conversation/chapter-nav/examples.mdx +30 -0
- package/components/conversation/chapter-nav/index.tsx +123 -0
- package/components/conversation/message/examples.mdx +53 -0
- package/components/conversation/message/index.tsx +130 -0
- package/components/conversation/message/working.tsx +102 -0
- package/components/conversation/reasoning/examples.mdx +32 -0
- package/components/conversation/reasoning/index.tsx +55 -0
- package/components/conversation/recap/examples.mdx +21 -0
- package/components/conversation/recap/index.tsx +67 -0
- package/components/conversation/todo-list/examples.mdx +32 -0
- package/components/conversation/todo-list/index.tsx +106 -0
- package/components/conversation/tool-call/examples.mdx +48 -0
- package/components/conversation/tool-call/index.tsx +142 -0
- package/components/conversation/work-summary/examples.mdx +50 -0
- package/components/conversation/work-summary/index.tsx +87 -0
- package/components/prompts/permission-request/examples.mdx +32 -0
- package/components/prompts/permission-request/index.tsx +74 -0
- package/components/prompts/plan-approval/examples.mdx +37 -0
- package/components/prompts/plan-approval/index.tsx +76 -0
- package/components/prompts/prompt-card/examples.mdx +31 -0
- package/components/prompts/prompt-card/index.tsx +82 -0
- package/components/prompts/question-prompt/examples.mdx +46 -0
- package/components/prompts/question-prompt/index.tsx +118 -0
- package/dist/blocks/conversation/agent-prompt/index.d.ts +7 -0
- package/dist/blocks/conversation/agent-prompt/index.js +13 -0
- package/dist/blocks/conversation/composer/index.d.ts +4 -0
- package/dist/blocks/conversation/composer/index.js +16 -0
- package/dist/blocks/conversation/failure-states/index.d.ts +4 -0
- package/dist/blocks/conversation/failure-states/index.js +8 -0
- package/dist/blocks/conversation/transcript/index.d.ts +50 -0
- package/dist/blocks/conversation/transcript/index.js +17 -0
- package/dist/blocks/conversation/transcript-search/index.d.ts +4 -0
- package/dist/blocks/conversation/transcript-search/index.js +11 -0
- package/dist/blocks/dialogs/command-palette/index.d.ts +5 -0
- package/dist/blocks/dialogs/command-palette/index.js +20 -0
- package/dist/blocks/dialogs/hook-dialog/index.d.ts +3 -0
- package/dist/blocks/dialogs/hook-dialog/index.js +12 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.d.ts +5 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.js +12 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.d.ts +2 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.js +11 -0
- package/dist/blocks/panes/artifacts-pane/index.d.ts +3 -0
- package/dist/blocks/panes/artifacts-pane/index.js +9 -0
- package/dist/blocks/panes/changes-pane/index.d.ts +3 -0
- package/dist/blocks/panes/changes-pane/index.js +9 -0
- package/dist/blocks/panes/file-pane/index.d.ts +3 -0
- package/dist/blocks/panes/file-pane/index.js +9 -0
- package/dist/blocks/panes/pr-pane/index.d.ts +3 -0
- package/dist/blocks/panes/pr-pane/index.js +10 -0
- package/dist/blocks/panes/side-pane/index.d.ts +5 -0
- package/dist/blocks/panes/side-pane/index.js +21 -0
- package/dist/blocks/panes/tasks-pane/index.d.ts +3 -0
- package/dist/blocks/panes/tasks-pane/index.js +10 -0
- package/dist/blocks/panes/terminal-pane/index.d.ts +3 -0
- package/dist/blocks/panes/terminal-pane/index.js +9 -0
- package/dist/blocks/panes/usage-pane/index.d.ts +4 -0
- package/dist/blocks/panes/usage-pane/index.js +11 -0
- package/dist/blocks/profiles/profile-onboarding/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-onboarding/index.js +11 -0
- package/dist/blocks/profiles/profile-switcher/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-switcher/index.js +12 -0
- package/dist/blocks/profiles/profile-usage/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-usage/index.js +10 -0
- package/dist/blocks/sessions/inbox/index.d.ts +2 -0
- package/dist/blocks/sessions/inbox/index.js +11 -0
- package/dist/blocks/sessions/session-board/index.d.ts +4 -0
- package/dist/blocks/sessions/session-board/index.js +27 -0
- package/dist/blocks/sessions/session-sidebar/index.d.ts +5 -0
- package/dist/blocks/sessions/session-sidebar/index.js +15 -0
- package/dist/blocks/settings/extensions/index.d.ts +2 -0
- package/dist/blocks/settings/extensions/index.js +9 -0
- package/dist/blocks/settings/hooks/index.d.ts +4 -0
- package/dist/blocks/settings/hooks/index.js +9 -0
- package/dist/blocks/settings/mcp-servers/index.d.ts +4 -0
- package/dist/blocks/settings/mcp-servers/index.js +9 -0
- package/dist/blocks/settings/memory/index.d.ts +4 -0
- package/dist/blocks/settings/memory/index.js +8 -0
- package/dist/blocks/settings/notifications/index.d.ts +2 -0
- package/dist/blocks/settings/notifications/index.js +8 -0
- package/dist/blocks/settings/permission-rules/index.d.ts +3 -0
- package/dist/blocks/settings/permission-rules/index.js +10 -0
- package/dist/blocks/settings/plugin-catalog/index.d.ts +2 -0
- package/dist/blocks/settings/plugin-catalog/index.js +11 -0
- package/dist/blocks/settings/plugins/index.d.ts +4 -0
- package/dist/blocks/settings/plugins/index.js +9 -0
- package/dist/blocks/settings/settings-window/index.d.ts +4 -0
- package/dist/blocks/settings/settings-window/index.js +8 -0
- package/dist/blocks/settings/worktrees/index.d.ts +4 -0
- package/dist/blocks/settings/worktrees/index.js +9 -0
- package/dist/components/conversation/agent-run/index.d.ts +3 -0
- package/dist/components/conversation/agent-run/index.js +10 -0
- package/dist/components/conversation/chapter-nav/index.d.ts +2 -0
- package/dist/components/conversation/chapter-nav/index.js +11 -0
- package/dist/components/conversation/message/index.d.ts +2 -0
- package/dist/components/conversation/message/index.js +15 -0
- package/dist/components/conversation/reasoning/index.d.ts +2 -0
- package/dist/components/conversation/reasoning/index.js +8 -0
- package/dist/components/conversation/recap/index.d.ts +2 -0
- package/dist/components/conversation/recap/index.js +9 -0
- package/dist/components/conversation/todo-list/index.d.ts +2 -0
- package/dist/components/conversation/todo-list/index.js +9 -0
- package/dist/components/conversation/tool-call/index.d.ts +3 -0
- package/dist/components/conversation/tool-call/index.js +13 -0
- package/dist/components/conversation/work-summary/index.d.ts +2 -0
- package/dist/components/conversation/work-summary/index.js +10 -0
- package/dist/components/prompts/permission-request/index.d.ts +2 -0
- package/dist/components/prompts/permission-request/index.js +9 -0
- package/dist/components/prompts/plan-approval/index.d.ts +2 -0
- package/dist/components/prompts/plan-approval/index.js +9 -0
- package/dist/components/prompts/prompt-card/index.d.ts +3 -0
- package/dist/components/prompts/prompt-card/index.js +8 -0
- package/dist/components/prompts/question-prompt/index.d.ts +2 -0
- package/dist/components/prompts/question-prompt/index.js +9 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +231 -0
- package/dist/lib/config-parts.d.ts +2 -0
- package/dist/lib/config-parts.js +16 -0
- package/dist/lib/icons.d.ts +2 -0
- package/dist/lib/icons.js +10 -0
- package/dist/lib/pace-bar.d.ts +11 -0
- package/dist/lib/pace-bar.js +6 -0
- package/dist/lib/pace.d.ts +4 -0
- package/dist/lib/pace.js +14 -0
- package/dist/lib/pane-parts.d.ts +25 -0
- package/dist/lib/pane-parts.js +11 -0
- package/dist/lib/row-trigger.d.ts +5 -0
- package/dist/lib/row-trigger.js +7 -0
- package/dist/lib/settings-parts.d.ts +70 -0
- package/dist/lib/settings-parts.js +24 -0
- package/dist/lib/side-pane-types.d.ts +2 -0
- package/dist/lib/side-pane-types.js +1 -0
- package/dist/lib/status-glyph.d.ts +8 -0
- package/dist/lib/status-glyph.js +12 -0
- package/dist/lib/types.d.ts +3 -0
- package/dist/lib/types.js +1 -0
- package/dist/shared/chunk-04a497rr.js +21 -0
- package/dist/shared/chunk-13yf0mza.d.ts +70 -0
- package/dist/shared/chunk-1hzrm8r5.d.ts +51 -0
- package/dist/shared/chunk-1qdwg7w5.d.ts +81 -0
- package/dist/shared/chunk-1yt061np.d.ts +64 -0
- package/dist/shared/chunk-218qabm5.js +250 -0
- package/dist/shared/chunk-2fk5aq60.js +313 -0
- package/dist/shared/chunk-3ps5h55t.d.ts +30 -0
- package/dist/shared/chunk-3yaftgh0.d.ts +28 -0
- package/dist/shared/chunk-4zvhpf2x.js +55 -0
- package/dist/shared/chunk-57hzzmjd.d.ts +67 -0
- package/dist/shared/chunk-58jh3mje.js +46 -0
- package/dist/shared/chunk-58qvny6a.d.ts +29 -0
- package/dist/shared/chunk-5fhkkn39.js +130 -0
- package/dist/shared/chunk-5hw0525a.d.ts +33 -0
- package/dist/shared/chunk-5meda998.js +238 -0
- package/dist/shared/chunk-5pqksw7z.js +91 -0
- package/dist/shared/chunk-6220dy5n.js +70 -0
- package/dist/shared/chunk-64bnh22t.d.ts +59 -0
- package/dist/shared/chunk-66sh633m.d.ts +60 -0
- package/dist/shared/chunk-6cmf27g3.d.ts +81 -0
- package/dist/shared/chunk-6kwk9vag.js +558 -0
- package/dist/shared/chunk-6rdwkymk.js +177 -0
- package/dist/shared/chunk-71j8qzvb.d.ts +57 -0
- package/dist/shared/chunk-74bvf3tw.d.ts +21 -0
- package/dist/shared/chunk-75zwypyr.d.ts +43 -0
- package/dist/shared/chunk-7mfer3tp.js +176 -0
- package/dist/shared/chunk-7rzjmcnh.d.ts +30 -0
- package/dist/shared/chunk-7zvb39cf.d.ts +26 -0
- package/dist/shared/chunk-8mecznyr.js +357 -0
- package/dist/shared/chunk-8pag6vmd.js +255 -0
- package/dist/shared/chunk-94grzz9f.js +187 -0
- package/dist/shared/chunk-9kw6m047.d.ts +32 -0
- package/dist/shared/chunk-at0jje23.d.ts +110 -0
- package/dist/shared/chunk-awd573h9.js +34 -0
- package/dist/shared/chunk-b171wjge.d.ts +25 -0
- package/dist/shared/chunk-b4dz15em.d.ts +36 -0
- package/dist/shared/chunk-b5ccp5de.js +35 -0
- package/dist/shared/chunk-bh2b5d1z.js +98 -0
- package/dist/shared/chunk-c36qvrwq.d.ts +30 -0
- package/dist/shared/chunk-c8wp058j.js +153 -0
- package/dist/shared/chunk-d2t72h4x.d.ts +35 -0
- package/dist/shared/chunk-dh3qy5fj.js +49 -0
- package/dist/shared/chunk-dxzrtvt9.d.ts +283 -0
- package/dist/shared/chunk-e46apgve.d.ts +40 -0
- package/dist/shared/chunk-ejtknc0w.js +21 -0
- package/dist/shared/chunk-eqajdxn8.js +82 -0
- package/dist/shared/chunk-fapc805j.js +130 -0
- package/dist/shared/chunk-fm1qyrae.d.ts +68 -0
- package/dist/shared/chunk-fqhcz6ss.d.ts +29 -0
- package/dist/shared/chunk-g88hweqh.d.ts +70 -0
- package/dist/shared/chunk-gb5ee5dw.d.ts +88 -0
- package/dist/shared/chunk-gewnsgza.js +61 -0
- package/dist/shared/chunk-hxjgey30.d.ts +36 -0
- package/dist/shared/chunk-jkkdq1mh.d.ts +213 -0
- package/dist/shared/chunk-jpq101w3.js +91 -0
- package/dist/shared/chunk-k3bv9k1v.d.ts +56 -0
- package/dist/shared/chunk-kreypnzp.d.ts +34 -0
- package/dist/shared/chunk-mnzw0bav.js +80 -0
- package/dist/shared/chunk-mrb3fp2f.d.ts +30 -0
- package/dist/shared/chunk-n1qq2wp9.js +6 -0
- package/dist/shared/chunk-n31qwnj2.js +1544 -0
- package/dist/shared/chunk-n4742y54.js +39 -0
- package/dist/shared/chunk-ndjvdkv7.d.ts +29 -0
- package/dist/shared/chunk-njf851p1.js +245 -0
- package/dist/shared/chunk-nk4578dr.js +73 -0
- package/dist/shared/chunk-nkbgg7bw.d.ts +24 -0
- package/dist/shared/chunk-nvh33x9x.js +488 -0
- package/dist/shared/chunk-paezqfg1.js +106 -0
- package/dist/shared/chunk-qemm9e3r.d.ts +21 -0
- package/dist/shared/chunk-qhxz1etk.js +96 -0
- package/dist/shared/chunk-qj5ev9ak.js +531 -0
- package/dist/shared/chunk-qnwggvjy.js +150 -0
- package/dist/shared/chunk-qt31n444.js +178 -0
- package/dist/shared/chunk-r5hz78pb.js +129 -0
- package/dist/shared/chunk-r6nb21kz.d.ts +102 -0
- package/dist/shared/chunk-rqrpvvz4.d.ts +107 -0
- package/dist/shared/chunk-s3r759ec.js +80 -0
- package/dist/shared/chunk-sdtjrw9w.d.ts +98 -0
- package/dist/shared/chunk-skg3m9m0.js +56 -0
- package/dist/shared/chunk-t21t9x7e.js +188 -0
- package/dist/shared/chunk-tc75ng2c.js +235 -0
- package/dist/shared/chunk-tkx1krwc.js +88 -0
- package/dist/shared/chunk-tprdqtb1.d.ts +30 -0
- package/dist/shared/chunk-tv9a1sek.js +137 -0
- package/dist/shared/chunk-tvbd27hg.d.ts +43 -0
- package/dist/shared/chunk-ty2ccknv.d.ts +54 -0
- package/dist/shared/chunk-v6yevw62.d.ts +28 -0
- package/dist/shared/chunk-v9q38p0x.js +258 -0
- package/dist/shared/chunk-vgh4f3sv.js +118 -0
- package/dist/shared/chunk-vjht1zn1.js +391 -0
- package/dist/shared/chunk-vsrkb0sp.d.ts +21 -0
- package/dist/shared/chunk-whsx7yp9.d.ts +37 -0
- package/dist/shared/chunk-wq9h37gy.js +86 -0
- package/dist/shared/chunk-x7az5x1y.d.ts +57 -0
- package/dist/shared/chunk-x9jf26yb.js +318 -0
- package/dist/shared/chunk-xbrrt07s.d.ts +23 -0
- package/dist/shared/chunk-xkchhs2z.js +129 -0
- package/dist/shared/chunk-xzfrskd7.js +202 -0
- package/dist/shared/chunk-y4cj4y54.js +423 -0
- package/dist/shared/chunk-y934at6m.js +7 -0
- package/dist/shared/chunk-zbpwhpjy.d.ts +75 -0
- package/dist/shared/chunk-zfhmbb7n.js +63 -0
- package/dist/shared/chunk-zk0t4vq5.js +71 -0
- package/dist/shared/chunk-znp9gna7.d.ts +23 -0
- package/dist/styles.css +467 -0
- package/index.ts +49 -0
- package/lib/config-parts.tsx +97 -0
- package/lib/icons.tsx +149 -0
- package/lib/pace-bar.tsx +24 -0
- package/lib/pace.ts +78 -0
- package/lib/pane-parts.tsx +76 -0
- package/lib/row-trigger.tsx +44 -0
- package/lib/settings-parts.tsx +232 -0
- package/lib/side-pane-types.ts +75 -0
- package/lib/status-glyph.tsx +25 -0
- package/lib/types.ts +204 -0
- package/mock/demo-reply.tsx +33 -0
- package/mock/demo-session.tsx +150 -0
- package/mock/mock-config.ts +173 -0
- package/mock/mock-extras.ts +288 -0
- package/mock/mock-panes.ts +190 -0
- package/mock/mock-settings.ts +92 -0
- package/mock/mock.ts +548 -0
- package/mock/screen-frame.tsx +49 -0
- package/package.json +114 -4
|
@@ -0,0 +1,1544 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useIcon2
|
|
5
|
+
} from "./chunk-xkchhs2z.js";
|
|
6
|
+
import {
|
|
7
|
+
RowTrigger2
|
|
8
|
+
} from "./chunk-n4742y54.js";
|
|
9
|
+
import {
|
|
10
|
+
ProfileSwitcher2
|
|
11
|
+
} from "./chunk-njf851p1.js";
|
|
12
|
+
|
|
13
|
+
// blocks/conversation/composer/index.tsx
|
|
14
|
+
import { SurfaceProvider as SurfaceProvider2, useSurface } from "@justanarthur/modo-ui";
|
|
15
|
+
import ShellCard from "@justanarthur/modo-ui/blocks/shell-card";
|
|
16
|
+
import Button2 from "@justanarthur/modo-ui/components/actions/button";
|
|
17
|
+
import List, { LIST_POPOVER, LIST_SWITCH } from "@justanarthur/modo-ui/components/data-display/list";
|
|
18
|
+
import Meter from "@justanarthur/modo-ui/components/feedback/meter";
|
|
19
|
+
import ChoiceList from "@justanarthur/modo-ui/components/inputs/choice-list";
|
|
20
|
+
import Select from "@justanarthur/modo-ui/components/inputs/select";
|
|
21
|
+
import Slider from "@justanarthur/modo-ui/components/inputs/slider";
|
|
22
|
+
import Switch from "@justanarthur/modo-ui/components/inputs/switch";
|
|
23
|
+
import Dropdown from "@justanarthur/modo-ui/components/overlays/dropdown";
|
|
24
|
+
import Popover from "@justanarthur/modo-ui/components/overlays/popover";
|
|
25
|
+
import { SURFACE_BG } from "@justanarthur/modo-ui/lib/surface-classes";
|
|
26
|
+
import { useControllableState as useControllableState4 } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
27
|
+
import { cn as cn5 } from "@justanarthur/modo-ui/lib/utils";
|
|
28
|
+
import { SizeProvider } from "@justanarthur/modo-ui/primitives/systems/sizes";
|
|
29
|
+
|
|
30
|
+
// blocks/conversation/composer/draft.tsx
|
|
31
|
+
import { SurfaceProvider, useAutosizeTextarea, useReduceMotion, useTouchPrimary } from "@justanarthur/modo-ui";
|
|
32
|
+
import { Button } from "@justanarthur/modo-ui/components/actions/button";
|
|
33
|
+
import { useIcon as useIcon5 } from "@justanarthur/modo-ui/lib/icon-context";
|
|
34
|
+
import { useShape as useShape2 } from "@justanarthur/modo-ui/lib/shape-context";
|
|
35
|
+
import { useSize as useSize3 } from "@justanarthur/modo-ui/lib/size-context";
|
|
36
|
+
import { spring as spring3 } from "@justanarthur/modo-ui/lib/springs";
|
|
37
|
+
import { surfaceClasses } from "@justanarthur/modo-ui/lib/surface-classes";
|
|
38
|
+
import { useControllableState as useControllableState3 } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
39
|
+
import { cn as cn4 } from "@justanarthur/modo-ui/lib/utils";
|
|
40
|
+
import { FluidHoverHighlight, useFluidHover } from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
|
|
41
|
+
import { SizeScope } from "@justanarthur/modo-ui/primitives/systems/sizes";
|
|
42
|
+
import { AnimatePresence, motion as motion2, Reorder as Reorder2 } from "motion/react";
|
|
43
|
+
import {
|
|
44
|
+
forwardRef as forwardRef2,
|
|
45
|
+
useCallback as useCallback5,
|
|
46
|
+
useEffect as useEffect3,
|
|
47
|
+
useId,
|
|
48
|
+
useMemo as useMemo2,
|
|
49
|
+
useRef as useRef6
|
|
50
|
+
} from "react";
|
|
51
|
+
|
|
52
|
+
// blocks/conversation/composer/file-preview-tile.tsx
|
|
53
|
+
import { Tooltip } from "@justanarthur/modo-ui/components/overlays/tooltip";
|
|
54
|
+
import { useIcon } from "@justanarthur/modo-ui/lib/icon-context";
|
|
55
|
+
import { spring } from "@justanarthur/modo-ui/lib/springs";
|
|
56
|
+
import { motion } from "motion/react";
|
|
57
|
+
import { forwardRef } from "react";
|
|
58
|
+
|
|
59
|
+
// blocks/conversation/composer/file-thumbnail.tsx
|
|
60
|
+
import { useShape } from "@justanarthur/modo-ui/lib/shape-context";
|
|
61
|
+
import { cn } from "@justanarthur/modo-ui/lib/utils";
|
|
62
|
+
import { useEffect, useState } from "react";
|
|
63
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
64
|
+
/*!
|
|
65
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
66
|
+
* `registry/default/file-thumbnail.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
67
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
68
|
+
*/
|
|
69
|
+
var pdfjsPromise = null;
|
|
70
|
+
var PDFJS_MISSING = "@justanarthur/modo-ui: PDF thumbnails need the optional peer dependency `pdfjs-dist` (npm install pdfjs-dist); showing the file icon instead.";
|
|
71
|
+
async function loadPdfjs() {
|
|
72
|
+
if (!pdfjsPromise) {
|
|
73
|
+
pdfjsPromise = import("pdfjs-dist").catch((error) => {
|
|
74
|
+
console.warn(PDFJS_MISSING);
|
|
75
|
+
throw error;
|
|
76
|
+
}).then((mod) => {
|
|
77
|
+
if (!mod.GlobalWorkerOptions.workerSrc) {
|
|
78
|
+
mod.GlobalWorkerOptions.workerSrc = `https://cdn.jsdelivr.net/npm/pdfjs-dist@${mod.version}/build/pdf.worker.min.mjs`;
|
|
79
|
+
}
|
|
80
|
+
return mod;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return pdfjsPromise;
|
|
84
|
+
}
|
|
85
|
+
async function renderPdfFirstPage(file, targetWidth) {
|
|
86
|
+
const pdfjs = await loadPdfjs();
|
|
87
|
+
const buffer = await file.arrayBuffer();
|
|
88
|
+
const pdf = await pdfjs.getDocument({ data: buffer }).promise;
|
|
89
|
+
const page = await pdf.getPage(1);
|
|
90
|
+
const baseViewport = page.getViewport({ scale: 1 });
|
|
91
|
+
const scale = targetWidth * 2 / baseViewport.width;
|
|
92
|
+
const viewport = page.getViewport({ scale });
|
|
93
|
+
const canvas = document.createElement("canvas");
|
|
94
|
+
canvas.width = viewport.width;
|
|
95
|
+
canvas.height = viewport.height;
|
|
96
|
+
await page.render({ canvas, viewport }).promise;
|
|
97
|
+
return canvas.toDataURL("image/png");
|
|
98
|
+
}
|
|
99
|
+
function FileThumbnail2({ file, size, className }) {
|
|
100
|
+
const shape = useShape();
|
|
101
|
+
const isImage = file.type.startsWith("image/");
|
|
102
|
+
const isPdf = file.type === "application/pdf";
|
|
103
|
+
const [imageUrl, setImageUrl] = useState(null);
|
|
104
|
+
useEffect(() => {
|
|
105
|
+
if (!isImage) {
|
|
106
|
+
setImageUrl(null);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const url = URL.createObjectURL(file);
|
|
110
|
+
setImageUrl(url);
|
|
111
|
+
return () => URL.revokeObjectURL(url);
|
|
112
|
+
}, [isImage, file]);
|
|
113
|
+
const [pdfUrl, setPdfUrl] = useState(null);
|
|
114
|
+
const [pdfError, setPdfError] = useState(false);
|
|
115
|
+
useEffect(() => {
|
|
116
|
+
setPdfError(false);
|
|
117
|
+
if (!isPdf) {
|
|
118
|
+
setPdfUrl(null);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let cancelled = false;
|
|
122
|
+
renderPdfFirstPage(file, size).then((url) => {
|
|
123
|
+
if (!cancelled)
|
|
124
|
+
setPdfUrl(url);
|
|
125
|
+
}).catch(() => {
|
|
126
|
+
if (!cancelled)
|
|
127
|
+
setPdfError(true);
|
|
128
|
+
});
|
|
129
|
+
return () => {
|
|
130
|
+
cancelled = true;
|
|
131
|
+
};
|
|
132
|
+
}, [file, isPdf, size]);
|
|
133
|
+
const previewUrl = imageUrl ?? pdfUrl;
|
|
134
|
+
const isPending = isImage && !imageUrl || isPdf && !pdfUrl && !pdfError;
|
|
135
|
+
return /* @__PURE__ */ jsx("div", {
|
|
136
|
+
className: cn("relative shrink-0 overflow-hidden bg-accent border border-border", shape.bg, className),
|
|
137
|
+
style: { width: size, height: size },
|
|
138
|
+
children: previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
139
|
+
src: previewUrl,
|
|
140
|
+
alt: file.name,
|
|
141
|
+
className: "absolute inset-0 w-full h-full object-cover"
|
|
142
|
+
}) : isPending ? /* @__PURE__ */ jsx("div", {
|
|
143
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
144
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
145
|
+
className: "w-6 h-6 rounded-full border-2 border-border border-t-muted-foreground animate-spin",
|
|
146
|
+
"aria-label": "Loading preview",
|
|
147
|
+
role: "status"
|
|
148
|
+
})
|
|
149
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: "absolute inset-0 flex items-center justify-center text-muted-foreground",
|
|
151
|
+
role: "img",
|
|
152
|
+
"aria-label": file.name,
|
|
153
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
154
|
+
width: Math.max(16, size * 0.35),
|
|
155
|
+
height: Math.max(16, size * 0.35),
|
|
156
|
+
viewBox: "0 0 24 24",
|
|
157
|
+
fill: "none",
|
|
158
|
+
stroke: "currentColor",
|
|
159
|
+
strokeWidth: "1.5",
|
|
160
|
+
strokeLinecap: "round",
|
|
161
|
+
strokeLinejoin: "round",
|
|
162
|
+
"aria-hidden": "true",
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsx("path", {
|
|
165
|
+
d: "M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z"
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx("path", {
|
|
168
|
+
d: "M14 3v5h5"
|
|
169
|
+
})
|
|
170
|
+
]
|
|
171
|
+
})
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// blocks/conversation/composer/file-preview-tile.tsx
|
|
177
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
178
|
+
/*!
|
|
179
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
180
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
181
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
182
|
+
*/
|
|
183
|
+
var FilePreviewTile = forwardRef(function FilePreviewTile({ file, onRemove, size }, ref) {
|
|
184
|
+
const XIcon = useIcon("x");
|
|
185
|
+
return /* @__PURE__ */ jsxs2(motion.div, {
|
|
186
|
+
ref,
|
|
187
|
+
layout: true,
|
|
188
|
+
initial: { opacity: 0, scale: 0.9 },
|
|
189
|
+
animate: { opacity: 1, scale: 1 },
|
|
190
|
+
exit: { opacity: 0, scale: 0.9, transition: spring.fast.exit },
|
|
191
|
+
transition: spring.fast,
|
|
192
|
+
className: "relative shrink-0 cursor-default group/tile",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ jsx2(FileThumbnail2, {
|
|
195
|
+
file,
|
|
196
|
+
size
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ jsx2(Tooltip, {
|
|
199
|
+
content: "Remove",
|
|
200
|
+
side: "top",
|
|
201
|
+
children: /* @__PURE__ */ jsx2("button", {
|
|
202
|
+
type: "button",
|
|
203
|
+
onClick: (e) => {
|
|
204
|
+
e.stopPropagation();
|
|
205
|
+
onRemove();
|
|
206
|
+
},
|
|
207
|
+
"aria-label": `Remove ${file.name}`,
|
|
208
|
+
className: "light absolute top-1 right-1 w-5 h-5 rounded-full bg-foreground text-background opacity-0 group-hover/tile:opacity-100 transition-opacity duration-fast flex items-center justify-center cursor-pointer outline-none focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-focus-ring",
|
|
209
|
+
children: /* @__PURE__ */ jsx2(XIcon, {
|
|
210
|
+
size: 12,
|
|
211
|
+
strokeWidth: 2.5
|
|
212
|
+
})
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
]
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
// blocks/conversation/composer/queued-row.tsx
|
|
220
|
+
import { Tooltip as Tooltip2 } from "@justanarthur/modo-ui/components/overlays/tooltip";
|
|
221
|
+
import { useIcon as useIcon3 } from "@justanarthur/modo-ui/lib/icon-context";
|
|
222
|
+
import { useSize } from "@justanarthur/modo-ui/lib/size-context";
|
|
223
|
+
import { spring as spring2 } from "@justanarthur/modo-ui/lib/springs";
|
|
224
|
+
import { cn as cn2 } from "@justanarthur/modo-ui/lib/utils";
|
|
225
|
+
import { Reorder } from "motion/react";
|
|
226
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
227
|
+
/*!
|
|
228
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
229
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
230
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
231
|
+
*/
|
|
232
|
+
function QueuedRow({ item, index, total, reduceMotion, isTouch, onEdit, onRemove, onMove }) {
|
|
233
|
+
const XIcon = useIcon3("x");
|
|
234
|
+
const ImageIcon = useIcon3("image");
|
|
235
|
+
const compactStep = useSize().variant === "compact";
|
|
236
|
+
const fileCount = item.files.length;
|
|
237
|
+
const label = item.text || `${fileCount} attachment${fileCount === 1 ? "" : "s"}`;
|
|
238
|
+
return /* @__PURE__ */ jsxs3(Reorder.Item, {
|
|
239
|
+
value: item,
|
|
240
|
+
layout: true,
|
|
241
|
+
initial: reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97 },
|
|
242
|
+
animate: { opacity: 1, scale: 1 },
|
|
243
|
+
exit: reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97, transition: spring2.fast.exit },
|
|
244
|
+
transition: spring2.fast,
|
|
245
|
+
"aria-label": `Queued message ${index + 1} of ${total}: ${label}`,
|
|
246
|
+
tabIndex: 0,
|
|
247
|
+
onDoubleClick: () => onEdit(item),
|
|
248
|
+
onKeyDown: (e) => {
|
|
249
|
+
if (e.key === "Enter" || e.key === "F2") {
|
|
250
|
+
e.preventDefault();
|
|
251
|
+
onEdit(item);
|
|
252
|
+
} else if (e.key === "Delete" || e.key === "Backspace") {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
onRemove(item);
|
|
255
|
+
} else if (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown")) {
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
onMove(item, e.key === "ArrowUp" ? -1 : 1);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
className: cn2("group/qrow flex items-center gap-2 rounded-lg bg-muted", compactStep ? "h-7 px-2 text-body-compact" : "h-8 px-2.5 text-body", "text-foreground/85 select-none outline-none", "cursor-grab active:cursor-grabbing", "focus-visible:ring-1 focus-visible:ring-focus-ring", "weight-normal"),
|
|
261
|
+
children: [
|
|
262
|
+
fileCount > 0 && /* @__PURE__ */ jsxs3("span", {
|
|
263
|
+
className: "flex shrink-0 items-center gap-0.5 text-muted-foreground",
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsx3(ImageIcon, {
|
|
266
|
+
size: 13
|
|
267
|
+
}),
|
|
268
|
+
item.text && /* @__PURE__ */ jsx3("span", {
|
|
269
|
+
className: "tabular-nums",
|
|
270
|
+
children: fileCount
|
|
271
|
+
})
|
|
272
|
+
]
|
|
273
|
+
}),
|
|
274
|
+
/* @__PURE__ */ jsx3("span", {
|
|
275
|
+
className: "min-w-0 flex-1 truncate text-trim py-1 -my-1",
|
|
276
|
+
children: label
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ jsx3(Tooltip2, {
|
|
279
|
+
content: "Remove",
|
|
280
|
+
side: "top",
|
|
281
|
+
children: /* @__PURE__ */ jsx3("button", {
|
|
282
|
+
type: "button",
|
|
283
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
284
|
+
onClick: (e) => {
|
|
285
|
+
e.stopPropagation();
|
|
286
|
+
onRemove(item);
|
|
287
|
+
},
|
|
288
|
+
"aria-label": `Remove queued message: ${label}`,
|
|
289
|
+
className: cn2("shrink-0 flex h-5 w-5 items-center justify-center rounded-full", "text-muted-foreground hover:text-foreground hover:bg-hover", isTouch ? "opacity-100" : "opacity-0 group-hover/qrow:opacity-100 focus-visible:opacity-100", "transition-opacity duration-fast cursor-pointer outline-none", "focus-visible:ring-1 focus-visible:ring-focus-ring"),
|
|
290
|
+
children: /* @__PURE__ */ jsx3(XIcon, {
|
|
291
|
+
size: 13,
|
|
292
|
+
strokeWidth: 2.5
|
|
293
|
+
})
|
|
294
|
+
})
|
|
295
|
+
})
|
|
296
|
+
]
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// blocks/conversation/composer/shared.ts
|
|
301
|
+
/*!
|
|
302
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
303
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
304
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
305
|
+
*/
|
|
306
|
+
function caretToEnd(ref, focus = true) {
|
|
307
|
+
requestAnimationFrame(() => {
|
|
308
|
+
const el = ref.current;
|
|
309
|
+
if (!el)
|
|
310
|
+
return;
|
|
311
|
+
if (focus)
|
|
312
|
+
el.focus();
|
|
313
|
+
el.setSelectionRange(el.value.length, el.value.length);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// blocks/conversation/composer/suggestion-row.tsx
|
|
318
|
+
import { useIcon as useIcon4 } from "@justanarthur/modo-ui/lib/icon-context";
|
|
319
|
+
import { useSize as useSize2 } from "@justanarthur/modo-ui/lib/size-context";
|
|
320
|
+
import { cn as cn3 } from "@justanarthur/modo-ui/lib/utils";
|
|
321
|
+
import { useRegisterFluidHoverItem } from "@justanarthur/modo-ui/primitives/systems/fluid-hover";
|
|
322
|
+
import { useRef } from "react";
|
|
323
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
324
|
+
/*!
|
|
325
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
326
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
327
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
328
|
+
*/
|
|
329
|
+
function SuggestionRow({ text, index, active, keyHint, optionId, registerItem, onSelect }) {
|
|
330
|
+
const EnterIcon = useIcon4("corner-down-left");
|
|
331
|
+
const ArrowDownIcon = useIcon4("arrow-down");
|
|
332
|
+
const compactStep = useSize2().variant === "compact";
|
|
333
|
+
const ref = useRef(null);
|
|
334
|
+
useRegisterFluidHoverItem(registerItem, index, ref);
|
|
335
|
+
return /* @__PURE__ */ jsxs4("div", {
|
|
336
|
+
ref,
|
|
337
|
+
id: optionId,
|
|
338
|
+
role: "option",
|
|
339
|
+
"aria-selected": active,
|
|
340
|
+
onClick: onSelect,
|
|
341
|
+
className: cn3("relative flex cursor-pointer items-center gap-2", compactStep ? "h-7 px-2 text-subtitle-compact" : "h-8 px-2.5 text-subtitle", "text-muted-foreground transition-colors duration-fast", active && "text-foreground", "weight-normal"),
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx4("span", {
|
|
344
|
+
className: "min-w-0 flex-1 truncate text-trim py-1 -my-1",
|
|
345
|
+
children: text
|
|
346
|
+
}),
|
|
347
|
+
!active && keyHint ? /* @__PURE__ */ jsx4(ArrowDownIcon, {
|
|
348
|
+
size: 13,
|
|
349
|
+
className: "shrink-0 text-muted-foreground/70 transition-opacity duration-fast"
|
|
350
|
+
}) : /* @__PURE__ */ jsx4(EnterIcon, {
|
|
351
|
+
size: 13,
|
|
352
|
+
className: cn3("shrink-0 transition-opacity duration-fast", active ? "opacity-100" : "opacity-0")
|
|
353
|
+
})
|
|
354
|
+
]
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// blocks/conversation/composer/use-composer-files.ts
|
|
359
|
+
import { useControllableState } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
360
|
+
import { useCallback, useMemo, useRef as useRef2, useState as useState2 } from "react";
|
|
361
|
+
/*!
|
|
362
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
363
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
364
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
365
|
+
*/
|
|
366
|
+
var NO_FILES = [];
|
|
367
|
+
var fingerprint = (file) => `${file.name}-${file.size}-${file.lastModified}`;
|
|
368
|
+
function matchesAccept(file, tokens) {
|
|
369
|
+
return tokens.some((token) => {
|
|
370
|
+
if (token.endsWith("/*"))
|
|
371
|
+
return file.type.startsWith(token.slice(0, -1));
|
|
372
|
+
if (token.startsWith("."))
|
|
373
|
+
return file.name.toLowerCase().endsWith(token.toLowerCase());
|
|
374
|
+
return file.type === token;
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
function useComposerFiles({
|
|
378
|
+
files,
|
|
379
|
+
defaultFiles,
|
|
380
|
+
onFilesChange,
|
|
381
|
+
accept,
|
|
382
|
+
maxFiles,
|
|
383
|
+
disabled
|
|
384
|
+
}) {
|
|
385
|
+
const supported = onFilesChange !== undefined || defaultFiles !== undefined;
|
|
386
|
+
const [list, setList] = useControllableState(files, defaultFiles ?? NO_FILES, onFilesChange);
|
|
387
|
+
const inputRef = useRef2(null);
|
|
388
|
+
const [dragOver, setDragOver] = useState2(false);
|
|
389
|
+
const acceptTokens = useMemo(() => accept.split(",").map((s) => s.trim()).filter(Boolean), [accept]);
|
|
390
|
+
const replace = useCallback((next) => {
|
|
391
|
+
if (!supported)
|
|
392
|
+
return;
|
|
393
|
+
setList(maxFiles != null ? next.slice(0, maxFiles) : next);
|
|
394
|
+
}, [supported, setList, maxFiles]);
|
|
395
|
+
const add = useCallback((incoming) => {
|
|
396
|
+
const seen = new Set(list.map(fingerprint));
|
|
397
|
+
const accepted = incoming.filter((file) => {
|
|
398
|
+
if (!matchesAccept(file, acceptTokens) || seen.has(fingerprint(file)))
|
|
399
|
+
return false;
|
|
400
|
+
seen.add(fingerprint(file));
|
|
401
|
+
return true;
|
|
402
|
+
});
|
|
403
|
+
if (accepted.length)
|
|
404
|
+
replace([...list, ...accepted]);
|
|
405
|
+
}, [list, acceptTokens, replace]);
|
|
406
|
+
const remove = useCallback((index) => replace(list.filter((_, i) => i !== index)), [list, replace]);
|
|
407
|
+
const openPicker = useCallback((acceptOverride) => {
|
|
408
|
+
const el = inputRef.current;
|
|
409
|
+
if (!el)
|
|
410
|
+
return;
|
|
411
|
+
if (!acceptOverride) {
|
|
412
|
+
el.click();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
el.accept = acceptOverride;
|
|
416
|
+
el.click();
|
|
417
|
+
queueMicrotask(() => {
|
|
418
|
+
if (inputRef.current)
|
|
419
|
+
inputRef.current.accept = accept;
|
|
420
|
+
});
|
|
421
|
+
}, [accept]);
|
|
422
|
+
const dropHandlers = {
|
|
423
|
+
onDragOver: (e) => {
|
|
424
|
+
if (!supported || disabled || !Array.from(e.dataTransfer.types).includes("Files"))
|
|
425
|
+
return;
|
|
426
|
+
e.preventDefault();
|
|
427
|
+
e.dataTransfer.dropEffect = "copy";
|
|
428
|
+
setDragOver(true);
|
|
429
|
+
},
|
|
430
|
+
onDragLeave: (e) => {
|
|
431
|
+
const next = e.relatedTarget;
|
|
432
|
+
if (next && e.currentTarget.contains(next))
|
|
433
|
+
return;
|
|
434
|
+
setDragOver(false);
|
|
435
|
+
},
|
|
436
|
+
onDrop: (e) => {
|
|
437
|
+
e.preventDefault();
|
|
438
|
+
setDragOver(false);
|
|
439
|
+
if (!supported || disabled)
|
|
440
|
+
return;
|
|
441
|
+
add(Array.from(e.dataTransfer.files));
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
const inputProps = {
|
|
445
|
+
ref: inputRef,
|
|
446
|
+
type: "file",
|
|
447
|
+
accept,
|
|
448
|
+
multiple: maxFiles == null || maxFiles > 1,
|
|
449
|
+
onChange: (e) => {
|
|
450
|
+
if (!e.target.files)
|
|
451
|
+
return;
|
|
452
|
+
add(Array.from(e.target.files));
|
|
453
|
+
e.target.value = "";
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
return {
|
|
457
|
+
supported,
|
|
458
|
+
controlled: files !== undefined,
|
|
459
|
+
files: list,
|
|
460
|
+
dragging: supported && dragOver,
|
|
461
|
+
replace,
|
|
462
|
+
remove,
|
|
463
|
+
openPicker,
|
|
464
|
+
dropHandlers,
|
|
465
|
+
inputProps
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// blocks/conversation/composer/use-history-nav.ts
|
|
470
|
+
import { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
|
|
471
|
+
/*!
|
|
472
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
473
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
474
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
475
|
+
*/
|
|
476
|
+
var isPlain = (e) => !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey;
|
|
477
|
+
function useHistoryNav(history, value, setValue, textareaRef) {
|
|
478
|
+
const [index, setIndex] = useState3(null);
|
|
479
|
+
const draft = useRef3("");
|
|
480
|
+
const exit = useCallback2(() => setIndex(null), []);
|
|
481
|
+
const onKeyDown = useCallback2((e) => {
|
|
482
|
+
if (!history.length || !isPlain(e))
|
|
483
|
+
return;
|
|
484
|
+
const el = e.currentTarget;
|
|
485
|
+
const caret = el.selectionStart ?? 0;
|
|
486
|
+
const end = el.selectionEnd ?? caret;
|
|
487
|
+
if (e.key === "ArrowUp" && !value.slice(0, caret).includes(`
|
|
488
|
+
`)) {
|
|
489
|
+
const start = index ?? history.length;
|
|
490
|
+
if (start === 0)
|
|
491
|
+
return;
|
|
492
|
+
e.preventDefault();
|
|
493
|
+
if (index == null)
|
|
494
|
+
draft.current = value;
|
|
495
|
+
setIndex(start - 1);
|
|
496
|
+
setValue(history[start - 1] ?? "");
|
|
497
|
+
caretToEnd(textareaRef, false);
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
if (e.key === "ArrowDown" && index != null && !value.slice(end).includes(`
|
|
501
|
+
`)) {
|
|
502
|
+
e.preventDefault();
|
|
503
|
+
const next = index + 1;
|
|
504
|
+
setIndex(next >= history.length ? null : next);
|
|
505
|
+
setValue(next >= history.length ? draft.current : history[next] ?? "");
|
|
506
|
+
caretToEnd(textareaRef, false);
|
|
507
|
+
}
|
|
508
|
+
}, [history, value, index, setValue, textareaRef]);
|
|
509
|
+
return { exit, onKeyDown };
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// blocks/conversation/composer/use-message-queue.ts
|
|
513
|
+
import { useControllableState as useControllableState2 } from "@justanarthur/modo-ui/lib/use-controllable-state";
|
|
514
|
+
import { useCallback as useCallback3, useEffect as useEffect2, useRef as useRef4, useState as useState4 } from "react";
|
|
515
|
+
/*!
|
|
516
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
517
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
518
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
519
|
+
*/
|
|
520
|
+
var NO_QUEUE = [];
|
|
521
|
+
function useMessageQueue(options) {
|
|
522
|
+
const { onStop, onSend } = options;
|
|
523
|
+
const statusEnabled = options.status !== undefined || options.defaultStatus !== undefined;
|
|
524
|
+
const statusControlled = options.status !== undefined;
|
|
525
|
+
const [statusValue, setStatus] = useControllableState2(options.status, options.defaultStatus ?? "idle", options.onStatusChange);
|
|
526
|
+
const status = statusEnabled ? statusValue : undefined;
|
|
527
|
+
const [queue, setQueue] = useControllableState2(options.queue, options.defaultQueue ?? NO_QUEUE, options.onQueueChange);
|
|
528
|
+
const queueRef = useRef4(queue);
|
|
529
|
+
queueRef.current = queue;
|
|
530
|
+
const supported = statusEnabled && (options.onQueueChange !== undefined || options.defaultQueue !== undefined);
|
|
531
|
+
const [announcement, setAnnouncement] = useState4("");
|
|
532
|
+
const canStop = onStop !== undefined || !statusControlled;
|
|
533
|
+
const stop = useCallback3(() => {
|
|
534
|
+
onStop?.();
|
|
535
|
+
if (!statusControlled)
|
|
536
|
+
setStatus("idle");
|
|
537
|
+
}, [onStop, statusControlled, setStatus]);
|
|
538
|
+
const previous = useRef4(status);
|
|
539
|
+
useEffect2(() => {
|
|
540
|
+
const prev = previous.current;
|
|
541
|
+
previous.current = status;
|
|
542
|
+
if (!supported || prev !== "streaming" || status !== "idle")
|
|
543
|
+
return;
|
|
544
|
+
const [next, ...rest] = queue;
|
|
545
|
+
if (!next)
|
|
546
|
+
return;
|
|
547
|
+
setQueue(rest);
|
|
548
|
+
onSend?.(next.text, next.files, { queuedId: next.id });
|
|
549
|
+
setAnnouncement(`Message sent.${rest.length ? ` ${rest.length} still queued.` : ""}`);
|
|
550
|
+
}, [status, supported, queue, setQueue, onSend]);
|
|
551
|
+
const enqueue = useCallback3((text, files) => setQueue([...queueRef.current, { id: crypto.randomUUID(), text, files }]), [setQueue]);
|
|
552
|
+
const remove = useCallback3((item) => setQueue(queueRef.current.filter((q) => q.id !== item.id)), [setQueue]);
|
|
553
|
+
const move = useCallback3((item, dir) => {
|
|
554
|
+
const next = [...queueRef.current];
|
|
555
|
+
const i = next.findIndex((q) => q.id === item.id);
|
|
556
|
+
const a = next[i];
|
|
557
|
+
const b = next[i + dir];
|
|
558
|
+
if (i < 0 || !a || !b)
|
|
559
|
+
return;
|
|
560
|
+
next[i] = b;
|
|
561
|
+
next[i + dir] = a;
|
|
562
|
+
setQueue(next);
|
|
563
|
+
}, [setQueue]);
|
|
564
|
+
return {
|
|
565
|
+
supported,
|
|
566
|
+
streaming: status === "streaming",
|
|
567
|
+
canStop,
|
|
568
|
+
stop,
|
|
569
|
+
queue,
|
|
570
|
+
setQueue,
|
|
571
|
+
enqueue,
|
|
572
|
+
remove,
|
|
573
|
+
move,
|
|
574
|
+
announcement
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// blocks/conversation/composer/use-region-height.ts
|
|
579
|
+
import { useCallback as useCallback4, useRef as useRef5, useState as useState5 } from "react";
|
|
580
|
+
/*!
|
|
581
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
582
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
583
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
584
|
+
*/
|
|
585
|
+
function useRegionHeight() {
|
|
586
|
+
const observer = useRef5(null);
|
|
587
|
+
const [height, setHeight] = useState5(null);
|
|
588
|
+
const ref = useCallback4((el) => {
|
|
589
|
+
observer.current?.disconnect();
|
|
590
|
+
observer.current = null;
|
|
591
|
+
if (!el)
|
|
592
|
+
return;
|
|
593
|
+
const sync = () => {
|
|
594
|
+
const next = el.parentElement?.scrollHeight ?? el.offsetHeight;
|
|
595
|
+
if (next > 0)
|
|
596
|
+
setHeight(next);
|
|
597
|
+
};
|
|
598
|
+
sync();
|
|
599
|
+
observer.current = new ResizeObserver(sync);
|
|
600
|
+
observer.current.observe(el);
|
|
601
|
+
}, []);
|
|
602
|
+
return [ref, height];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
// blocks/conversation/composer/draft.tsx
|
|
606
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
607
|
+
/*!
|
|
608
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
609
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
610
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
611
|
+
*/
|
|
612
|
+
var DEFAULT_ACCEPT = "image/png,image/jpeg,application/pdf";
|
|
613
|
+
var NO_STRINGS = [];
|
|
614
|
+
var REGION_SPRING = { ...spring3.moderate, bounce: 0 };
|
|
615
|
+
var isPlain2 = (e) => !e.shiftKey && !e.altKey && !e.metaKey && !e.ctrlKey;
|
|
616
|
+
var ComposerDraft2 = forwardRef2(({
|
|
617
|
+
size,
|
|
618
|
+
value: valueProp,
|
|
619
|
+
defaultValue,
|
|
620
|
+
onValueChange,
|
|
621
|
+
onSend,
|
|
622
|
+
placeholder = "Ask me anything…",
|
|
623
|
+
leftSlot,
|
|
624
|
+
rightSlot,
|
|
625
|
+
disabled,
|
|
626
|
+
minRows = 1,
|
|
627
|
+
maxRows = 8,
|
|
628
|
+
clickToFocus = true,
|
|
629
|
+
sendLabel = "Send",
|
|
630
|
+
files,
|
|
631
|
+
defaultFiles,
|
|
632
|
+
onFilesChange,
|
|
633
|
+
accept = DEFAULT_ACCEPT,
|
|
634
|
+
maxFiles,
|
|
635
|
+
filePreviewSize = 80,
|
|
636
|
+
textareaProps,
|
|
637
|
+
status,
|
|
638
|
+
defaultStatus,
|
|
639
|
+
onStatusChange,
|
|
640
|
+
onStop,
|
|
641
|
+
queue,
|
|
642
|
+
defaultQueue,
|
|
643
|
+
onQueueChange,
|
|
644
|
+
showQueue = true,
|
|
645
|
+
history = NO_STRINGS,
|
|
646
|
+
placeholderSuggestion,
|
|
647
|
+
suggestions,
|
|
648
|
+
className,
|
|
649
|
+
...props
|
|
650
|
+
}, ref) => {
|
|
651
|
+
const shape = useShape2();
|
|
652
|
+
const compactStep = useSize3(size).variant === "compact";
|
|
653
|
+
const ArrowUpIcon = useIcon5("arrow-up");
|
|
654
|
+
const reduceMotion = useReduceMotion();
|
|
655
|
+
const isTouch = useTouchPrimary();
|
|
656
|
+
const textareaRef = useRef6(null);
|
|
657
|
+
const {
|
|
658
|
+
onBlur: textareaOnBlur,
|
|
659
|
+
"aria-describedby": textareaDescribedBy,
|
|
660
|
+
...restTextareaProps
|
|
661
|
+
} = textareaProps ?? {};
|
|
662
|
+
const valueControlled = valueProp !== undefined;
|
|
663
|
+
const [value, setValue] = useControllableState3(valueProp, defaultValue ?? "", onValueChange);
|
|
664
|
+
const attachments = useComposerFiles({ files, defaultFiles, onFilesChange, accept, maxFiles, disabled });
|
|
665
|
+
const messages = useMessageQueue({
|
|
666
|
+
status,
|
|
667
|
+
defaultStatus,
|
|
668
|
+
onStatusChange,
|
|
669
|
+
onStop,
|
|
670
|
+
queue,
|
|
671
|
+
defaultQueue,
|
|
672
|
+
onQueueChange,
|
|
673
|
+
onSend
|
|
674
|
+
});
|
|
675
|
+
const recall = useHistoryNav(history, value, setValue, textareaRef);
|
|
676
|
+
useAutosizeTextarea(textareaRef, { minRows, maxRows }, [value, compactStep]);
|
|
677
|
+
const suggestionList = suggestions ?? NO_STRINGS;
|
|
678
|
+
const suggestionsOpen = suggestionList.length > 0 && value === "";
|
|
679
|
+
const suggestionListRef = useRef6(null);
|
|
680
|
+
const suggestionHover = useFluidHover(suggestionListRef);
|
|
681
|
+
const {
|
|
682
|
+
activeIndex: activeSuggestion,
|
|
683
|
+
setActiveIndex: setActiveSuggestion,
|
|
684
|
+
handlers: suggestionHandlers,
|
|
685
|
+
registerItem: registerSuggestion,
|
|
686
|
+
remeasure
|
|
687
|
+
} = suggestionHover;
|
|
688
|
+
const suggestionListId = useId();
|
|
689
|
+
const ghostHintId = useId();
|
|
690
|
+
const showGhost = !!placeholderSuggestion && value === "" && !attachments.dragging;
|
|
691
|
+
const [filesRegionRef, filesRegionHeight] = useRegionHeight();
|
|
692
|
+
const [queueRegionRef, queueRegionHeight] = useRegionHeight();
|
|
693
|
+
const [suggestionsRegionRef, suggestionsRegionHeight] = useRegionHeight();
|
|
694
|
+
useEffect3(() => {
|
|
695
|
+
if (suggestionsOpen)
|
|
696
|
+
remeasure();
|
|
697
|
+
else
|
|
698
|
+
setActiveSuggestion(null);
|
|
699
|
+
}, [suggestionsOpen, remeasure, setActiveSuggestion]);
|
|
700
|
+
const acceptSuggestion = useCallback5((text) => {
|
|
701
|
+
setActiveSuggestion(null);
|
|
702
|
+
recall.exit();
|
|
703
|
+
setValue(text);
|
|
704
|
+
caretToEnd(textareaRef);
|
|
705
|
+
}, [setValue, setActiveSuggestion, recall.exit]);
|
|
706
|
+
const trimmed = value.trim();
|
|
707
|
+
const canSend = !disabled && (trimmed.length > 0 || attachments.files.length > 0);
|
|
708
|
+
const handleSend = () => {
|
|
709
|
+
if (!canSend)
|
|
710
|
+
return;
|
|
711
|
+
recall.exit();
|
|
712
|
+
if (messages.streaming && messages.supported) {
|
|
713
|
+
messages.enqueue(trimmed, attachments.files);
|
|
714
|
+
setValue("");
|
|
715
|
+
attachments.replace([]);
|
|
716
|
+
caretToEnd(textareaRef);
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
onSend?.(trimmed, attachments.files);
|
|
720
|
+
if (!valueControlled)
|
|
721
|
+
setValue("");
|
|
722
|
+
if (!attachments.controlled)
|
|
723
|
+
attachments.replace([]);
|
|
724
|
+
};
|
|
725
|
+
const editQueued = (item) => {
|
|
726
|
+
recall.exit();
|
|
727
|
+
setValue(item.text);
|
|
728
|
+
attachments.replace(item.files);
|
|
729
|
+
messages.remove(item);
|
|
730
|
+
caretToEnd(textareaRef);
|
|
731
|
+
};
|
|
732
|
+
const buttonMode = !messages.streaming ? "send" : canSend && messages.supported ? "queue" : messages.canStop ? "stop" : "send";
|
|
733
|
+
const buttonLabel = buttonMode === "stop" ? "Stop" : buttonMode === "queue" ? "Queue message" : sendLabel;
|
|
734
|
+
const handleKeyDown = (e) => {
|
|
735
|
+
if (e.nativeEvent.isComposing)
|
|
736
|
+
return;
|
|
737
|
+
if (suggestionsOpen && isPlain2(e)) {
|
|
738
|
+
if (e.key === "ArrowDown") {
|
|
739
|
+
e.preventDefault();
|
|
740
|
+
setActiveSuggestion((prev) => prev == null ? 0 : Math.min(prev + 1, suggestionList.length - 1));
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
if (activeSuggestion != null) {
|
|
744
|
+
if (e.key === "ArrowUp") {
|
|
745
|
+
e.preventDefault();
|
|
746
|
+
setActiveSuggestion(activeSuggestion === 0 ? null : activeSuggestion - 1);
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
if (e.key === "Enter") {
|
|
750
|
+
e.preventDefault();
|
|
751
|
+
const picked = suggestionList[activeSuggestion];
|
|
752
|
+
if (picked !== undefined)
|
|
753
|
+
acceptSuggestion(picked);
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
if (e.key === "Escape") {
|
|
757
|
+
e.preventDefault();
|
|
758
|
+
setActiveSuggestion(null);
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
if (e.key === "Tab" && !e.shiftKey && placeholderSuggestion && value === "") {
|
|
764
|
+
e.preventDefault();
|
|
765
|
+
acceptSuggestion(placeholderSuggestion);
|
|
766
|
+
return;
|
|
767
|
+
}
|
|
768
|
+
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
769
|
+
recall.onKeyDown(e);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
773
|
+
e.preventDefault();
|
|
774
|
+
handleSend();
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
const handleContainerMouseDown = (e) => {
|
|
778
|
+
if (!clickToFocus || disabled)
|
|
779
|
+
return;
|
|
780
|
+
const target = e.target;
|
|
781
|
+
if (target === textareaRef.current)
|
|
782
|
+
return;
|
|
783
|
+
if (target.closest('button, a, input, select, textarea, [contenteditable], [role="button"], [data-draft-queue]'))
|
|
784
|
+
return;
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
textareaRef.current?.focus();
|
|
787
|
+
};
|
|
788
|
+
const slotCtx = useMemo2(() => ({ openFilePicker: attachments.openPicker, files: attachments.files }), [attachments.openPicker, attachments.files]);
|
|
789
|
+
const leftContent = typeof leftSlot === "function" ? leftSlot(slotCtx) : leftSlot;
|
|
790
|
+
const rightContent = typeof rightSlot === "function" ? rightSlot(slotCtx) : rightSlot;
|
|
791
|
+
const textStep = compactStep ? "text-subtitle-compact leading-4.5 px-1.5 py-1.5" : "text-subtitle leading-5 px-2 py-2";
|
|
792
|
+
return /* @__PURE__ */ jsx5(SizeScope, {
|
|
793
|
+
size,
|
|
794
|
+
children: /* @__PURE__ */ jsx5("div", {
|
|
795
|
+
ref,
|
|
796
|
+
"data-composer-draft": "",
|
|
797
|
+
"data-click-to-focus": clickToFocus && !disabled ? "" : undefined,
|
|
798
|
+
"data-drag-over": attachments.dragging ? "" : undefined,
|
|
799
|
+
onMouseDown: handleContainerMouseDown,
|
|
800
|
+
...attachments.dropHandlers,
|
|
801
|
+
className: cn4("flex flex-col gap-1 p-2 transition-[box-shadow,color] duration-fast", surfaceClasses(2, 2), shape.container, clickToFocus && !disabled && "cursor-text", disabled && "opacity-50 pointer-events-none", className),
|
|
802
|
+
...props,
|
|
803
|
+
children: /* @__PURE__ */ jsxs5(SurfaceProvider, {
|
|
804
|
+
value: 2,
|
|
805
|
+
children: [
|
|
806
|
+
attachments.supported && /* @__PURE__ */ jsx5("input", {
|
|
807
|
+
...attachments.inputProps,
|
|
808
|
+
className: "hidden",
|
|
809
|
+
"aria-hidden": "true",
|
|
810
|
+
tabIndex: -1
|
|
811
|
+
}),
|
|
812
|
+
/* @__PURE__ */ jsx5(AnimatePresence, {
|
|
813
|
+
initial: false,
|
|
814
|
+
children: attachments.files.length > 0 && /* @__PURE__ */ jsx5(motion2.div, {
|
|
815
|
+
initial: { height: 0, opacity: 0 },
|
|
816
|
+
animate: { height: filesRegionHeight ?? 0, opacity: 1 },
|
|
817
|
+
exit: { height: 0, opacity: 0 },
|
|
818
|
+
transition: REGION_SPRING,
|
|
819
|
+
className: "overflow-hidden",
|
|
820
|
+
children: /* @__PURE__ */ jsx5("div", {
|
|
821
|
+
ref: filesRegionRef,
|
|
822
|
+
className: "flex flex-wrap gap-2 pb-1",
|
|
823
|
+
children: /* @__PURE__ */ jsx5(AnimatePresence, {
|
|
824
|
+
initial: false,
|
|
825
|
+
mode: "popLayout",
|
|
826
|
+
children: attachments.files.map((file, i) => /* @__PURE__ */ jsx5(FilePreviewTile, {
|
|
827
|
+
file,
|
|
828
|
+
onRemove: () => attachments.remove(i),
|
|
829
|
+
size: filePreviewSize
|
|
830
|
+
}, `${file.name}-${file.size}-${file.lastModified}`))
|
|
831
|
+
})
|
|
832
|
+
})
|
|
833
|
+
}, "preview-row")
|
|
834
|
+
}),
|
|
835
|
+
messages.supported && showQueue && /* @__PURE__ */ jsx5(AnimatePresence, {
|
|
836
|
+
initial: false,
|
|
837
|
+
children: messages.queue.length > 0 && /* @__PURE__ */ jsx5(motion2.div, {
|
|
838
|
+
initial: { height: 0, opacity: 0 },
|
|
839
|
+
animate: { height: queueRegionHeight ?? 0, opacity: 1 },
|
|
840
|
+
exit: { height: 0, opacity: 0 },
|
|
841
|
+
transition: REGION_SPRING,
|
|
842
|
+
className: "overflow-hidden",
|
|
843
|
+
children: /* @__PURE__ */ jsx5(Reorder2.Group, {
|
|
844
|
+
ref: queueRegionRef,
|
|
845
|
+
axis: "y",
|
|
846
|
+
values: messages.queue,
|
|
847
|
+
onReorder: messages.setQueue,
|
|
848
|
+
"data-draft-queue": true,
|
|
849
|
+
className: "flex flex-col gap-1 pb-1",
|
|
850
|
+
children: /* @__PURE__ */ jsx5(AnimatePresence, {
|
|
851
|
+
initial: false,
|
|
852
|
+
children: messages.queue.map((item, i) => /* @__PURE__ */ jsx5(QueuedRow, {
|
|
853
|
+
item,
|
|
854
|
+
index: i,
|
|
855
|
+
total: messages.queue.length,
|
|
856
|
+
reduceMotion,
|
|
857
|
+
isTouch,
|
|
858
|
+
onEdit: editQueued,
|
|
859
|
+
onRemove: messages.remove,
|
|
860
|
+
onMove: messages.move
|
|
861
|
+
}, item.id))
|
|
862
|
+
})
|
|
863
|
+
})
|
|
864
|
+
}, "queue-row")
|
|
865
|
+
}),
|
|
866
|
+
/* @__PURE__ */ jsxs5("div", {
|
|
867
|
+
className: "relative",
|
|
868
|
+
children: [
|
|
869
|
+
/* @__PURE__ */ jsx5("textarea", {
|
|
870
|
+
ref: textareaRef,
|
|
871
|
+
value,
|
|
872
|
+
onChange: (e) => {
|
|
873
|
+
recall.exit();
|
|
874
|
+
setActiveSuggestion(null);
|
|
875
|
+
setValue(e.target.value);
|
|
876
|
+
},
|
|
877
|
+
onKeyDown: handleKeyDown,
|
|
878
|
+
onBlur: (e) => {
|
|
879
|
+
setActiveSuggestion(null);
|
|
880
|
+
textareaOnBlur?.(e);
|
|
881
|
+
},
|
|
882
|
+
placeholder: attachments.dragging ? "Drop files here to add to chat" : placeholderSuggestion ? undefined : placeholder,
|
|
883
|
+
disabled,
|
|
884
|
+
rows: minRows,
|
|
885
|
+
"aria-label": textareaProps?.["aria-label"] ?? "Message",
|
|
886
|
+
"aria-describedby": [showGhost ? ghostHintId : null, textareaDescribedBy].filter(Boolean).join(" ") || undefined,
|
|
887
|
+
"aria-activedescendant": activeSuggestion != null ? `${suggestionListId}-${activeSuggestion}` : undefined,
|
|
888
|
+
className: cn4("w-full resize-none rounded-none bg-transparent outline-none", "text-foreground placeholder:text-muted-foreground", textStep, "weight-normal"),
|
|
889
|
+
...restTextareaProps
|
|
890
|
+
}),
|
|
891
|
+
showGhost && /* @__PURE__ */ jsx5("div", {
|
|
892
|
+
"aria-hidden": "true",
|
|
893
|
+
className: cn4("pointer-events-none absolute inset-0 overflow-hidden text-muted-foreground", textStep, "weight-normal"),
|
|
894
|
+
children: /* @__PURE__ */ jsxs5("span", {
|
|
895
|
+
className: "flex max-w-full items-center gap-1.5",
|
|
896
|
+
children: [
|
|
897
|
+
/* @__PURE__ */ jsx5("span", {
|
|
898
|
+
className: "min-w-0 truncate",
|
|
899
|
+
children: placeholderSuggestion
|
|
900
|
+
}),
|
|
901
|
+
/* @__PURE__ */ jsx5("kbd", {
|
|
902
|
+
className: cn4("inline-flex shrink-0 -translate-y-px items-center rounded-box border border-border bg-background px-1 font-sans text-muted-foreground", compactStep ? "h-4 text-micro-compact" : "h-[18px] text-micro"),
|
|
903
|
+
children: "Tab"
|
|
904
|
+
})
|
|
905
|
+
]
|
|
906
|
+
})
|
|
907
|
+
}),
|
|
908
|
+
showGhost && /* @__PURE__ */ jsxs5("span", {
|
|
909
|
+
id: ghostHintId,
|
|
910
|
+
className: "sr-only",
|
|
911
|
+
children: [
|
|
912
|
+
"Suggested prompt: ",
|
|
913
|
+
placeholderSuggestion,
|
|
914
|
+
". Press Tab to fill the composer with it."
|
|
915
|
+
]
|
|
916
|
+
})
|
|
917
|
+
]
|
|
918
|
+
}),
|
|
919
|
+
/* @__PURE__ */ jsxs5("div", {
|
|
920
|
+
className: cn4("flex items-center justify-between", compactStep ? "gap-1.5 [&_button]:h-6 [&_button.w-7]:w-6 [&_button]:text-caption-compact" : "gap-2"),
|
|
921
|
+
children: [
|
|
922
|
+
/* @__PURE__ */ jsx5("div", {
|
|
923
|
+
className: "flex items-center gap-1.5 min-w-0",
|
|
924
|
+
children: leftContent
|
|
925
|
+
}),
|
|
926
|
+
/* @__PURE__ */ jsxs5("div", {
|
|
927
|
+
className: "flex items-center gap-1.5 shrink-0",
|
|
928
|
+
children: [
|
|
929
|
+
rightContent,
|
|
930
|
+
/* @__PURE__ */ jsx5(Button, {
|
|
931
|
+
type: "button",
|
|
932
|
+
variant: "primary",
|
|
933
|
+
size: "icon-compact",
|
|
934
|
+
onClick: buttonMode === "stop" ? messages.stop : handleSend,
|
|
935
|
+
disabled: buttonMode === "stop" ? disabled : !canSend,
|
|
936
|
+
"aria-label": buttonLabel,
|
|
937
|
+
children: /* @__PURE__ */ jsx5(AnimatePresence, {
|
|
938
|
+
mode: "wait",
|
|
939
|
+
initial: false,
|
|
940
|
+
children: /* @__PURE__ */ jsx5(motion2.span, {
|
|
941
|
+
initial: reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6 },
|
|
942
|
+
animate: { opacity: 1, scale: 1 },
|
|
943
|
+
exit: reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.6, transition: spring3.fast.exit },
|
|
944
|
+
transition: spring3.fast,
|
|
945
|
+
className: "flex items-center justify-center leading-none",
|
|
946
|
+
children: buttonMode === "stop" ? /* @__PURE__ */ jsx5("span", {
|
|
947
|
+
className: "h-3 w-3 rounded-glyph bg-current"
|
|
948
|
+
}) : /* @__PURE__ */ jsx5(ArrowUpIcon, {
|
|
949
|
+
size: compactStep ? 15 : 19,
|
|
950
|
+
className: cn4("block", compactStep ? "!h-[15px] !w-[15px]" : "!h-[19px] !w-[19px]")
|
|
951
|
+
})
|
|
952
|
+
}, buttonMode === "stop" ? "stop" : "arrow")
|
|
953
|
+
})
|
|
954
|
+
})
|
|
955
|
+
]
|
|
956
|
+
})
|
|
957
|
+
]
|
|
958
|
+
}),
|
|
959
|
+
suggestionList.length > 0 && /* @__PURE__ */ jsx5(AnimatePresence, {
|
|
960
|
+
initial: false,
|
|
961
|
+
children: suggestionsOpen && /* @__PURE__ */ jsx5(motion2.div, {
|
|
962
|
+
initial: { height: 0, opacity: 0 },
|
|
963
|
+
animate: { height: suggestionsRegionHeight ?? 0, opacity: 1 },
|
|
964
|
+
exit: { height: 0 },
|
|
965
|
+
transition: REGION_SPRING,
|
|
966
|
+
className: "-mx-2 -mt-1 overflow-hidden",
|
|
967
|
+
children: /* @__PURE__ */ jsxs5("div", {
|
|
968
|
+
ref: (el) => {
|
|
969
|
+
suggestionListRef.current = el;
|
|
970
|
+
suggestionsRegionRef(el);
|
|
971
|
+
},
|
|
972
|
+
role: "listbox",
|
|
973
|
+
id: suggestionListId,
|
|
974
|
+
"aria-label": "Suggested prompts",
|
|
975
|
+
onMouseEnter: suggestionHandlers.onMouseEnter,
|
|
976
|
+
onMouseMove: suggestionHandlers.onMouseMove,
|
|
977
|
+
onMouseLeave: suggestionHandlers.onMouseLeave,
|
|
978
|
+
onClick: suggestionHandlers.onClick,
|
|
979
|
+
className: "relative mt-2 flex flex-col border-t border-border/60 px-1.5 pt-1.5",
|
|
980
|
+
children: [
|
|
981
|
+
/* @__PURE__ */ jsx5(FluidHoverHighlight, {
|
|
982
|
+
hover: suggestionHover,
|
|
983
|
+
className: shape.bg
|
|
984
|
+
}),
|
|
985
|
+
suggestionList.map((s, i) => /* @__PURE__ */ jsx5(SuggestionRow, {
|
|
986
|
+
text: s,
|
|
987
|
+
index: i,
|
|
988
|
+
active: i === activeSuggestion,
|
|
989
|
+
keyHint: i === 0 && activeSuggestion == null,
|
|
990
|
+
optionId: `${suggestionListId}-${i}`,
|
|
991
|
+
registerItem: registerSuggestion,
|
|
992
|
+
onSelect: () => acceptSuggestion(s)
|
|
993
|
+
}, `${s}-${i}`))
|
|
994
|
+
]
|
|
995
|
+
})
|
|
996
|
+
}, "suggestions")
|
|
997
|
+
}),
|
|
998
|
+
/* @__PURE__ */ jsx5("span", {
|
|
999
|
+
className: "sr-only",
|
|
1000
|
+
role: "status",
|
|
1001
|
+
"aria-live": "polite",
|
|
1002
|
+
children: messages.announcement
|
|
1003
|
+
})
|
|
1004
|
+
]
|
|
1005
|
+
})
|
|
1006
|
+
})
|
|
1007
|
+
});
|
|
1008
|
+
});
|
|
1009
|
+
ComposerDraft2.displayName = "Composer.Draft";
|
|
1010
|
+
|
|
1011
|
+
// blocks/conversation/composer/index.tsx
|
|
1012
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1013
|
+
/*!
|
|
1014
|
+
* Local addition: the AI app's composer, in a ShellCard. The draft
|
|
1015
|
+
* (./draft.tsx) is Fluid Functionalism's InputMessage (attachments, queue,
|
|
1016
|
+
* history, suggestions, send and stop), ported in modo-ui and moved here, with
|
|
1017
|
+
* two controls: one +
|
|
1018
|
+
* palette (attach, @-files, commands, skills, plugins) and one run-settings
|
|
1019
|
+
* popover (model, effort, permissions, fast mode, output style, context).
|
|
1020
|
+
* The shell's row says where the session runs: the project (with worktree
|
|
1021
|
+
* and setup) and the profile (with its usage). Every menu grows out of its
|
|
1022
|
+
* button.
|
|
1023
|
+
*/
|
|
1024
|
+
function AddPalette({ files, commands, onAttach }) {
|
|
1025
|
+
const Plus = useIcon2("plus");
|
|
1026
|
+
const Paperclip = useIcon2("paperclip");
|
|
1027
|
+
const File = useIcon2("file-text");
|
|
1028
|
+
const Command = useIcon2("command");
|
|
1029
|
+
const groups = [
|
|
1030
|
+
{ label: "Commands", kind: "command" },
|
|
1031
|
+
{ label: "Skills", kind: "skill" },
|
|
1032
|
+
{ label: "Plugins", kind: "plugin" }
|
|
1033
|
+
];
|
|
1034
|
+
let index = 1;
|
|
1035
|
+
return /* @__PURE__ */ jsxs6(Dropdown.Menu, {
|
|
1036
|
+
children: [
|
|
1037
|
+
/* @__PURE__ */ jsx6(Dropdown.Trigger, {
|
|
1038
|
+
render: /* @__PURE__ */ jsx6(Button2, {
|
|
1039
|
+
variant: "ghost",
|
|
1040
|
+
size: "icon-compact",
|
|
1041
|
+
"aria-label": "Add files, mentions and commands",
|
|
1042
|
+
children: /* @__PURE__ */ jsx6(Plus, {})
|
|
1043
|
+
})
|
|
1044
|
+
}),
|
|
1045
|
+
/* @__PURE__ */ jsxs6(Dropdown.Content, {
|
|
1046
|
+
side: "top",
|
|
1047
|
+
align: "start",
|
|
1048
|
+
className: "w-72",
|
|
1049
|
+
children: [
|
|
1050
|
+
/* @__PURE__ */ jsx6(Dropdown.Search, {
|
|
1051
|
+
filter: true,
|
|
1052
|
+
placeholder: "Files, commands, skills"
|
|
1053
|
+
}),
|
|
1054
|
+
/* @__PURE__ */ jsx6(Dropdown.Item, {
|
|
1055
|
+
index: 0,
|
|
1056
|
+
icon: Paperclip,
|
|
1057
|
+
label: "Attach files…",
|
|
1058
|
+
onSelect: onAttach
|
|
1059
|
+
}),
|
|
1060
|
+
/* @__PURE__ */ jsx6(Dropdown.Label, {
|
|
1061
|
+
children: "Mention a file"
|
|
1062
|
+
}),
|
|
1063
|
+
files.map((path) => /* @__PURE__ */ jsx6(Dropdown.Item, {
|
|
1064
|
+
index: index++,
|
|
1065
|
+
icon: File,
|
|
1066
|
+
label: path
|
|
1067
|
+
}, path)),
|
|
1068
|
+
groups.map((group) => /* @__PURE__ */ jsxs6("div", {
|
|
1069
|
+
className: "contents",
|
|
1070
|
+
children: [
|
|
1071
|
+
/* @__PURE__ */ jsx6(Dropdown.Label, {
|
|
1072
|
+
children: group.label
|
|
1073
|
+
}),
|
|
1074
|
+
commands.filter((c) => c.kind === group.kind).map((c) => /* @__PURE__ */ jsx6(Dropdown.Item, {
|
|
1075
|
+
index: index++,
|
|
1076
|
+
icon: Command,
|
|
1077
|
+
label: c.name
|
|
1078
|
+
}, c.name))
|
|
1079
|
+
]
|
|
1080
|
+
}, group.kind)),
|
|
1081
|
+
/* @__PURE__ */ jsx6(Dropdown.Empty, {
|
|
1082
|
+
children: "Nothing found"
|
|
1083
|
+
})
|
|
1084
|
+
]
|
|
1085
|
+
})
|
|
1086
|
+
]
|
|
1087
|
+
});
|
|
1088
|
+
}
|
|
1089
|
+
function inList(value, options, fallback = options[0] ?? "") {
|
|
1090
|
+
return options.includes(value) ? value : fallback;
|
|
1091
|
+
}
|
|
1092
|
+
function ProjectPicker({
|
|
1093
|
+
projects,
|
|
1094
|
+
branches,
|
|
1095
|
+
branch,
|
|
1096
|
+
locked,
|
|
1097
|
+
project,
|
|
1098
|
+
onProjectChange,
|
|
1099
|
+
worktree,
|
|
1100
|
+
onWorktreeChange,
|
|
1101
|
+
baseBranch,
|
|
1102
|
+
onBaseBranchChange
|
|
1103
|
+
}) {
|
|
1104
|
+
const label = projects.find((p) => p.path === project)?.label ?? "";
|
|
1105
|
+
const Folder = useIcon2("folder");
|
|
1106
|
+
const Branch = useIcon2("git-branch");
|
|
1107
|
+
return /* @__PURE__ */ jsxs6(Popover, {
|
|
1108
|
+
children: [
|
|
1109
|
+
/* @__PURE__ */ jsx6(Popover.Trigger, {
|
|
1110
|
+
render: /* @__PURE__ */ jsxs6(RowTrigger2, {
|
|
1111
|
+
"aria-label": `Project: ${label}${worktree ? ", new worktree" : ""}`,
|
|
1112
|
+
children: [
|
|
1113
|
+
/* @__PURE__ */ jsx6(Folder, {
|
|
1114
|
+
size: 14,
|
|
1115
|
+
strokeWidth: 1.5,
|
|
1116
|
+
className: "shrink-0 text-muted-foreground"
|
|
1117
|
+
}),
|
|
1118
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1119
|
+
className: "min-w-0 truncate",
|
|
1120
|
+
children: label
|
|
1121
|
+
}),
|
|
1122
|
+
worktree && /* @__PURE__ */ jsx6(Branch, {
|
|
1123
|
+
size: 14,
|
|
1124
|
+
strokeWidth: 1.5,
|
|
1125
|
+
className: "shrink-0 text-muted-foreground"
|
|
1126
|
+
})
|
|
1127
|
+
]
|
|
1128
|
+
})
|
|
1129
|
+
}),
|
|
1130
|
+
/* @__PURE__ */ jsx6(Popover.Content, {
|
|
1131
|
+
side: "top",
|
|
1132
|
+
align: "start",
|
|
1133
|
+
sideOffset: 8,
|
|
1134
|
+
className: LIST_POPOVER,
|
|
1135
|
+
children: /* @__PURE__ */ jsxs6(SizeProvider, {
|
|
1136
|
+
size: "default",
|
|
1137
|
+
children: [
|
|
1138
|
+
/* @__PURE__ */ jsx6(List.Section, {
|
|
1139
|
+
title: locked ? "This session runs in" : "Project",
|
|
1140
|
+
children: /* @__PURE__ */ jsx6(ChoiceList, {
|
|
1141
|
+
label: "Project",
|
|
1142
|
+
value: project,
|
|
1143
|
+
onValueChange: onProjectChange,
|
|
1144
|
+
options: projects.map((g) => ({
|
|
1145
|
+
value: g.path,
|
|
1146
|
+
label: g.label,
|
|
1147
|
+
disabled: locked && g.path !== project,
|
|
1148
|
+
content: /* @__PURE__ */ jsxs6("span", {
|
|
1149
|
+
className: "flex min-w-0 flex-1 items-baseline justify-between gap-2",
|
|
1150
|
+
children: [
|
|
1151
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1152
|
+
className: "text-body text-foreground",
|
|
1153
|
+
children: g.label
|
|
1154
|
+
}),
|
|
1155
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1156
|
+
className: "truncate font-mono text-caption text-muted-foreground",
|
|
1157
|
+
children: g.path
|
|
1158
|
+
})
|
|
1159
|
+
]
|
|
1160
|
+
})
|
|
1161
|
+
}))
|
|
1162
|
+
})
|
|
1163
|
+
}),
|
|
1164
|
+
/* @__PURE__ */ jsxs6(List.Section, {
|
|
1165
|
+
title: "Checkout",
|
|
1166
|
+
children: [
|
|
1167
|
+
branch && /* @__PURE__ */ jsx6(List.Row, {
|
|
1168
|
+
label: "Branch",
|
|
1169
|
+
children: /* @__PURE__ */ jsx6("span", {
|
|
1170
|
+
className: "min-w-0 truncate font-mono text-caption text-muted-foreground",
|
|
1171
|
+
children: branch
|
|
1172
|
+
})
|
|
1173
|
+
}),
|
|
1174
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1175
|
+
label: "New worktree",
|
|
1176
|
+
children: /* @__PURE__ */ jsx6(Switch, {
|
|
1177
|
+
label: "New worktree",
|
|
1178
|
+
checked: worktree,
|
|
1179
|
+
onCheckedChange: onWorktreeChange,
|
|
1180
|
+
disabled: locked,
|
|
1181
|
+
className: LIST_SWITCH
|
|
1182
|
+
})
|
|
1183
|
+
}),
|
|
1184
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1185
|
+
label: "Run setup script",
|
|
1186
|
+
children: /* @__PURE__ */ jsx6(Switch, {
|
|
1187
|
+
label: "Run setup script",
|
|
1188
|
+
defaultChecked: true,
|
|
1189
|
+
disabled: locked,
|
|
1190
|
+
className: LIST_SWITCH
|
|
1191
|
+
})
|
|
1192
|
+
}),
|
|
1193
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1194
|
+
label: "Base branch",
|
|
1195
|
+
children: /* @__PURE__ */ jsxs6(Select, {
|
|
1196
|
+
value: baseBranch,
|
|
1197
|
+
onValueChange: onBaseBranchChange,
|
|
1198
|
+
disabled: locked,
|
|
1199
|
+
children: [
|
|
1200
|
+
/* @__PURE__ */ jsx6(Select.Trigger, {
|
|
1201
|
+
variant: "borderless",
|
|
1202
|
+
className: "min-w-0"
|
|
1203
|
+
}),
|
|
1204
|
+
/* @__PURE__ */ jsx6(Select.Content, {
|
|
1205
|
+
children: branches.map((b, i) => /* @__PURE__ */ jsx6(Select.Item, {
|
|
1206
|
+
index: i,
|
|
1207
|
+
value: b,
|
|
1208
|
+
children: b
|
|
1209
|
+
}, b))
|
|
1210
|
+
})
|
|
1211
|
+
]
|
|
1212
|
+
})
|
|
1213
|
+
})
|
|
1214
|
+
]
|
|
1215
|
+
})
|
|
1216
|
+
]
|
|
1217
|
+
})
|
|
1218
|
+
})
|
|
1219
|
+
]
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
function RunSettings({
|
|
1223
|
+
models,
|
|
1224
|
+
efforts,
|
|
1225
|
+
permissionModes,
|
|
1226
|
+
outputStyles,
|
|
1227
|
+
context,
|
|
1228
|
+
compacting,
|
|
1229
|
+
model,
|
|
1230
|
+
onModelChange,
|
|
1231
|
+
effort,
|
|
1232
|
+
onEffortChange,
|
|
1233
|
+
mode,
|
|
1234
|
+
onModeChange,
|
|
1235
|
+
fast,
|
|
1236
|
+
onFastChange,
|
|
1237
|
+
style,
|
|
1238
|
+
onStyleChange
|
|
1239
|
+
}) {
|
|
1240
|
+
const activeMode = permissionModes.find((m) => m.label === mode);
|
|
1241
|
+
const ModeIcon = useIcon2(activeMode?.icon ?? "shield-check");
|
|
1242
|
+
const Zap = useIcon2("zap");
|
|
1243
|
+
const percent = Math.round(context * 100);
|
|
1244
|
+
return /* @__PURE__ */ jsxs6(Popover, {
|
|
1245
|
+
children: [
|
|
1246
|
+
/* @__PURE__ */ jsx6(Popover.Trigger, {
|
|
1247
|
+
render: /* @__PURE__ */ jsxs6(RowTrigger2, {
|
|
1248
|
+
className: "max-w-full",
|
|
1249
|
+
"aria-label": `Run settings: ${model}, ${effort} effort, ${mode}, context ${percent}%`,
|
|
1250
|
+
children: [
|
|
1251
|
+
/* @__PURE__ */ jsx6(ModeIcon, {
|
|
1252
|
+
size: 14,
|
|
1253
|
+
strokeWidth: 1.5,
|
|
1254
|
+
className: "shrink-0 text-muted-foreground"
|
|
1255
|
+
}),
|
|
1256
|
+
fast && /* @__PURE__ */ jsx6(Zap, {
|
|
1257
|
+
size: 14,
|
|
1258
|
+
strokeWidth: 1.5,
|
|
1259
|
+
className: "shrink-0 text-muted-foreground"
|
|
1260
|
+
}),
|
|
1261
|
+
/* @__PURE__ */ jsxs6("span", {
|
|
1262
|
+
className: "min-w-0 truncate",
|
|
1263
|
+
children: [
|
|
1264
|
+
model,
|
|
1265
|
+
" · ",
|
|
1266
|
+
effort
|
|
1267
|
+
]
|
|
1268
|
+
}),
|
|
1269
|
+
/* @__PURE__ */ jsx6(Meter, {
|
|
1270
|
+
variant: "ring",
|
|
1271
|
+
label: "Context used",
|
|
1272
|
+
value: compacting ? 0.3 : context,
|
|
1273
|
+
warnAt: 0.8,
|
|
1274
|
+
errorAt: 0.95
|
|
1275
|
+
})
|
|
1276
|
+
]
|
|
1277
|
+
})
|
|
1278
|
+
}),
|
|
1279
|
+
/* @__PURE__ */ jsx6(Popover.Content, {
|
|
1280
|
+
side: "top",
|
|
1281
|
+
align: "end",
|
|
1282
|
+
sideOffset: 8,
|
|
1283
|
+
className: LIST_POPOVER,
|
|
1284
|
+
children: /* @__PURE__ */ jsxs6(SizeProvider, {
|
|
1285
|
+
size: "default",
|
|
1286
|
+
children: [
|
|
1287
|
+
/* @__PURE__ */ jsx6(List.Section, {
|
|
1288
|
+
title: "Model",
|
|
1289
|
+
children: /* @__PURE__ */ jsx6(ChoiceList, {
|
|
1290
|
+
label: "Model",
|
|
1291
|
+
value: model,
|
|
1292
|
+
onValueChange: onModelChange,
|
|
1293
|
+
options: models.map((m) => ({
|
|
1294
|
+
value: m.name,
|
|
1295
|
+
label: m.name,
|
|
1296
|
+
content: /* @__PURE__ */ jsxs6("span", {
|
|
1297
|
+
className: "flex min-w-0 flex-1 items-baseline justify-between gap-2",
|
|
1298
|
+
children: [
|
|
1299
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1300
|
+
className: "text-body text-foreground",
|
|
1301
|
+
children: m.name
|
|
1302
|
+
}),
|
|
1303
|
+
/* @__PURE__ */ jsx6("span", {
|
|
1304
|
+
className: "truncate text-caption text-muted-foreground",
|
|
1305
|
+
children: m.note
|
|
1306
|
+
})
|
|
1307
|
+
]
|
|
1308
|
+
})
|
|
1309
|
+
}))
|
|
1310
|
+
})
|
|
1311
|
+
}),
|
|
1312
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1313
|
+
className: "px-[var(--space-2)]",
|
|
1314
|
+
children: /* @__PURE__ */ jsx6(Slider, {
|
|
1315
|
+
size: "default",
|
|
1316
|
+
label: "Effort",
|
|
1317
|
+
min: 0,
|
|
1318
|
+
max: efforts.length - 1,
|
|
1319
|
+
step: 1,
|
|
1320
|
+
value: Math.max(efforts.indexOf(effort), 0),
|
|
1321
|
+
onValueChange: (v) => onEffortChange(efforts[typeof v === "number" ? v : v[0]] ?? effort),
|
|
1322
|
+
formatValue: (v) => efforts[v] ?? ""
|
|
1323
|
+
})
|
|
1324
|
+
}),
|
|
1325
|
+
/* @__PURE__ */ jsxs6(List.Section, {
|
|
1326
|
+
title: "Behaviour",
|
|
1327
|
+
children: [
|
|
1328
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1329
|
+
label: "Permissions",
|
|
1330
|
+
children: /* @__PURE__ */ jsxs6(Select, {
|
|
1331
|
+
value: mode,
|
|
1332
|
+
onValueChange: onModeChange,
|
|
1333
|
+
children: [
|
|
1334
|
+
/* @__PURE__ */ jsx6(Select.Trigger, {
|
|
1335
|
+
variant: "borderless",
|
|
1336
|
+
icon: ModeIcon,
|
|
1337
|
+
className: "min-w-0",
|
|
1338
|
+
title: activeMode?.note
|
|
1339
|
+
}),
|
|
1340
|
+
/* @__PURE__ */ jsx6(Select.Content, {
|
|
1341
|
+
children: permissionModes.map((m, i) => /* @__PURE__ */ jsx6(Select.Item, {
|
|
1342
|
+
index: i,
|
|
1343
|
+
value: m.label,
|
|
1344
|
+
children: m.label
|
|
1345
|
+
}, m.label))
|
|
1346
|
+
})
|
|
1347
|
+
]
|
|
1348
|
+
})
|
|
1349
|
+
}),
|
|
1350
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1351
|
+
label: "Fast mode",
|
|
1352
|
+
children: /* @__PURE__ */ jsx6(Switch, {
|
|
1353
|
+
label: "Fast mode",
|
|
1354
|
+
checked: fast,
|
|
1355
|
+
onCheckedChange: onFastChange,
|
|
1356
|
+
className: LIST_SWITCH
|
|
1357
|
+
})
|
|
1358
|
+
}),
|
|
1359
|
+
/* @__PURE__ */ jsx6(List.Row, {
|
|
1360
|
+
label: "Output style",
|
|
1361
|
+
children: /* @__PURE__ */ jsxs6(Select, {
|
|
1362
|
+
value: style,
|
|
1363
|
+
onValueChange: onStyleChange,
|
|
1364
|
+
children: [
|
|
1365
|
+
/* @__PURE__ */ jsx6(Select.Trigger, {
|
|
1366
|
+
variant: "borderless",
|
|
1367
|
+
className: "min-w-0"
|
|
1368
|
+
}),
|
|
1369
|
+
/* @__PURE__ */ jsx6(Select.Content, {
|
|
1370
|
+
children: outputStyles.map((o, i) => /* @__PURE__ */ jsx6(Select.Item, {
|
|
1371
|
+
index: i,
|
|
1372
|
+
value: o,
|
|
1373
|
+
children: o
|
|
1374
|
+
}, o))
|
|
1375
|
+
})
|
|
1376
|
+
]
|
|
1377
|
+
})
|
|
1378
|
+
})
|
|
1379
|
+
]
|
|
1380
|
+
}),
|
|
1381
|
+
/* @__PURE__ */ jsx6(List.Section, {
|
|
1382
|
+
title: "Context",
|
|
1383
|
+
aside: compacting ? "Compacting…" : `${percent}% of the window`,
|
|
1384
|
+
children: /* @__PURE__ */ jsxs6(List.Row, {
|
|
1385
|
+
label: "Compacts at 95%",
|
|
1386
|
+
children: [
|
|
1387
|
+
/* @__PURE__ */ jsx6(Meter, {
|
|
1388
|
+
variant: "line",
|
|
1389
|
+
className: "w-20",
|
|
1390
|
+
label: "Context used",
|
|
1391
|
+
value: compacting ? 0.3 : context,
|
|
1392
|
+
warnAt: 0.8,
|
|
1393
|
+
errorAt: 0.95
|
|
1394
|
+
}),
|
|
1395
|
+
/* @__PURE__ */ jsx6(Button2, {
|
|
1396
|
+
variant: "ghost",
|
|
1397
|
+
size: "compact",
|
|
1398
|
+
disabled: compacting || context < 0.2,
|
|
1399
|
+
children: "Compact"
|
|
1400
|
+
})
|
|
1401
|
+
]
|
|
1402
|
+
})
|
|
1403
|
+
})
|
|
1404
|
+
]
|
|
1405
|
+
})
|
|
1406
|
+
})
|
|
1407
|
+
]
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
function LiftedDraft(props) {
|
|
1411
|
+
const level = Math.min(useSurface() + 1, 8);
|
|
1412
|
+
return /* @__PURE__ */ jsx6(SurfaceProvider2, {
|
|
1413
|
+
value: level,
|
|
1414
|
+
children: /* @__PURE__ */ jsx6(ComposerDraft2, {
|
|
1415
|
+
...props,
|
|
1416
|
+
className: cn5(SURFACE_BG[level], props.className)
|
|
1417
|
+
})
|
|
1418
|
+
});
|
|
1419
|
+
}
|
|
1420
|
+
var Composer2 = Object.assign(function Composer({
|
|
1421
|
+
models,
|
|
1422
|
+
efforts,
|
|
1423
|
+
permissionModes,
|
|
1424
|
+
outputStyles,
|
|
1425
|
+
commands,
|
|
1426
|
+
files,
|
|
1427
|
+
projects,
|
|
1428
|
+
branches,
|
|
1429
|
+
branch,
|
|
1430
|
+
project: projectProp,
|
|
1431
|
+
defaultProject,
|
|
1432
|
+
onProjectChange,
|
|
1433
|
+
worktree: worktreeProp,
|
|
1434
|
+
defaultWorktree = true,
|
|
1435
|
+
onWorktreeChange,
|
|
1436
|
+
baseBranch: baseBranchProp,
|
|
1437
|
+
defaultBaseBranch,
|
|
1438
|
+
onBaseBranchChange,
|
|
1439
|
+
profiles,
|
|
1440
|
+
model: modelProp,
|
|
1441
|
+
defaultModel,
|
|
1442
|
+
onModelChange,
|
|
1443
|
+
effort: effortProp,
|
|
1444
|
+
defaultEffort,
|
|
1445
|
+
onEffortChange,
|
|
1446
|
+
permissionMode: permissionModeProp,
|
|
1447
|
+
defaultPermissionMode,
|
|
1448
|
+
onPermissionModeChange,
|
|
1449
|
+
fast: fastProp,
|
|
1450
|
+
defaultFast = false,
|
|
1451
|
+
onFastChange,
|
|
1452
|
+
outputStyle: outputStyleProp,
|
|
1453
|
+
defaultOutputStyle,
|
|
1454
|
+
onOutputStyleChange,
|
|
1455
|
+
context = 0.62,
|
|
1456
|
+
compacting = false,
|
|
1457
|
+
defaultStatus = "idle",
|
|
1458
|
+
target = false,
|
|
1459
|
+
profile,
|
|
1460
|
+
defaultProfile,
|
|
1461
|
+
onProfileChange,
|
|
1462
|
+
placeholder = "Ask, or type / for commands",
|
|
1463
|
+
className,
|
|
1464
|
+
...draft
|
|
1465
|
+
}) {
|
|
1466
|
+
const projectPaths = projects.map((p) => p.path);
|
|
1467
|
+
const modelNames = models.map((m) => m.name);
|
|
1468
|
+
const modeLabels = permissionModes.map((m) => m.label);
|
|
1469
|
+
const middleEffort = efforts[Math.floor(efforts.length / 2)] ?? "";
|
|
1470
|
+
const [project, setProject] = useControllableState4(projectProp, defaultProject ?? "", onProjectChange);
|
|
1471
|
+
const [worktree, setWorktree] = useControllableState4(worktreeProp, defaultWorktree, onWorktreeChange);
|
|
1472
|
+
const [baseBranch, setBaseBranch] = useControllableState4(baseBranchProp, defaultBaseBranch ?? "", onBaseBranchChange);
|
|
1473
|
+
const [model, setModel] = useControllableState4(modelProp, defaultModel ?? "", onModelChange);
|
|
1474
|
+
const [effort, setEffort] = useControllableState4(effortProp, defaultEffort ?? middleEffort, onEffortChange);
|
|
1475
|
+
const [mode, setMode] = useControllableState4(permissionModeProp, defaultPermissionMode ?? "", onPermissionModeChange);
|
|
1476
|
+
const [fast, setFast] = useControllableState4(fastProp, defaultFast, onFastChange);
|
|
1477
|
+
const [style, setStyle] = useControllableState4(outputStyleProp, defaultOutputStyle ?? "", onOutputStyleChange);
|
|
1478
|
+
return /* @__PURE__ */ jsx6(ShellCard, {
|
|
1479
|
+
variant: "elevated",
|
|
1480
|
+
className: cn5("w-full", className),
|
|
1481
|
+
footer: /* @__PURE__ */ jsx6(SizeProvider, {
|
|
1482
|
+
size: "compact",
|
|
1483
|
+
children: /* @__PURE__ */ jsxs6(ShellCard.Footer, {
|
|
1484
|
+
className: "justify-start gap-[var(--space-1)] pt-[var(--space-1)]",
|
|
1485
|
+
children: [
|
|
1486
|
+
/* @__PURE__ */ jsx6(ProjectPicker, {
|
|
1487
|
+
projects,
|
|
1488
|
+
branches,
|
|
1489
|
+
branch,
|
|
1490
|
+
locked: !target,
|
|
1491
|
+
project: inList(project, projectPaths),
|
|
1492
|
+
onProjectChange: setProject,
|
|
1493
|
+
worktree,
|
|
1494
|
+
onWorktreeChange: setWorktree,
|
|
1495
|
+
baseBranch: inList(baseBranch, branches),
|
|
1496
|
+
onBaseBranchChange: setBaseBranch
|
|
1497
|
+
}),
|
|
1498
|
+
/* @__PURE__ */ jsx6(ProfileSwitcher2, {
|
|
1499
|
+
profiles,
|
|
1500
|
+
value: profile,
|
|
1501
|
+
defaultValue: defaultProfile,
|
|
1502
|
+
onValueChange: onProfileChange,
|
|
1503
|
+
side: "top"
|
|
1504
|
+
}),
|
|
1505
|
+
/* @__PURE__ */ jsx6("div", {
|
|
1506
|
+
className: "ml-auto min-w-0",
|
|
1507
|
+
children: /* @__PURE__ */ jsx6(RunSettings, {
|
|
1508
|
+
models,
|
|
1509
|
+
efforts,
|
|
1510
|
+
permissionModes,
|
|
1511
|
+
outputStyles,
|
|
1512
|
+
context,
|
|
1513
|
+
compacting,
|
|
1514
|
+
model: inList(model, modelNames),
|
|
1515
|
+
onModelChange: setModel,
|
|
1516
|
+
effort: inList(effort, efforts, middleEffort),
|
|
1517
|
+
onEffortChange: setEffort,
|
|
1518
|
+
mode: inList(mode, modeLabels),
|
|
1519
|
+
onModeChange: setMode,
|
|
1520
|
+
fast,
|
|
1521
|
+
onFastChange: setFast,
|
|
1522
|
+
style: inList(style, outputStyles),
|
|
1523
|
+
onStyleChange: setStyle
|
|
1524
|
+
})
|
|
1525
|
+
})
|
|
1526
|
+
]
|
|
1527
|
+
})
|
|
1528
|
+
}),
|
|
1529
|
+
children: /* @__PURE__ */ jsx6(LiftedDraft, {
|
|
1530
|
+
...draft,
|
|
1531
|
+
placeholder,
|
|
1532
|
+
defaultStatus,
|
|
1533
|
+
defaultFiles: [],
|
|
1534
|
+
leftSlot: ({ openFilePicker }) => /* @__PURE__ */ jsx6(AddPalette, {
|
|
1535
|
+
files,
|
|
1536
|
+
commands,
|
|
1537
|
+
onAttach: () => openFilePicker()
|
|
1538
|
+
})
|
|
1539
|
+
})
|
|
1540
|
+
});
|
|
1541
|
+
}, { Draft: ComposerDraft2 });
|
|
1542
|
+
var composer_default = Composer2;
|
|
1543
|
+
|
|
1544
|
+
export { FileThumbnail2, ComposerDraft2, Composer2, composer_default };
|