feat(gui): configure Codex auto-switch threshold - #337
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe GUI adds configurable Codex auto-switch thresholds with validated persistence, revision-aware synchronization, editable controls, localized feedback, responsive styling, documentation updates, and expanded tests. Additional changes update test timeouts, request context fixtures, native execution commands, and a root-suite investigation record. ChangesCodex auto-switch threshold
Root-suite investigation record
Test maintenance
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CodexAccountPool
participant useCodexAutoSwitch
participant CodexAutoSwitchSetting
participant CodexAuthAPI
CodexAccountPool->>useCodexAutoSwitch: beginServerRead
CodexAccountPool->>CodexAuthAPI: GET accounts and active configuration
CodexAuthAPI-->>useCodexAutoSwitch: active threshold
useCodexAutoSwitch-->>CodexAutoSwitchSetting: threshold and draft state
CodexAutoSwitchSetting->>useCodexAutoSwitch: commit or toggle
useCodexAutoSwitch->>CodexAuthAPI: PUT auto-switch threshold
CodexAuthAPI-->>useCodexAutoSwitch: success or failure
useCodexAutoSwitch-->>CodexAutoSwitchSetting: feedback and updated threshold
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5f84301252
ℹ️ 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".
5f84301 to
b58c221
Compare
|
Maintainer takeover update: I rebased the contributor commits onto Mounted Root-suite follow-up: the four reported Final verification at Thank you for the original contribution. The contributor branch is updated and green. Because this PR changes |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devlog/_plan/260724_bugfix_train/061_root_suite_investigation.md`:
- Around line 121-128: Revise the investigation table and the conclusion near
the cited lines so the four success-path tests are labeled only as inferred
candidates, not as the reported failures. State that the original failure names
and assertions remain unresolved at suite level unless CI/test-reporter metadata
is recovered, and remove the unsupported “no fix is justified” closure.
In `@gui/src/codex-auto-switch.ts`:
- Around line 64-80: The putAutoSwitchThreshold request can remain pending
indefinitely because its fetch has no timeout. Add a finite AbortSignal timeout
to the fetch options in putAutoSwitchThreshold, ensuring timeout-triggered
aborts flow through the existing catch and return false while preserving current
validation and response handling.
- Around line 45-62: Update planAutoSwitchToggleWrite so disabling always
returns a plan with threshold 0 when current > 0; use the parsed draft as
lastEnabled only when valid, otherwise fall back to the existing lastEnabled
value. Update the related test assertion to expect a disable write instead of
null for invalid drafts.
In `@gui/src/hooks/useCodexAutoSwitch.ts`:
- Around line 188-202: The toggle disable path must work even when the draft is
unparseable. In gui/src/hooks/useCodexAutoSwitch.ts:188-202, update toggle
around planAutoSwitchToggleWrite to fall back to lastEnabledRef.current when the
plan is null and current > 0, while preserving invalid-draft rejection for other
cases. In gui/tests/codex-auto-switch-controller.test.tsx:177-262, add coverage
that clears the input, clicks .toggle, and asserts a threshold: 0 write without
an invalid-feedback alert.
In `@gui/tests/codex-account-auto-switch.test.tsx`:
- Around line 141-147: Update the read-only attribute assertion in the “keeps
the focused input present but read-only while a write is pending” test to match
renderToStaticMarkup’s lowercase `readonly=""` output, while leaving the other
assertions unchanged.
In `@gui/tests/codex-auto-switch-controller.test.tsx`:
- Around line 177-262: Add regression coverage in the “Codex auto-switch
controller interactions” suite for clicking the toggle with an empty draft:
focus the input, clear it, click the harness toggle, and verify the PUT records
threshold 0 without rendering invalid-feedback alert. Use the existing harness
helpers and preserve the current assertions for other interactions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 761d19a1-597b-474d-8983-fca1f27b9cbb
📒 Files selected for processing (19)
devlog/_plan/260724_bugfix_train/061_root_suite_investigation.mddocs-site/src/content/docs/guides/web-dashboard.mddocs-site/src/content/docs/ja/guides/web-dashboard.mddocs-site/src/content/docs/ko/guides/web-dashboard.mddocs-site/src/content/docs/ru/guides/web-dashboard.mddocs-site/src/content/docs/zh-cn/guides/web-dashboard.mdgui/src/codex-auto-switch.tsgui/src/components/CodexAccountPool.tsxgui/src/components/CodexAutoSwitchSetting.tsxgui/src/hooks/useCodexAutoSwitch.tsgui/src/i18n/de.tsgui/src/i18n/en.tsgui/src/i18n/ja.tsgui/src/i18n/ko.tsgui/src/i18n/ru.tsgui/src/i18n/zh.tsgui/src/styles.cssgui/tests/codex-account-auto-switch.test.tsxgui/tests/codex-auto-switch-controller.test.tsx
Ingwannu
left a comment
There was a problem hiding this comment.
The threshold control is useful, but the current GUI interaction contract is not complete. Clicking the toggle after editing can lose the click through blur/save ordering; disabling can silently no-op when the draft is temporarily invalid; the PUT can remain pending indefinitely; and the mounted suite does not cover the invalid-draft toggle path. Please make toggle intent atomic, add a finite abort/timeout, correct the unsupported root-suite evidence wording, add the missing mounted regressions, and re-request review.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@devlog/_plan/260724_bugfix_train/061_root_suite_investigation.md`:
- Around line 127-132: Update the four-row candidate table to add explicit
classification and disposition columns required by the rubric. Populate every
candidate row with classification “Unresolved — original failure identity
unavailable” and disposition “No per-failure disposition; suite-level
unresolved,” while preserving the existing evidence and owner-path fields.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 80664e8d-cc42-40e0-9d36-8110f68a9b5e
📒 Files selected for processing (8)
devlog/_plan/260724_bugfix_train/061_root_suite_investigation.mdgui/src/codex-auto-switch.tsgui/src/components/CodexAutoSwitchSetting.tsxgui/src/hooks/useCodexAutoSwitch.tsgui/tests/codex-account-auto-switch.test.tsxgui/tests/codex-auto-switch-controller.test.tsxtests/cursor-native-exec.test.tstests/settings-stream-mode.test.ts
Resolve the settings stream fixture with upstream and widen Windows integration-test timeouts observed under full-suite load.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
gui/src/i18n/ru.ts (1)
110-111: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winKeep Codex clamp explanations current and localized.
These messages explain why reasoning options are currently hidden, but the Russian and Chinese wording can read as historical rather than describing the active binary.
gui/src/i18n/ru.ts#L110-L111: replaceиспользовалwithиспользуетand translatereasoning effortasуровни рассуждений.gui/src/i18n/zh.ts#L105-L106: replace使用了with正在使用, matching the active-runtime wording at Line 107.Proposed wording
-Некоторые уровни reasoning effort скрыты, потому что OpenCodex использовал Codex {version}. +Некоторые уровни рассуждений скрыты, потому что OpenCodex использует Codex {version}. -Некоторые уровни reasoning effort скрыты, потому что OpenCodex использовал Codex {version} (удалены: {efforts}). +Некоторые уровни рассуждений скрыты, потому что OpenCodex использует Codex {version} (удалены: {efforts}).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@gui/src/i18n/ru.ts` around lines 110 - 111, Update the clamp explanation translations: in gui/src/i18n/ru.ts lines 110-111, use active wording with “использует” and translate “reasoning effort” as “уровни рассуждений”; in gui/src/i18n/zh.ts lines 105-106, replace “使用了” with “正在使用” to match the active-runtime wording.tests/codex-catalog.test.ts (1)
52-69: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winAdd the missing
OcxConfigfields to these test fixtures.src/types.tsrequires bothportanddefaultProvider, and the inline objects intests/codex-catalog.test.ts#L52-L69andtests/management-provider-validation.test.ts#L123-L141omit them. Add those fields or reuse a shared typed test config.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/codex-catalog.test.ts` around lines 52 - 69, Add the required OcxConfig fields port and defaultProvider to the inline configuration fixture used by providerDiscoveryDto in tests/codex-catalog.test.ts:52-69. Apply the same fixture update to the inline OcxConfig object in tests/management-provider-validation.test.ts:123-141, or reuse a shared typed test configuration, ensuring both fields are present and valid.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@gui/src/i18n/ru.ts`:
- Around line 110-111: Update the clamp explanation translations: in
gui/src/i18n/ru.ts lines 110-111, use active wording with “использует” and
translate “reasoning effort” as “уровни рассуждений”; in gui/src/i18n/zh.ts
lines 105-106, replace “使用了” with “正在使用” to match the active-runtime wording.
In `@tests/codex-catalog.test.ts`:
- Around line 52-69: Add the required OcxConfig fields port and defaultProvider
to the inline configuration fixture used by providerDiscoveryDto in
tests/codex-catalog.test.ts:52-69. Apply the same fixture update to the inline
OcxConfig object in tests/management-provider-validation.test.ts:123-141, or
reuse a shared typed test configuration, ensuring both fields are present and
valid.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: e2235b0f-be1e-4ed3-967b-fb907e766ed5
📒 Files selected for processing (20)
docs-site/src/content/docs/guides/web-dashboard.mddocs-site/src/content/docs/ja/guides/web-dashboard.mddocs-site/src/content/docs/ko/guides/web-dashboard.mddocs-site/src/content/docs/ru/guides/web-dashboard.mddocs-site/src/content/docs/zh-cn/guides/web-dashboard.mdgui/src/i18n/de.tsgui/src/i18n/en.tsgui/src/i18n/ja.tsgui/src/i18n/ko.tsgui/src/i18n/ru.tsgui/src/i18n/zh.tsgui/src/styles.csstests/cli-provider.test.tstests/codex-catalog.test.tstests/codex-v2-gate.test.tstests/combo-management-api.test.tstests/injection-model-api.test.tstests/management-provider-validation.test.tstests/server-auth.test.tstests/server-combo-failover-e2e.test.ts
|
@coderabbitai review |
✅ Action performedReview finished.
|
- CodexAutoSwitchSetting.tsx: presentational component (threshold input, toggle, feedback, retry) with typed props interface - useCodexAutoSwitch.ts: controller hook owning state, refs, revision-based read reconciliation, commit/cancel/toggle, feedback timer cleanup - CodexAccountPool.tsx: imports hook + component, removes inline auto-switch state/refs/callbacks (553 lines, below 650 target) - 4 mounted happy-dom interaction tests: Enter+blur single PUT, stale refresh ignore, failed-write rollback, Escape cancel Existing 16 pure helper/SSR/transport tests unchanged and green. Verification: bun run typecheck, 23 pass / 0 fail across 2 test files.
Summary
Verification
bun run typecheck— passed.bun run lint:gui— passed.cd gui && bun run lint:i18n— passed.bun test ./gui/tests— 26 passed, including all 16 threshold cases.bun run privacy:scan— passed.bun run build:gui— passed; existing large-chunk advisory only.cd docs-site && bun run build— passed, 121 pages.bun run doctor:gui:if-changed— advisory exit 0; the only feature-file finding is an existing barrel import.upstream/dev— approved with no findings.The isolated root suite completed with 3780 passed, 4 skipped, and 4 failures confined to the unchanged
release-helpertest.tests/release-helper.test.tsandscripts/release.tshave no diff fromupstream/dev; the complete release-helper file passed 5/5 when rerun standalone.Checklist
Summary by CodeRabbit