refactor: extract experimental sync target wrapper#274
refactor: extract experimental sync target wrapper#274ndycode wants to merge 2 commits intorefactor/pr2-dashboard-preview-helpers-6from
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthroughintroduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes notes for reviewmissing regression coverage: the existing integration tests for concurrency risk: windows edge case: verify 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@test/experimental-sync-target-entry.test.ts`:
- Around line 5-25: Update the test for loadExperimentalSyncTargetEntry to
deterministically exercise the readJson/retry wiring: mock readFileWithRetry
(the function passed into loadExperimentalSyncTargetEntry) to fail on the first
call with a windows-like transient error and succeed on the second call, and
assert that loadExperimentalSyncTargetState is still called and the final result
matches the expected shape; ensure you use vitest mocks (vi.fn) and
deterministic async behavior (returning Promises) so the retry branch in
loadExperimentalSyncTargetEntry (the logic that calls readJson /
readFileWithRetry) is executed and validated rather than only testing delegation
and final shape.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 21c6e111-45ce-41eb-ba40-2794c6552c5f
📒 Files selected for processing (3)
lib/codex-manager/experimental-sync-target-entry.tslib/codex-manager/settings-hub.tstest/experimental-sync-target-entry.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Greptile Review
🧰 Additional context used
📓 Path-based instructions (2)
test/**
⚙️ CodeRabbit configuration file
tests must stay deterministic and use vitest. demand regression cases that reproduce concurrency bugs, token refresh races, and windows filesystem behavior. reject changes that mock real secrets or skip assertions.
Files:
test/experimental-sync-target-entry.test.ts
lib/**
⚙️ CodeRabbit configuration file
focus on auth rotation, windows filesystem IO, and concurrency. verify every change cites affected tests (vitest) and that new queues handle EBUSY/429 scenarios. check for logging that leaks tokens or emails.
Files:
lib/codex-manager/experimental-sync-target-entry.tslib/codex-manager/settings-hub.ts
🔇 Additional comments (2)
lib/codex-manager/settings-hub.ts (1)
773-779: good extraction wiring in settings hub.the delegation in
lib/codex-manager/settings-hub.ts:773cleanly forwards the same io and normalization dependencies, which keepsloadExperimentalSyncTargetslim without changing call semantics.lib/codex-manager/experimental-sync-target-entry.ts (1)
46-63: entry helper implementation looks solid.
lib/codex-manager/experimental-sync-target-entry.ts:46throughlib/codex-manager/experimental-sync-target-entry.ts:63correctly centralizes retrying fs reads, json parsing, and normalization wiring in one place.
# Conflicts: # lib/codex-manager/experimental-sync-target-entry.ts # test/experimental-sync-target-entry.test.ts
# Conflicts: # lib/codex-manager/experimental-sync-target-entry.ts # test/experimental-sync-target-entry.test.ts
Summary
settings-hubValidation
npm run typechecknpm run lint -- lib/codex-manager/experimental-sync-target-entry.ts lib/codex-manager/settings-hub.ts test/experimental-sync-target-entry.test.tsnpm run test -- test/experimental-sync-target-entry.test.tsnote: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this pr extracts the windows-safe
readJsonwrapper (withEBUSY/EPERM/EAGAIN/ENOTEMPTY/EACCESretry) out ofsettings-hub.tsinto a focusedloadExperimentalSyncTargetEntryhelper, then adds a targeted vitest suite for it. the refactor is behavior-preserving and the extraction boundary is clean.C:\state.json) and asserts the full retry options object — goodJSON.parseon a partial/empty file (possible on windows during concurrent writes) throws an unguardedSyntaxError; no test covers this path and no mapping to an{ kind: "error" }result is present — this was pre-existing behavior but worth closing now that the logic lives in an isolated, testable unitcapturedReadJsonin test 2 is captured and only checkedtoBeDefined(); the meaningful assertion isreadFileWithRetry.toHaveBeenCalledWith, which already proves the wiringConfidence Score: 5/5
JSON.parse) was pre-existing and is not a regression introduced here; test coverage for the new unit is solid for the happy path and the windows retry pathJSON.parseon a partial/empty file is unguarded; low urgency since this was pre-existing, but the isolated unit is now the right place to fix itImportant Files Changed
JSON.parseon partial file content is unguarded and untestedJSON.parsefailure path andcapturedReadJsonassertion is redundantSequence Diagram
sequenceDiagram participant SH as settings-hub.ts participant ESTE as experimental-sync-target-entry.ts participant EST as experimental-sync-target.ts participant RFR as readFileWithRetry SH->>ESTE: loadExperimentalSyncTargetEntry({ loadExperimentalSyncTargetState, detectTarget, readFileWithRetry, normalizeAccountStorage, sleep }) ESTE->>EST: loadExperimentalSyncTargetState({ detectTarget, readJson, normalizeAccountStorage }) EST->>ESTE: calls readJson(path) ESTE->>RFR: readFileWithRetry(path, { retryableCodes: [EBUSY,EPERM,EAGAIN,ENOTEMPTY,EACCES], maxAttempts: 4, sleep }) RFR-->>ESTE: raw string ESTE-->>EST: JSON.parse(raw) EST-->>SH: { kind, detection, destination? }Prompt To Fix All With AI
Last reviewed commit: "Exercise sync target..."