feat(dashboard): copyable 'connect CLI' command in API-key-created popup + fix X close#60
Merged
Merged
Conversation
…d popup
After creating an API key, the success popup now shows a second copyable
field: a ready-to-paste command that registers THIS server in the cix CLI
and makes it the default, so the flow is create → copy → paste → use.
The command writes a single `server.<alias>` entry (URL + the new key as
one unit — the key belongs to the server), then sets it as default:
cix config set server.<alias>.url <origin> && \
cix config set server.<alias>.key <key> && \
cix config set default_server <alias>
- <origin> comes from window.location.origin (dashboard is served
same-origin from cix-server, so it's always the correct base URL).
- <alias> is derived from window.location.host, sanitized to [a-z0-9-]
so it's dot-/whitespace-free as the CLI's parseServerKey requires.
Copy logic refactored into a reusable copyText() helper driving two
independent button states (key + command), preserving the existing
secure-context / execCommand fallback. Frontend-only; no CLI or server
change — the command uses existing `cix config set` commands.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The onOpenChange handler returned early whenever a key was revealed (`if (!next && revealed) return;`), which swallowed the close event from the top-right X button — the dialog could then only be dismissed by reloading the page. Accidental dismissal (outside-click, Escape) is already blocked separately at the DialogContent layer via preventDefault, so that early-return only ever harmed the explicit X click. Remove the guard so X (and "I've saved it") close and reset the dialog, while Escape / outside-click stay blocked at the content layer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two dashboard changes to the "API key created" popup
(
server/dashboard/src/modules/api-keys/components/CreateApiKeyDialog.tsx):New feature — after a key is created, the popup now shows a copyable,
ready-to-paste command that registers this server (URL + the freshly
minted key, as a single
server.<alias>entry) in the cix CLI and makes itthe default:
Flow: create key → copy command → paste in terminal →
cix search "…"works.Bug fix — the popup's top-right X button now actually closes the
dialog. Previously, while a key was revealed it could only be dismissed by
reloading the page.
Why
config after minting a key. The API key belongs to the server it was created
on, so the command writes both into one server entry — no guessing the URL,
no separate "set the key" step.
which is confusing and looks broken.
How
window.location.originis exactly the base URL the CLI must talk to — no newendpoint or server/CLI change needed.
window.location.hostand folded to[a-z0-9-](
cix.example.com→cix-example-com,localhost:21847→localhost-21847).The CLI parses
server.<alias>.urlby splitting on dots, so the alias must bedot-free —
cixServerAlias()guarantees that.navigator.clipboardpath with adocument.execCommandfallback for plain-HTTP deploys (extracted into a sharedcopyText()helper; separate "copied" state for the key vs. the command).if (!next && revealed) return;guard inonOpenChangethat swallowed every close while a key was revealed. Accidentaldismissal (Escape / outside-click) stays blocked at the
DialogContentlayervia
preventDefault, so only the explicit X (and "I've saved it") close — andboth now reset state.
auth change. Built
dist/is gitignored (CI builds it), so no bundle iscommitted.
Type of change
Checklist
npm run typecheck(tsc) passesnpm run build(vite) passesfull_key)🤖 Generated with Claude Code