Skip to content

feat(cli-auth): polish paste-code page + CLI keybindings#4075

Merged
saddlepaddle merged 2 commits into
mainfrom
mature-romano
May 5, 2026
Merged

feat(cli-auth): polish paste-code page + CLI keybindings#4075
saddlepaddle merged 2 commits into
mainfrom
mature-romano

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented May 5, 2026

Summary

  • Rewrote the /cli/auth/code page to match Claude Code's auth-code UI: single-line w-fit code box, ghost copy button that flips to "✓ Copied!" on press, click-anywhere-on-the-box to copy, and selection happens on release (programmatic Range) so it stays as a ctrl+c fallback if clipboard.writeText silently fails.
  • Wired standard terminal readline shortcuts in the CLI paste-code prompt: option+backspace / ctrl+w delete the previous word, cmd+backspace / ctrl+u / ctrl+k clear the buffer. Plain backspace still deletes one char.

No DB or schema changes. Prod superset-cli oauth_clients row is unaffected (verified).

Test plan

  • superset auth login against local dev: paste flow renders the new page, click on text or button copies, selection highlights on release.
  • superset auth login paste prompt: option+backspace deletes a word, ctrl+u clears the buffer.
  • superset auth login against prod still works (no redirect_uri changes).

🤖 Generated with Claude Code


Summary by cubic

Polished the CLI auth paste-code flow. Rebuilt the web auth-code page to match Claude Code and added readline shortcuts in the CLI prompt; copy feedback is now accurate and word deletion matches readline.

  • New Features

    • Web page (/cli/auth/code): single-line code box; click box or ghost button to copy; programmatic selection on copy for reliable Ctrl/Cmd+C fallback.
    • CLI prompt: Option+Backspace/Ctrl+W delete previous word; Cmd+Backspace/Ctrl+U/Ctrl+K clear input; Backspace still deletes one char.
  • Bug Fixes

    • Copy button only shows “Copied!” when clipboard write succeeds; selection still happens for manual copy fallback.
    • Word-delete now preserves the preceding space (e.g., "hello world" + Ctrl+W → "hello ").

Written for commit c3cb97d. Summary will update on new commits.

Summary by CodeRabbit

  • New Features

    • Added CLI login shortcuts: Ctrl+U or Ctrl+K to clear input; improved word/suffix deletion via Meta+Backspace/Delete and Ctrl+W.
  • Refactor

    • Simplified CLI auth code display: unified copy state, more reliable copy + manual-selection fallback, streamlined copy button and keyboard interaction, and removed tooltip for a cleaner UI.

Web `/cli/auth/code` page rewritten to match Claude Code's auth-code UI:
single-line `w-fit` code box, ghost copy button that flips to "Copied!"
on press, click-anywhere-on-box to copy, and selection happens on release
(programmatic Range) so it stays as a ctrl+c fallback if clipboard write
silently fails.

CLI `LoginUI` now wires the standard terminal readline shortcuts in the
paste-code prompt: option+backspace / ctrl+w delete the previous word,
cmd+backspace / ctrl+u / ctrl+k clear the buffer. Plain backspace still
deletes one char.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f13a6e70-9805-437b-ac6b-3c0be3b10cf8

📥 Commits

Reviewing files that changed from the base of the PR and between 5054f99 and c3cb97d.

📒 Files selected for processing (2)
  • apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
  • packages/cli/src/commands/auth/login/LoginUI.tsx
✅ Files skipped from review due to trivial changes (1)
  • packages/cli/src/commands/auth/login/LoginUI.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx

📝 Walkthrough

Walkthrough

Refactors the CLI auth code display to use a single copied state, unified copy/selection logic, and keyboard-accessible code area; separately adds input-edit keybindings (Ctrl+u/Ctrl+k clear, Meta+Backspace/Delete and Ctrl+w delete a trailing word) in the CLI login UI.

Changes

CLI Auth Code Display Refactor

Layer / File(s) Summary
Component State
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
Replaces useCopiedFlag() with an inline copied boolean and timerRef; adds codeRef and unmount cleanup.
Copy & Selection Logic
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
Adds selectCode() to programmatically select the <code> node; handleCopy() attempts copyToClipboard(value), selects code afterward, and only toggles copied on successful clipboard writes with a reset timeout.
UI & Accessibility
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
Replaces tooltip-wrapped <button> with a div using role="button" and tabIndex handling Enter/Space; <code> uses ref={codeRef}.
Copy Button
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
Simplifies copy button to variant="ghost" and toggles LuCheck/“Copied!” vs LuClipboard/“Copy Code” based on single copied state.

Login UI Keyboard Shortcuts

