test: direct suite for settings-hub shared merge/persist helpers#584
Conversation
lib/codex-manager/settings-hub/shared.ts ships ForTests injection variants that nothing exercised. These 14 cases pin: - copyDashboardSettingValue array cloning (no shared references) - applyDashboardDefaultsForKeys resetting only listed keys without mutating the draft - mergeDashboardSettingsForKeys taking only the panel's keys - persistDashboardSettingsSelection re-reading the latest settings so a concurrent edit to an unrelated key is preserved, retrying EBUSY through the real queued-retry policy, and warning + returning the clone-normalized selection when the write keeps failing - persistBackendConfigSelection saving the backend patch, returning a defensive clone (fallback chain not shared), and the warn + fallback path - clampBackendNumber min/max clamping and rounding https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Review limit reached
More reviews will be available in 4 minutes and 53 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review follow-up: the previous failure case used a code-less error, which exercises only the non-retryable single-attempt path. That case is now named accurately and pins attempt count = 1; two new cases drive persistent EBUSY through all four queued-retry attempts for the dashboard and backend persists before the warn + fallback. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
test/settings-hub-shared.test.ts(14 cases) for the merge/persist helpers inlib/codex-manager/settings-hub/shared.ts. The module ships...ForTestsinjection variants that nothing exercised; the settings panels were the only callers.What Changed
One new test file, mocking only the disk seams (
loadDashboardDisplaySettings/saveDashboardDisplaySettings/savePluginConfigvia importOriginal spreads) while the merge logic, the real queued-retry policy, and the realbackendSettingsEqual/cloneDashboardSettingsstay live:copyDashboardSettingValue: array values are cloned, never shared — a later mutation of the target must not write through to the source settings object.applyDashboardDefaultsForKeys/mergeDashboardSettingsForKeys: only the listed keys move; inputs are never mutated.persistDashboardSettingsSelection— the load-merge-save transaction the panels rely on:EBUSYthrough the real queued-retry policy with no user-facing warning;Settings save failed (<scope>) after retries: <message>line and returns the clone-normalized selection as fallback (never the caller's object).persistBackendConfigSelection: saves the backend patch, returns a defensive clone (unsupportedCodexFallbackChainnot reference-shared), and the warn + fallback path.clampBackendNumber: min/max clamping and rounding sweep.Validation
npm run typecheck(also runs in the pre-commit hook)npx eslint test/settings-hub-shared.test.ts --max-warnings=0npm test -- test/settings-hub-shared.test.ts— 14/14Docs and Governance Checklist
Risk and Rollback
Additional Notes
main.https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
adds
test/settings-hub-shared.test.tswith 14 cases covering the merge/persist helpers inlib/codex-manager/settings-hub/shared.ts. no source changes.copyDashboardSettingValueare never reference-shared between source and target.persistDashboardSettingsSelectionre-reads from disk inside the queue slot so a concurrent write to an unrelated key is preserved.EBUSYtests that assert all four attempts fire and the warn+fallback path triggers; this closes the gap flagged in the previous review round.Confidence Score: 5/5
test-only change with no source modifications; safe to merge.
one new test file, no production code touched. the ebusy exhaustion and fallback paths are correctly exercised; the concurrency re-read case is properly constructed. the only thing worth a follow-up is the ~750ms of real sleep in three tests, which is a run-time comfort issue, not a correctness problem.
no files require special attention.
Important Files Changed
loadDashboardDisplaySettingscall-count assertions.Sequence Diagram
sequenceDiagram participant Test participant persistDashboardSettingsSelectionForTests participant withQueuedRetry participant loadDashboardDisplaySettings (mock) participant saveDashboardDisplaySettings (mock) Test->>persistDashboardSettingsSelectionForTests: selected, keys, scope persistDashboardSettingsSelectionForTests->>withQueuedRetry: "pathKey, task(), { sleep }" loop up to 4 attempts (EBUSY path) withQueuedRetry->>loadDashboardDisplaySettings (mock): re-read latest loadDashboardDisplaySettings (mock)-->>withQueuedRetry: latest settings withQueuedRetry->>saveDashboardDisplaySettings (mock): merged settings saveDashboardDisplaySettings (mock)-->>withQueuedRetry: EBUSY (or success) withQueuedRetry->>withQueuedRetry: sleep(backoff) if retryable end alt success withQueuedRetry-->>persistDashboardSettingsSelectionForTests: merged persistDashboardSettingsSelectionForTests-->>Test: merged else exhausted / non-retryable withQueuedRetry-->>persistDashboardSettingsSelectionForTests: throw error persistDashboardSettingsSelectionForTests->>persistDashboardSettingsSelectionForTests: warnPersistFailure persistDashboardSettingsSelectionForTests-->>Test: cloneDashboardSettings(selected) endPrompt To Fix All With AI
Reviews (2): Last reviewed commit: "test: cover EBUSY retry exhaustion for b..." | Re-trigger Greptile