@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,580 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Local addition: the AI app's "Add profile" flow. A Dialog stepper: pick a
|
|
3
|
+
* kind (a Claude account in its own config dir, or an Anthropic-compatible
|
|
4
|
+
* provider), name it, sign in (the `claude login` output in a LogView, or a
|
|
5
|
+
* test request against the provider), done. The sign-in itself runs outside;
|
|
6
|
+
* its state comes in through `signIn`.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use client'
|
|
10
|
+
|
|
11
|
+
import Button from '@justanarthur/modo-ui/components/actions/button'
|
|
12
|
+
import Copy from '@justanarthur/modo-ui/components/actions/copy'
|
|
13
|
+
import List from '@justanarthur/modo-ui/components/data-display/list'
|
|
14
|
+
import LogView from '@justanarthur/modo-ui/components/data-display/log-view'
|
|
15
|
+
import { Spinner } from '@justanarthur/modo-ui/components/feedback/progress'
|
|
16
|
+
import ChoiceList from '@justanarthur/modo-ui/components/inputs/choice-list'
|
|
17
|
+
import Input, { Label } from '@justanarthur/modo-ui/components/inputs/input'
|
|
18
|
+
import Dialog from '@justanarthur/modo-ui/components/overlays/dialog'
|
|
19
|
+
import { useControllableState } from '@justanarthur/modo-ui/lib/use-controllable-state'
|
|
20
|
+
import { cn } from '@justanarthur/modo-ui/lib/utils'
|
|
21
|
+
import { type ReactElement, type ReactNode, useId, useState } from 'react'
|
|
22
|
+
import { type IconName, useIcon } from '../../../lib/icons'
|
|
23
|
+
import type { Profile } from '../../../lib/types'
|
|
24
|
+
|
|
25
|
+
export type OnboardingStep = 'kind' | 'details' | 'sign-in' | 'done'
|
|
26
|
+
|
|
27
|
+
/** The model each Claude tier maps to on a compatible provider (`ANTHROPIC_DEFAULT_<TIER>_MODEL`). */
|
|
28
|
+
export interface ModelMapping {
|
|
29
|
+
opus: string
|
|
30
|
+
sonnet: string
|
|
31
|
+
haiku: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** What the form holds while a profile is being added. */
|
|
35
|
+
export interface ProfileDraft {
|
|
36
|
+
kind: Profile['provider']
|
|
37
|
+
name: string
|
|
38
|
+
configDir: string
|
|
39
|
+
baseUrl: string
|
|
40
|
+
/** The env var the API key is read from; the key itself never enters the app. */
|
|
41
|
+
apiKeyEnv: string
|
|
42
|
+
models: ModelMapping
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Where the sign-in (or, for a compatible provider, the test request) stands. */
|
|
46
|
+
export interface SignInStatus {
|
|
47
|
+
state: 'idle' | 'waiting' | 'success' | 'failed'
|
|
48
|
+
/** The CLI's output so far, one string per line (ANSI colors read). */
|
|
49
|
+
log: string[]
|
|
50
|
+
/** The sign-in page `claude login` opened, to open again or copy. */
|
|
51
|
+
url?: string
|
|
52
|
+
/** The signed-in account, once it succeeded. */
|
|
53
|
+
account?: string
|
|
54
|
+
/** The account's plan, once it succeeded. */
|
|
55
|
+
plan?: string
|
|
56
|
+
/** Why it failed. */
|
|
57
|
+
error?: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const STEPS: { id: OnboardingStep; label: string }[] = [
|
|
61
|
+
{ id: 'kind', label: 'Kind' },
|
|
62
|
+
{ id: 'details', label: 'Details' },
|
|
63
|
+
{ id: 'sign-in', label: 'Sign in' },
|
|
64
|
+
{ id: 'done', label: 'Done' },
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
const EMPTY_DRAFT: ProfileDraft = {
|
|
68
|
+
kind: 'anthropic',
|
|
69
|
+
name: '',
|
|
70
|
+
configDir: '',
|
|
71
|
+
baseUrl: '',
|
|
72
|
+
apiKeyEnv: '',
|
|
73
|
+
models: { opus: '', sonnet: '', haiku: '' },
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const IDLE: SignInStatus = { state: 'idle', log: [] }
|
|
77
|
+
|
|
78
|
+
function configDirFor(draft: ProfileDraft) {
|
|
79
|
+
return draft.configDir || (draft.name ? `~/.claude-${draft.name}` : '')
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function ready(draft: ProfileDraft) {
|
|
83
|
+
if (!draft.name) return false
|
|
84
|
+
if (draft.kind === 'anthropic') return true
|
|
85
|
+
return Boolean(draft.baseUrl && draft.apiKeyEnv)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function toProfile(draft: ProfileDraft, signIn: SignInStatus): Profile {
|
|
89
|
+
const compatible = draft.kind === 'compatible'
|
|
90
|
+
return {
|
|
91
|
+
id: draft.name,
|
|
92
|
+
name: draft.name,
|
|
93
|
+
configDir: configDirFor(draft),
|
|
94
|
+
provider: draft.kind,
|
|
95
|
+
baseUrl: compatible ? draft.baseUrl : undefined,
|
|
96
|
+
plan: signIn.plan ?? (compatible ? 'API key' : ''),
|
|
97
|
+
account: signIn.account ?? (compatible ? draft.baseUrl : ''),
|
|
98
|
+
defaultModel: compatible ? draft.models.sonnet || draft.models.opus : (signIn.plan ?? ''),
|
|
99
|
+
limits: [],
|
|
100
|
+
running: 0,
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function Stepper({ step }: { step: OnboardingStep }) {
|
|
105
|
+
const Check = useIcon('check')
|
|
106
|
+
const at = STEPS.findIndex(s => s.id === step)
|
|
107
|
+
return (
|
|
108
|
+
<ol aria-label="Steps" className="m-0 flex list-none items-center gap-[var(--space-2)] p-0">
|
|
109
|
+
{STEPS.map((s, i) => (
|
|
110
|
+
<li
|
|
111
|
+
key={s.id}
|
|
112
|
+
aria-current={i === at ? 'step' : undefined}
|
|
113
|
+
className={cn(
|
|
114
|
+
'flex items-center gap-[var(--space-1)] text-caption transition-[color] duration-fast',
|
|
115
|
+
i <= at ? 'text-foreground' : 'text-muted-foreground',
|
|
116
|
+
)}
|
|
117
|
+
>
|
|
118
|
+
<span
|
|
119
|
+
className={cn(
|
|
120
|
+
'flex size-4 items-center justify-center rounded-full text-micro tabular-nums transition-[background-color,color] duration-fast',
|
|
121
|
+
i < at && 'bg-foreground text-background',
|
|
122
|
+
i === at && 'bg-brand text-background',
|
|
123
|
+
i > at && 'border border-border',
|
|
124
|
+
)}
|
|
125
|
+
>
|
|
126
|
+
{i < at ? <Check size={10} strokeWidth={2.5} /> : i + 1}
|
|
127
|
+
</span>
|
|
128
|
+
{s.label}
|
|
129
|
+
{i < STEPS.length - 1 && <span aria-hidden="true" className="ml-[var(--space-1)] h-px w-4 bg-border" />}
|
|
130
|
+
</li>
|
|
131
|
+
))}
|
|
132
|
+
</ol>
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function KindOption({ icon, title, note }: { icon: IconName; title: string; note: string }) {
|
|
137
|
+
const Icon = useIcon(icon)
|
|
138
|
+
return (
|
|
139
|
+
<span className="flex min-w-0 flex-1 items-start gap-[var(--space-3)]">
|
|
140
|
+
<Icon size={16} strokeWidth={1.5} className="mt-0.5 shrink-0 text-muted-foreground" />
|
|
141
|
+
<span className="flex min-w-0 flex-col">
|
|
142
|
+
<span className="text-body text-foreground">{title}</span>
|
|
143
|
+
<span className="text-caption text-muted-foreground">{note}</span>
|
|
144
|
+
</span>
|
|
145
|
+
</span>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function Field({
|
|
150
|
+
label,
|
|
151
|
+
hint,
|
|
152
|
+
value,
|
|
153
|
+
placeholder,
|
|
154
|
+
invalid,
|
|
155
|
+
onChange,
|
|
156
|
+
}: {
|
|
157
|
+
label: string
|
|
158
|
+
hint?: ReactNode
|
|
159
|
+
value: string
|
|
160
|
+
placeholder?: string
|
|
161
|
+
invalid?: boolean
|
|
162
|
+
onChange: (value: string) => void
|
|
163
|
+
}) {
|
|
164
|
+
const id = useId()
|
|
165
|
+
return (
|
|
166
|
+
<div className="flex flex-col gap-[var(--space-1)]">
|
|
167
|
+
<Label htmlFor={id} invalid={invalid}>
|
|
168
|
+
{label}
|
|
169
|
+
</Label>
|
|
170
|
+
<Input
|
|
171
|
+
id={id}
|
|
172
|
+
variant="bordered"
|
|
173
|
+
value={value}
|
|
174
|
+
placeholder={placeholder}
|
|
175
|
+
invalid={invalid}
|
|
176
|
+
onValueChange={onChange}
|
|
177
|
+
/>
|
|
178
|
+
{hint && <span className="text-caption text-muted-foreground">{hint}</span>}
|
|
179
|
+
</div>
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function Details({
|
|
184
|
+
draft,
|
|
185
|
+
taken,
|
|
186
|
+
onChange,
|
|
187
|
+
}: {
|
|
188
|
+
draft: ProfileDraft
|
|
189
|
+
taken: string[]
|
|
190
|
+
onChange: (draft: ProfileDraft) => void
|
|
191
|
+
}) {
|
|
192
|
+
const set = (patch: Partial<ProfileDraft>) => onChange({ ...draft, ...patch })
|
|
193
|
+
const clash = taken.includes(draft.name)
|
|
194
|
+
const name = (
|
|
195
|
+
<Field
|
|
196
|
+
label="Name"
|
|
197
|
+
value={draft.name}
|
|
198
|
+
placeholder={draft.kind === 'anthropic' ? 'work' : 'zcode'}
|
|
199
|
+
invalid={clash}
|
|
200
|
+
hint={clash ? 'A profile with this name exists.' : 'Shown in the sidebar and the profile switcher.'}
|
|
201
|
+
onChange={value => set({ name: value.trim() })}
|
|
202
|
+
/>
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
if (draft.kind === 'anthropic')
|
|
206
|
+
return (
|
|
207
|
+
<div className="flex flex-col gap-[var(--space-4)]">
|
|
208
|
+
{name}
|
|
209
|
+
<Field
|
|
210
|
+
label="Config dir"
|
|
211
|
+
value={draft.configDir}
|
|
212
|
+
placeholder={configDirFor(draft) || '~/.claude-work'}
|
|
213
|
+
hint={
|
|
214
|
+
<>
|
|
215
|
+
Its own sign-in, settings, memory and limits. The app runs{' '}
|
|
216
|
+
<code className="font-mono">CLAUDE_CONFIG_DIR={configDirFor(draft) || '…'} claude</code>.
|
|
217
|
+
</>
|
|
218
|
+
}
|
|
219
|
+
onChange={value => set({ configDir: value })}
|
|
220
|
+
/>
|
|
221
|
+
</div>
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
const tier = (key: keyof ModelMapping, label: string, placeholder: string) => (
|
|
225
|
+
<List.Row key={key} label={label}>
|
|
226
|
+
<Input
|
|
227
|
+
aria-label={`${label} model`}
|
|
228
|
+
variant="bordered"
|
|
229
|
+
size="compact"
|
|
230
|
+
className="w-48"
|
|
231
|
+
value={draft.models[key]}
|
|
232
|
+
placeholder={placeholder}
|
|
233
|
+
onValueChange={value => set({ models: { ...draft.models, [key]: value } })}
|
|
234
|
+
/>
|
|
235
|
+
</List.Row>
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
return (
|
|
239
|
+
<div className="flex flex-col gap-[var(--space-4)]">
|
|
240
|
+
{name}
|
|
241
|
+
<Field
|
|
242
|
+
label="Base URL"
|
|
243
|
+
value={draft.baseUrl}
|
|
244
|
+
placeholder="https://api.z.ai/api/anthropic"
|
|
245
|
+
hint="Set as ANTHROPIC_BASE_URL for this profile's sessions."
|
|
246
|
+
onChange={value => set({ baseUrl: value.trim() })}
|
|
247
|
+
/>
|
|
248
|
+
<Field
|
|
249
|
+
label="API key env var"
|
|
250
|
+
value={draft.apiKeyEnv}
|
|
251
|
+
placeholder="ZAI_API_KEY"
|
|
252
|
+
hint="Read from your shell and passed as ANTHROPIC_AUTH_TOKEN; the key never enters the app."
|
|
253
|
+
onChange={value => set({ apiKeyEnv: value.trim() })}
|
|
254
|
+
/>
|
|
255
|
+
<List.Section title="Model mapping" aside="What each Claude tier asks for">
|
|
256
|
+
{tier('opus', 'Opus', 'GLM-4.6')}
|
|
257
|
+
{tier('sonnet', 'Sonnet', 'GLM-4.6')}
|
|
258
|
+
{tier('haiku', 'Haiku', 'GLM-4.5-Air')}
|
|
259
|
+
</List.Section>
|
|
260
|
+
</div>
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function SignIn({ draft, status, onRetry }: { draft: ProfileDraft; status: SignInStatus; onRetry?: () => void }) {
|
|
265
|
+
const CircleCheck = useIcon('circle-check')
|
|
266
|
+
const CircleX = useIcon('circle-x')
|
|
267
|
+
const External = useIcon('external-link')
|
|
268
|
+
const Retry = useIcon('rotate-ccw')
|
|
269
|
+
const compatible = draft.kind === 'compatible'
|
|
270
|
+
|
|
271
|
+
const head: Record<SignInStatus['state'], { icon: ReactNode; title: string; detail: ReactNode }> = {
|
|
272
|
+
idle: {
|
|
273
|
+
icon: <Spinner className="size-4" />,
|
|
274
|
+
title: compatible ? 'Starting the test request…' : 'Starting claude login…',
|
|
275
|
+
detail: compatible ? draft.baseUrl : configDirFor(draft),
|
|
276
|
+
},
|
|
277
|
+
waiting: {
|
|
278
|
+
icon: <Spinner className="size-4" />,
|
|
279
|
+
title: compatible ? `Testing ${draft.baseUrl}…` : 'Waiting for the browser…',
|
|
280
|
+
detail: compatible
|
|
281
|
+
? `One short request with the key from $${draft.apiKeyEnv}.`
|
|
282
|
+
: 'Finish signing in on the page that opened; this step moves on by itself.',
|
|
283
|
+
},
|
|
284
|
+
success: {
|
|
285
|
+
icon: <CircleCheck size={16} strokeWidth={1.5} className="text-status-success" />,
|
|
286
|
+
title: compatible ? 'The provider answered' : `Signed in as ${status.account ?? 'your account'}`,
|
|
287
|
+
detail: status.plan ?? (compatible ? draft.models.sonnet : undefined),
|
|
288
|
+
},
|
|
289
|
+
failed: {
|
|
290
|
+
icon: <CircleX size={16} strokeWidth={1.5} className="text-status-error" />,
|
|
291
|
+
title: compatible ? 'The provider refused the request' : 'Sign-in did not finish',
|
|
292
|
+
detail: status.error,
|
|
293
|
+
},
|
|
294
|
+
}
|
|
295
|
+
const { icon, title, detail } = head[status.state]
|
|
296
|
+
|
|
297
|
+
return (
|
|
298
|
+
<div className="flex flex-col gap-[var(--space-3)]">
|
|
299
|
+
<div className="flex items-start gap-[var(--space-3)]">
|
|
300
|
+
<span className="mt-0.5 flex shrink-0">{icon}</span>
|
|
301
|
+
<div aria-live="polite" className="flex min-w-0 flex-1 flex-col">
|
|
302
|
+
<span className="text-body weight-medium text-foreground">{title}</span>
|
|
303
|
+
{detail && <span className="text-caption text-muted-foreground">{detail}</span>}
|
|
304
|
+
</div>
|
|
305
|
+
{status.state === 'failed' && onRetry && (
|
|
306
|
+
<Button variant="secondary" size="compact" leadingIcon={Retry} onClick={onRetry}>
|
|
307
|
+
Try again
|
|
308
|
+
</Button>
|
|
309
|
+
)}
|
|
310
|
+
{status.state === 'waiting' && status.url && (
|
|
311
|
+
<Button variant="ghost" size="compact" leadingIcon={External} asChild>
|
|
312
|
+
<a href={status.url} target="_blank" rel="noreferrer">
|
|
313
|
+
Open again
|
|
314
|
+
</a>
|
|
315
|
+
</Button>
|
|
316
|
+
)}
|
|
317
|
+
</div>
|
|
318
|
+
{status.state === 'waiting' && status.url && <Copy value={status.url} label="Sign-in link" size="compact" />}
|
|
319
|
+
<LogView label={compatible ? 'Test request' : 'claude login'} lines={status.log} maxHeight={180} wrap />
|
|
320
|
+
</div>
|
|
321
|
+
)
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function Summary({ draft, status }: { draft: ProfileDraft; status: SignInStatus }) {
|
|
325
|
+
const compatible = draft.kind === 'compatible'
|
|
326
|
+
return (
|
|
327
|
+
<List>
|
|
328
|
+
<List.Section title={draft.name}>
|
|
329
|
+
<List.Row label="Kind">
|
|
330
|
+
<span className="pr-[var(--space-3)] text-muted-foreground">
|
|
331
|
+
{compatible ? 'Compatible provider' : 'Claude account'}
|
|
332
|
+
</span>
|
|
333
|
+
</List.Row>
|
|
334
|
+
<List.Row label={compatible ? 'Base URL' : 'Config dir'}>
|
|
335
|
+
<span className="min-w-0 truncate pr-[var(--space-3)] font-mono text-muted-foreground">
|
|
336
|
+
{compatible ? draft.baseUrl : configDirFor(draft)}
|
|
337
|
+
</span>
|
|
338
|
+
</List.Row>
|
|
339
|
+
{compatible ? (
|
|
340
|
+
<List.Row label="Models">
|
|
341
|
+
<span className="min-w-0 truncate pr-[var(--space-3)] text-muted-foreground">
|
|
342
|
+
{[draft.models.opus, draft.models.sonnet, draft.models.haiku].filter(Boolean).join(' · ') ||
|
|
343
|
+
'Provider default'}
|
|
344
|
+
</span>
|
|
345
|
+
</List.Row>
|
|
346
|
+
) : (
|
|
347
|
+
<List.Row label="Account">
|
|
348
|
+
<span className="min-w-0 truncate pr-[var(--space-3)] text-muted-foreground">
|
|
349
|
+
{[status.account, status.plan].filter(Boolean).join(' · ')}
|
|
350
|
+
</span>
|
|
351
|
+
</List.Row>
|
|
352
|
+
)}
|
|
353
|
+
</List.Section>
|
|
354
|
+
</List>
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
interface ProfileOnboardingPanelProps {
|
|
359
|
+
/** The step shown (controlled). Pair with `onStepChange`. */
|
|
360
|
+
step?: OnboardingStep
|
|
361
|
+
/** The step it starts on. Defaults to `'kind'`. */
|
|
362
|
+
defaultStep?: OnboardingStep
|
|
363
|
+
/** Called when Back or Continue moves to another step. */
|
|
364
|
+
onStepChange?: (step: OnboardingStep) => void
|
|
365
|
+
/** What the form starts with: a kind, a name, a provider's base URL and models. */
|
|
366
|
+
defaultDraft?: Partial<ProfileDraft>
|
|
367
|
+
/** Names already taken, so a clash is caught before the sign-in. */
|
|
368
|
+
taken?: string[]
|
|
369
|
+
/** Where the sign-in stands; the app runs `claude login` (or the test request) and reports back. Defaults to idle. */
|
|
370
|
+
signIn?: SignInStatus
|
|
371
|
+
/** Called on entering the sign-in step, with what the form holds: start `claude login` or the test request here. */
|
|
372
|
+
onSignIn?: (draft: ProfileDraft) => void
|
|
373
|
+
/** Called with the new profile when Add profile is pressed on the last step. */
|
|
374
|
+
onComplete?: (profile: Profile) => void
|
|
375
|
+
/** Called when Cancel is pressed on the first step. */
|
|
376
|
+
onCancel?: () => void
|
|
377
|
+
/** Classes for the root. */
|
|
378
|
+
className?: string
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/** The stepper's body, without the Dialog: for a page of its own, or the docs. */
|
|
382
|
+
function ProfileOnboardingPanel({
|
|
383
|
+
step,
|
|
384
|
+
defaultStep = 'kind',
|
|
385
|
+
onStepChange,
|
|
386
|
+
defaultDraft,
|
|
387
|
+
taken = [],
|
|
388
|
+
signIn = IDLE,
|
|
389
|
+
onSignIn,
|
|
390
|
+
onComplete,
|
|
391
|
+
onCancel,
|
|
392
|
+
className,
|
|
393
|
+
}: ProfileOnboardingPanelProps) {
|
|
394
|
+
const [current, setCurrent] = useControllableState(step, defaultStep, onStepChange)
|
|
395
|
+
const [draft, setDraft] = useState<ProfileDraft>({
|
|
396
|
+
...EMPTY_DRAFT,
|
|
397
|
+
...defaultDraft,
|
|
398
|
+
models: { ...EMPTY_DRAFT.models, ...defaultDraft?.models },
|
|
399
|
+
})
|
|
400
|
+
const at = STEPS.findIndex(s => s.id === current)
|
|
401
|
+
const compatible = draft.kind === 'compatible'
|
|
402
|
+
|
|
403
|
+
const go = (next: OnboardingStep) => {
|
|
404
|
+
if (next === 'sign-in') onSignIn?.(draft)
|
|
405
|
+
setCurrent(next)
|
|
406
|
+
}
|
|
407
|
+
const back = STEPS[at - 1]?.id
|
|
408
|
+
const canContinue =
|
|
409
|
+
current === 'kind' ||
|
|
410
|
+
(current === 'details' && ready(draft) && !taken.includes(draft.name)) ||
|
|
411
|
+
(current === 'sign-in' && signIn.state === 'success')
|
|
412
|
+
|
|
413
|
+
const titles: Record<OnboardingStep, { title: string; description: string }> = {
|
|
414
|
+
kind: {
|
|
415
|
+
title: 'Add a profile',
|
|
416
|
+
description: 'Each profile is its own claude process, with its own sign-in and limits.',
|
|
417
|
+
},
|
|
418
|
+
details: compatible
|
|
419
|
+
? {
|
|
420
|
+
title: 'Point it at the provider',
|
|
421
|
+
description: 'Sessions under this profile talk to the base URL instead of Anthropic.',
|
|
422
|
+
}
|
|
423
|
+
: {
|
|
424
|
+
title: 'Name it and give it a home',
|
|
425
|
+
description: 'A new config dir keeps this account apart from your others.',
|
|
426
|
+
},
|
|
427
|
+
'sign-in': compatible
|
|
428
|
+
? { title: 'Test the connection', description: 'One request checks the URL, the key and the model mapping.' }
|
|
429
|
+
: { title: 'Sign in', description: 'claude login opens your browser for the account this profile uses.' },
|
|
430
|
+
done: { title: 'Ready', description: 'New sessions can run under it from the profile switcher.' },
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return (
|
|
434
|
+
<div className={cn('flex flex-col gap-[var(--space-5)]', className)}>
|
|
435
|
+
<Stepper step={current} />
|
|
436
|
+
<div className="flex flex-col gap-[var(--space-1)]">
|
|
437
|
+
<h2 className="m-0 text-title text-foreground">{titles[current].title}</h2>
|
|
438
|
+
<p className="m-0 text-body text-muted-foreground">{titles[current].description}</p>
|
|
439
|
+
</div>
|
|
440
|
+
|
|
441
|
+
{current === 'kind' && (
|
|
442
|
+
<ChoiceList
|
|
443
|
+
label="Kind"
|
|
444
|
+
value={draft.kind}
|
|
445
|
+
onValueChange={kind => setDraft({ ...draft, kind: kind === 'compatible' ? 'compatible' : 'anthropic' })}
|
|
446
|
+
options={[
|
|
447
|
+
{
|
|
448
|
+
value: 'anthropic',
|
|
449
|
+
label: 'Claude account',
|
|
450
|
+
content: (
|
|
451
|
+
<KindOption
|
|
452
|
+
icon="user"
|
|
453
|
+
title="Claude account"
|
|
454
|
+
note="Sign in to claude.ai in a new config dir: another plan, another org."
|
|
455
|
+
/>
|
|
456
|
+
),
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
value: 'compatible',
|
|
460
|
+
label: 'Anthropic-compatible provider',
|
|
461
|
+
content: (
|
|
462
|
+
<KindOption
|
|
463
|
+
icon="server"
|
|
464
|
+
title="Anthropic-compatible provider"
|
|
465
|
+
note="A base URL and an API key, such as Z.ai's GLM coding plan."
|
|
466
|
+
/>
|
|
467
|
+
),
|
|
468
|
+
},
|
|
469
|
+
]}
|
|
470
|
+
/>
|
|
471
|
+
)}
|
|
472
|
+
{current === 'details' && <Details draft={draft} taken={taken} onChange={setDraft} />}
|
|
473
|
+
{current === 'sign-in' && <SignIn draft={draft} status={signIn} onRetry={() => onSignIn?.(draft)} />}
|
|
474
|
+
{current === 'done' && <Summary draft={draft} status={signIn} />}
|
|
475
|
+
|
|
476
|
+
<div className="flex items-center justify-end gap-[var(--space-2)]">
|
|
477
|
+
{back ? (
|
|
478
|
+
<Button variant="ghost" onClick={() => setCurrent(back)}>
|
|
479
|
+
Back
|
|
480
|
+
</Button>
|
|
481
|
+
) : (
|
|
482
|
+
onCancel && (
|
|
483
|
+
<Button variant="ghost" onClick={onCancel}>
|
|
484
|
+
Cancel
|
|
485
|
+
</Button>
|
|
486
|
+
)
|
|
487
|
+
)}
|
|
488
|
+
{current === 'done' ? (
|
|
489
|
+
<Button onClick={() => onComplete?.(toProfile(draft, signIn))}>Add profile</Button>
|
|
490
|
+
) : (
|
|
491
|
+
<Button disabled={!canContinue} onClick={() => go(STEPS[at + 1]?.id ?? 'done')}>
|
|
492
|
+
{current === 'details' ? (compatible ? 'Test connection' : 'Sign in') : 'Continue'}
|
|
493
|
+
</Button>
|
|
494
|
+
)}
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
interface ProfileOnboardingProps {
|
|
501
|
+
/** The control that opens it, such as the switcher's "Add profile" button. */
|
|
502
|
+
trigger?: ReactElement
|
|
503
|
+
/** Controlled open state. */
|
|
504
|
+
open?: boolean
|
|
505
|
+
/** Initial open state, for an uncontrolled dialog. Defaults to `false`. */
|
|
506
|
+
defaultOpen?: boolean
|
|
507
|
+
/** Called when the dialog opens or closes. */
|
|
508
|
+
onOpenChange?: (open: boolean) => void
|
|
509
|
+
/** The step shown (controlled). Pair with `onStepChange`. */
|
|
510
|
+
step?: OnboardingStep
|
|
511
|
+
/** The step it starts on. Defaults to `'kind'`. */
|
|
512
|
+
defaultStep?: OnboardingStep
|
|
513
|
+
/** Called when Back or Continue moves to another step. */
|
|
514
|
+
onStepChange?: (step: OnboardingStep) => void
|
|
515
|
+
/** What the form starts with: a kind, a name, a provider's base URL and models. */
|
|
516
|
+
defaultDraft?: Partial<ProfileDraft>
|
|
517
|
+
/** Names already taken, so a clash is caught before the sign-in. */
|
|
518
|
+
taken?: string[]
|
|
519
|
+
/** Where the sign-in stands; the app runs `claude login` (or the test request) and reports back. Defaults to idle. */
|
|
520
|
+
signIn?: SignInStatus
|
|
521
|
+
/** Called on entering the sign-in step, with what the form holds: start `claude login` or the test request here. */
|
|
522
|
+
onSignIn?: (draft: ProfileDraft) => void
|
|
523
|
+
/** Called with the new profile when Add profile is pressed on the last step; the dialog closes. */
|
|
524
|
+
onComplete?: (profile: Profile) => void
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Adds a profile: a Claude account in a config dir of its own, or an
|
|
529
|
+
* Anthropic-compatible provider behind a base URL.
|
|
530
|
+
*
|
|
531
|
+
* Four steps, shown along the top. Pick the kind; name it and give it a
|
|
532
|
+
* config dir (or a base URL, the env var that holds the API key, and which
|
|
533
|
+
* model each Claude tier maps to); sign in; done. Entering the sign-in step
|
|
534
|
+
* calls `onSignIn`, where the app starts `claude login` under the new
|
|
535
|
+
* `CLAUDE_CONFIG_DIR` (or a test request against the provider) and feeds
|
|
536
|
+
* its progress back through `signIn`: the CLI's output scrolls in a log,
|
|
537
|
+
* "waiting for the browser" with the link to open again or copy, then
|
|
538
|
+
* success with the account and plan, or the error and a retry. Continue
|
|
539
|
+
* waits for success. The last step hands the new profile to `onComplete`.
|
|
540
|
+
* The dialog grows out of its trigger; `ProfileOnboarding.Panel` is the same
|
|
541
|
+
* stepper without it.
|
|
542
|
+
*
|
|
543
|
+
* Statics:
|
|
544
|
+
* - `ProfileOnboarding.Panel` — the stepper on its own: the same props, minus the dialog's.
|
|
545
|
+
*
|
|
546
|
+
* @example {@include ./examples.mdx}
|
|
547
|
+
*/
|
|
548
|
+
const ProfileOnboarding = Object.assign(
|
|
549
|
+
function ProfileOnboarding({
|
|
550
|
+
trigger,
|
|
551
|
+
open,
|
|
552
|
+
defaultOpen = false,
|
|
553
|
+
onOpenChange,
|
|
554
|
+
onComplete,
|
|
555
|
+
...panel
|
|
556
|
+
}: ProfileOnboardingProps) {
|
|
557
|
+
const [isOpen, setOpen] = useControllableState(open, defaultOpen, onOpenChange)
|
|
558
|
+
return (
|
|
559
|
+
<Dialog open={isOpen} onOpenChange={setOpen}>
|
|
560
|
+
{trigger && <Dialog.Trigger render={trigger} />}
|
|
561
|
+
<Dialog.Content width="lg" aria-label="Add a profile">
|
|
562
|
+
<ProfileOnboardingPanel
|
|
563
|
+
{...panel}
|
|
564
|
+
onCancel={() => setOpen(false)}
|
|
565
|
+
onComplete={profile => {
|
|
566
|
+
onComplete?.(profile)
|
|
567
|
+
setOpen(false)
|
|
568
|
+
}}
|
|
569
|
+
/>
|
|
570
|
+
</Dialog.Content>
|
|
571
|
+
</Dialog>
|
|
572
|
+
)
|
|
573
|
+
},
|
|
574
|
+
{ Panel: ProfileOnboardingPanel },
|
|
575
|
+
)
|
|
576
|
+
|
|
577
|
+
export type { ProfileOnboardingPanelProps, ProfileOnboardingProps }
|
|
578
|
+
export { ProfileOnboarding, ProfileOnboardingPanel }
|
|
579
|
+
|
|
580
|
+
export default ProfileOnboarding
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import ProfileSwitcher from './index'
|
|
2
|
+
import { PROFILES } from '../../../mock/mock'
|
|
3
|
+
|
|
4
|
+
# Switcher
|
|
5
|
+
|
|
6
|
+
Press the trigger: the panel grows out of it. Pick a profile and its background melts over; the arrow keys move the pick.
|
|
7
|
+
|
|
8
|
+
<div className="flex h-[560px] w-full items-start justify-center pt-6">
|
|
9
|
+
<ProfileSwitcher profiles={PROFILES} />
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
# Near a limit
|
|
13
|
+
|
|
14
|
+
`work` starts active here: its session meter is past 90%, so it reads red before you start anything there.
|
|
15
|
+
|
|
16
|
+
<div className="flex h-[560px] w-full items-start justify-center pt-6">
|
|
17
|
+
<ProfileSwitcher profiles={PROFILES} defaultValue="work" />
|
|
18
|
+
</div>
|