@justanarthur/modo-ui-ai 0.0.0-stage → 0.2.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 +114 -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 +517 -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 +204 -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 +33 -0
- package/blocks/dialogs/command-palette/index.tsx +232 -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 +13 -0
- package/blocks/panes/usage-pane/index.tsx +75 -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 +18 -0
- package/blocks/profiles/profile-switcher/index.tsx +197 -0
- package/blocks/profiles/profile-usage/examples.mdx +21 -0
- package/blocks/profiles/profile-usage/index.tsx +127 -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 +43 -0
- package/blocks/sessions/session-sidebar/index.tsx +442 -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 +30 -0
- package/components/conversation/agent-run/index.tsx +82 -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 +128 -0
- package/components/conversation/message/working.tsx +102 -0
- package/components/conversation/reasoning/examples.mdx +22 -0
- package/components/conversation/reasoning/index.tsx +54 -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 +15 -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 +11 -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 +26 -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 +12 -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-1aq2xzv5.js +558 -0
- package/dist/shared/chunk-1f96cz69.js +45 -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-4248zvmh.js +177 -0
- package/dist/shared/chunk-45rqgey6.d.ts +25 -0
- package/dist/shared/chunk-4n0v64qx.js +179 -0
- package/dist/shared/chunk-4zvhpf2x.js +55 -0
- package/dist/shared/chunk-57hzzmjd.d.ts +67 -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-5k6xwqfj.d.ts +68 -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-6g4970a6.d.ts +20 -0
- package/dist/shared/chunk-75zwypyr.d.ts +43 -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-8xg5gwwy.js +38 -0
- package/dist/shared/chunk-9kw6m047.d.ts +32 -0
- package/dist/shared/chunk-a4s440b6.js +79 -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-bh2b5d1z.js +98 -0
- package/dist/shared/chunk-bzs6amnv.js +187 -0
- package/dist/shared/chunk-c36qvrwq.d.ts +30 -0
- package/dist/shared/chunk-c8wp058j.js +153 -0
- package/dist/shared/chunk-cd4f87as.d.ts +28 -0
- package/dist/shared/chunk-cmwby8f9.js +467 -0
- package/dist/shared/chunk-d2t72h4x.d.ts +35 -0
- package/dist/shared/chunk-dh3qy5fj.js +49 -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-fbn0h7cr.js +123 -0
- package/dist/shared/chunk-fqhcz6ss.d.ts +29 -0
- package/dist/shared/chunk-g28hweee.d.ts +35 -0
- package/dist/shared/chunk-g88hweqh.d.ts +70 -0
- package/dist/shared/chunk-gewnsgza.js +61 -0
- package/dist/shared/chunk-gkyk663q.d.ts +53 -0
- package/dist/shared/chunk-hd4gtj5z.d.ts +23 -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-k5zegxje.d.ts +81 -0
- package/dist/shared/chunk-kreypnzp.d.ts +34 -0
- package/dist/shared/chunk-kw9npka5.js +224 -0
- package/dist/shared/chunk-mrb3fp2f.d.ts +30 -0
- package/dist/shared/chunk-n1qq2wp9.js +6 -0
- package/dist/shared/chunk-n4742y54.js +39 -0
- package/dist/shared/chunk-ndjvdkv7.d.ts +29 -0
- package/dist/shared/chunk-nk4578dr.js +73 -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-r5hz78pb.js +129 -0
- package/dist/shared/chunk-r6nb21kz.d.ts +102 -0
- package/dist/shared/chunk-rjfwje37.d.ts +234 -0
- package/dist/shared/chunk-rqrpvvz4.d.ts +107 -0
- package/dist/shared/chunk-rzajcn44.d.ts +49 -0
- package/dist/shared/chunk-s3r759ec.js +80 -0
- package/dist/shared/chunk-sdtjrw9w.d.ts +98 -0
- package/dist/shared/chunk-sfqvyzcs.d.ts +68 -0
- package/dist/shared/chunk-skg3m9m0.js +56 -0
- package/dist/shared/chunk-szkvrqg1.d.ts +54 -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-v6yevw62.d.ts +28 -0
- package/dist/shared/chunk-v9q38p0x.js +258 -0
- package/dist/shared/chunk-vd59gzzd.js +86 -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-w5z8qnf8.js +175 -0
- package/dist/shared/chunk-wgvzavx1.js +1488 -0
- package/dist/shared/chunk-whsx7yp9.d.ts +37 -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 +74 -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,517 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's composer, in a ShellCard. The draft
|
|
3
|
+
* (./draft.tsx) is Fluid Functionalism's InputMessage (attachments, queue,
|
|
4
|
+
* history, suggestions, send and stop), ported in modo-ui and moved here, with
|
|
5
|
+
* two controls: one +
|
|
6
|
+
* palette (attach, @-files, commands, skills, plugins) and one run-settings
|
|
7
|
+
* popover (model, effort, permissions, fast mode, output style, context).
|
|
8
|
+
* The shell's row says where the session runs: the project (with worktree
|
|
9
|
+
* and setup) and the profile (with its usage). Every menu grows out of its
|
|
10
|
+
* button.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use client'
|
|
14
|
+
|
|
15
|
+
import { SurfaceProvider, useSurface } from '@justanarthur/modo-ui'
|
|
16
|
+
import ShellCard from '@justanarthur/modo-ui/blocks/shell-card'
|
|
17
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
18
|
+
import List, { LIST_POPOVER, LIST_SWITCH } from '@justanarthur/modo-ui/components/data-display/list'
|
|
19
|
+
import Meter from '@justanarthur/modo-ui/components/feedback/meter'
|
|
20
|
+
import ChoiceList from '@justanarthur/modo-ui/components/inputs/choice-list'
|
|
21
|
+
import Select from '@justanarthur/modo-ui/components/inputs/select'
|
|
22
|
+
import Slider from '@justanarthur/modo-ui/components/inputs/slider'
|
|
23
|
+
import Switch from '@justanarthur/modo-ui/components/inputs/switch'
|
|
24
|
+
import Dropdown from '@justanarthur/modo-ui/components/overlays/dropdown'
|
|
25
|
+
import Popover from '@justanarthur/modo-ui/components/overlays/popover'
|
|
26
|
+
import { SURFACE_BG } from '@justanarthur/modo-ui/lib/surface-classes'
|
|
27
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
28
|
+
import { SizeProvider } from '@justanarthur/modo-ui/primitives/systems/sizes'
|
|
29
|
+
import { useState } from 'react'
|
|
30
|
+
import { useIcon } from '../../../lib/icons'
|
|
31
|
+
import { RowTrigger } from '../../../lib/row-trigger'
|
|
32
|
+
import type { Command, Model, PermissionMode, Profile, Project } from '../../../lib/types'
|
|
33
|
+
import ProfileSwitcher from '../../profiles/profile-switcher'
|
|
34
|
+
import {
|
|
35
|
+
ComposerDraft,
|
|
36
|
+
type ComposerDraftProps,
|
|
37
|
+
type DraftSlotContext,
|
|
38
|
+
type DraftStatus,
|
|
39
|
+
type QueuedMessage,
|
|
40
|
+
} from './draft'
|
|
41
|
+
|
|
42
|
+
/** One + button: attach, mention a file, run a command, skill or plugin — one searchable list. */
|
|
43
|
+
function AddPalette({ files, commands, onAttach }: { files: string[]; commands: Command[]; onAttach: () => void }) {
|
|
44
|
+
const Plus = useIcon('plus')
|
|
45
|
+
const Paperclip = useIcon('paperclip')
|
|
46
|
+
const File = useIcon('file-text')
|
|
47
|
+
const Command = useIcon('command')
|
|
48
|
+
const groups = [
|
|
49
|
+
{ label: 'Commands', kind: 'command' },
|
|
50
|
+
{ label: 'Skills', kind: 'skill' },
|
|
51
|
+
{ label: 'Plugins', kind: 'plugin' },
|
|
52
|
+
] as const
|
|
53
|
+
let index = 1
|
|
54
|
+
return (
|
|
55
|
+
<Dropdown.Menu>
|
|
56
|
+
<Dropdown.Trigger
|
|
57
|
+
render={
|
|
58
|
+
<Button variant="ghost" size="icon-compact" aria-label="Add files, mentions and commands">
|
|
59
|
+
<Plus />
|
|
60
|
+
</Button>
|
|
61
|
+
}
|
|
62
|
+
/>
|
|
63
|
+
<Dropdown.Content side="top" align="start" className="w-72">
|
|
64
|
+
<Dropdown.Search filter placeholder="Files, commands, skills" />
|
|
65
|
+
<Dropdown.Item index={0} icon={Paperclip} label="Attach files…" onSelect={onAttach} />
|
|
66
|
+
<Dropdown.Label>Mention a file</Dropdown.Label>
|
|
67
|
+
{files.map(path => (
|
|
68
|
+
<Dropdown.Item key={path} index={index++} icon={File} label={path} />
|
|
69
|
+
))}
|
|
70
|
+
{groups.map(group => (
|
|
71
|
+
<div key={group.kind} className="contents">
|
|
72
|
+
<Dropdown.Label>{group.label}</Dropdown.Label>
|
|
73
|
+
{commands
|
|
74
|
+
.filter(c => c.kind === group.kind)
|
|
75
|
+
.map(c => (
|
|
76
|
+
<Dropdown.Item key={c.name} index={index++} icon={Command} label={c.name} />
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
))}
|
|
80
|
+
<Dropdown.Empty>Nothing found</Dropdown.Empty>
|
|
81
|
+
</Dropdown.Content>
|
|
82
|
+
</Dropdown.Menu>
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Where a session runs: the project, a worktree of its own and how it is set up. */
|
|
87
|
+
function ProjectPicker({
|
|
88
|
+
projects,
|
|
89
|
+
branches,
|
|
90
|
+
branch,
|
|
91
|
+
locked,
|
|
92
|
+
}: {
|
|
93
|
+
projects: Project[]
|
|
94
|
+
branches: string[]
|
|
95
|
+
branch?: string
|
|
96
|
+
locked: boolean
|
|
97
|
+
}) {
|
|
98
|
+
const [project, setProject] = useState(projects[0]?.label ?? '')
|
|
99
|
+
const [worktree, setWorktree] = useState(true)
|
|
100
|
+
const Folder = useIcon('folder')
|
|
101
|
+
const Branch = useIcon('git-branch')
|
|
102
|
+
return (
|
|
103
|
+
<Popover>
|
|
104
|
+
<Popover.Trigger
|
|
105
|
+
render={
|
|
106
|
+
<RowTrigger aria-label={`Project: ${project}${worktree ? ', new worktree' : ''}`}>
|
|
107
|
+
<Folder size={14} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
|
|
108
|
+
<span className="min-w-0 truncate">{project}</span>
|
|
109
|
+
{worktree && <Branch size={14} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />}
|
|
110
|
+
</RowTrigger>
|
|
111
|
+
}
|
|
112
|
+
/>
|
|
113
|
+
<Popover.Content side="top" align="start" sideOffset={8} className={LIST_POPOVER}>
|
|
114
|
+
<SizeProvider size="default">
|
|
115
|
+
<List.Section title={locked ? 'This session runs in' : 'Project'}>
|
|
116
|
+
<ChoiceList
|
|
117
|
+
label="Project"
|
|
118
|
+
value={project}
|
|
119
|
+
onValueChange={setProject}
|
|
120
|
+
options={projects.map(g => ({
|
|
121
|
+
value: g.label,
|
|
122
|
+
label: g.label,
|
|
123
|
+
disabled: locked && g.label !== project,
|
|
124
|
+
content: (
|
|
125
|
+
<span className="flex min-w-0 flex-1 items-baseline justify-between gap-2">
|
|
126
|
+
<span className="text-body text-foreground">{g.label}</span>
|
|
127
|
+
<span className="truncate font-mono text-caption text-muted-foreground">{g.path}</span>
|
|
128
|
+
</span>
|
|
129
|
+
),
|
|
130
|
+
}))}
|
|
131
|
+
/>
|
|
132
|
+
</List.Section>
|
|
133
|
+
<List.Section title="Checkout">
|
|
134
|
+
{branch && (
|
|
135
|
+
<List.Row label="Branch">
|
|
136
|
+
<span className="min-w-0 truncate font-mono text-caption text-muted-foreground">{branch}</span>
|
|
137
|
+
</List.Row>
|
|
138
|
+
)}
|
|
139
|
+
<List.Row label="New worktree">
|
|
140
|
+
<Switch
|
|
141
|
+
label="New worktree"
|
|
142
|
+
checked={worktree}
|
|
143
|
+
onCheckedChange={setWorktree}
|
|
144
|
+
disabled={locked}
|
|
145
|
+
className={LIST_SWITCH}
|
|
146
|
+
/>
|
|
147
|
+
</List.Row>
|
|
148
|
+
<List.Row label="Run setup script">
|
|
149
|
+
<Switch label="Run setup script" defaultChecked disabled={locked} className={LIST_SWITCH} />
|
|
150
|
+
</List.Row>
|
|
151
|
+
<List.Row label="Base branch">
|
|
152
|
+
<Select defaultValue={branches[0]} disabled={locked}>
|
|
153
|
+
<Select.Trigger variant="borderless" className="min-w-0" />
|
|
154
|
+
<Select.Content>
|
|
155
|
+
{branches.map((b, i) => (
|
|
156
|
+
<Select.Item key={b} index={i} value={b}>
|
|
157
|
+
{b}
|
|
158
|
+
</Select.Item>
|
|
159
|
+
))}
|
|
160
|
+
</Select.Content>
|
|
161
|
+
</Select>
|
|
162
|
+
</List.Row>
|
|
163
|
+
</List.Section>
|
|
164
|
+
</SizeProvider>
|
|
165
|
+
</Popover.Content>
|
|
166
|
+
</Popover>
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
interface RunSettingsProps {
|
|
171
|
+
models: Model[]
|
|
172
|
+
efforts: string[]
|
|
173
|
+
permissionModes: PermissionMode[]
|
|
174
|
+
outputStyles: string[]
|
|
175
|
+
context: number
|
|
176
|
+
compacting: boolean
|
|
177
|
+
defaultModel: string
|
|
178
|
+
defaultEffort: string
|
|
179
|
+
defaultMode: string
|
|
180
|
+
defaultFast: boolean
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** How the agent runs, behind one trigger: "Opus 5.5 · High ◔". */
|
|
184
|
+
function RunSettings({
|
|
185
|
+
models,
|
|
186
|
+
efforts,
|
|
187
|
+
permissionModes,
|
|
188
|
+
outputStyles,
|
|
189
|
+
context,
|
|
190
|
+
compacting,
|
|
191
|
+
defaultModel,
|
|
192
|
+
defaultEffort,
|
|
193
|
+
defaultMode,
|
|
194
|
+
defaultFast,
|
|
195
|
+
}: RunSettingsProps) {
|
|
196
|
+
const [model, setModel] = useState(defaultModel)
|
|
197
|
+
const [effort, setEffort] = useState(defaultEffort)
|
|
198
|
+
const [mode, setMode] = useState(defaultMode)
|
|
199
|
+
const [fast, setFast] = useState(defaultFast)
|
|
200
|
+
const [style, setStyle] = useState(outputStyles[0] ?? '')
|
|
201
|
+
const activeMode = permissionModes.find(m => m.label === mode)
|
|
202
|
+
const ModeIcon = useIcon(activeMode?.icon ?? 'shield-check')
|
|
203
|
+
const Zap = useIcon('zap')
|
|
204
|
+
const percent = Math.round(context * 100)
|
|
205
|
+
|
|
206
|
+
return (
|
|
207
|
+
<Popover>
|
|
208
|
+
<Popover.Trigger
|
|
209
|
+
render={
|
|
210
|
+
<RowTrigger
|
|
211
|
+
className="max-w-full"
|
|
212
|
+
aria-label={`Run settings: ${model}, ${effort} effort, ${mode}, context ${percent}%`}
|
|
213
|
+
>
|
|
214
|
+
<ModeIcon size={14} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />
|
|
215
|
+
{fast && <Zap size={14} strokeWidth={1.5} className="shrink-0 text-muted-foreground" />}
|
|
216
|
+
<span className="min-w-0 truncate">
|
|
217
|
+
{model} · {effort}
|
|
218
|
+
</span>
|
|
219
|
+
<Meter variant="ring" label="Context used" value={compacting ? 0.3 : context} warnAt={0.8} errorAt={0.95} />
|
|
220
|
+
</RowTrigger>
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
<Popover.Content side="top" align="end" sideOffset={8} className={LIST_POPOVER}>
|
|
224
|
+
<SizeProvider size="default">
|
|
225
|
+
<List.Section title="Model">
|
|
226
|
+
<ChoiceList
|
|
227
|
+
label="Model"
|
|
228
|
+
value={model}
|
|
229
|
+
onValueChange={setModel}
|
|
230
|
+
options={models.map(m => ({
|
|
231
|
+
value: m.name,
|
|
232
|
+
label: m.name,
|
|
233
|
+
content: (
|
|
234
|
+
<span className="flex min-w-0 flex-1 items-baseline justify-between gap-2">
|
|
235
|
+
<span className="text-body text-foreground">{m.name}</span>
|
|
236
|
+
<span className="truncate text-caption text-muted-foreground">{m.note}</span>
|
|
237
|
+
</span>
|
|
238
|
+
),
|
|
239
|
+
}))}
|
|
240
|
+
/>
|
|
241
|
+
</List.Section>
|
|
242
|
+
<div className="px-[var(--space-2)]">
|
|
243
|
+
<Slider
|
|
244
|
+
size="default"
|
|
245
|
+
label="Effort"
|
|
246
|
+
min={0}
|
|
247
|
+
max={efforts.length - 1}
|
|
248
|
+
step={1}
|
|
249
|
+
value={Math.max(efforts.indexOf(effort), 0)}
|
|
250
|
+
onValueChange={v => setEffort(efforts[typeof v === 'number' ? v : v[0]] ?? effort)}
|
|
251
|
+
formatValue={v => efforts[v] ?? ''}
|
|
252
|
+
/>
|
|
253
|
+
</div>
|
|
254
|
+
<List.Section title="Behaviour">
|
|
255
|
+
<List.Row label="Permissions">
|
|
256
|
+
<Select value={mode} onValueChange={setMode}>
|
|
257
|
+
<Select.Trigger variant="borderless" icon={ModeIcon} className="min-w-0" title={activeMode?.note} />
|
|
258
|
+
<Select.Content>
|
|
259
|
+
{permissionModes.map((m, i) => (
|
|
260
|
+
<Select.Item key={m.label} index={i} value={m.label}>
|
|
261
|
+
{m.label}
|
|
262
|
+
</Select.Item>
|
|
263
|
+
))}
|
|
264
|
+
</Select.Content>
|
|
265
|
+
</Select>
|
|
266
|
+
</List.Row>
|
|
267
|
+
<List.Row label="Fast mode">
|
|
268
|
+
<Switch label="Fast mode" checked={fast} onCheckedChange={setFast} className={LIST_SWITCH} />
|
|
269
|
+
</List.Row>
|
|
270
|
+
<List.Row label="Output style">
|
|
271
|
+
<Select value={style} onValueChange={setStyle}>
|
|
272
|
+
<Select.Trigger variant="borderless" className="min-w-0" />
|
|
273
|
+
<Select.Content>
|
|
274
|
+
{outputStyles.map((o, i) => (
|
|
275
|
+
<Select.Item key={o} index={i} value={o}>
|
|
276
|
+
{o}
|
|
277
|
+
</Select.Item>
|
|
278
|
+
))}
|
|
279
|
+
</Select.Content>
|
|
280
|
+
</Select>
|
|
281
|
+
</List.Row>
|
|
282
|
+
</List.Section>
|
|
283
|
+
<List.Section title="Context" aside={compacting ? 'Compacting…' : `${percent}% of the window`}>
|
|
284
|
+
<List.Row label="Compacts at 95%">
|
|
285
|
+
<Meter
|
|
286
|
+
variant="line"
|
|
287
|
+
className="w-20"
|
|
288
|
+
label="Context used"
|
|
289
|
+
value={compacting ? 0.3 : context}
|
|
290
|
+
warnAt={0.8}
|
|
291
|
+
errorAt={0.95}
|
|
292
|
+
/>
|
|
293
|
+
<Button variant="ghost" size="compact" disabled={compacting || context < 0.2}>
|
|
294
|
+
Compact
|
|
295
|
+
</Button>
|
|
296
|
+
</List.Row>
|
|
297
|
+
</List.Section>
|
|
298
|
+
</SizeProvider>
|
|
299
|
+
</Popover.Content>
|
|
300
|
+
</Popover>
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The draft paints a fixed surface 2; inside a lifted shell that reads as a
|
|
306
|
+
* hole. This lifts it one level above whatever holds it instead.
|
|
307
|
+
*/
|
|
308
|
+
function LiftedDraft(props: ComposerDraftProps) {
|
|
309
|
+
const level = Math.min(useSurface() + 1, 8)
|
|
310
|
+
return (
|
|
311
|
+
<SurfaceProvider value={level}>
|
|
312
|
+
<ComposerDraft {...props} className={cn(SURFACE_BG[level], props.className)} />
|
|
313
|
+
</SurfaceProvider>
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
interface ComposerProps {
|
|
318
|
+
/** The models the active profile offers, each with a note. */
|
|
319
|
+
models: Model[]
|
|
320
|
+
/** The effort steps, lowest first. */
|
|
321
|
+
efforts: string[]
|
|
322
|
+
/** The permission modes, each with its icon and note. */
|
|
323
|
+
permissionModes: PermissionMode[]
|
|
324
|
+
/** The output styles. */
|
|
325
|
+
outputStyles: string[]
|
|
326
|
+
/** The commands, skills and plugins the + palette runs. */
|
|
327
|
+
commands: Command[]
|
|
328
|
+
/** Files the + palette can mention. */
|
|
329
|
+
files: string[]
|
|
330
|
+
/** The project folders a session can run in. */
|
|
331
|
+
projects: Project[]
|
|
332
|
+
/** Branches a new worktree can start from. */
|
|
333
|
+
branches: string[]
|
|
334
|
+
/** The session's own branch, shown in the project menu. Omit before the session has one. */
|
|
335
|
+
branch?: string
|
|
336
|
+
/** The profiles a session can run under. */
|
|
337
|
+
profiles: Profile[]
|
|
338
|
+
/** Initial model, by name. Defaults to the first model. */
|
|
339
|
+
defaultModel?: string
|
|
340
|
+
/** Initial permission mode, by label. Defaults to the first mode. */
|
|
341
|
+
defaultPermissionMode?: string
|
|
342
|
+
/** Initial effort. Defaults to the middle step. */
|
|
343
|
+
defaultEffort?: string
|
|
344
|
+
/** Start with fast mode on. Defaults to `false`. */
|
|
345
|
+
defaultFast?: boolean
|
|
346
|
+
/** Used share of the context window, 0–1. Defaults to `0.62`. */
|
|
347
|
+
context?: number
|
|
348
|
+
/** The conversation is being compacted: the context meter says so. Defaults to `false`. */
|
|
349
|
+
compacting?: boolean
|
|
350
|
+
/** Whether a reply is streaming. While it is, Enter queues the draft and the empty draft's button stops the reply; on the streaming→idle edge the head of the queue sends. Pair with `onStatusChange` / `onStop`, or set `defaultStatus`. */
|
|
351
|
+
status?: DraftStatus
|
|
352
|
+
/** The initial status when uncontrolled; Stop then flips it to `"idle"` itself. Defaults to `"idle"`. */
|
|
353
|
+
defaultStatus?: DraftStatus
|
|
354
|
+
/** Called with the status when the uncontrolled composer changes it (Stop). */
|
|
355
|
+
onStatusChange?: (status: DraftStatus) => void
|
|
356
|
+
/** Called when Stop is pressed. Halt the reply and set `status` to `"idle"`. */
|
|
357
|
+
onStop?: () => void
|
|
358
|
+
/** The draft's text, controlled. Pair with `onValueChange`. */
|
|
359
|
+
value?: string
|
|
360
|
+
/** The draft's initial text when uncontrolled. Defaults to `""`. */
|
|
361
|
+
defaultValue?: string
|
|
362
|
+
/** Called with the draft's text on every change. */
|
|
363
|
+
onValueChange?: (value: string) => void
|
|
364
|
+
/** The messages queued while a reply streams, controlled: `{ id, text, files }` each. Pair with `onQueueChange`. */
|
|
365
|
+
queue?: QueuedMessage[]
|
|
366
|
+
/** The initial queue when uncontrolled. Defaults to `[]`. */
|
|
367
|
+
defaultQueue?: QueuedMessage[]
|
|
368
|
+
/** Called when a message is queued, edited back, removed, reordered or sent from the queue. */
|
|
369
|
+
onQueueChange?: (queue: QueuedMessage[]) => void
|
|
370
|
+
/** Messages sent before, oldest first: ↑ on the draft's first line recalls them, ↓ on its last walks back to the draft. Defaults to `[]`. */
|
|
371
|
+
history?: string[]
|
|
372
|
+
/** Prompts listed under the draft while it is empty: ↓ / ↑ walk them without leaving the text, Enter or a click fills one in. */
|
|
373
|
+
suggestions?: string[]
|
|
374
|
+
/** A prompt shown as the placeholder with a Tab keycap: Tab fills it in. Wins over `placeholder`. */
|
|
375
|
+
placeholderSuggestion?: string
|
|
376
|
+
/** The file types the palette's Attach and a drop take, as an `accept` string. Defaults to `"image/png,image/jpeg,application/pdf"`. */
|
|
377
|
+
accept?: string
|
|
378
|
+
/** The most files a message takes; extra ones are dropped. */
|
|
379
|
+
maxFiles?: number
|
|
380
|
+
/** A new session: the project and profile can still be picked. Otherwise they show where this session runs. Defaults to `false`. */
|
|
381
|
+
target?: boolean
|
|
382
|
+
/** The profile the session runs under, by id. Defaults to the first profile. */
|
|
383
|
+
defaultProfile?: string
|
|
384
|
+
/** Called with the profile picked. */
|
|
385
|
+
onProfileChange?: (profile: string) => void
|
|
386
|
+
/** The draft's placeholder. Defaults to `'Ask, or type / for commands'`. */
|
|
387
|
+
placeholder?: string
|
|
388
|
+
/** Called with the trimmed text and the attached files when a message is sent, or sent from the queue. */
|
|
389
|
+
onSend?: (text: string, files: File[]) => void
|
|
390
|
+
/** Classes for the root. */
|
|
391
|
+
className?: string
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Where you write to the session, with every per-session control behind
|
|
396
|
+
* four triggers, held in a ShellCard.
|
|
397
|
+
*
|
|
398
|
+
* The draft grows with its text, then scrolls; Enter sends and Shift+Enter
|
|
399
|
+
* breaks the line. Files dropped anywhere on it, or attached from the +
|
|
400
|
+
* palette, preview as tiles above the text (images as themselves, PDFs by
|
|
401
|
+
* their first page with the optional `pdfjs-dist`, the rest as an icon).
|
|
402
|
+
* While a reply streams (`status`) the button queues what you type: queued
|
|
403
|
+
* messages stack above the draft, reorder by drag or Alt+↑/↓, come back into
|
|
404
|
+
* the draft on a double-click, and the first one sends when the reply ends;
|
|
405
|
+
* with the draft empty the button stops the reply. ↑ on the first line
|
|
406
|
+
* recalls sent messages (`history`); `suggestions` list prompts under an
|
|
407
|
+
* empty draft and `placeholderSuggestion` offers one behind a Tab keycap.
|
|
408
|
+
* The + opens one searchable palette: attach, mention a file, run a
|
|
409
|
+
* command, skill or plugin.
|
|
410
|
+
*
|
|
411
|
+
* The row under it, on the shell, holds the rest. On the left, where the
|
|
412
|
+
* session runs: the project, whose popover also holds the worktree, the
|
|
413
|
+
* setup script and the base branch, and the profile, with two thin lines for
|
|
414
|
+
* its session and weekly limits (see the profile switcher). On the right,
|
|
415
|
+
* how it runs: one trigger showing the permission mode, the model, the
|
|
416
|
+
* effort and a small context ring opens the model (with a note on each), a
|
|
417
|
+
* tall effort slider, the permission mode, fast mode, the output style and
|
|
418
|
+
* the context with a compact button. All three popovers share one layout: a
|
|
419
|
+
* caption per section, then rows with the label on the left and the control
|
|
420
|
+
* on the right.
|
|
421
|
+
*
|
|
422
|
+
* Every draft prop has its uncontrolled twin (`defaultValue`,
|
|
423
|
+
* `defaultQueue`, `defaultStatus`), so a composer runs with no state in the
|
|
424
|
+
* caller.
|
|
425
|
+
*
|
|
426
|
+
* Statics:
|
|
427
|
+
* - `Composer.Draft` — the draft alone, without the shell and its menus:
|
|
428
|
+
* the props above plus `leftSlot` / `rightSlot` (content, or a render
|
|
429
|
+
* function given `{ openFilePicker, files }`), `files` / `defaultFiles` /
|
|
430
|
+
* `onFilesChange` (attachments are on once either is set), `minRows` /
|
|
431
|
+
* `maxRows`, `size`, `disabled`, `showQueue` and `textareaProps`.
|
|
432
|
+
*
|
|
433
|
+
* Also exported: `FileThumbnail`, the square preview of an attachment, for
|
|
434
|
+
* the files a sent message carried.
|
|
435
|
+
*
|
|
436
|
+
* @example {@include ./examples.mdx}
|
|
437
|
+
* @source https://github.com/mickadesign/fluid-functionalism/blob/b3587bdbd83fc66c2a6aae3817ffb856cb09260b/registry/default/input-message.tsx Fluid Functionalism
|
|
438
|
+
* @license MIT © 2026 Micka Touillaud
|
|
439
|
+
*/
|
|
440
|
+
const Composer = Object.assign(
|
|
441
|
+
function Composer({
|
|
442
|
+
models,
|
|
443
|
+
efforts,
|
|
444
|
+
permissionModes,
|
|
445
|
+
outputStyles,
|
|
446
|
+
commands,
|
|
447
|
+
files,
|
|
448
|
+
projects,
|
|
449
|
+
branches,
|
|
450
|
+
branch,
|
|
451
|
+
profiles,
|
|
452
|
+
defaultModel,
|
|
453
|
+
defaultPermissionMode,
|
|
454
|
+
defaultEffort,
|
|
455
|
+
defaultFast = false,
|
|
456
|
+
context = 0.62,
|
|
457
|
+
compacting = false,
|
|
458
|
+
defaultStatus = 'idle',
|
|
459
|
+
target = false,
|
|
460
|
+
defaultProfile,
|
|
461
|
+
onProfileChange,
|
|
462
|
+
placeholder = 'Ask, or type / for commands',
|
|
463
|
+
className,
|
|
464
|
+
...draft
|
|
465
|
+
}: ComposerProps) {
|
|
466
|
+
return (
|
|
467
|
+
<ShellCard
|
|
468
|
+
variant="elevated"
|
|
469
|
+
className={cn('w-full', className)}
|
|
470
|
+
footer={
|
|
471
|
+
<SizeProvider size="compact">
|
|
472
|
+
<ShellCard.Footer className="justify-start gap-[var(--space-1)] pt-[var(--space-1)]">
|
|
473
|
+
<ProjectPicker projects={projects} branches={branches} branch={branch} locked={!target} />
|
|
474
|
+
<ProfileSwitcher
|
|
475
|
+
profiles={profiles}
|
|
476
|
+
defaultValue={defaultProfile}
|
|
477
|
+
onValueChange={onProfileChange}
|
|
478
|
+
side="top"
|
|
479
|
+
/>
|
|
480
|
+
<div className="ml-auto min-w-0">
|
|
481
|
+
<RunSettings
|
|
482
|
+
models={models}
|
|
483
|
+
efforts={efforts}
|
|
484
|
+
permissionModes={permissionModes}
|
|
485
|
+
outputStyles={outputStyles}
|
|
486
|
+
context={context}
|
|
487
|
+
compacting={compacting}
|
|
488
|
+
defaultModel={defaultModel ?? models[0]?.name ?? ''}
|
|
489
|
+
defaultEffort={defaultEffort ?? efforts[Math.floor(efforts.length / 2)] ?? ''}
|
|
490
|
+
defaultMode={defaultPermissionMode ?? permissionModes[0]?.label ?? ''}
|
|
491
|
+
defaultFast={defaultFast}
|
|
492
|
+
/>
|
|
493
|
+
</div>
|
|
494
|
+
</ShellCard.Footer>
|
|
495
|
+
</SizeProvider>
|
|
496
|
+
}
|
|
497
|
+
>
|
|
498
|
+
<LiftedDraft
|
|
499
|
+
{...draft}
|
|
500
|
+
placeholder={placeholder}
|
|
501
|
+
defaultStatus={defaultStatus}
|
|
502
|
+
defaultFiles={[]}
|
|
503
|
+
leftSlot={({ openFilePicker }) => (
|
|
504
|
+
<AddPalette files={files} commands={commands} onAttach={() => openFilePicker()} />
|
|
505
|
+
)}
|
|
506
|
+
/>
|
|
507
|
+
</ShellCard>
|
|
508
|
+
)
|
|
509
|
+
},
|
|
510
|
+
{ Draft: ComposerDraft },
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
export { FileThumbnail } from './file-thumbnail'
|
|
514
|
+
export type { ComposerDraftProps, ComposerProps, DraftSlotContext, DraftStatus, QueuedMessage }
|
|
515
|
+
export { Composer, ComposerDraft }
|
|
516
|
+
|
|
517
|
+
export default Composer
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
3
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
4
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import { Tooltip } from '@justanarthur/modo-ui/components/overlays/tooltip'
|
|
10
|
+
import { useIcon } from '@justanarthur/modo-ui/lib/icon-context'
|
|
11
|
+
import { useSize } from '@justanarthur/modo-ui/lib/size-context'
|
|
12
|
+
import { spring } from '@justanarthur/modo-ui/lib/springs'
|
|
13
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
14
|
+
import { Reorder } from 'motion/react'
|
|
15
|
+
import type { QueuedMessage } from './shared'
|
|
16
|
+
|
|
17
|
+
interface QueuedRowProps {
|
|
18
|
+
item: QueuedMessage
|
|
19
|
+
index: number
|
|
20
|
+
total: number
|
|
21
|
+
reduceMotion: boolean
|
|
22
|
+
isTouch: boolean
|
|
23
|
+
onEdit: (item: QueuedMessage) => void
|
|
24
|
+
onRemove: (item: QueuedMessage) => void
|
|
25
|
+
onMove: (item: QueuedMessage, dir: -1 | 1) => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** A pending message: a recessed, draggable row. The top row dispatches next. */
|
|
29
|
+
function QueuedRow({ item, index, total, reduceMotion, isTouch, onEdit, onRemove, onMove }: QueuedRowProps) {
|
|
30
|
+
const XIcon = useIcon('x')
|
|
31
|
+
const ImageIcon = useIcon('image')
|
|
32
|
+
const compactStep = useSize().variant === 'compact'
|
|
33
|
+
const fileCount = item.files.length
|
|
34
|
+
const label = item.text || `${fileCount} attachment${fileCount === 1 ? '' : 's'}`
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Reorder.Item
|
|
38
|
+
value={item}
|
|
39
|
+
layout
|
|
40
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97 }}
|
|
41
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
42
|
+
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.97, transition: spring.fast.exit }}
|
|
43
|
+
transition={spring.fast}
|
|
44
|
+
aria-label={`Queued message ${index + 1} of ${total}: ${label}`}
|
|
45
|
+
tabIndex={0}
|
|
46
|
+
onDoubleClick={() => onEdit(item)}
|
|
47
|
+
onKeyDown={e => {
|
|
48
|
+
if (e.key === 'Enter' || e.key === 'F2') {
|
|
49
|
+
e.preventDefault()
|
|
50
|
+
onEdit(item)
|
|
51
|
+
} else if (e.key === 'Delete' || e.key === 'Backspace') {
|
|
52
|
+
e.preventDefault()
|
|
53
|
+
onRemove(item)
|
|
54
|
+
} else if (e.altKey && (e.key === 'ArrowUp' || e.key === 'ArrowDown')) {
|
|
55
|
+
e.preventDefault()
|
|
56
|
+
onMove(item, e.key === 'ArrowUp' ? -1 : 1)
|
|
57
|
+
}
|
|
58
|
+
}}
|
|
59
|
+
className={cn(
|
|
60
|
+
'group/qrow flex items-center gap-2 rounded-lg bg-muted',
|
|
61
|
+
compactStep ? 'h-7 px-2 text-body-compact' : 'h-8 px-2.5 text-body',
|
|
62
|
+
'text-foreground/85 select-none outline-none',
|
|
63
|
+
'cursor-grab active:cursor-grabbing',
|
|
64
|
+
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
65
|
+
'weight-normal',
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
{fileCount > 0 && (
|
|
69
|
+
<span className="flex shrink-0 items-center gap-0.5 text-muted-foreground">
|
|
70
|
+
<ImageIcon size={13} />
|
|
71
|
+
{item.text && <span className="tabular-nums">{fileCount}</span>}
|
|
72
|
+
</span>
|
|
73
|
+
)}
|
|
74
|
+
{/* py-1/-my-1: truncate's overflow-hidden would clip glyphs outside the trimmed box. */}
|
|
75
|
+
<span className="min-w-0 flex-1 truncate text-trim py-1 -my-1">{label}</span>
|
|
76
|
+
<Tooltip content="Remove" side="top">
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
// Keeps the press from starting a drag and the click from reaching the row's edit.
|
|
80
|
+
onPointerDown={e => e.stopPropagation()}
|
|
81
|
+
onClick={e => {
|
|
82
|
+
e.stopPropagation()
|
|
83
|
+
onRemove(item)
|
|
84
|
+
}}
|
|
85
|
+
aria-label={`Remove queued message: ${label}`}
|
|
86
|
+
className={cn(
|
|
87
|
+
'shrink-0 flex h-5 w-5 items-center justify-center rounded-full',
|
|
88
|
+
'text-muted-foreground hover:text-foreground hover:bg-hover',
|
|
89
|
+
// Touch has no hover to reveal it.
|
|
90
|
+
isTouch ? 'opacity-100' : 'opacity-0 group-hover/qrow:opacity-100 focus-visible:opacity-100',
|
|
91
|
+
'transition-opacity duration-fast cursor-pointer outline-none',
|
|
92
|
+
'focus-visible:ring-1 focus-visible:ring-focus-ring',
|
|
93
|
+
)}
|
|
94
|
+
>
|
|
95
|
+
<XIcon size={13} strokeWidth={2.5} />
|
|
96
|
+
</button>
|
|
97
|
+
</Tooltip>
|
|
98
|
+
</Reorder.Item>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export { QueuedRow }
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
3
|
+
* `registry/default/input-message.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
4
|
+
* MIT License © 2026 Micka Touillaud (notice: LICENSE.fluid-functionalism). Local changes: see ui/PORTING.md.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { ReactNode, RefObject } from 'react'
|
|
8
|
+
|
|
9
|
+
type DraftStatus = 'idle' | 'streaming'
|
|
10
|
+
|
|
11
|
+
interface DraftSlotContext {
|
|
12
|
+
/** Opens the native file picker. Pass `acceptOverride` (e.g. `"image/*"`) to narrow the accepted types for this one invocation. */
|
|
13
|
+
openFilePicker: (acceptOverride?: string) => void
|
|
14
|
+
/** Currently-attached files. */
|
|
15
|
+
files: File[]
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type DraftSlot = ReactNode | ((ctx: DraftSlotContext) => ReactNode)
|
|
19
|
+
|
|
20
|
+
/** A message held in the queue while the assistant is responding: the trimmed text and the files attached when it was queued, so editing restores both. `id` is minted on enqueue. */
|
|
21
|
+
interface QueuedMessage {
|
|
22
|
+
id: string
|
|
23
|
+
text: string
|
|
24
|
+
files: File[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Moves the caret to the end of the textarea on the next frame, optionally focusing it. */
|
|
28
|
+
function caretToEnd(ref: RefObject<HTMLTextAreaElement | null>, focus = true) {
|
|
29
|
+
requestAnimationFrame(() => {
|
|
30
|
+
const el = ref.current
|
|
31
|
+
if (!el) return
|
|
32
|
+
if (focus) el.focus()
|
|
33
|
+
el.setSelectionRange(el.value.length, el.value.length)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export type { DraftSlot, DraftSlotContext, DraftStatus, QueuedMessage }
|
|
38
|
+
export { caretToEnd }
|