Skip to content

fix: complete GitHub Copilot TUI & auth-files support#504

Closed
conversun wants to merge 2 commits intorouter-for-me:mainfrom
conversun:fix/github-copilot-tui-support-v2
Closed

fix: complete GitHub Copilot TUI & auth-files support#504
conversun wants to merge 2 commits intorouter-for-me:mainfrom
conversun:fix/github-copilot-tui-support-v2

Conversation

@conversun
Copy link
Copy Markdown

Summary

  • Add GitHub Copilot to TUI OAuth tab with device-flow user code display
  • Fix auth-files tab reading non-existent channel/auth_type fields; use actual API response fields (type/provider)
  • Add github-copilot to NormalizeOAuthProvider for callback routing consistency
  • Clear stale OAuth session state (userCode, providerName, etc.) on flow reset to prevent cross-provider UI leaks

Changes

File Change
internal/tui/oauth_tab.go Add GitHub Copilot provider entry; propagate user_code from API; show device-flow code in remote mode; hide callback input for device-flow; reset transient state on Esc/re-enter
internal/tui/auth_tab.go List view: channeltype; Detail view: ChannelType, Auth Type/auth_typeProvider/provider, File Name/file_nameFile Name/name
internal/tui/i18n.go Add oauth_user_code i18n string (zh: 验证码, en: User Code)
internal/api/handlers/management/oauth_sessions.go NormalizeOAuthProvider: "github""github", "github-copilot", "copilot" all return "github-copilot"

Testing

  • go build ./internal/tui/... ./internal/api/handlers/management/... — compiles cleanly
  • go test ./internal/tui/... ./internal/api/handlers/management/... -count=1 — all tests pass

- 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.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for GitHub Copilot OAuth device flows. Key changes include updating the backend provider normalization, adding internationalization strings for user codes, and modifying the TUI to display device-specific codes while conditionally managing callback inputs. The review feedback identifies a logic error where the TUI captures keyboard focus unnecessarily during device flows, which breaks navigation, and points out redundant data fields in the authentication detail view.

m.authURL = msg.url
m.authState = msg.state
m.providerName = msg.providerName
m.userCode = msg.userCode
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

For device-based OAuth flows (like GitHub Copilot) where a userCode is provided, the TUI should not enter the manual callback input mode. Currently, m.callbackInput.Focus() (line 116) and m.inputActive = true (line 117) are executed unconditionally. This causes the TUI to capture keyboard input for a hidden text field, which prevents normal navigation keys (like L for language or Esc for exit) from working as expected and requires the user to press Esc twice to return to the provider list.

Please wrap the focus and activation logic in a check: if msg.userCode == "" { ... }.

Comment on lines +278 to +279
{"File Name", "name", false},
{"Provider", "provider", false},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The field "File Name" has been updated to use the key "name", which is already displayed at the top of the detail view under the label "Name" (line 273). This results in the same information being shown twice. Since the API has consolidated these fields, you should remove the redundant entry.

Suggested change
{"File Name", "name", false},
{"Provider", "provider", false},
{"Provider", "provider", false},

@conversun
Copy link
Copy Markdown
Author

Rebased onto v6.9.22-0 (latest origin/main). See replacement PR.

@conversun conversun closed this Apr 10, 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.

1 participant