Repository navigation
feat(auth): copy the device-flow user code to the clipboard - #44
Merged
Merged
Conversation
Transcribing the hyphenated user code is the clunkiest step of login, and a typo costs a full browser round-trip. login now attempts a best-effort clipboard copy with an honest status line: - pyperclip (native pbcopy/clip.exe/xclip/wl-copy, WSL-aware) first: definitive result on any desktop session. - OSC 52 escape sequence as fallback: travels back through the SSH channel, so it works over plain SSH in supporting terminals (tmux gets the DCS passthrough wrapper; no escape bytes on piped stdout). Delivery is unacknowledged, so the message hedges. If neither mechanism is available (headless host, unsupported terminal), nothing is printed and login proceeds exactly as before. The helper never raises or blocks login.
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.
Closes #43
Summary
campus auth loginnow attempts to copy the user code to the clipboard right after printing it, with a status line that reflects what actually happened:Code copied to clipboard.— pyperclip succeeded (pbcopy / clip.exe / ctypes / xclip / wl-copy; WSL-aware). Definitive.Sent the code to your terminal's clipboard (OSC 52); if it doesn't paste, copy it manually.— no native mechanism (e.g. headless SSH host), so the OSC 52 sequence was emitted instead. Delivery is unacknowledged by terminals, hence the hedge.Design notes
set-clipboard external— we also send the DCS passthrough wrapper; iTerm2 requires opt-in; VTE/GNOME Terminal ignores it). With X forwarding, pyperclip correctly targets the user's own local clipboard.Test plan
tests/unit/test_clipboard.py: native success, native-failure → OSC 52, missing-pyperclip → OSC 52, non-TTY suppression, tmux DCS wrapping.test_auth_login_binds_tokens_to_target_auth_urlpatches the helper (CI never touches a real clipboard) and asserts the status line.ruff checkclean; full suite: 167 passed.