fix: complete GitHub Copilot TUI & auth-files support#508
fix: complete GitHub Copilot TUI & auth-files support#508conversun wants to merge 2 commits intorouter-for-me:mainfrom
Conversation
- Add GitHub Copilot to OAuth tab provider list with device flow user_code display - Fix auth-files tab reading non-existent 'channel' field; use 'type'/'provider' from API - Add 'github-copilot' to NormalizeOAuthProvider for callback routing - Add i18n strings for user code display (zh/en)
Prevent userCode/providerName from leaking across OAuth sessions, which would hide the callback input for redirect-based providers after visiting a device-flow provider like GitHub Copilot.
There was a problem hiding this comment.
Code Review
This pull request introduces support for GitHub Copilot via the OAuth device flow. Key changes include updating the provider normalization logic to handle Copilot, adding a userCode field to the TUI model to display verification codes, and modifying the TUI to hide the callback URL input when a device code is present. Feedback highlights a potential issue where input focus might block TUI navigation during device-based authentication and identifies a redundant field in the authentication detail view.
| m.authURL = msg.url | ||
| m.authState = msg.state | ||
| m.providerName = msg.providerName | ||
| m.userCode = msg.userCode |
There was a problem hiding this comment.
For device-based OAuth flows (like GitHub Copilot), the userCode is provided and the user does not need to paste a callback URL. However, the logic following this hunk (specifically line 117, which is outside the diff) unconditionally sets m.inputActive = true and line 116 calls Focus().
This is problematic because when inputActive is true, the TUI redirects all keystrokes to the (now hidden) text input. This will prevent the user from scrolling the viewport or using other navigation keys while waiting for authentication. Please ensure that inputActive is only set to true and Focus() is only called if m.userCode is empty.
| {"File Name", "name", false}, | ||
| {"Provider", "provider", false}, |
There was a problem hiding this comment.
The 'File Name' entry is now redundant because it uses the 'name' key, which is already displayed as 'Name' on line 273. Since the API response fields have been normalized, this duplicate entry should be removed to keep the detail view clean.
| {"File Name", "name", false}, | |
| {"Provider", "provider", false}, | |
| {"Provider", "provider", false}, |
|
Closing - changes require corresponding Web panel modifications that are out of scope. |
Summary
channel/auth_typefields; use actual API response fields (type/provider)github-copilottoNormalizeOAuthProviderfor callback routing consistencyuserCode,providerName, etc.) on flow reset to prevent cross-provider UI leaksChanges
internal/tui/oauth_tab.gouser_codefrom API; show device-flow code in remote mode; hide callback input for device-flow; reset transient state on Esc/re-enterinternal/tui/auth_tab.gochannel→type; Detail view:Channel→Type,Auth Type/auth_type→Provider/provider,File Name/file_name→File Name/nameinternal/tui/i18n.gooauth_user_codei18n string (zh: 验证码, en: User Code)internal/api/handlers/management/oauth_sessions.goNormalizeOAuthProvider:"github"→"github", "github-copilot", "copilot"all return"github-copilot"Testing
origin/mainlatest)go build/go test— all pass