Skip to content

fix(pi-fff): avoid blocking session start during finder warmup#478

Open
cokekitten wants to merge 1 commit into
dmtrKovalenko:mainfrom
cokekitten:fix-pi-fff-nonblocking-session-start
Open

fix(pi-fff): avoid blocking session start during finder warmup#478
cokekitten wants to merge 1 commit into
dmtrKovalenko:mainfrom
cokekitten:fix-pi-fff-nonblocking-session-start

Conversation

@cokekitten
Copy link
Copy Markdown

Summary

Fixes #477.

pi-fff currently awaits ensureFinder() during session_start, and ensureFinder() calls FileFinder.create() followed by waitForScan(15000). Since Pi recreates the session runtime for /new and /resume, this can make session switching appear stuck while the finder scan warms up.

This change:

  • schedules finder warmup after session_start returns, so Pi session replacement is not blocked
  • keeps tool behavior intact: the first fff tool/autocomplete use still awaits the shared in-flight finderPromise if warmup is not done yet
  • adds a lifecycle guard so stale warmups from a previous session do not notify or affect a newer session
  • returns the local createdFinder from ensureFinder() after waitForScan() to avoid returning a destroyed/replaced global finder if shutdown happens during warmup

Validation

cd packages/pi-fff
npx tsc --noEmit

finderCwd = cwd;
await finder.waitForScan(15000);
return finder;
await createdFinder.waitForScan(15000);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to actually get rid of the wait we proably should redesign the waitForScan internally, it is anyway blocking now while it should do the pool for is_scanning

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This PR only removes the session_start blocking path; waitForScan itself can still block the first tool use. I kept the scope small here, but happy to follow up with a separate PR redesigning waitForScan to poll is_scanning internally if you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pi-fff blocks Pi /new and /resume while waiting for FileFinder scan on session_start

2 participants