Fix rules files not loading and config file rescan clearing tokens#53659
Open
AJenbo wants to merge 1 commit intozed-industries:mainfrom
Open
Fix rules files not loading and config file rescan clearing tokens#53659AJenbo wants to merge 1 commit intozed-industries:mainfrom
AJenbo wants to merge 1 commit intozed-industries:mainfrom
Conversation
Wait for worktree scan to complete before looking up rules files (AGENTS.md, CLAUDE.md, .rules, etc.) so that entry_for_path does not return None for files that exist on disk but haven't been indexed yet. In watch_config_dir, skip files that fail to load during Rescan events instead of sending empty content. The previous unwrap_or_default() turned read errors into empty strings, which consumers like CopilotChat interpreted as 'file has no content', clearing OAuth tokens and triggering repeated re-authentication prompts.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #52453
Fixes #53246
Both issues were introduced by #51208 ("Handle Linux FS Rescan Events"), which added
PathEventKind::Rescanhandling.Rules files not loading (#52453)
load_worktree_info_for_system_promptcalledload_worktree_rules_filesynchronously, which usesentry_for_path()on the current worktree snapshot. If the background scanner hasn't finished its initial scan, the entry doesn't exist yet and the lookup returnsNone— the code concludes no rules file exists. This was always a latent race condition, but became more visible after Rescan events were introduced, since they can trigger additionalWorktreeUpdatedEntrieschurn that interacts with the refresh mechanism.The fix awaits
scan_complete()on local worktrees before performing the rules file lookup, ensuring the full directory tree is indexed first.Config file rescan clearing OAuth tokens (#53246)
The
Rescanhandlers inwatch_config_dirusedfs.load(file_path).await.unwrap_or_default(), which turns any file-read error into an empty string. This empty string flows to consumers likeCopilotChat, whereextract_oauth_token("")returnsNone, causing the OAuth token to be unconditionally overwritten withNone— triggering re-authentication.The fix changes both Rescan handlers to skip files that fail to load (using
if let Ok(contents) = ...), matching the pattern already used by theCreated/Changedhandler.Release Notes: