fix(pi-fff): avoid blocking session start during finder warmup#478
fix(pi-fff): avoid blocking session start during finder warmup#478cokekitten wants to merge 1 commit into
Conversation
| finderCwd = cwd; | ||
| await finder.waitForScan(15000); | ||
| return finder; | ||
| await createdFinder.waitForScan(15000); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@gustav-fff please update the PR to include the refactoring and rebase on top of the main (use merge not rebase to be able to push to fork)
There was a problem hiding this comment.
[triage-bot] DIRECTED: cannot push merge to fork — gustav-fff OAuth token lacks workflow scope, and merging main brings in .github/workflows/* changes. Github rejects: refusing to allow an OAuth App to create or update workflow .github/workflows/external-tests.yml without workflow scope. Options: (1) you push the merge yourself from cokekitten/fix-pi-fff-nonblocking-session-start, or (2) re-target this PR to a same-repo branch so I can push. Also — need scope confirmation on the refactor: packages/fff-node/src/finder.ts:438 already polls isScanning() async in JS; the blocking one is C FFI fff_wait_for_scan (crates/fff-c/src/lib.rs:836) used by fff-bun. Do you want the refactor in fff-node (drop the blocking C wait entirely, keep JS polling), in fff-bun (same async polling as fff-node), or in Rust SharedFilePicker::wait_for_scan (crates/fff-core/src/shared.rs:119)?
Honk-Honk 🪿
Summary
Fixes #477.
pi-fffcurrently awaitsensureFinder()duringsession_start, andensureFinder()callsFileFinder.create()followed bywaitForScan(15000). Since Pi recreates the session runtime for/newand/resume, this can make session switching appear stuck while the finder scan warms up.This change:
session_startreturns, so Pi session replacement is not blockedfinderPromiseif warmup is not done yetcreatedFinderfromensureFinder()afterwaitForScan()to avoid returning a destroyed/replaced global finder if shutdown happens during warmupValidation
cd packages/pi-fff npx tsc --noEmit