Layer / File(s) Summary
Input Edit Keybindings
packages/cli/src/commands/auth/login/LoginUI.tsx
Adds Ctrl+u and Ctrl+k to clear the input and reset validationError; intercepts Meta+Backspace/Delete and Ctrl+w to trim the trailing word via v.replace(/\S+\s*$/, "").
Existing Behavior Preservation
packages/cli/src/commands/auth/login/LoginUI.tsx
Keeps single-character backspace/delete, Enter-submit validation, Escape/Ctrl+C cancel, and paste/copy behaviors unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I nibbled at tooltips, cleaned the trail,
One copied state now tells a single tale.
Keys hop and clear the line with nimble cheer,
Code selected, copied — quick and clear.
Hooray, a tidy CLI — hop, clap, and cheer!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: polishing the CLI auth paste-code page and adding CLI keybindings, matching the actual refactoring of the web component and new CLI keybinding features.
Description check ✅ Passed The PR description includes a comprehensive summary, test plan, and additional context. While missing the formal template sections (Related Issues, Type of Change), the core information is well-documented and exceeds the template requirements in substance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mature-romano

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

  • Rewrites the /cli/auth/code page to a single-line code box with click-to-copy and a ghost button; setCopied(true) fires unconditionally before the clipboard write resolves, so "Copied!" is shown even when the write silently fails, which can mislead users who won't know to Ctrl+C the selected text.
  • Adds readline shortcuts (ctrl+u/ctrl+k to clear, ctrl+w/option+backspace for word-delete) to the CLI paste prompt; the word-delete regex /\\s*\\S+\\s*$/ also strips the space preceding the deleted word, diverging slightly from standard readline behavior.
  • No schema or redirect-URI changes; the oauth_clients row is unaffected.

Confidence Score: 3/5

Mergeable but the optimistic "Copied!" feedback on clipboard failure is a present UX defect that could mislead users into not manually copying the auth code.

One P1 finding (unconditional copied state set before clipboard attempt, misrepresenting failure) pulls the score below the P1 ceiling of 4. The P2 word-delete regex quirk is minor. No security or data-loss risk.

apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsxhandleCopy sets copied state before verifying clipboard success.

Important Files Changed

Filename Overview
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx Rewrites the auth-code display UI: single-line code box with click-to-copy, ghost button, and programmatic selection fallback. setCopied(true) fires unconditionally before the clipboard write resolves, showing misleading "Copied!" feedback on silent failure.
packages/cli/src/commands/auth/login/LoginUI.tsx Adds readline shortcuts (ctrl+u/k to clear, ctrl+w / option+backspace for word-delete). The word-delete regex eats the preceding space, diverging slightly from standard readline behavior.

Sequence Diagram

sequenceDiagram
    participant User
    participant CodeBox as Code Box (div[role=button])
    participant CopyBtn as Copy Button
    participant handleCopy
    participant Clipboard as navigator.clipboard
    participant Selection as window.getSelection

    User->>CodeBox: click
    CodeBox->>handleCopy: onClick
    handleCopy->>handleCopy: setCopied(true) ← immediate (unconditional)
    handleCopy->>Clipboard: copyToClipboard(value)
    alt write succeeds
        Clipboard-->>handleCopy: true
    else write fails silently
        Clipboard-->>handleCopy: false
    end
    handleCopy->>Selection: selectCode() (Range fallback)
    Note over handleCopy,Selection: "Copied!" shown regardless of outcome

    User->>CopyBtn: click
    CopyBtn->>handleCopy: onClick (same flow)
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx:61-67
**"Copied!" shown unconditionally before clipboard attempt**

`setCopied(true)` fires immediately — before `copyToClipboard` is even called — and regardless of whether the write succeeds. The previous code conditioned the flash on `if (ok) flash()`. When `navigator.clipboard.writeText` silently fails (e.g. no permission, non-secure context) the UI confidently declares "Copied!" while the clipboard is unchanged. The `selectCode()` fallback only helps users who notice the selection and know to press Ctrl+C, but the feedback actively misleads them into thinking no action is needed.

### Issue 2 of 2
packages/cli/src/commands/auth/login/LoginUI.tsx:60
**Word-delete regex swallows the preceding space**

`/\s*\S+\s*$/` removes any whitespace *before* the final word, not just trailing whitespace. For `"hello world"`, pressing `ctrl+w` yields `"hello"` instead of the standard readline result `"hello "` (the space belongs to the previous word boundary). In bash, `ctrl+w` (WERASE) and `option+backspace` (META-DEL) delete the word but preserve the space that preceded it. The regex should instead be `/ *\S+$/` (strip only the non-whitespace token plus any directly trailing spaces, leaving the preceding delimiter intact).

