Skip to content

feat(grokbuild): persist official auth.json for multi-account switching - #6792

Open
652036 wants to merge 6 commits into
farion1231:mainfrom
652036:feat/grokbuild-official-auth-profiles
Open

feat(grokbuild): persist official auth.json for multi-account switching#6792
652036 wants to merge 6 commits into
farion1231:mainfrom
652036:feat/grokbuild-official-auth-profiles

Conversation

@652036

@652036 652036 commented Aug 25, 2026

Copy link
Copy Markdown

Summary / 概述

Grok Official previously wrote an empty ~/.grok/config.toml and never snapshotted ~/.grok/auth.json, so only one official Grok CLI login could exist.

This change stores auth.json on each official Grok provider (same { auth, config } shape as Codex), restores it on switch, backfills the live session when leaving a card, and strips OAuth scopes when switching to a third-party relay so the official session cannot override api_key.

Adding Grok Official now creates a new card instead of only ensuring the seed, so multiple official accounts can be saved and switched like Codex / Claude.

Follow-ups already included:

  • Snapshot live OAuth onto an official card before stripping on third-party writes (do not discard a grok login that was never copied).
  • Adopt CLI-refreshed / newly logged-in live auth when saving or syncing the current official card.
  • Prettier format fix for GrokBuildProviderForm.tsx.

Related Issue / 关联 Issue

Fixes #

Screenshots / 截图

Official Grok cards now include an auth.json editor. Selecting Grok Official again adds another account card instead of reusing grokbuild-official.

Checklist / 检查清单

  • pnpm typecheck passes / 通过 TypeScript 类型检查
  • pnpm format:check passes (changed frontend files) / 已检查改动的前端文件格式
  • cargo clippy passes (if Rust code changed) / 通过 Clippy 检查(如修改了 Rust 代码)
  • Updated i18n files if user-facing text changed / 如修改了用户可见文本,已更新国际化文件

652036 added 3 commits August 24, 2026 11:42
Official Grok login previously left ~/.grok/auth.json live-only, so only
one account could be used. Snapshot auth.json onto each official provider
like Codex, restore it on switch, and drop the live session when moving
to a third-party relay so api_key actually wins.
Do not delete ~/.grok/auth.json on a third-party write unless the live
session was copied onto an official card. When saving or syncing the
current official card, merge live tokens (including a newer grok login)
instead of writing the stale DB snapshot.
@652036
652036 requested a review from farion1231 as a code owner August 25, 2026 06:45
@github-actions github-actions Bot added frontend Frontend (React/TypeScript) backend Backend (Rust/Tauri) i18n Internationalization (zh/en/ja) labels Aug 25, 2026
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7f842a0243

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src-tauri/src/services/provider/live.rs Outdated
Comment on lines +766 to +770
if crate::grok_config::merge_live_grok_oauth_into_settings(
&mut official.settings_config,
&live,
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.

P1 Badge Treat an already-saved OAuth snapshot as preserved

When switching from the seeded grokbuild-official card to a relay, switch_normal first backfills the live auth onto that same row, so its stored auth is now identical to live. merge_live_grok_oauth_into_settings returns false for this equality case, and because every matching row is then treated as an unsuccessful preservation, preserve_live_grok_oauth_in_db returns false; write_grok_live_with_db consequently skips stripping OAuth. The live official session therefore continues to override the relay's api_key, breaking the normal seeded-official-to-relay switch. Distinguish an already-identical snapshot from an identity conflict and return the safe-to-strip result for the former.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. After switch_normal backfills the live session onto grokbuild-official, stored already equals live, so merge was returning false and we skipped the strip. I now treat that identical snapshot as already preserved, so official → relay still drops OAuth.

cargo test after pointing TEMP at a WSL UNC path re-links and mt.exe fails (LNK1327). Compile with native TEMP, then execute the test binary with WSL TEMP so the ignored UNC contract still sees wsl.localhost.
@github-actions github-actions Bot added the actions CI/CD workflows label Aug 26, 2026
@652036

652036 commented Aug 26, 2026

Copy link
Copy Markdown
Author

Windows + WSL2 CI failed on the last run — not because of the Grok auth.json change (the other backend jobs were green).

That job sets TEMP to a WSL path and then runs cargo test again. link.exe / mt.exe can't write manifests there; the workflow even has a comment about this.

I pushed a CI-only fix: compile the tests with a normal Windows temp dir, then run the already-built test binary with the WSL TEMP so the UNC contract test still sees wsl.localhost.

The new run is waiting for a workflow approval (action_required). Could someone approve it when you get a chance?

652036 added 2 commits August 26, 2026 07:03
switch_normal can backfill live auth onto grokbuild-official first, so
stored==live is success, not a conflict. Preserve that case so a relay
switch still strips OAuth and api_key wins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

actions CI/CD workflows backend Backend (Rust/Tauri) frontend Frontend (React/TypeScript) i18n Internationalization (zh/en/ja)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants