Skip to content

feat(dashboard): copyable 'connect CLI' command in API-key-created popup + fix X close#60

Merged
dvcdsys merged 2 commits into
developfrom
feat/api-key-cli-connect-hint
Jun 3, 2026
Merged

feat(dashboard): copyable 'connect CLI' command in API-key-created popup + fix X close#60
dvcdsys merged 2 commits into
developfrom
feat/api-key-cli-connect-hint

Conversation

@dvcdsys
Copy link
Copy Markdown
Owner

@dvcdsys dvcdsys commented Jun 3, 2026

What

Two dashboard changes to the "API key created" popup
(server/dashboard/src/modules/api-keys/components/CreateApiKeyDialog.tsx):

  1. 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 it
    the default:

    cix config set server.<alias>.url <origin> && \
      cix config set server.<alias>.key <key> && \
      cix config set default_server <alias>
    

    Flow: create key → copy command → paste in terminal → cix search "…" works.

  2. 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

  • Feature: removes the manual, error-prone step of hand-assembling the CLI
    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.
  • Fix: the reveal screen was effectively un-closable except by reloading,
    which is confusing and looks broken.

How

  • Server URL: the dashboard is served same-origin from cix-server, so
    window.location.origin is exactly the base URL the CLI must talk to — no new
    endpoint or server/CLI change needed.
  • Alias: derived from window.location.host and folded to [a-z0-9-]
    (cix.example.comcix-example-com, localhost:21847localhost-21847).
    The CLI parses server.<alias>.url by splitting on dots, so the alias must be
    dot-free — cixServerAlias() guarantees that.
  • Copy: reuses the existing secure-context navigator.clipboard path with a
    document.execCommand fallback for plain-HTTP deploys (extracted into a shared
    copyText() helper; separate "copied" state for the key vs. the command).
  • X-close fix: removed the if (!next && revealed) return; guard in
    onOpenChange that swallowed every close while a key was revealed. Accidental
    dismissal (Escape / outside-click) stays blocked at the DialogContent layer
    via preventDefault, so only the explicit X (and "I've saved it") close — and
    both now reset state.
  • Scope: frontend-only, one file. No CLI command, Go server, OpenAPI, or
    auth change. Built dist/ is gitignored (CI builds it), so no bundle is
    committed.

Type of change

  • Bug fix
  • New feature

Checklist

  • npm run typecheck (tsc) passes
  • npm run build (vite) passes
  • No secrets or API keys committed (the key is generated at runtime from full_key)
  • Tested against a running API server — pending manual browser verification

🤖 Generated with Claude Code

dvcdsys and others added 2 commits June 3, 2026 11:18
…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>
@dvcdsys dvcdsys merged commit 8e4e5fe into develop Jun 3, 2026
1 check passed
@dvcdsys dvcdsys deleted the feat/api-key-cli-connect-hint branch June 3, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant