You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(link): avoid writing an empty initial selection on disconnect - #8989
A Link only records initial routing choices when the operator supplies an explicit client selection. Disconnect also clears this state for links without one. Previously that clear created an empty initial-<linkId>.json, including its state directory if missing.
Leave an absent selection absent. An existing record still goes through the same atomic no-follow write. Check the nearest existing entry so a broken directory link still surfaces an error. The disconnect journal and its phase transitions are unchanged.
Verification
Windows NTFS, Bun 1.4.4. The new regression failed on d61cca12 because the directory and file were created. bun test tests/clients/route-intent-connect-recovery.test.ts passed all 11 tests with the patch, including rollback after a recorded selection, older-Home provisioning, and an unreachable directory.
bun run typecheck, bun run structure:check, bun run privacy:scan, and git diff --check passed.
Seven alternating calls per revision after a warm-up, using distinct existing test directories with missing selection files. The base created 7 files and took a median of 226.97 ms per clear. The patch created 0 files and took 0.60 ms. This measures one operation on one host. The full Windows disconnect deadline in fix(link): restore guarded stop cleanup with native Windows owner proof #8933 remains open.
Local validation covered the changed contract and its rollback callers. The broader import-graph suite is left to PR CI to avoid duplicating the ongoing Windows recovery work.
Checklist
Scope stays focused and avoids unrelated cleanup.
Updated the client integration contract in structure/clients/integrations.md.
Reviewed existing write, link identity, and directory error handling. The change adds no credential access or logging.
Summary by CodeRabbit
Bug Fixes
Clearing an absent route selection no longer creates a state directory.
Attempts to clear a selection when its state path passes through a broken symlink now report an error and leave the symlink intact, preventing unintended filesystem changes.
No actionable comments were generated in the recent review.
Walkthrough
clearInitialRouteIntent now checks the target path and its ancestors before writing an empty selection. Tests cover clearing when the selection is absent and when the state path traverses a dangling symlink.
clearInitialRouteIntent checks the target path and its ancestors before writing an empty selection. Tests verify that clearing an absent selection does not create the state directory, preserves an unrelated file, and throws when the path traverses a dangling symlink. The responsibility description for src/integrations/state.ts is updated.
lidge-jun/opencodex#8416: This PR reintroduced the clearInitialRouteIntent behavior that the current change modifies.
lidge-jun/opencodex#8276: This PR introduced the initial route selection path that the current change updates.
Merge Risk: Minimal · up to 28694
Disconnecting a Link without an explicit client selection no longer creates an empty selection file or its state directory. No merge-blocking risk was identified.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(link): avoid writing an empty initial selection on disconnect" matches the main change described in the PR objectives and raw summary. The PR stops clearInitialRouteIntent from creating…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(link): avoid writing an empty initial selection on disconnect" matches the main change described in the PR objectives and raw summary. The PR stops clearInitialRouteIntent from creating an absent initial selection file and its state directory during disconnect, and it adds a dangling-symlink check. The title is specific and concise, and it follows a conventional commit style. It does not cover the symlink ancestor check, but that is a secondary detail.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Checks on this head: 17 passed, 14 skipped, none pending or failing (Ubuntu PR CI; Windows/macOS are covered by the next dev batch gate).
Review threads: none unresolved.
Review: gpt-6.1-terra, two rounds, final verdict PASS.
Regression: tests/clients/route-intent-connect-recovery.test.ts passes on this head (11 pass) and fails with src/integrations/route-intent-initial.ts restored from dev (1 fail).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
initial-<linkId>.json, including its state directory if missing.Verification
d61cca12because the directory and file were created.bun test tests/clients/route-intent-connect-recovery.test.tspassed all 11 tests with the patch, including rollback after a recorded selection, older-Home provisioning, and an unreachable directory.bun run typecheck,bun run structure:check,bun run privacy:scan, andgit diff --checkpassed.Checklist
structure/clients/integrations.md.Summary by CodeRabbit