```suggestion
		setValue((v) => v.replace(/ *\S+$/, ""));
```

Reviews (1): Last reviewed commit: "feat(cli-auth): polish paste-code page +..." | Re-trigger Greptile

Comment on lines +61 to 67
const handleCopy = async () => {
setCopied(true);
if (timerRef.current) clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => setCopied(false), 2000);
};
return [copied, flash] as const;
}

export function CliAuthCodeDisplay({ code, state }: CliAuthCodeDisplayProps) {
const value = `${code}#${state}`;
const [boxCopied, flashBox] = useCopiedFlag();
const [buttonCopied, flashButton] = useCopiedFlag();

const handleCopy = async (flash: () => void) => {
const ok = await copyToClipboard(value);
if (ok) flash();
await copyToClipboard(value);
selectCode();
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 "Copied!" shown unconditionally before clipboard attempt

setCopied(true) fires immediately — before copyToClipboard is even called — and regardless of whether the write succeeds. The previous code conditioned the flash on if (ok) flash(). When navigator.clipboard.writeText silently fails (e.g. no permission, non-secure context) the UI confidently declares "Copied!" while the clipboard is unchanged. The selectCode() fallback only helps users who notice the selection and know to press Ctrl+C, but the feedback actively misleads them into thinking no action is needed.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
Line: 61-67

Comment:
**"Copied!" shown unconditionally before clipboard attempt**

`setCopied(true)` fires immediately — before `copyToClipboard` is even called — and regardless of whether the write succeeds. The previous code conditioned the flash on `if (ok) flash()`. When `navigator.clipboard.writeText` silently fails (e.g. no permission, non-secure context) the UI confidently declares "Copied!" while the clipboard is unchanged. The `selectCode()` fallback only helps users who notice the selection and know to press Ctrl+C, but the feedback actively misleads them into thinking no action is needed.

How can I resolve this? If you propose a fix, please make it concise.

(key.meta && (key.backspace || key.delete)) ||
(key.ctrl && input === "w")
) {
setValue((v) => v.replace(/\s*\S+\s*$/, ""));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Word-delete regex swallows the preceding space

/\s*\S+\s*$/ removes any whitespace before the final word, not just trailing whitespace. For "hello world", pressing ctrl+w yields "hello" instead of the standard readline result "hello " (the space belongs to the previous word boundary). In bash, ctrl+w (WERASE) and option+backspace (META-DEL) delete the word but preserve the space that preceded it. The regex should instead be / *\S+$/ (strip only the non-whitespace token plus any directly trailing spaces, leaving the preceding delimiter intact).

Suggested change
setValue((v) => v.replace(/\s*\S+\s*$/, ""));
setValue((v) => v.replace(/ *\S+$/, ""));
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli/src/commands/auth/login/LoginUI.tsx
Line: 60

Comment:
**Word-delete regex swallows the preceding space**

`/\s*\S+\s*$/` removes any whitespace *before* the final word, not just trailing whitespace. For `"hello world"`, pressing `ctrl+w` yields `"hello"` instead of the standard readline result `"hello "` (the space belongs to the previous word boundary). In bash, `ctrl+w` (WERASE) and `option+backspace` (META-DEL) delete the word but preserve the space that preceded it. The regex should instead be `/ *\S+$/` (strip only the non-whitespace token plus any directly trailing spaces, leaving the preceding delimiter intact).

```suggestion
		setValue((v) => v.replace(/ *\S+$/, ""));
```

How can I resolve this? If you propose a fix, please make it concise.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx (1)

80-86: 💤 Low value

onClick passes async handleCopy directly — inconsistent with onKeyDown.

Line 80 assigns handleCopy (an async function) directly to onClick, while line 84 explicitly uses void handleCopy(). Projects with @typescript-eslint/no-misused-promises will flag the direct assignment because MouseEventHandler expects () => void, not () => Promise<void>.

🔧 Proposed fix
-        onClick={handleCopy}
+        onClick={() => void handleCopy()}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx`
around lines 80 - 86, The onClick currently passes the async function handleCopy
directly (onClick={handleCopy}), which can trigger
`@typescript-eslint/no-misused-promises`; change it to an inline void-invoking
wrapper like onClick={() => { void handleCopy(); }} (similar to the onKeyDown
usage) so the handler signature is () => void; update the CliAuthCodeDisplay JSX
to replace the direct reference to handleCopy with the arrow wrapper to avoid
returning a Promise from onClick.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx`:
- Around line 80-86: The onClick currently passes the async function handleCopy
directly (onClick={handleCopy}), which can trigger
`@typescript-eslint/no-misused-promises`; change it to an inline void-invoking
wrapper like onClick={() => { void handleCopy(); }} (similar to the onKeyDown
usage) so the handler signature is () => void; update the CliAuthCodeDisplay JSX
to replace the direct reference to handleCopy with the arrow wrapper to avoid
returning a Promise from onClick.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ff49a2c2-8df7-4265-ab9f-a57a0c54931c

📥 Commits

Reviewing files that changed from the base of the PR and between de916d8 and 5054f99.

📒 Files selected for processing (2)
  • apps/web/src/app/cli/auth/code/components/CliAuthCodeDisplay/CliAuthCodeDisplay.tsx
  • packages/cli/src/commands/auth/login/LoginUI.tsx

…separator

- CliAuthCodeDisplay: re-condition the "Copied!" flash on a successful
  clipboard.writeText. selectCode() still runs unconditionally so users on
  contexts that block the clipboard API can ctrl+c the highlighted text.
- LoginUI: word-delete regex now preserves the preceding separator space,
  matching readline WERASE / option+backspace behavior. "hello world" +
  ctrl+w now yields "hello " instead of "hello".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@saddlepaddle saddlepaddle merged commit 2ea3ce4 into main May 5, 2026
16 checks passed
@saddlepaddle saddlepaddle mentioned this pull request May 5, 2026
5 tasks
saddlepaddle added a commit that referenced this pull request May 5, 2026
Two CLI changes since v0.2.7, both fixing remote-auth UX:

- `superset auth login` now races the loopback callback and the paste
  prompt in parallel, with an Ink UI for the paste path. Fixes login
  on remote machines where SSH_CONNECTION isn't set (tmux reattach,
  VS Code Remote, Codespaces, mosh). `c` copies the auth URL via
  OSC 52 with native `pbcopy`/`clip`/`wl-copy`/`xclip`/`xsel`
  fallback. Esc / Ctrl-C exit cleanly. (#4072)
- Polished the `/cli/auth/code` web page to match Claude Code's
  paste-code UI (single-line code box, ghost copy button, click-to-
  copy with selection-on-release fallback). Wired standard readline
  shortcuts in the CLI paste prompt: option+backspace / ctrl+w
  delete the previous word; cmd+backspace / ctrl+u / ctrl+k clear
  the buffer. (#4075)

Push cli-v0.2.8 after this lands to fire the release pipeline.
saddlepaddle added a commit that referenced this pull request May 6, 2026
* feat(cli-auth): polish paste-code page + CLI keybindings

Web `/cli/auth/code` page rewritten to match Claude Code's auth-code UI:
single-line `w-fit` code box, ghost copy button that flips to "Copied!"
on press, click-anywhere-on-box to copy, and selection happens on release
(programmatic Range) so it stays as a ctrl+c fallback if clipboard write
silently fails.

CLI `LoginUI` now wires the standard terminal readline shortcuts in the
paste-code prompt: option+backspace / ctrl+w delete the previous word,
cmd+backspace / ctrl+u / ctrl+k clear the buffer. Plain backspace still
deletes one char.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(cli-auth): only flash "Copied!" on success, preserve word-delete separator

- CliAuthCodeDisplay: re-condition the "Copied!" flash on a successful
  clipboard.writeText. selectCode() still runs unconditionally so users on
  contexts that block the clipboard API can ctrl+c the highlighted text.
- LoginUI: word-delete regex now preserves the preceding separator space,
  matching readline WERASE / option+backspace behavior. "hello world" +
  ctrl+w now yields "hello " instead of "hello".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
saddlepaddle added a commit that referenced this pull request May 6, 2026
Two CLI changes since v0.2.7, both fixing remote-auth UX:

- `superset auth login` now races the loopback callback and the paste
  prompt in parallel, with an Ink UI for the paste path. Fixes login
  on remote machines where SSH_CONNECTION isn't set (tmux reattach,
  VS Code Remote, Codespaces, mosh). `c` copies the auth URL via
  OSC 52 with native `pbcopy`/`clip`/`wl-copy`/`xclip`/`xsel`
  fallback. Esc / Ctrl-C exit cleanly. (#4072)
- Polished the `/cli/auth/code` web page to match Claude Code's
  paste-code UI (single-line code box, ghost copy button, click-to-
  copy with selection-on-release fallback). Wired standard readline
  shortcuts in the CLI paste prompt: option+backspace / ctrl+w
  delete the previous word; cmd+backspace / ctrl+u / ctrl+k clear
  the buffer. (#4075)

Push cli-v0.2.8 after this lands to fire the release pipeline.
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