Skip to content

fix(ui): enable paste on initial PAT token prompt#152

Merged
mpkrass7 merged 1 commit into
datasciencemonkey:mainfrom
KabeerThockchom:fix/pat-paste-on-first-prompt
Apr 30, 2026
Merged

fix(ui): enable paste on initial PAT token prompt#152
mpkrass7 merged 1 commit into
datasciencemonkey:mainfrom
KabeerThockchom:fix/pat-paste-on-first-prompt

Conversation

@KabeerThockchom
Copy link
Copy Markdown

Summary

On the first-run flow, the terminal prompts the user to paste a short-lived PAT (static/index.html:1492). In practice, paste did nothing — users had to type the token by hand. Two issues combined to cause this:

  1. No focus on the terminal when the prompt rendered. Browsers route paste events to the currently focused element. Without term.focus(), focus sat on <body> and xterm's helper textarea never received the paste event.
  2. Document-level paste listener short-circuited on !sessionId for ALL paste types. Since pane.sessionId is only set after getOrPromptSession runs (post-auth), the capture-phase listener at static/index.html:2029 consumed and dropped text paste during the PAT prompt — even with the xterm textarea focused.

The masking input handler also wrote a single * for any pasted multi-character chunk, which looked broken.

Changes (static/index.html)

  • Added term.focus() immediately after the Token: prompt write so xterm owns focus before term.onData is wired up.
  • Restricted the capture-phase paste listener's early-exit to image paste only — text paste now falls through to xterm's native handler regardless of session state.
  • Hardened the PAT-prompt input handler to mask multi-character chunks (one * per printable char) and auto-submit when a paste ends in \r / \n.

No backend changes. No new dependencies.

Test plan

  • Built and deployed to a Databricks App. Cmd+V on the first-run PAT prompt now pastes the token in a single shot.
  • Image paste in a normal session still uploads correctly via /api/upload.
  • Typing the token by hand still works (no regression on the keystroke path).
  • Backspace correctly deletes one masked char at a time.

Why it never repro'd in CI

There is no test harness for static/index.html, and the PAT prompt only fires when /api/pat-status returns invalid — a state that's already configured-away in most local dev setups.

This pull request and its description were written by Isaac.

Two issues prevented paste from working on the first-run PAT prompt:
1. Terminal had no focus when the prompt rendered, so xterm's helper
   textarea never received the browser paste event. Added term.focus()
   right after writing the Token: prompt.
2. The document-level capture-phase paste listener short-circuited on
   !sessionId for ALL paste types, dropping text paste before xterm
   could see it. Restricted that early-exit to image paste only;
   text paste now falls through to xterm regardless of session state.

Also made the masking handler tolerate multi-character chunks
(pasted strings) and auto-submit on a trailing newline.

Co-authored-by: Isaac
@mpkrass7 mpkrass7 merged commit 1cec6a4 into datasciencemonkey:main Apr 30, 2026
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.

2 participants