feat(grokbuild): add first-class Grok Build support#5453
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be9847074a
ℹ️ 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".
farion1231
left a comment
There was a problem hiding this comment.
Thanks for this contribution — this is one of the most complete external PRs this repo has received. I reproduced all five verification claims locally (fmt / clippy / 1992 lib tests + integration suites / tsc / 451 vitest, all green) and cross-checked the config schema, MCP layout, AGENTS.md, and --resume against x.ai's docs. The transactional hot-switch is a genuine improvement, and I found no regressions to existing apps: Codex/Claude forwarding stays byte-identical, and failover/circuit-breaker state is fully namespaced per app.
That said, please address the following before merge:
Required
-
Deleted MCP servers resurrect on switch-back.
services/provider/live.rs:836—restore_live_settings_for_provider_backfillearly-returns for non-Codex apps, so the projected[mcp_servers.*]gets baked verbatim into the outgoing Grok provider snapshot. Sinceproject_servers_to_apponly reconciles servers still in the DB, a server deleted in cc-switch resurrects in~/.grok/config.toml(possibly with stale credentials) on the next switch back. Grok needs the same strip Codex has (strip_codex_mcp_servers_from_settings; see the regression testcodex_switch_backfill_strips_synced_mcp_serversas a template). The live-import path (live.rs:1450) needs the same strip. -
Inline
api_keyis hard-required, rejecting documented config styles.grok_config.rs:104— per x.ai's settings reference,api_keyis discouraged;env_key/ session token /XAI_API_KEYare canonical (resolution orderapi_key > env_key > session token > XAI_API_KEY). A validenv_key-style config fails "import from live" with an error, and the startup auto-import silently no-ops. Suggest acceptingapi_keyORenv_keyon import/validation. -
Grok route doesn't survive an app restart.
lib.rs:1746—restore_proxy_state_on_startupiterates the hardcoded["claude", "codex", "gemini"]. With only the Grok route enabled, the proxy never starts after a restart and the route silently drops to direct upstream whileproxy_config.enabledstays true in the UI. (The live config itself is fine —restore_live_configsanddetect_takeover_in_live_configsboth cover Grok — only the re-takeover loop is missing.) Please add"grokbuild"plus a restart regression test. -
Preset
apiFormatisn't mapped into TOMLapi_backend.GrokBuildProviderForm.tsx—handlePresetChangesetsmeta.apiFormatbut never updatesapiBackend, so the generated TOML always saysapi_backend = "responses". Under proxy takeover this happens to work (the conversion gate readsmeta.api_format), but in direct mode Grok CLI will speak Responses to a Chat-only gateway. x.ai documentsapi_backend = chat_completions | responses | messages, so please mapopenai_chat → chat_completions/anthropic → messageswhen generating the TOML. -
First-launch MCP import misses Grok. The empty-table import block at
lib.rs:761calls the per-app importers for claude/codex/gemini/opencode/hermes but not the already-implementedimport_from_grokbuild(the adjacent prompts loop does include GrokBuild). Existing~/.grok/config.tomlMCP servers won't be picked up on first launch.
Recommended (fine as a follow-up)
- Cached tokens double-counted for GrokBuild. GrokBuild flows through Responses semantics where
input_tokensincludes cache, butgrokbuildis missing from all four cache-inclusive lists:proxy/usage/calculator.rs:62,proxy/usage/logger.rs:74(rows should be TOTAL, not FRESH),services/sql_helpers.rs:19, and the frontend mirrortypes/usage.ts:198. Result: cache portion billed at both input and cache rates, and cache-hit rate badly understated. - Deeplink coverage is partial. The prompt whitelist (
deeplink/parser.rs:193) and MCP apps whitelist (parser.rs:265) still reject grokbuild; the existing-server apps merge (deeplink/mcp.rs:104) only merges claude/codex/gemini — this also predates the PR for opencode/hermes, so consider looping over the flags instead of per-field merging; and the provider inline-config dispatch (deeplink/provider.rs:642) has no Grok branch, soconfig/configUrldeeplinks fail with "Invalid app type". - No GrokBuild entry in usage UI.
types/usage.ts:175KNOWN_APP_TYPES(dashboard filter) andPricingConfigPanel.tsxPRICING_APPSomit grokbuild even though it records real proxy usage. custom_endpointsconflation in the form.GrokBuildProviderForm.tsx:186-197, 329-356persists the union of baseUrl + preset endpoints + priorcustom_endpointsback intometa.custom_endpoints, so an endpoint removed in the speed-test modal resurrects on save. The Codex form persists only user-added endpoints.- Rollback gap for the Codex direct-write branch.
rollback_hot_switch_preparation(services/proxy.rs:433) never restores thehas_backup && !live_taken_overCodex direct write (proxy.rs:~2465) on commit failure — the PR moved that write ahead of the commit, so a commit failure now leaves~/.codexon the new provider until the next proxy stop self-heals it.
Nits
README app lists (4 locales) still say 7 apps; the inline rawConfigError renders hardcoded English (should go through t()); five grokBuild.* i18n keys are unused; test gaps worth closing: delete_session (destructive remove_dir_all guards untested), validateGrokBuildConfig error branches / profile-rename, and the form's validation-error + edit-mode paths.
|
Addressed all maintainer and inline review feedback in Required:
Recommended:
Nits/tests:
Validation completed locally: TypeScript, Prettier, 457 Vitest tests, rustfmt, strict Clippy, 1993 Cargo tests (2 ignored), renderer production build, and Tauri debug build. |
Follow-up: Grok Build lifecycle and provider icon alignmentThis PR now includes two additional consistency improvements: 1. Grok CLI lifecycle management (
|
farion1231
left a comment
There was a problem hiding this comment.
Thank you for your contribution!
* feat(grokbuild): add backend integration * feat(grokbuild): add provider and management UI * test(grokbuild): cover configuration and integrations * fix(grokbuild): address backend review feedback * fix(grokbuild): complete UI review feedback * feat(grokbuild): add CLI lifecycle management * fix(grokbuild): align provider icon fallback * test(grokbuild): cover provider icon persistence
* feat(grokbuild): add backend integration * feat(grokbuild): add provider and management UI * test(grokbuild): cover configuration and integrations * fix(grokbuild): address backend review feedback * fix(grokbuild): complete UI review feedback * feat(grokbuild): add CLI lifecycle management * fix(grokbuild): align provider icon fallback * test(grokbuild): cover provider icon persistence
Summary / ??
Add Grok Build CLI as a first-class switchable app backed by its native
~/.grok/config.tomlformat.[models]/[model.*]configuration/grokbuild/v1/responsesroute with its own provider namespace and failover queue~/.grok/AGENTS.md), Skills, native sessions, settings, and tray switchingRelated Issue / ?? Issue
Fixes #5407
Related prior discussion: #4825
Implementation Notes
headersand omits Codex-onlytype/http_headersfields.[mcp_servers.*]entries inconfig.toml.~/.grok/sessions/**/summary.jsonandchat_history.jsonl, and resumes withgrok --resume <session-id>.@xai-official/grokpackage; updates stay anchored to the detected npm/Volta/pnpm/Bun installation, including Grok-specific WSL directory overrides.Screenshots / ??
No static screenshot included. The complete Tauri debug build was manually verified on Windows 11 with real Grok provider, session, and Skills data.
Verification
npm run typechecknpm run format:checknpm run test:unit -- --testTimeout=15000(72 files, 462 tests)cargo fmt --all -- --checkcargo clippy --all-targets --all-features -- -D warningscargo testwith isolatedLOCALAPPDATA(1,995 passed, 2 ignored, plus all integration suites)npx tauri build --debug --no-bundle --ignore-version-mismatcheswith the existing production frontend bundleChecklist / ????
pnpm typecheckequivalent passes via the repositorynpm run typecheckscriptpnpm format:checkequivalent passes via the repositorynpm run format:checkscriptcargo clippypasses with warnings denied