@justanarthur/modo-ui-ai 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSE.fluid-functionalism +21 -0
- package/README.md +105 -2
- package/blocks/conversation/agent-prompt/examples.mdx +44 -0
- package/blocks/conversation/agent-prompt/index.tsx +114 -0
- package/blocks/conversation/composer/draft.css +25 -0
- package/blocks/conversation/composer/draft.tsx +589 -0
- package/blocks/conversation/composer/examples.mdx +164 -0
- package/blocks/conversation/composer/file-preview-tile.tsx +59 -0
- package/blocks/conversation/composer/file-thumbnail.tsx +146 -0
- package/blocks/conversation/composer/index.tsx +651 -0
- package/blocks/conversation/composer/queued-row.tsx +102 -0
- package/blocks/conversation/composer/shared.ts +38 -0
- package/blocks/conversation/composer/suggestion-row.tsx +64 -0
- package/blocks/conversation/composer/use-composer-files.ts +142 -0
- package/blocks/conversation/composer/use-history-nav.ts +60 -0
- package/blocks/conversation/composer/use-message-queue.ts +108 -0
- package/blocks/conversation/composer/use-region-height.ts +34 -0
- package/blocks/conversation/failure-states/examples.mdx +58 -0
- package/blocks/conversation/failure-states/index.tsx +274 -0
- package/blocks/conversation/transcript/examples.mdx +43 -0
- package/blocks/conversation/transcript/index.tsx +206 -0
- package/blocks/conversation/transcript-search/examples.mdx +50 -0
- package/blocks/conversation/transcript-search/index.tsx +469 -0
- package/blocks/dialogs/command-palette/examples.mdx +50 -0
- package/blocks/dialogs/command-palette/index.tsx +239 -0
- package/blocks/dialogs/hook-dialog/examples.mdx +44 -0
- package/blocks/dialogs/hook-dialog/index.tsx +286 -0
- package/blocks/dialogs/mcp-server-dialog/examples.mdx +57 -0
- package/blocks/dialogs/mcp-server-dialog/index.tsx +415 -0
- package/blocks/dialogs/shortcuts-sheet/examples.mdx +36 -0
- package/blocks/dialogs/shortcuts-sheet/index.tsx +186 -0
- package/blocks/panes/artifacts-pane/examples.mdx +23 -0
- package/blocks/panes/artifacts-pane/index.tsx +82 -0
- package/blocks/panes/changes-pane/examples.mdx +23 -0
- package/blocks/panes/changes-pane/index.tsx +248 -0
- package/blocks/panes/file-pane/examples.mdx +13 -0
- package/blocks/panes/file-pane/index.tsx +102 -0
- package/blocks/panes/pr-pane/examples.mdx +13 -0
- package/blocks/panes/pr-pane/index.tsx +191 -0
- package/blocks/panes/side-pane/examples.mdx +58 -0
- package/blocks/panes/side-pane/index.tsx +187 -0
- package/blocks/panes/tasks-pane/examples.mdx +23 -0
- package/blocks/panes/tasks-pane/index.tsx +127 -0
- package/blocks/panes/terminal-pane/examples.mdx +13 -0
- package/blocks/panes/terminal-pane/index.tsx +99 -0
- package/blocks/panes/usage-pane/examples.mdx +23 -0
- package/blocks/panes/usage-pane/index.tsx +78 -0
- package/blocks/profiles/profile-onboarding/examples.mdx +80 -0
- package/blocks/profiles/profile-onboarding/index.tsx +580 -0
- package/blocks/profiles/profile-switcher/examples.mdx +29 -0
- package/blocks/profiles/profile-switcher/index.tsx +212 -0
- package/blocks/profiles/profile-usage/examples.mdx +41 -0
- package/blocks/profiles/profile-usage/index.tsx +141 -0
- package/blocks/sessions/inbox/examples.mdx +35 -0
- package/blocks/sessions/inbox/index.tsx +372 -0
- package/blocks/sessions/session-board/examples.mdx +34 -0
- package/blocks/sessions/session-board/index.tsx +570 -0
- package/blocks/sessions/session-sidebar/examples.mdx +93 -0
- package/blocks/sessions/session-sidebar/index.tsx +497 -0
- package/blocks/settings/extensions/examples.mdx +10 -0
- package/blocks/settings/extensions/index.tsx +72 -0
- package/blocks/settings/hooks/examples.mdx +16 -0
- package/blocks/settings/hooks/index.tsx +127 -0
- package/blocks/settings/mcp-servers/examples.mdx +26 -0
- package/blocks/settings/mcp-servers/index.tsx +204 -0
- package/blocks/settings/memory/examples.mdx +22 -0
- package/blocks/settings/memory/index.tsx +113 -0
- package/blocks/settings/notifications/examples.mdx +8 -0
- package/blocks/settings/notifications/index.tsx +63 -0
- package/blocks/settings/permission-rules/examples.mdx +37 -0
- package/blocks/settings/permission-rules/index.tsx +317 -0
- package/blocks/settings/plugin-catalog/examples.mdx +52 -0
- package/blocks/settings/plugin-catalog/index.tsx +407 -0
- package/blocks/settings/plugins/examples.mdx +10 -0
- package/blocks/settings/plugins/index.tsx +72 -0
- package/blocks/settings/settings-window/examples.mdx +40 -0
- package/blocks/settings/settings-window/index.tsx +188 -0
- package/blocks/settings/worktrees/examples.mdx +17 -0
- package/blocks/settings/worktrees/index.tsx +145 -0
- package/components/conversation/agent-run/examples.mdx +38 -0
- package/components/conversation/agent-run/index.tsx +83 -0
- package/components/conversation/chapter-nav/examples.mdx +30 -0
- package/components/conversation/chapter-nav/index.tsx +123 -0
- package/components/conversation/message/examples.mdx +53 -0
- package/components/conversation/message/index.tsx +130 -0
- package/components/conversation/message/working.tsx +102 -0
- package/components/conversation/reasoning/examples.mdx +32 -0
- package/components/conversation/reasoning/index.tsx +55 -0
- package/components/conversation/recap/examples.mdx +21 -0
- package/components/conversation/recap/index.tsx +67 -0
- package/components/conversation/todo-list/examples.mdx +32 -0
- package/components/conversation/todo-list/index.tsx +106 -0
- package/components/conversation/tool-call/examples.mdx +48 -0
- package/components/conversation/tool-call/index.tsx +142 -0
- package/components/conversation/work-summary/examples.mdx +50 -0
- package/components/conversation/work-summary/index.tsx +87 -0
- package/components/prompts/permission-request/examples.mdx +32 -0
- package/components/prompts/permission-request/index.tsx +74 -0
- package/components/prompts/plan-approval/examples.mdx +37 -0
- package/components/prompts/plan-approval/index.tsx +76 -0
- package/components/prompts/prompt-card/examples.mdx +31 -0
- package/components/prompts/prompt-card/index.tsx +82 -0
- package/components/prompts/question-prompt/examples.mdx +46 -0
- package/components/prompts/question-prompt/index.tsx +118 -0
- package/dist/blocks/conversation/agent-prompt/index.d.ts +7 -0
- package/dist/blocks/conversation/agent-prompt/index.js +13 -0
- package/dist/blocks/conversation/composer/index.d.ts +4 -0
- package/dist/blocks/conversation/composer/index.js +16 -0
- package/dist/blocks/conversation/failure-states/index.d.ts +4 -0
- package/dist/blocks/conversation/failure-states/index.js +8 -0
- package/dist/blocks/conversation/transcript/index.d.ts +50 -0
- package/dist/blocks/conversation/transcript/index.js +17 -0
- package/dist/blocks/conversation/transcript-search/index.d.ts +4 -0
- package/dist/blocks/conversation/transcript-search/index.js +11 -0
- package/dist/blocks/dialogs/command-palette/index.d.ts +5 -0
- package/dist/blocks/dialogs/command-palette/index.js +20 -0
- package/dist/blocks/dialogs/hook-dialog/index.d.ts +3 -0
- package/dist/blocks/dialogs/hook-dialog/index.js +12 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.d.ts +5 -0
- package/dist/blocks/dialogs/mcp-server-dialog/index.js +12 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.d.ts +2 -0
- package/dist/blocks/dialogs/shortcuts-sheet/index.js +11 -0
- package/dist/blocks/panes/artifacts-pane/index.d.ts +3 -0
- package/dist/blocks/panes/artifacts-pane/index.js +9 -0
- package/dist/blocks/panes/changes-pane/index.d.ts +3 -0
- package/dist/blocks/panes/changes-pane/index.js +9 -0
- package/dist/blocks/panes/file-pane/index.d.ts +3 -0
- package/dist/blocks/panes/file-pane/index.js +9 -0
- package/dist/blocks/panes/pr-pane/index.d.ts +3 -0
- package/dist/blocks/panes/pr-pane/index.js +10 -0
- package/dist/blocks/panes/side-pane/index.d.ts +5 -0
- package/dist/blocks/panes/side-pane/index.js +21 -0
- package/dist/blocks/panes/tasks-pane/index.d.ts +3 -0
- package/dist/blocks/panes/tasks-pane/index.js +10 -0
- package/dist/blocks/panes/terminal-pane/index.d.ts +3 -0
- package/dist/blocks/panes/terminal-pane/index.js +9 -0
- package/dist/blocks/panes/usage-pane/index.d.ts +4 -0
- package/dist/blocks/panes/usage-pane/index.js +11 -0
- package/dist/blocks/profiles/profile-onboarding/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-onboarding/index.js +11 -0
- package/dist/blocks/profiles/profile-switcher/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-switcher/index.js +12 -0
- package/dist/blocks/profiles/profile-usage/index.d.ts +4 -0
- package/dist/blocks/profiles/profile-usage/index.js +10 -0
- package/dist/blocks/sessions/inbox/index.d.ts +2 -0
- package/dist/blocks/sessions/inbox/index.js +11 -0
- package/dist/blocks/sessions/session-board/index.d.ts +4 -0
- package/dist/blocks/sessions/session-board/index.js +27 -0
- package/dist/blocks/sessions/session-sidebar/index.d.ts +5 -0
- package/dist/blocks/sessions/session-sidebar/index.js +15 -0
- package/dist/blocks/settings/extensions/index.d.ts +2 -0
- package/dist/blocks/settings/extensions/index.js +9 -0
- package/dist/blocks/settings/hooks/index.d.ts +4 -0
- package/dist/blocks/settings/hooks/index.js +9 -0
- package/dist/blocks/settings/mcp-servers/index.d.ts +4 -0
- package/dist/blocks/settings/mcp-servers/index.js +9 -0
- package/dist/blocks/settings/memory/index.d.ts +4 -0
- package/dist/blocks/settings/memory/index.js +8 -0
- package/dist/blocks/settings/notifications/index.d.ts +2 -0
- package/dist/blocks/settings/notifications/index.js +8 -0
- package/dist/blocks/settings/permission-rules/index.d.ts +3 -0
- package/dist/blocks/settings/permission-rules/index.js +10 -0
- package/dist/blocks/settings/plugin-catalog/index.d.ts +2 -0
- package/dist/blocks/settings/plugin-catalog/index.js +11 -0
- package/dist/blocks/settings/plugins/index.d.ts +4 -0
- package/dist/blocks/settings/plugins/index.js +9 -0
- package/dist/blocks/settings/settings-window/index.d.ts +4 -0
- package/dist/blocks/settings/settings-window/index.js +8 -0
- package/dist/blocks/settings/worktrees/index.d.ts +4 -0
- package/dist/blocks/settings/worktrees/index.js +9 -0
- package/dist/components/conversation/agent-run/index.d.ts +3 -0
- package/dist/components/conversation/agent-run/index.js +10 -0
- package/dist/components/conversation/chapter-nav/index.d.ts +2 -0
- package/dist/components/conversation/chapter-nav/index.js +11 -0
- package/dist/components/conversation/message/index.d.ts +2 -0
- package/dist/components/conversation/message/index.js +15 -0
- package/dist/components/conversation/reasoning/index.d.ts +2 -0
- package/dist/components/conversation/reasoning/index.js +8 -0
- package/dist/components/conversation/recap/index.d.ts +2 -0
- package/dist/components/conversation/recap/index.js +9 -0
- package/dist/components/conversation/todo-list/index.d.ts +2 -0
- package/dist/components/conversation/todo-list/index.js +9 -0
- package/dist/components/conversation/tool-call/index.d.ts +3 -0
- package/dist/components/conversation/tool-call/index.js +13 -0
- package/dist/components/conversation/work-summary/index.d.ts +2 -0
- package/dist/components/conversation/work-summary/index.js +10 -0
- package/dist/components/prompts/permission-request/index.d.ts +2 -0
- package/dist/components/prompts/permission-request/index.js +9 -0
- package/dist/components/prompts/plan-approval/index.d.ts +2 -0
- package/dist/components/prompts/plan-approval/index.js +9 -0
- package/dist/components/prompts/prompt-card/index.d.ts +3 -0
- package/dist/components/prompts/prompt-card/index.js +8 -0
- package/dist/components/prompts/question-prompt/index.d.ts +2 -0
- package/dist/components/prompts/question-prompt/index.js +9 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +231 -0
- package/dist/lib/config-parts.d.ts +2 -0
- package/dist/lib/config-parts.js +16 -0
- package/dist/lib/icons.d.ts +2 -0
- package/dist/lib/icons.js +10 -0
- package/dist/lib/pace-bar.d.ts +11 -0
- package/dist/lib/pace-bar.js +6 -0
- package/dist/lib/pace.d.ts +4 -0
- package/dist/lib/pace.js +14 -0
- package/dist/lib/pane-parts.d.ts +25 -0
- package/dist/lib/pane-parts.js +11 -0
- package/dist/lib/row-trigger.d.ts +5 -0
- package/dist/lib/row-trigger.js +7 -0
- package/dist/lib/settings-parts.d.ts +70 -0
- package/dist/lib/settings-parts.js +24 -0
- package/dist/lib/side-pane-types.d.ts +2 -0
- package/dist/lib/side-pane-types.js +1 -0
- package/dist/lib/status-glyph.d.ts +8 -0
- package/dist/lib/status-glyph.js +12 -0
- package/dist/lib/types.d.ts +3 -0
- package/dist/lib/types.js +1 -0
- package/dist/shared/chunk-04a497rr.js +21 -0
- package/dist/shared/chunk-13yf0mza.d.ts +70 -0
- package/dist/shared/chunk-1hzrm8r5.d.ts +51 -0
- package/dist/shared/chunk-1qdwg7w5.d.ts +81 -0
- package/dist/shared/chunk-1yt061np.d.ts +64 -0
- package/dist/shared/chunk-218qabm5.js +250 -0
- package/dist/shared/chunk-2fk5aq60.js +313 -0
- package/dist/shared/chunk-3ps5h55t.d.ts +30 -0
- package/dist/shared/chunk-3yaftgh0.d.ts +28 -0
- package/dist/shared/chunk-4zvhpf2x.js +55 -0
- package/dist/shared/chunk-57hzzmjd.d.ts +67 -0
- package/dist/shared/chunk-58jh3mje.js +46 -0
- package/dist/shared/chunk-58qvny6a.d.ts +29 -0
- package/dist/shared/chunk-5fhkkn39.js +130 -0
- package/dist/shared/chunk-5hw0525a.d.ts +33 -0
- package/dist/shared/chunk-5meda998.js +238 -0
- package/dist/shared/chunk-5pqksw7z.js +91 -0
- package/dist/shared/chunk-6220dy5n.js +70 -0
- package/dist/shared/chunk-64bnh22t.d.ts +59 -0
- package/dist/shared/chunk-66sh633m.d.ts +60 -0
- package/dist/shared/chunk-6cmf27g3.d.ts +81 -0
- package/dist/shared/chunk-6kwk9vag.js +558 -0
- package/dist/shared/chunk-6rdwkymk.js +177 -0
- package/dist/shared/chunk-71j8qzvb.d.ts +57 -0
- package/dist/shared/chunk-74bvf3tw.d.ts +21 -0
- package/dist/shared/chunk-75zwypyr.d.ts +43 -0
- package/dist/shared/chunk-7mfer3tp.js +176 -0
- package/dist/shared/chunk-7rzjmcnh.d.ts +30 -0
- package/dist/shared/chunk-7zvb39cf.d.ts +26 -0
- package/dist/shared/chunk-8mecznyr.js +357 -0
- package/dist/shared/chunk-8pag6vmd.js +255 -0
- package/dist/shared/chunk-94grzz9f.js +187 -0
- package/dist/shared/chunk-9kw6m047.d.ts +32 -0
- package/dist/shared/chunk-at0jje23.d.ts +110 -0
- package/dist/shared/chunk-awd573h9.js +34 -0
- package/dist/shared/chunk-b171wjge.d.ts +25 -0
- package/dist/shared/chunk-b4dz15em.d.ts +36 -0
- package/dist/shared/chunk-b5ccp5de.js +35 -0
- package/dist/shared/chunk-bh2b5d1z.js +98 -0
- package/dist/shared/chunk-c36qvrwq.d.ts +30 -0
- package/dist/shared/chunk-c8wp058j.js +153 -0
- package/dist/shared/chunk-d2t72h4x.d.ts +35 -0
- package/dist/shared/chunk-dh3qy5fj.js +49 -0
- package/dist/shared/chunk-dxzrtvt9.d.ts +283 -0
- package/dist/shared/chunk-e46apgve.d.ts +40 -0
- package/dist/shared/chunk-ejtknc0w.js +21 -0
- package/dist/shared/chunk-eqajdxn8.js +82 -0
- package/dist/shared/chunk-fapc805j.js +130 -0
- package/dist/shared/chunk-fm1qyrae.d.ts +68 -0
- package/dist/shared/chunk-fqhcz6ss.d.ts +29 -0
- package/dist/shared/chunk-g88hweqh.d.ts +70 -0
- package/dist/shared/chunk-gb5ee5dw.d.ts +88 -0
- package/dist/shared/chunk-gewnsgza.js +61 -0
- package/dist/shared/chunk-hxjgey30.d.ts +36 -0
- package/dist/shared/chunk-jkkdq1mh.d.ts +213 -0
- package/dist/shared/chunk-jpq101w3.js +91 -0
- package/dist/shared/chunk-k3bv9k1v.d.ts +56 -0
- package/dist/shared/chunk-kreypnzp.d.ts +34 -0
- package/dist/shared/chunk-mnzw0bav.js +80 -0
- package/dist/shared/chunk-mrb3fp2f.d.ts +30 -0
- package/dist/shared/chunk-n1qq2wp9.js +6 -0
- package/dist/shared/chunk-n31qwnj2.js +1544 -0
- package/dist/shared/chunk-n4742y54.js +39 -0
- package/dist/shared/chunk-ndjvdkv7.d.ts +29 -0
- package/dist/shared/chunk-njf851p1.js +245 -0
- package/dist/shared/chunk-nk4578dr.js +73 -0
- package/dist/shared/chunk-nkbgg7bw.d.ts +24 -0
- package/dist/shared/chunk-nvh33x9x.js +488 -0
- package/dist/shared/chunk-paezqfg1.js +106 -0
- package/dist/shared/chunk-qemm9e3r.d.ts +21 -0
- package/dist/shared/chunk-qhxz1etk.js +96 -0
- package/dist/shared/chunk-qj5ev9ak.js +531 -0
- package/dist/shared/chunk-qnwggvjy.js +150 -0
- package/dist/shared/chunk-qt31n444.js +178 -0
- package/dist/shared/chunk-r5hz78pb.js +129 -0
- package/dist/shared/chunk-r6nb21kz.d.ts +102 -0
- package/dist/shared/chunk-rqrpvvz4.d.ts +107 -0
- package/dist/shared/chunk-s3r759ec.js +80 -0
- package/dist/shared/chunk-sdtjrw9w.d.ts +98 -0
- package/dist/shared/chunk-skg3m9m0.js +56 -0
- package/dist/shared/chunk-t21t9x7e.js +188 -0
- package/dist/shared/chunk-tc75ng2c.js +235 -0
- package/dist/shared/chunk-tkx1krwc.js +88 -0
- package/dist/shared/chunk-tprdqtb1.d.ts +30 -0
- package/dist/shared/chunk-tv9a1sek.js +137 -0
- package/dist/shared/chunk-tvbd27hg.d.ts +43 -0
- package/dist/shared/chunk-ty2ccknv.d.ts +54 -0
- package/dist/shared/chunk-v6yevw62.d.ts +28 -0
- package/dist/shared/chunk-v9q38p0x.js +258 -0
- package/dist/shared/chunk-vgh4f3sv.js +118 -0
- package/dist/shared/chunk-vjht1zn1.js +391 -0
- package/dist/shared/chunk-vsrkb0sp.d.ts +21 -0
- package/dist/shared/chunk-whsx7yp9.d.ts +37 -0
- package/dist/shared/chunk-wq9h37gy.js +86 -0
- package/dist/shared/chunk-x7az5x1y.d.ts +57 -0
- package/dist/shared/chunk-x9jf26yb.js +318 -0
- package/dist/shared/chunk-xbrrt07s.d.ts +23 -0
- package/dist/shared/chunk-xkchhs2z.js +129 -0
- package/dist/shared/chunk-xzfrskd7.js +202 -0
- package/dist/shared/chunk-y4cj4y54.js +423 -0
- package/dist/shared/chunk-y934at6m.js +7 -0
- package/dist/shared/chunk-zbpwhpjy.d.ts +75 -0
- package/dist/shared/chunk-zfhmbb7n.js +63 -0
- package/dist/shared/chunk-zk0t4vq5.js +71 -0
- package/dist/shared/chunk-znp9gna7.d.ts +23 -0
- package/dist/styles.css +467 -0
- package/index.ts +49 -0
- package/lib/config-parts.tsx +97 -0
- package/lib/icons.tsx +149 -0
- package/lib/pace-bar.tsx +24 -0
- package/lib/pace.ts +78 -0
- package/lib/pane-parts.tsx +76 -0
- package/lib/row-trigger.tsx +44 -0
- package/lib/settings-parts.tsx +232 -0
- package/lib/side-pane-types.ts +75 -0
- package/lib/status-glyph.tsx +25 -0
- package/lib/types.ts +204 -0
- package/mock/demo-reply.tsx +33 -0
- package/mock/demo-session.tsx +150 -0
- package/mock/mock-config.ts +173 -0
- package/mock/mock-extras.ts +288 -0
- package/mock/mock-panes.ts +190 -0
- package/mock/mock-settings.ts +92 -0
- package/mock/mock.ts +548 -0
- package/mock/screen-frame.tsx +49 -0
- package/package.json +114 -4
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's "Add MCP server" form. A Dialog over the
|
|
3
|
+
* transport (stdio, http, sse), its command and env or its URL and headers,
|
|
4
|
+
* the scope and profiles it applies to, and a connection test whose state
|
|
5
|
+
* comes in through `test`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
10
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
11
|
+
import { Spinner } from '@justanarthur/modo-ui/components/feedback/progress'
|
|
12
|
+
import Checkbox from '@justanarthur/modo-ui/components/inputs/checkbox'
|
|
13
|
+
import Input from '@justanarthur/modo-ui/components/inputs/input'
|
|
14
|
+
import KeyValue, { type KeyValuePair } from '@justanarthur/modo-ui/components/inputs/key-value'
|
|
15
|
+
import Dialog from '@justanarthur/modo-ui/components/overlays/dialog'
|
|
16
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
17
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
18
|
+
import Code from '@justanarthur/modo-ui/primitives/content/code'
|
|
19
|
+
import { type ReactElement, type ReactNode, useState } from 'react'
|
|
20
|
+
import { type ConfigScope, Field, Fieldset, SCOPE_NOTE, SCOPES, Segmented } from '../../../lib/config-parts'
|
|
21
|
+
import { useIcon } from '../../../lib/icons'
|
|
22
|
+
import type { Profile } from '../../../lib/types'
|
|
23
|
+
|
|
24
|
+
export type McpTransport = 'stdio' | 'http' | 'sse'
|
|
25
|
+
|
|
26
|
+
/** An MCP server as the form writes it. */
|
|
27
|
+
export interface McpServerConfig {
|
|
28
|
+
name: string
|
|
29
|
+
transport: McpTransport
|
|
30
|
+
/** The executable a stdio server runs. */
|
|
31
|
+
command: string
|
|
32
|
+
/** Its arguments, one word each. */
|
|
33
|
+
args: string[]
|
|
34
|
+
/** Env vars passed to a stdio server. */
|
|
35
|
+
env: KeyValuePair[]
|
|
36
|
+
/** Where an http or sse server answers. */
|
|
37
|
+
url: string
|
|
38
|
+
/** Headers sent to an http or sse server. */
|
|
39
|
+
headers: KeyValuePair[]
|
|
40
|
+
scope: ConfigScope
|
|
41
|
+
/** Ids of the profiles whose sessions load it. */
|
|
42
|
+
profiles: string[]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Where the connection test stands; the app runs it and reports back. */
|
|
46
|
+
export interface McpConnectionTest {
|
|
47
|
+
state: 'idle' | 'testing' | 'ok' | 'failed'
|
|
48
|
+
/** The tools the server listed, once it answered. */
|
|
49
|
+
tools?: string[]
|
|
50
|
+
/** Why it failed: the tail of its stderr or the HTTP error. */
|
|
51
|
+
error?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const TRANSPORTS: { value: McpTransport; label: string }[] = [
|
|
55
|
+
{ value: 'stdio', label: 'stdio' },
|
|
56
|
+
{ value: 'http', label: 'HTTP' },
|
|
57
|
+
{ value: 'sse', label: 'SSE' },
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
const EMPTY: McpServerConfig = {
|
|
61
|
+
name: '',
|
|
62
|
+
transport: 'stdio',
|
|
63
|
+
command: '',
|
|
64
|
+
args: [],
|
|
65
|
+
env: [],
|
|
66
|
+
url: '',
|
|
67
|
+
headers: [],
|
|
68
|
+
scope: 'user',
|
|
69
|
+
profiles: [],
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const IDLE: McpConnectionTest = { state: 'idle' }
|
|
73
|
+
|
|
74
|
+
function errors(server: McpServerConfig, taken: string[]) {
|
|
75
|
+
return {
|
|
76
|
+
name: taken.includes(server.name) ? 'A server with this name exists.' : undefined,
|
|
77
|
+
url:
|
|
78
|
+
server.transport !== 'stdio' && server.url && !/^https?:\/\/\S+$/.test(server.url)
|
|
79
|
+
? 'Starts with http:// or https://.'
|
|
80
|
+
: undefined,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function complete(server: McpServerConfig) {
|
|
85
|
+
if (!server.name) return false
|
|
86
|
+
return server.transport === 'stdio' ? Boolean(server.command) : Boolean(server.url)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function TestResult({ test }: { test: McpConnectionTest }) {
|
|
90
|
+
const CircleCheck = useIcon('circle-check')
|
|
91
|
+
const CircleX = useIcon('circle-x')
|
|
92
|
+
|
|
93
|
+
const head: Record<McpConnectionTest['state'], { icon: ReactNode; title: string }> = {
|
|
94
|
+
idle: { icon: null, title: 'Not tested yet' },
|
|
95
|
+
testing: { icon: <Spinner className="size-4" />, title: 'Connecting…' },
|
|
96
|
+
ok: {
|
|
97
|
+
icon: <CircleCheck size={16} strokeWidth={1.5} className="text-status-success" />,
|
|
98
|
+
title: `Connected · ${test.tools?.length ?? 0} tools`,
|
|
99
|
+
},
|
|
100
|
+
failed: {
|
|
101
|
+
icon: <CircleX size={16} strokeWidth={1.5} className="text-status-error" />,
|
|
102
|
+
title: 'Could not connect',
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
const { icon, title } = head[test.state]
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<div aria-live="polite" className="flex min-w-0 flex-col gap-[var(--space-2)]">
|
|
109
|
+
<span
|
|
110
|
+
className={cn(
|
|
111
|
+
'flex items-center gap-[var(--space-2)] text-body',
|
|
112
|
+
test.state === 'idle' ? 'text-muted-foreground' : 'text-foreground',
|
|
113
|
+
)}
|
|
114
|
+
>
|
|
115
|
+
{icon}
|
|
116
|
+
{title}
|
|
117
|
+
</span>
|
|
118
|
+
{test.state === 'ok' && test.tools && test.tools.length > 0 && (
|
|
119
|
+
<span className="font-mono text-caption text-muted-foreground">{test.tools.join(', ')}</span>
|
|
120
|
+
)}
|
|
121
|
+
{test.state === 'failed' && test.error && <Code language="txt">{test.error}</Code>}
|
|
122
|
+
</div>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface McpServerDialogPanelProps {
|
|
127
|
+
/** What the form starts with; a server with a name is being edited. Defaults to an empty stdio server. */
|
|
128
|
+
defaultServer?: Partial<McpServerConfig>
|
|
129
|
+
/** The profiles it can apply to. Defaults to `[]`. */
|
|
130
|
+
profiles?: Profile[]
|
|
131
|
+
/** Server names already taken, so a clash is caught before saving. Defaults to `[]`. */
|
|
132
|
+
taken?: string[]
|
|
133
|
+
/** Where the connection test stands. Defaults to idle. */
|
|
134
|
+
test?: McpConnectionTest
|
|
135
|
+
/** Called with what the form holds when "Test connection" is pressed: run the test here. */
|
|
136
|
+
onTest?: (server: McpServerConfig) => void
|
|
137
|
+
/** Called with the server when Save is pressed. */
|
|
138
|
+
onSave?: (server: McpServerConfig) => void
|
|
139
|
+
/** Called with the server when Delete is pressed; leave it out and no Delete shows. */
|
|
140
|
+
onDelete?: (server: McpServerConfig) => void
|
|
141
|
+
/** Called when Cancel is pressed; leave it out and no Cancel shows. */
|
|
142
|
+
onCancel?: () => void
|
|
143
|
+
/** Classes for the root. */
|
|
144
|
+
className?: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The form without the Dialog: for a settings page, or the docs. */
|
|
148
|
+
function McpServerDialogPanel({
|
|
149
|
+
defaultServer,
|
|
150
|
+
profiles = [],
|
|
151
|
+
taken = [],
|
|
152
|
+
test = IDLE,
|
|
153
|
+
onTest,
|
|
154
|
+
onSave,
|
|
155
|
+
onDelete,
|
|
156
|
+
onCancel,
|
|
157
|
+
className,
|
|
158
|
+
}: McpServerDialogPanelProps) {
|
|
159
|
+
const [server, setServer] = useState<McpServerConfig>({ ...EMPTY, ...defaultServer })
|
|
160
|
+
const [args, setArgs] = useState(server.args.join(' '))
|
|
161
|
+
const Plug = useIcon('plug')
|
|
162
|
+
const Trash = useIcon('trash')
|
|
163
|
+
const editing = Boolean(defaultServer?.name)
|
|
164
|
+
const set = (patch: Partial<McpServerConfig>) => setServer({ ...server, ...patch })
|
|
165
|
+
const issues = errors(server, editing ? taken.filter(n => n !== defaultServer?.name) : taken)
|
|
166
|
+
const valid = complete(server) && !issues.name && !issues.url
|
|
167
|
+
const stdio = server.transport === 'stdio'
|
|
168
|
+
const result = { ...server, args: args.split(/\s+/).filter(Boolean) }
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div className={cn('flex flex-col gap-[var(--space-5)]', className)}>
|
|
172
|
+
<div className="flex flex-col gap-[var(--space-1)] pr-[var(--space-6)]">
|
|
173
|
+
<h2 className="m-0 text-title text-foreground">
|
|
174
|
+
{editing ? `Edit ${defaultServer?.name}` : 'Add an MCP server'}
|
|
175
|
+
</h2>
|
|
176
|
+
<p className="m-0 text-body text-muted-foreground">
|
|
177
|
+
Tools the sessions can call. A stdio server runs as a child process; http and sse servers answer on a URL.
|
|
178
|
+
</p>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div className="grid grid-cols-1 gap-[var(--space-4)] @md:grid-cols-[minmax(0,1fr)_auto]">
|
|
182
|
+
<Field label="Name" error={issues.name} hint="How tools are named: mcp__<name>__<tool>.">
|
|
183
|
+
{id => (
|
|
184
|
+
<Input
|
|
185
|
+
id={id}
|
|
186
|
+
variant="bordered"
|
|
187
|
+
value={server.name}
|
|
188
|
+
placeholder="postgres"
|
|
189
|
+
invalid={Boolean(issues.name)}
|
|
190
|
+
onValueChange={name => set({ name: name.trim() })}
|
|
191
|
+
/>
|
|
192
|
+
)}
|
|
193
|
+
</Field>
|
|
194
|
+
<Fieldset legend="Transport">
|
|
195
|
+
<Segmented
|
|
196
|
+
label="Transport"
|
|
197
|
+
options={TRANSPORTS}
|
|
198
|
+
value={server.transport}
|
|
199
|
+
onValueChange={transport => set({ transport })}
|
|
200
|
+
/>
|
|
201
|
+
</Fieldset>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
{stdio ? (
|
|
205
|
+
<>
|
|
206
|
+
<div className="grid grid-cols-1 gap-[var(--space-4)] @md:grid-cols-2">
|
|
207
|
+
<Field label="Command">
|
|
208
|
+
{id => (
|
|
209
|
+
<Input
|
|
210
|
+
id={id}
|
|
211
|
+
variant="bordered"
|
|
212
|
+
className="font-mono"
|
|
213
|
+
value={server.command}
|
|
214
|
+
placeholder="npx"
|
|
215
|
+
onValueChange={command => set({ command })}
|
|
216
|
+
/>
|
|
217
|
+
)}
|
|
218
|
+
</Field>
|
|
219
|
+
<Field label="Arguments" hint="Separated by spaces.">
|
|
220
|
+
{id => (
|
|
221
|
+
<Input
|
|
222
|
+
id={id}
|
|
223
|
+
variant="bordered"
|
|
224
|
+
className="font-mono"
|
|
225
|
+
value={args}
|
|
226
|
+
placeholder="-y @modelcontextprotocol/server-postgres"
|
|
227
|
+
onValueChange={setArgs}
|
|
228
|
+
/>
|
|
229
|
+
)}
|
|
230
|
+
</Field>
|
|
231
|
+
</div>
|
|
232
|
+
<Fieldset legend="Environment" hint="New values are masked, for keys and tokens; the eye shows one.">
|
|
233
|
+
<KeyValue
|
|
234
|
+
label="Environment variables"
|
|
235
|
+
keyPlaceholder="NAME"
|
|
236
|
+
valuePlaceholder="value"
|
|
237
|
+
addLabel="Add variable"
|
|
238
|
+
secretByDefault
|
|
239
|
+
value={server.env}
|
|
240
|
+
onValueChange={env => set({ env })}
|
|
241
|
+
/>
|
|
242
|
+
</Fieldset>
|
|
243
|
+
</>
|
|
244
|
+
) : (
|
|
245
|
+
<>
|
|
246
|
+
<Field label="URL" error={issues.url}>
|
|
247
|
+
{id => (
|
|
248
|
+
<Input
|
|
249
|
+
id={id}
|
|
250
|
+
variant="bordered"
|
|
251
|
+
className="font-mono"
|
|
252
|
+
value={server.url}
|
|
253
|
+
placeholder={server.transport === 'sse' ? 'https://mcp.example.com/sse' : 'https://mcp.example.com/mcp'}
|
|
254
|
+
invalid={Boolean(issues.url)}
|
|
255
|
+
onValueChange={url => set({ url: url.trim() })}
|
|
256
|
+
/>
|
|
257
|
+
)}
|
|
258
|
+
</Field>
|
|
259
|
+
<Fieldset legend="Headers" hint="New values are masked, for tokens; the eye shows one.">
|
|
260
|
+
<KeyValue
|
|
261
|
+
label="Request headers"
|
|
262
|
+
keyPlaceholder="Header"
|
|
263
|
+
addLabel="Add header"
|
|
264
|
+
secretByDefault
|
|
265
|
+
value={server.headers}
|
|
266
|
+
onValueChange={headers => set({ headers })}
|
|
267
|
+
/>
|
|
268
|
+
</Fieldset>
|
|
269
|
+
</>
|
|
270
|
+
)}
|
|
271
|
+
|
|
272
|
+
<Fieldset legend="Scope" hint={SCOPE_NOTE[server.scope]}>
|
|
273
|
+
<Segmented label="Scope" options={SCOPES} value={server.scope} onValueChange={scope => set({ scope })} />
|
|
274
|
+
</Fieldset>
|
|
275
|
+
|
|
276
|
+
{profiles.length > 0 && (
|
|
277
|
+
<Fieldset
|
|
278
|
+
legend="Profiles"
|
|
279
|
+
hint="Sessions under the profiles you check load it; none checked means every profile."
|
|
280
|
+
>
|
|
281
|
+
<div className="-mx-[var(--space-2)]">
|
|
282
|
+
<Checkbox.Group
|
|
283
|
+
aria-label="Profiles"
|
|
284
|
+
checkedIndices={new Set(profiles.flatMap((p, i) => (server.profiles.includes(p.id) ? [i] : [])))}
|
|
285
|
+
onCheckedIndicesChange={picked =>
|
|
286
|
+
set({ profiles: profiles.filter((_, i) => picked.has(i)).map(p => p.id) })
|
|
287
|
+
}
|
|
288
|
+
>
|
|
289
|
+
{profiles.map(p => (
|
|
290
|
+
<Checkbox key={p.id} label={p.name} />
|
|
291
|
+
))}
|
|
292
|
+
</Checkbox.Group>
|
|
293
|
+
</div>
|
|
294
|
+
</Fieldset>
|
|
295
|
+
)}
|
|
296
|
+
|
|
297
|
+
<div className="flex flex-wrap items-start gap-[var(--space-3)] border-t border-border pt-[var(--space-4)]">
|
|
298
|
+
<div className="min-w-0 flex-1">
|
|
299
|
+
<TestResult test={test} />
|
|
300
|
+
</div>
|
|
301
|
+
<Button
|
|
302
|
+
variant="secondary"
|
|
303
|
+
size="compact"
|
|
304
|
+
leadingIcon={Plug}
|
|
305
|
+
disabled={!valid}
|
|
306
|
+
loading={test.state === 'testing'}
|
|
307
|
+
onClick={() => onTest?.(result)}
|
|
308
|
+
>
|
|
309
|
+
Test connection
|
|
310
|
+
</Button>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<div className="flex items-center gap-[var(--space-2)]">
|
|
314
|
+
{editing && onDelete && (
|
|
315
|
+
<Button variant="ghost" leadingIcon={Trash} className="text-destructive" onClick={() => onDelete(result)}>
|
|
316
|
+
Delete
|
|
317
|
+
</Button>
|
|
318
|
+
)}
|
|
319
|
+
<div className="ml-auto flex gap-[var(--space-2)]">
|
|
320
|
+
{onCancel && (
|
|
321
|
+
<Button variant="ghost" onClick={onCancel}>
|
|
322
|
+
Cancel
|
|
323
|
+
</Button>
|
|
324
|
+
)}
|
|
325
|
+
<Button disabled={!valid} onClick={() => onSave?.(result)}>
|
|
326
|
+
{editing ? 'Save' : 'Add server'}
|
|
327
|
+
</Button>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
interface McpServerDialogProps {
|
|
335
|
+
/** The control that opens it, such as the MCP section's "Add server" button. */
|
|
336
|
+
trigger?: ReactElement
|
|
337
|
+
/** Controlled open state. */
|
|
338
|
+
open?: boolean
|
|
339
|
+
/** Initial open state, for an uncontrolled dialog. Defaults to `false`. */
|
|
340
|
+
defaultOpen?: boolean
|
|
341
|
+
/** Called when the dialog opens or closes. */
|
|
342
|
+
onOpenChange?: (open: boolean) => void
|
|
343
|
+
/** What the form starts with; a server with a name is being edited. Defaults to an empty stdio server. */
|
|
344
|
+
defaultServer?: Partial<McpServerConfig>
|
|
345
|
+
/** The profiles it can apply to. Defaults to `[]`. */
|
|
346
|
+
profiles?: Profile[]
|
|
347
|
+
/** Server names already taken, so a clash is caught before saving. Defaults to `[]`. */
|
|
348
|
+
taken?: string[]
|
|
349
|
+
/** Where the connection test stands. Defaults to idle. */
|
|
350
|
+
test?: McpConnectionTest
|
|
351
|
+
/** Called with what the form holds when "Test connection" is pressed: run the test here. */
|
|
352
|
+
onTest?: (server: McpServerConfig) => void
|
|
353
|
+
/** Called with the server when Save is pressed; the dialog closes. */
|
|
354
|
+
onSave?: (server: McpServerConfig) => void
|
|
355
|
+
/** Called with the server when Delete is pressed; the dialog closes. Leave it out and no Delete shows. */
|
|
356
|
+
onDelete?: (server: McpServerConfig) => void
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Adds or edits an MCP server: how the sessions reach it, where it is
|
|
361
|
+
* configured and who loads it.
|
|
362
|
+
*
|
|
363
|
+
* Pick the transport and the form follows it: a stdio server takes a
|
|
364
|
+
* command, its arguments and env vars (values masked, the eye shows one);
|
|
365
|
+
* an http or sse server takes a URL and headers. The scope says which file
|
|
366
|
+
* it lands in (your config dir, the repo, or the repo's local file) and the
|
|
367
|
+
* profiles which sessions load it. "Test connection" hands the form to
|
|
368
|
+
* `onTest`; the app connects and reports back through `test`: connecting,
|
|
369
|
+
* the tools it listed, or the error. Save waits for a name and a command
|
|
370
|
+
* or URL. The dialog grows out of its trigger; `McpServerDialog.Panel` is
|
|
371
|
+
* the same form without it.
|
|
372
|
+
*
|
|
373
|
+
* Statics:
|
|
374
|
+
* - `McpServerDialog.Panel` — the form on its own: the same props, minus the dialog's, plus `onCancel`.
|
|
375
|
+
*
|
|
376
|
+
* @example {@include ./examples.mdx}
|
|
377
|
+
*/
|
|
378
|
+
const McpServerDialog = Object.assign(
|
|
379
|
+
function McpServerDialog({
|
|
380
|
+
trigger,
|
|
381
|
+
open,
|
|
382
|
+
defaultOpen = false,
|
|
383
|
+
onOpenChange,
|
|
384
|
+
onSave,
|
|
385
|
+
onDelete,
|
|
386
|
+
...panel
|
|
387
|
+
}: McpServerDialogProps) {
|
|
388
|
+
const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange)
|
|
389
|
+
const close = <T,>(handler?: (server: T) => void) =>
|
|
390
|
+
handler &&
|
|
391
|
+
((server: T) => {
|
|
392
|
+
handler(server)
|
|
393
|
+
setOpen(false)
|
|
394
|
+
})
|
|
395
|
+
return (
|
|
396
|
+
<Dialog open={isOpen} onOpenChange={setOpen}>
|
|
397
|
+
{trigger && <Dialog.Trigger render={trigger} />}
|
|
398
|
+
<Dialog.Content width="lg" aria-label="MCP server" className="@container">
|
|
399
|
+
<McpServerDialogPanel
|
|
400
|
+
{...panel}
|
|
401
|
+
onSave={close(onSave)}
|
|
402
|
+
onDelete={close(onDelete)}
|
|
403
|
+
onCancel={() => setOpen(false)}
|
|
404
|
+
/>
|
|
405
|
+
</Dialog.Content>
|
|
406
|
+
</Dialog>
|
|
407
|
+
)
|
|
408
|
+
},
|
|
409
|
+
{ Panel: McpServerDialogPanel },
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
export type { McpServerDialogPanelProps, McpServerDialogProps }
|
|
413
|
+
export { McpServerDialog, McpServerDialogPanel }
|
|
414
|
+
|
|
415
|
+
export default McpServerDialog
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import ShortcutsSheet from './index'
|
|
2
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
3
|
+
import { SHORTCUTS } from '../../../mock/mock-extras'
|
|
4
|
+
|
|
5
|
+
# Sheet
|
|
6
|
+
|
|
7
|
+
Press the button or ⌘/: the dialog grows out of it with the filter focused. Try "pane", "send" or "⌥".
|
|
8
|
+
|
|
9
|
+
<ShortcutsSheet groups={SHORTCUTS} trigger={<Button variant="secondary">Keyboard shortcuts</Button>} />
|
|
10
|
+
|
|
11
|
+
# The list
|
|
12
|
+
|
|
13
|
+
`ShortcutsSheet.Panel` on its own: a chord is one keycap, a sequence several.
|
|
14
|
+
|
|
15
|
+
<div className="flex h-[640px] w-full max-w-[880px] flex-col rounded-xl border border-border bg-background p-6">
|
|
16
|
+
<ShortcutsSheet.Panel groups={SHORTCUTS} className="flex-1" />
|
|
17
|
+
</div>
|
|
18
|
+
|
|
19
|
+
# Filtered
|
|
20
|
+
|
|
21
|
+
Groups with nothing left hide.
|
|
22
|
+
|
|
23
|
+
<div className="flex h-[280px] w-full max-w-[880px] flex-col rounded-xl border border-border bg-background p-6">
|
|
24
|
+
<ShortcutsSheet.Panel groups={SHORTCUTS} defaultQuery="pane" className="flex-1" />
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
# Light and dark
|
|
28
|
+
|
|
29
|
+
<div className="grid w-full gap-3 @3xl:grid-cols-2">
|
|
30
|
+
<div className="light flex h-[360px] flex-col rounded-xl border border-border bg-background p-6 text-foreground">
|
|
31
|
+
<ShortcutsSheet.Panel groups={SHORTCUTS} defaultQuery="session" className="flex-1" />
|
|
32
|
+
</div>
|
|
33
|
+
<div className="dark flex h-[360px] flex-col rounded-xl border border-border bg-background p-6 text-foreground">
|
|
34
|
+
<ShortcutsSheet.Panel groups={SHORTCUTS} defaultQuery="session" className="flex-1" />
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's keyboard shortcuts reference. A Dialog with
|
|
3
|
+
* the shortcuts in groups (sessions, navigation, composer, panes), each a
|
|
4
|
+
* label and its keys as Kbd chips, and a field that filters them by what
|
|
5
|
+
* they do or by their keys.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use client'
|
|
9
|
+
|
|
10
|
+
import Kbd from '@justanarthur/modo-ui/components/data-display/kbd'
|
|
11
|
+
import Input from '@justanarthur/modo-ui/components/inputs/input'
|
|
12
|
+
import Dialog from '@justanarthur/modo-ui/components/overlays/dialog'
|
|
13
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
14
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
15
|
+
import ScrollArea from '@justanarthur/modo-ui/primitives/layout/scroll-area'
|
|
16
|
+
import { type ReactElement, useEffect } from 'react'
|
|
17
|
+
import { useIcon } from '../../../lib/icons'
|
|
18
|
+
|
|
19
|
+
export interface Shortcut {
|
|
20
|
+
/** What it does. */
|
|
21
|
+
label: string
|
|
22
|
+
/** The keys: one string per chord, several for a sequence (`['G', 'S']`). */
|
|
23
|
+
keys: string[]
|
|
24
|
+
/** More words the filter matches. */
|
|
25
|
+
keywords?: string[]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ShortcutGroup {
|
|
29
|
+
label: string
|
|
30
|
+
shortcuts: Shortcut[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function matches(shortcut: Shortcut, query: string) {
|
|
34
|
+
const q = query.trim().toLowerCase()
|
|
35
|
+
if (!q) return true
|
|
36
|
+
return [shortcut.label, shortcut.keys.join(' '), ...(shortcut.keywords ?? [])].some(text =>
|
|
37
|
+
text.toLowerCase().includes(q),
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ShortcutsSheetPanelProps {
|
|
42
|
+
/** The shortcuts, in groups. */
|
|
43
|
+
groups: ShortcutGroup[]
|
|
44
|
+
/** Controlled filter. Pair with `onQueryChange`. */
|
|
45
|
+
query?: string
|
|
46
|
+
/** The filter it starts with. Defaults to `''`. */
|
|
47
|
+
defaultQuery?: string
|
|
48
|
+
/** Called as the filter changes. */
|
|
49
|
+
onQueryChange?: (query: string) => void
|
|
50
|
+
/** Classes for the root. */
|
|
51
|
+
className?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The shortcuts on their own, without the Dialog: the filter and the groups. */
|
|
55
|
+
function ShortcutsSheetPanel({ groups, query, defaultQuery = '', onQueryChange, className }: ShortcutsSheetPanelProps) {
|
|
56
|
+
const [q, setQ] = useControllableState(query, defaultQuery, onQueryChange)
|
|
57
|
+
const SearchIcon = useIcon('search')
|
|
58
|
+
const shown = groups
|
|
59
|
+
.map(group => ({ ...group, shortcuts: group.shortcuts.filter(s => matches(s, q)) }))
|
|
60
|
+
.filter(group => group.shortcuts.length > 0)
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div className={cn('@container flex min-h-0 flex-col gap-[var(--space-4)]', className)}>
|
|
64
|
+
<div className="flex items-center gap-[var(--space-3)] pr-[var(--space-6)]">
|
|
65
|
+
<h2 className="m-0 text-title text-foreground">Keyboard shortcuts</h2>
|
|
66
|
+
<Input
|
|
67
|
+
autoFocus
|
|
68
|
+
variant="bordered"
|
|
69
|
+
size="compact"
|
|
70
|
+
icon={SearchIcon}
|
|
71
|
+
aria-label="Filter shortcuts"
|
|
72
|
+
placeholder="Filter…"
|
|
73
|
+
className="ml-auto w-56"
|
|
74
|
+
value={q}
|
|
75
|
+
onValueChange={setQ}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
<ScrollArea className="min-h-0 flex-1" viewportClassName="scroll-fade">
|
|
79
|
+
{shown.length === 0 ? (
|
|
80
|
+
<p className="m-0 py-[var(--space-6)] text-center text-body text-muted-foreground">
|
|
81
|
+
No shortcut matches “{q.trim()}”.
|
|
82
|
+
</p>
|
|
83
|
+
) : (
|
|
84
|
+
<div className="grid grid-cols-1 gap-x-[var(--space-6)] gap-y-[var(--space-5)] @lg:grid-cols-2">
|
|
85
|
+
{shown.map(group => (
|
|
86
|
+
<section key={group.label} aria-label={group.label} className="flex flex-col">
|
|
87
|
+
<span className="pb-[var(--space-1)] text-caption text-muted-foreground">{group.label}</span>
|
|
88
|
+
<dl className="m-0 flex flex-col">
|
|
89
|
+
{group.shortcuts.map(shortcut => (
|
|
90
|
+
<div
|
|
91
|
+
key={shortcut.label}
|
|
92
|
+
className="flex h-8 items-center gap-[var(--space-3)] border-b border-border last:border-b-0"
|
|
93
|
+
>
|
|
94
|
+
<dt className="min-w-0 flex-1 truncate text-body text-foreground">{shortcut.label}</dt>
|
|
95
|
+
<dd className="m-0 flex shrink-0 items-center gap-[var(--space-1)]">
|
|
96
|
+
{shortcut.keys.map((key, i) => (
|
|
97
|
+
<span key={`${i}-${key}`} className="flex items-center gap-[var(--space-1)]">
|
|
98
|
+
{i > 0 && <span className="text-caption text-muted-foreground">then</span>}
|
|
99
|
+
<Kbd>{key}</Kbd>
|
|
100
|
+
</span>
|
|
101
|
+
))}
|
|
102
|
+
</dd>
|
|
103
|
+
</div>
|
|
104
|
+
))}
|
|
105
|
+
</dl>
|
|
106
|
+
</section>
|
|
107
|
+
))}
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
</ScrollArea>
|
|
111
|
+
</div>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
interface ShortcutsSheetProps {
|
|
116
|
+
/** The shortcuts, in groups. */
|
|
117
|
+
groups: ShortcutGroup[]
|
|
118
|
+
/** The control that opens it. */
|
|
119
|
+
trigger?: ReactElement
|
|
120
|
+
/** Controlled open state. */
|
|
121
|
+
open?: boolean
|
|
122
|
+
/** Initial open state, for an uncontrolled dialog. Defaults to `false`. */
|
|
123
|
+
defaultOpen?: boolean
|
|
124
|
+
/** Called when the dialog opens or closes. */
|
|
125
|
+
onOpenChange?: (open: boolean) => void
|
|
126
|
+
/** The key that toggles it with ⌘ (Ctrl elsewhere); `false` leaves the keyboard alone. Defaults to `'/'`. */
|
|
127
|
+
hotkey?: string | false
|
|
128
|
+
/** The filter it starts with. Defaults to `''`. */
|
|
129
|
+
defaultQuery?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Every keyboard shortcut in the app, in one place: sessions, navigation,
|
|
134
|
+
* the composer and the panes.
|
|
135
|
+
*
|
|
136
|
+
* Each row is what the shortcut does and its keys, a chord as one keycap and
|
|
137
|
+
* a sequence as several. Type to filter by what a shortcut does or by its
|
|
138
|
+
* keys ("⌘", "pane", "send"); groups with nothing left hide. ⌘/ (Ctrl+/
|
|
139
|
+
* elsewhere) opens it from anywhere; the dialog grows out of its trigger.
|
|
140
|
+
* `ShortcutsSheet.Panel` is the same list without the dialog.
|
|
141
|
+
*
|
|
142
|
+
* Statics:
|
|
143
|
+
* - `ShortcutsSheet.Panel` — the list on its own: `groups`, `query`, `defaultQuery`.
|
|
144
|
+
*
|
|
145
|
+
* @example {@include ./examples.mdx}
|
|
146
|
+
*/
|
|
147
|
+
const ShortcutsSheet = Object.assign(
|
|
148
|
+
function ShortcutsSheet({
|
|
149
|
+
groups,
|
|
150
|
+
trigger,
|
|
151
|
+
open,
|
|
152
|
+
defaultOpen = false,
|
|
153
|
+
onOpenChange,
|
|
154
|
+
hotkey = '/',
|
|
155
|
+
defaultQuery,
|
|
156
|
+
}: ShortcutsSheetProps) {
|
|
157
|
+
const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange)
|
|
158
|
+
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
if (!hotkey) return
|
|
161
|
+
const onKey = (event: KeyboardEvent) => {
|
|
162
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === hotkey) {
|
|
163
|
+
event.preventDefault()
|
|
164
|
+
setOpen(!isOpen)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
window.addEventListener('keydown', onKey)
|
|
168
|
+
return () => window.removeEventListener('keydown', onKey)
|
|
169
|
+
}, [hotkey, isOpen, setOpen])
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<Dialog open={isOpen} onOpenChange={setOpen}>
|
|
173
|
+
{trigger && <Dialog.Trigger render={trigger} />}
|
|
174
|
+
<Dialog.Content width="xl" aria-label="Keyboard shortcuts" className="flex h-[min(600px,80dvh)] flex-col">
|
|
175
|
+
<ShortcutsSheetPanel groups={groups} defaultQuery={defaultQuery} className="flex-1" />
|
|
176
|
+
</Dialog.Content>
|
|
177
|
+
</Dialog>
|
|
178
|
+
)
|
|
179
|
+
},
|
|
180
|
+
{ Panel: ShortcutsSheetPanel },
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
export type { ShortcutsSheetPanelProps, ShortcutsSheetProps }
|
|
184
|
+
export { ShortcutsSheet, ShortcutsSheetPanel }
|
|
185
|
+
|
|
186
|
+
export default ShortcutsSheet
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SizeProvider } from '@justanarthur/modo-ui/primitives/systems/sizes'
|
|
2
|
+
import { PANE_ARTIFACTS } from '../../../mock/mock-panes'
|
|
3
|
+
import ArtifactsPane from './index'
|
|
4
|
+
|
|
5
|
+
# Artifacts
|
|
6
|
+
|
|
7
|
+
What Claude made in this session, newest first; a press opens one.
|
|
8
|
+
|
|
9
|
+
<div className="w-full max-w-sm overflow-hidden rounded-xl border border-border bg-background p-2">
|
|
10
|
+
<SizeProvider size="compact">
|
|
11
|
+
<ArtifactsPane artifacts={PANE_ARTIFACTS} />
|
|
12
|
+
</SizeProvider>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
# No artifacts
|
|
16
|
+
|
|
17
|
+
Before Claude makes anything, the pane says what lands there.
|
|
18
|
+
|
|
19
|
+
<div className="w-full max-w-sm overflow-hidden rounded-xl border border-border bg-background p-2">
|
|
20
|
+
<SizeProvider size="compact">
|
|
21
|
+
<ArtifactsPane artifacts={[]} />
|
|
22
|
+
</SizeProvider>
|
|
23
|
+
</div>
|