@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,232 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's ⌘K palette on the Command overlay — switch
|
|
3
|
+
* to a session, start one in a project under a profile, run a command or
|
|
4
|
+
* skill, open a pane, a settings section or another profile.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
10
|
+
import Kbd from '@justanarthur/modo-ui/components/data-display/kbd'
|
|
11
|
+
import Command, { type CommandGroup } from '@justanarthur/modo-ui/components/overlays/command'
|
|
12
|
+
import type { ReactElement } from 'react'
|
|
13
|
+
import { useIcons } from '../../../lib/icons'
|
|
14
|
+
import { STATUS_GLYPH } from '../../../lib/status-glyph'
|
|
15
|
+
import type { Command as AgentCommand, PaletteItem, Profile, Project, Session } from '../../../lib/types'
|
|
16
|
+
import { PANES } from '../../panes/side-pane'
|
|
17
|
+
import type { SettingsWindowSection } from '../../settings/settings-window'
|
|
18
|
+
|
|
19
|
+
interface CommandPaletteProps {
|
|
20
|
+
/** The sessions to switch to, most recent first. */
|
|
21
|
+
sessions: Session[]
|
|
22
|
+
/** The folders a new session can start in. */
|
|
23
|
+
projects: Project[]
|
|
24
|
+
/** The profiles a new session can run under, and to switch to. */
|
|
25
|
+
profiles: Profile[]
|
|
26
|
+
/** Slash commands, skills and plugins. */
|
|
27
|
+
commands: AgentCommand[]
|
|
28
|
+
/** Settings sections to open; without them, one row opens the settings. */
|
|
29
|
+
settings?: SettingsWindowSection[]
|
|
30
|
+
/** The active profile's id: new sessions start under it. Defaults to the first profile. */
|
|
31
|
+
profile?: string
|
|
32
|
+
/** The current project's path: "New session as …" starts there. Defaults to the first project. */
|
|
33
|
+
project?: string
|
|
34
|
+
/** Called with the picked row; the palette closes. */
|
|
35
|
+
onSelect?: (item: PaletteItem) => void
|
|
36
|
+
/** Controlled open state. */
|
|
37
|
+
open?: boolean
|
|
38
|
+
/** Initial open state, for an uncontrolled palette. Defaults to `false`. */
|
|
39
|
+
defaultOpen?: boolean
|
|
40
|
+
/** Called when the palette opens or closes. */
|
|
41
|
+
onOpenChange?: (open: boolean) => void
|
|
42
|
+
/** The key that toggles it with ⌘ (Ctrl elsewhere); `false` leaves the keyboard alone. Defaults to `'k'`. */
|
|
43
|
+
hotkey?: string | false
|
|
44
|
+
/** Replaces the Search button. `null` draws no trigger: the hotkey and `open` still work. */
|
|
45
|
+
trigger?: ReactElement | null
|
|
46
|
+
/** The trigger's label. Defaults to `'Search'`. */
|
|
47
|
+
label?: string
|
|
48
|
+
/** Classes for the trigger. */
|
|
49
|
+
className?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The AI app's ⌘K palette: one search over sessions, new sessions,
|
|
54
|
+
* commands, panes, settings and profiles.
|
|
55
|
+
*
|
|
56
|
+
* Type to filter every group at once: a session by its title, branch or
|
|
57
|
+
* project; a new session by its project or profile; a command or skill by
|
|
58
|
+
* its name or description. Sessions show their live state (running, waiting
|
|
59
|
+
* on you). New sessions start in each project under the active profile, or
|
|
60
|
+
* under each other profile in the current project. Picking a row hands it to
|
|
61
|
+
* `onSelect` and closes the panel. The panel is Command's: it grows out of
|
|
62
|
+
* the trigger, and ⌘K (Ctrl+K elsewhere) toggles it from anywhere.
|
|
63
|
+
*
|
|
64
|
+
* @example {@include ./examples.mdx}
|
|
65
|
+
*/
|
|
66
|
+
export default function CommandPalette({
|
|
67
|
+
sessions,
|
|
68
|
+
projects,
|
|
69
|
+
profiles,
|
|
70
|
+
commands,
|
|
71
|
+
settings,
|
|
72
|
+
profile,
|
|
73
|
+
project,
|
|
74
|
+
onSelect,
|
|
75
|
+
open,
|
|
76
|
+
defaultOpen,
|
|
77
|
+
onOpenChange,
|
|
78
|
+
hotkey = 'k',
|
|
79
|
+
trigger,
|
|
80
|
+
label = 'Search',
|
|
81
|
+
className,
|
|
82
|
+
}: CommandPaletteProps) {
|
|
83
|
+
const icons = useIcons()
|
|
84
|
+
const active = profiles.find(p => p.id === profile) ?? profiles[0]
|
|
85
|
+
const here = projects.find(p => p.path === project) ?? projects[0]
|
|
86
|
+
const pick = (item: PaletteItem) => () => onSelect?.(item)
|
|
87
|
+
const kind = (k: AgentCommand['kind']) => (k === 'command' ? icons.command : k === 'skill' ? icons.zap : icons.puzzle)
|
|
88
|
+
|
|
89
|
+
const groups: CommandGroup[] = [
|
|
90
|
+
{
|
|
91
|
+
label: 'Sessions',
|
|
92
|
+
items: sessions.map(s => ({
|
|
93
|
+
label: s.title,
|
|
94
|
+
icon: STATUS_GLYPH[s.status] ?? icons['message-circle'],
|
|
95
|
+
shortcut: s.updated,
|
|
96
|
+
keywords: [s.branch ?? '', s.project ?? '', s.profile],
|
|
97
|
+
onSelect: pick({ kind: 'session', id: s.id }),
|
|
98
|
+
})),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: 'New',
|
|
102
|
+
items: [
|
|
103
|
+
...(active
|
|
104
|
+
? projects.map(p => ({
|
|
105
|
+
label: `New session in ${p.label}`,
|
|
106
|
+
icon: icons.plus,
|
|
107
|
+
shortcut: active.name,
|
|
108
|
+
keywords: [p.path, active.name],
|
|
109
|
+
onSelect: pick({ kind: 'new-session', project: p.path, profile: active.id }),
|
|
110
|
+
}))
|
|
111
|
+
: []),
|
|
112
|
+
...(here
|
|
113
|
+
? profiles
|
|
114
|
+
.filter(p => p !== active)
|
|
115
|
+
.map(p => ({
|
|
116
|
+
label: `New ${p.name} session`,
|
|
117
|
+
icon: icons.plus,
|
|
118
|
+
shortcut: here.label,
|
|
119
|
+
keywords: [p.plan, p.account, here.path],
|
|
120
|
+
onSelect: pick({ kind: 'new-session', project: here.path, profile: p.id }),
|
|
121
|
+
}))
|
|
122
|
+
: []),
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: 'Commands',
|
|
127
|
+
items: commands
|
|
128
|
+
.filter(c => c.kind === 'command')
|
|
129
|
+
.map(c => ({
|
|
130
|
+
label: c.name,
|
|
131
|
+
icon: kind(c.kind),
|
|
132
|
+
keywords: [c.description],
|
|
133
|
+
onSelect: pick({ kind: 'command', name: c.name }),
|
|
134
|
+
})),
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
label: 'Skills',
|
|
138
|
+
items: commands
|
|
139
|
+
.filter(c => c.kind !== 'command')
|
|
140
|
+
.map(c => ({
|
|
141
|
+
label: c.name,
|
|
142
|
+
icon: kind(c.kind),
|
|
143
|
+
keywords: [c.description, c.kind],
|
|
144
|
+
onSelect: pick({ kind: 'command', name: c.name }),
|
|
145
|
+
})),
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
label: 'Find',
|
|
149
|
+
items: [
|
|
150
|
+
{
|
|
151
|
+
label: 'Search transcripts',
|
|
152
|
+
icon: icons.search,
|
|
153
|
+
keywords: ['find', 'history', 'messages'],
|
|
154
|
+
onSelect: pick({ kind: 'search' }),
|
|
155
|
+
},
|
|
156
|
+
{ label: 'Keyboard shortcuts', icon: icons.command, shortcut: '⌘/', onSelect: pick({ kind: 'shortcuts' }) },
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: 'Panes',
|
|
161
|
+
items: PANES.map(p => ({
|
|
162
|
+
label: `Open ${p.label.toLowerCase()}`,
|
|
163
|
+
icon: icons[p.icon],
|
|
164
|
+
keywords: ['pane', 'side'],
|
|
165
|
+
onSelect: pick({ kind: 'pane', pane: p.id }),
|
|
166
|
+
})),
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
label: 'Settings',
|
|
170
|
+
items: [
|
|
171
|
+
{ label: 'Open settings', icon: icons.settings, shortcut: '⌘,', onSelect: pick({ kind: 'settings' }) },
|
|
172
|
+
...(settings ?? []).map(s => ({
|
|
173
|
+
label: `Settings: ${s.label}`,
|
|
174
|
+
icon: icons[s.icon],
|
|
175
|
+
keywords: [s.keywords],
|
|
176
|
+
onSelect: pick({ kind: 'settings', section: s.id }),
|
|
177
|
+
})),
|
|
178
|
+
],
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
label: 'Profiles',
|
|
182
|
+
items: [
|
|
183
|
+
...profiles.map(p => ({
|
|
184
|
+
label: `Switch to ${p.name}`,
|
|
185
|
+
icon: icons.user,
|
|
186
|
+
shortcut: p.plan,
|
|
187
|
+
keywords: [p.account, p.configDir],
|
|
188
|
+
disabled: p === active,
|
|
189
|
+
onSelect: pick({ kind: 'profile', id: p.id }),
|
|
190
|
+
})),
|
|
191
|
+
{ label: 'Manage profiles', icon: icons.users, onSelect: pick({ kind: 'profiles' }) },
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Command open={open} defaultOpen={defaultOpen} onOpenChange={onOpenChange} hotkey={hotkey}>
|
|
198
|
+
{trigger !== null && (
|
|
199
|
+
<Command.Trigger
|
|
200
|
+
render={
|
|
201
|
+
trigger ?? (
|
|
202
|
+
<Button
|
|
203
|
+
variant="secondary"
|
|
204
|
+
size="compact"
|
|
205
|
+
leadingIcon={icons.search}
|
|
206
|
+
aria-label={label}
|
|
207
|
+
className={className}
|
|
208
|
+
>
|
|
209
|
+
{/* A narrow window keeps the icon: the label and hotkey need the room the title wants. */}
|
|
210
|
+
<span className="hidden @lg:inline">{label}</span>
|
|
211
|
+
{hotkey && (
|
|
212
|
+
<Kbd variant="plain" className="ml-3 hidden @lg:inline-flex">
|
|
213
|
+
{`⌘${hotkey.toUpperCase()}`}
|
|
214
|
+
</Kbd>
|
|
215
|
+
)}
|
|
216
|
+
</Button>
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
<Command.Content
|
|
222
|
+
label="Command palette"
|
|
223
|
+
placeholder="Search sessions, commands and settings…"
|
|
224
|
+
items={groups.filter(g => g.items.length > 0)}
|
|
225
|
+
/>
|
|
226
|
+
</Command>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type { CommandPaletteProps }
|
|
231
|
+
|
|
232
|
+
export { CommandPalette }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import HookDialog from './index'
|
|
2
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
3
|
+
import { HOOK_GUARD, HOOK_LINT } from '../../../mock/mock-config'
|
|
4
|
+
|
|
5
|
+
# Add a hook
|
|
6
|
+
|
|
7
|
+
Press the button: the dialog grows out of it. The snippet under the form follows every keystroke.
|
|
8
|
+
|
|
9
|
+
<HookDialog trigger={<Button variant="secondary">Add hook</Button>} configDir="~/.claude-jobiflow" />
|
|
10
|
+
|
|
11
|
+
# After an edit
|
|
12
|
+
|
|
13
|
+
A PostToolUse hook on Edit and Write, checked into the repo.
|
|
14
|
+
|
|
15
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
16
|
+
<HookDialog.Panel editing defaultHook={HOOK_LINT} />
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
# A guard
|
|
20
|
+
|
|
21
|
+
A PreToolUse hook on Bash that exits 2 to block a dangerous command.
|
|
22
|
+
|
|
23
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
24
|
+
<HookDialog.Panel editing defaultHook={HOOK_GUARD} configDir="~/.claude-jobiflow" />
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
# An event without a matcher
|
|
28
|
+
|
|
29
|
+
Stop runs every time a turn ends, so the matcher stands disabled and the snippet leaves it out.
|
|
30
|
+
|
|
31
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
32
|
+
<HookDialog.Panel defaultHook={{ event: 'Stop', command: 'osascript -e \'display notification "Turn done"\'', scope: 'local' }} />
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
# Light and dark
|
|
36
|
+
|
|
37
|
+
<div className="grid w-full gap-3 @3xl:grid-cols-2">
|
|
38
|
+
<div className="light @container rounded-xl border border-border bg-background p-6 text-foreground">
|
|
39
|
+
<HookDialog.Panel defaultHook={HOOK_LINT} />
|
|
40
|
+
</div>
|
|
41
|
+
<div className="dark @container rounded-xl border border-border bg-background p-6 text-foreground">
|
|
42
|
+
<HookDialog.Panel defaultHook={HOOK_GUARD} />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's "Add hook" form. A Dialog over the event, the
|
|
3
|
+
* matcher, the command, the timeout and the scope, with the settings.json
|
|
4
|
+
* snippet it writes shown as you type.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use client'
|
|
8
|
+
|
|
9
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
10
|
+
import Input from '@justanarthur/modo-ui/components/inputs/input'
|
|
11
|
+
import Select from '@justanarthur/modo-ui/components/inputs/select'
|
|
12
|
+
import Textarea from '@justanarthur/modo-ui/components/inputs/textarea'
|
|
13
|
+
import Dialog from '@justanarthur/modo-ui/components/overlays/dialog'
|
|
14
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
15
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
16
|
+
import Code from '@justanarthur/modo-ui/primitives/content/code'
|
|
17
|
+
import { type ReactElement, useState } from 'react'
|
|
18
|
+
import {
|
|
19
|
+
type ConfigScope,
|
|
20
|
+
Field,
|
|
21
|
+
Fieldset,
|
|
22
|
+
SCOPE_NOTE,
|
|
23
|
+
SCOPES,
|
|
24
|
+
Segmented,
|
|
25
|
+
settingsFile,
|
|
26
|
+
} from '../../../lib/config-parts'
|
|
27
|
+
import { useIcon } from '../../../lib/icons'
|
|
28
|
+
|
|
29
|
+
export type HookEvent =
|
|
30
|
+
| 'PreToolUse'
|
|
31
|
+
| 'PostToolUse'
|
|
32
|
+
| 'UserPromptSubmit'
|
|
33
|
+
| 'Notification'
|
|
34
|
+
| 'Stop'
|
|
35
|
+
| 'SubagentStop'
|
|
36
|
+
| 'PreCompact'
|
|
37
|
+
| 'SessionStart'
|
|
38
|
+
| 'SessionEnd'
|
|
39
|
+
|
|
40
|
+
/** A hook as the form writes it. */
|
|
41
|
+
export interface HookConfig {
|
|
42
|
+
event: HookEvent
|
|
43
|
+
/** What it fires on: a tool pattern for the tool events, a source for SessionStart and PreCompact, empty for every one. */
|
|
44
|
+
matcher: string
|
|
45
|
+
command: string
|
|
46
|
+
/** Seconds before the harness gives up on it. */
|
|
47
|
+
timeout: number
|
|
48
|
+
scope: ConfigScope
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Each event: when it fires, and what its matcher matches (none when it takes no matcher). */
|
|
52
|
+
const EVENTS: Record<HookEvent, { note: string; matcher?: { hint: string; placeholder: string } }> = {
|
|
53
|
+
PreToolUse: {
|
|
54
|
+
note: 'Before a tool runs; exit 2 blocks the call and tells Claude why.',
|
|
55
|
+
matcher: {
|
|
56
|
+
hint: 'Tool names or a regex: Bash, Edit|Write, mcp__github__.*. Empty matches every tool.',
|
|
57
|
+
placeholder: 'Bash',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
PostToolUse: {
|
|
61
|
+
note: 'After a tool succeeds, with its input and response.',
|
|
62
|
+
matcher: { hint: 'Tool names or a regex: Edit|Write. Empty matches every tool.', placeholder: 'Edit|Write' },
|
|
63
|
+
},
|
|
64
|
+
UserPromptSubmit: { note: 'When you send a prompt, before Claude sees it; its output joins the context.' },
|
|
65
|
+
Notification: { note: 'When Claude needs your permission or has been idle waiting for input.' },
|
|
66
|
+
Stop: { note: 'When the main agent finishes its turn; exit 2 makes it keep going.' },
|
|
67
|
+
SubagentStop: { note: 'When a subagent finishes.' },
|
|
68
|
+
PreCompact: {
|
|
69
|
+
note: 'Before the context is compacted.',
|
|
70
|
+
matcher: { hint: 'manual (from /compact) or auto. Empty matches both.', placeholder: 'auto' },
|
|
71
|
+
},
|
|
72
|
+
SessionStart: {
|
|
73
|
+
note: 'When a session starts or resumes; its output joins the context.',
|
|
74
|
+
matcher: { hint: 'startup, resume, clear or compact. Empty matches every start.', placeholder: 'startup' },
|
|
75
|
+
},
|
|
76
|
+
SessionEnd: { note: 'When a session ends.' },
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const EVENT_NAMES = Object.keys(EVENTS) as HookEvent[]
|
|
80
|
+
|
|
81
|
+
const EMPTY: HookConfig = { event: 'PreToolUse', matcher: '', command: '', timeout: 60, scope: 'user' }
|
|
82
|
+
|
|
83
|
+
/** The settings.json fragment the hook becomes. */
|
|
84
|
+
function snippet(hook: HookConfig) {
|
|
85
|
+
const hooks = [{ type: 'command', command: hook.command || '…', timeout: hook.timeout }]
|
|
86
|
+
const entry = EVENTS[hook.event].matcher ? { matcher: hook.matcher, hooks } : { hooks }
|
|
87
|
+
return JSON.stringify({ hooks: { [hook.event]: [entry] } }, null, 2)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface HookDialogPanelProps {
|
|
91
|
+
/** What the form starts with; editing an existing hook passes it here. Defaults to an empty PreToolUse hook. */
|
|
92
|
+
defaultHook?: Partial<HookConfig>
|
|
93
|
+
/** The config dir user-scoped hooks are written to. Defaults to `'~/.claude'`. */
|
|
94
|
+
configDir?: string
|
|
95
|
+
/** Whether the form edits an existing hook: the title and the button say so. Defaults to `false`. */
|
|
96
|
+
editing?: boolean
|
|
97
|
+
/** Called with the hook when Save is pressed. */
|
|
98
|
+
onSave?: (hook: HookConfig) => void
|
|
99
|
+
/** Called when Cancel is pressed; leave it out and no Cancel shows. */
|
|
100
|
+
onCancel?: () => void
|
|
101
|
+
/** Classes for the root. */
|
|
102
|
+
className?: string
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** The form without the Dialog: for a settings page, or the docs. */
|
|
106
|
+
function HookDialogPanel({
|
|
107
|
+
defaultHook,
|
|
108
|
+
configDir = '~/.claude',
|
|
109
|
+
editing = false,
|
|
110
|
+
onSave,
|
|
111
|
+
onCancel,
|
|
112
|
+
className,
|
|
113
|
+
}: HookDialogPanelProps) {
|
|
114
|
+
const [hook, setHook] = useState<HookConfig>({ ...EMPTY, ...defaultHook })
|
|
115
|
+
const [timeout, setTimeoutText] = useState(String(hook.timeout))
|
|
116
|
+
const Webhook = useIcon('webhook')
|
|
117
|
+
const set = (patch: Partial<HookConfig>) => setHook({ ...hook, ...patch })
|
|
118
|
+
const event = EVENTS[hook.event]
|
|
119
|
+
const timeoutError = /^[1-9]\d*$/.test(timeout) ? undefined : 'Whole seconds, at least 1.'
|
|
120
|
+
const valid = Boolean(hook.command.trim()) && !timeoutError
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div className={cn('flex flex-col gap-[var(--space-5)]', className)}>
|
|
124
|
+
<div className="flex flex-col gap-[var(--space-1)] pr-[var(--space-6)]">
|
|
125
|
+
<h2 className="m-0 text-title text-foreground">{editing ? 'Edit hook' : 'Add a hook'}</h2>
|
|
126
|
+
<p className="m-0 text-body text-muted-foreground">
|
|
127
|
+
A shell command the harness runs on a session event, with the event as JSON on stdin.
|
|
128
|
+
</p>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div className="grid grid-cols-1 gap-[var(--space-4)] @md:grid-cols-2">
|
|
132
|
+
<Field label="Event" hint={event.note}>
|
|
133
|
+
{id => (
|
|
134
|
+
<Select
|
|
135
|
+
value={hook.event}
|
|
136
|
+
onValueChange={value => {
|
|
137
|
+
const next = EVENT_NAMES.find(e => e === value) ?? hook.event
|
|
138
|
+
set({ event: next, matcher: EVENTS[next].matcher ? hook.matcher : '' })
|
|
139
|
+
}}
|
|
140
|
+
>
|
|
141
|
+
<Select.Trigger id={id} icon={Webhook} />
|
|
142
|
+
<Select.Content>
|
|
143
|
+
{EVENT_NAMES.map((name, i) => (
|
|
144
|
+
<Select.Item key={name} index={i} value={name}>
|
|
145
|
+
{name}
|
|
146
|
+
</Select.Item>
|
|
147
|
+
))}
|
|
148
|
+
</Select.Content>
|
|
149
|
+
</Select>
|
|
150
|
+
)}
|
|
151
|
+
</Field>
|
|
152
|
+
<Field label="Matcher" hint={event.matcher?.hint ?? `${hook.event} takes no matcher: it runs every time.`}>
|
|
153
|
+
{id => (
|
|
154
|
+
<Input
|
|
155
|
+
id={id}
|
|
156
|
+
variant="bordered"
|
|
157
|
+
className="font-mono"
|
|
158
|
+
value={hook.matcher}
|
|
159
|
+
placeholder={event.matcher?.placeholder}
|
|
160
|
+
disabled={!event.matcher}
|
|
161
|
+
onValueChange={matcher => set({ matcher })}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
164
|
+
</Field>
|
|
165
|
+
</div>
|
|
166
|
+
|
|
167
|
+
<Field
|
|
168
|
+
label="Command"
|
|
169
|
+
hint="Exit 0 passes; exit 2 blocks or feeds stderr back to Claude, by event; other codes warn."
|
|
170
|
+
>
|
|
171
|
+
{id => (
|
|
172
|
+
<Textarea
|
|
173
|
+
id={id}
|
|
174
|
+
variant="bordered"
|
|
175
|
+
className="font-mono"
|
|
176
|
+
minRows={2}
|
|
177
|
+
maxRows={6}
|
|
178
|
+
value={hook.command}
|
|
179
|
+
placeholder="bun run lint --fix"
|
|
180
|
+
onValueChange={command => set({ command })}
|
|
181
|
+
/>
|
|
182
|
+
)}
|
|
183
|
+
</Field>
|
|
184
|
+
|
|
185
|
+
<div className="grid grid-cols-1 gap-[var(--space-4)] @md:grid-cols-[8rem_minmax(0,1fr)]">
|
|
186
|
+
<Field label="Timeout (s)" error={timeoutError}>
|
|
187
|
+
{id => (
|
|
188
|
+
<Input
|
|
189
|
+
id={id}
|
|
190
|
+
variant="bordered"
|
|
191
|
+
inputMode="numeric"
|
|
192
|
+
className="tabular-nums"
|
|
193
|
+
value={timeout}
|
|
194
|
+
invalid={Boolean(timeoutError)}
|
|
195
|
+
onValueChange={text => {
|
|
196
|
+
setTimeoutText(text)
|
|
197
|
+
if (/^[1-9]\d*$/.test(text)) set({ timeout: Number(text) })
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
)}
|
|
201
|
+
</Field>
|
|
202
|
+
<Fieldset legend="Scope" hint={SCOPE_NOTE[hook.scope]}>
|
|
203
|
+
<Segmented label="Scope" options={SCOPES} value={hook.scope} onValueChange={scope => set({ scope })} />
|
|
204
|
+
</Fieldset>
|
|
205
|
+
</div>
|
|
206
|
+
|
|
207
|
+
<Fieldset legend={`Written to ${settingsFile(hook.scope, configDir)}`}>
|
|
208
|
+
<Code language="json">{snippet(hook)}</Code>
|
|
209
|
+
</Fieldset>
|
|
210
|
+
|
|
211
|
+
<div className="flex justify-end gap-[var(--space-2)]">
|
|
212
|
+
{onCancel && (
|
|
213
|
+
<Button variant="ghost" onClick={onCancel}>
|
|
214
|
+
Cancel
|
|
215
|
+
</Button>
|
|
216
|
+
)}
|
|
217
|
+
<Button disabled={!valid} onClick={() => onSave?.(hook)}>
|
|
218
|
+
{editing ? 'Save' : 'Add hook'}
|
|
219
|
+
</Button>
|
|
220
|
+
</div>
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
interface HookDialogProps {
|
|
226
|
+
/** The control that opens it, such as the hooks section's "Add hook" button. */
|
|
227
|
+
trigger?: ReactElement
|
|
228
|
+
/** Controlled open state. */
|
|
229
|
+
open?: boolean
|
|
230
|
+
/** Initial open state, for an uncontrolled dialog. Defaults to `false`. */
|
|
231
|
+
defaultOpen?: boolean
|
|
232
|
+
/** Called when the dialog opens or closes. */
|
|
233
|
+
onOpenChange?: (open: boolean) => void
|
|
234
|
+
/** What the form starts with; editing an existing hook passes it here. Defaults to an empty PreToolUse hook. */
|
|
235
|
+
defaultHook?: Partial<HookConfig>
|
|
236
|
+
/** The config dir user-scoped hooks are written to. Defaults to `'~/.claude'`. */
|
|
237
|
+
configDir?: string
|
|
238
|
+
/** Whether the form edits an existing hook: the title and the button say so. Defaults to `false`. */
|
|
239
|
+
editing?: boolean
|
|
240
|
+
/** Called with the hook when Save is pressed; the dialog closes. */
|
|
241
|
+
onSave?: (hook: HookConfig) => void
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Adds or edits a hook: a command the harness runs on a session event.
|
|
246
|
+
*
|
|
247
|
+
* Pick the event, and the form says when it fires and what its matcher
|
|
248
|
+
* takes: a tool pattern for PreToolUse and PostToolUse, a source for
|
|
249
|
+
* SessionStart and PreCompact; the other events take none, and the field
|
|
250
|
+
* stands disabled. The command is a mono field that grows with it; the
|
|
251
|
+
* timeout takes whole seconds; the scope says which settings file it lands
|
|
252
|
+
* in. Under the form, the settings.json fragment it writes follows every
|
|
253
|
+
* keystroke. The dialog grows out of its trigger; `HookDialog.Panel` is the
|
|
254
|
+
* same form without it.
|
|
255
|
+
*
|
|
256
|
+
* Statics:
|
|
257
|
+
* - `HookDialog.Panel` — the form on its own: the same props, minus the dialog's, plus `onCancel`.
|
|
258
|
+
*
|
|
259
|
+
* @example {@include ./examples.mdx}
|
|
260
|
+
*/
|
|
261
|
+
const HookDialog = Object.assign(
|
|
262
|
+
function HookDialog({ trigger, open, defaultOpen = false, onOpenChange, onSave, ...panel }: HookDialogProps) {
|
|
263
|
+
const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange)
|
|
264
|
+
return (
|
|
265
|
+
<Dialog open={isOpen} onOpenChange={setOpen}>
|
|
266
|
+
{trigger && <Dialog.Trigger render={trigger} />}
|
|
267
|
+
<Dialog.Content width="lg" aria-label="Hook" className="@container">
|
|
268
|
+
<HookDialogPanel
|
|
269
|
+
{...panel}
|
|
270
|
+
onCancel={() => setOpen(false)}
|
|
271
|
+
onSave={hook => {
|
|
272
|
+
onSave?.(hook)
|
|
273
|
+
setOpen(false)
|
|
274
|
+
}}
|
|
275
|
+
/>
|
|
276
|
+
</Dialog.Content>
|
|
277
|
+
</Dialog>
|
|
278
|
+
)
|
|
279
|
+
},
|
|
280
|
+
{ Panel: HookDialogPanel },
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
export type { HookDialogPanelProps, HookDialogProps }
|
|
284
|
+
export { HookDialog, HookDialogPanel }
|
|
285
|
+
|
|
286
|
+
export default HookDialog
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import McpServerDialog from './index'
|
|
2
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
3
|
+
import { PROFILES } from '../../../mock/mock'
|
|
4
|
+
import { MCP_LINEAR, MCP_POSTGRES, MCP_TAKEN, MCP_TEST_FAILED, MCP_TEST_OK, MCP_TEST_TESTING } from '../../../mock/mock-config'
|
|
5
|
+
|
|
6
|
+
# Add a server
|
|
7
|
+
|
|
8
|
+
Press the button: the dialog grows out of it. Pick a transport and the form follows it.
|
|
9
|
+
|
|
10
|
+
<McpServerDialog
|
|
11
|
+
trigger={<Button variant="secondary">Add server</Button>}
|
|
12
|
+
profiles={PROFILES}
|
|
13
|
+
taken={MCP_TAKEN}
|
|
14
|
+
/>
|
|
15
|
+
|
|
16
|
+
# A stdio server
|
|
17
|
+
|
|
18
|
+
A command, its arguments and env vars; values stay masked until the eye shows one.
|
|
19
|
+
|
|
20
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
21
|
+
<McpServerDialog.Panel profiles={PROFILES} taken={MCP_TAKEN} defaultServer={MCP_POSTGRES} test={MCP_TEST_OK} onDelete={() => {}} />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
# An http server
|
|
25
|
+
|
|
26
|
+
A URL and headers. Type a URL without its scheme to see it caught.
|
|
27
|
+
|
|
28
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
29
|
+
<McpServerDialog.Panel profiles={PROFILES} taken={MCP_TAKEN} defaultServer={MCP_LINEAR} />
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
# Testing
|
|
33
|
+
|
|
34
|
+
The test button spins while the app connects.
|
|
35
|
+
|
|
36
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
37
|
+
<McpServerDialog.Panel defaultServer={MCP_POSTGRES} test={MCP_TEST_TESTING} />
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
# Connection failed
|
|
41
|
+
|
|
42
|
+
The server's last words, so you can fix the command or env and test again.
|
|
43
|
+
|
|
44
|
+
<div className="@container w-full max-w-[540px] rounded-xl border border-border bg-background p-6">
|
|
45
|
+
<McpServerDialog.Panel defaultServer={MCP_POSTGRES} test={MCP_TEST_FAILED} />
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
# Light and dark
|
|
49
|
+
|
|
50
|
+
<div className="grid w-full gap-3 @3xl:grid-cols-2">
|
|
51
|
+
<div className="light @container rounded-xl border border-border bg-background p-6 text-foreground">
|
|
52
|
+
<McpServerDialog.Panel defaultServer={MCP_LINEAR} test={MCP_TEST_OK} />
|
|
53
|
+
</div>
|
|
54
|
+
<div className="dark @container rounded-xl border border-border bg-background p-6 text-foreground">
|
|
55
|
+
<McpServerDialog.Panel defaultServer={MCP_LINEAR} test={MCP_TEST_FAILED} />
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|