fix(pi-fff): make home-dir scanning configurable, warn when indexing $HOME (#743) - #749
Conversation
dmtrKovalenko
left a comment
There was a problem hiding this comment.
@gustav-fff iterate on revie
|
|
||
| // Warn when launched from $HOME with home scanning on: indexing a large | ||
| // home tree can run for a long time in the background (issue #743). | ||
| const atHome = |
There was a problem hiding this comment.
let's cache the os.homedir once per the process
|
|
||
| export interface AuxOpts { | ||
| enableFsRootScanning: boolean; | ||
| enableHomeDirScanning?: boolean; |
There was a problem hiding this comment.
Every time the llm is trying to spawn the aux picker in home dir we should send the notification to the user
| "FFF is indexing your entire home directory ($HOME) in the background — this can take a while on large trees. Disable with --fff-enable-home-scan=false (or FFF_ENABLE_HOME_SCAN=0).", | ||
| "warning", | ||
| ); | ||
| ctx.ui.setStatus?.("fff", "FFF: indexing $HOME"); |
There was a problem hiding this comment.
| ctx.ui.setStatus?.("fff", "FFF: indexing $HOME"); | |
| ctx.ui.setStatus?.("fff", "Agent is indexing $HOME, this can lead to high CPU"); |
|
|
||
| // Clear the status once the initial scan settles; if it is still running | ||
| // past the wait, keep the user informed that it continues in background. | ||
| if (atHome) { |
There was a problem hiding this comment.
are you sure this is actually getting called multiple times? I feel like it would be called just once so we might need to run timeout based scanning or add a callback to the ensureFinder to make sure this warning is cleaned
…tatus Review follow-ups on #749: - Resolve os.homedir() once per process in src/paths.ts (HOME_DIR) instead of on each call; aux-finders and index both use it. - AuxOpts.onHomeDirScan fires whenever the agent spawns an aux picker rooted at or above $HOME, so the user is notified every time, not only at startup. - Replace the one-shot post-waitForScan progress check with a 1s poller. waitForScan() also resolves on timeout, so a single check could leave a stale footer forever. The interval is unref'd and cleared on session_shutdown and in destroyFinder(). - Footer text now reads "Agent is indexing $HOME, this can lead to high CPU".
|
[triage-bot] DIRECTED: pushed f83f9f2. All three review points addressed. 1. Cache 2. Notify on every aux picker over $HOME — if (enableHomeDirScanning && rootCovers(maybeRoot, HOME_DIR)) {
this.opts.onHomeDirScan?.(maybeRoot);
}Wired to the same 3. You are right, the one-shot check was wrong. 4. Footer text taken verbatim from your suggestion: Tests: 53 pass, 0 fail (was 46). 7 new covering the aux notification, the polling loop with Honk-Honk 🪿 |
…tatus Review follow-ups on #749: - Resolve os.homedir() once per process in src/paths.ts (HOME_DIR) instead of on each call; aux-finders and index both use it. - AuxOpts.onHomeDirScan fires whenever the agent spawns an aux picker rooted at or above $HOME, so the user is notified every time, not only at startup. - Replace the one-shot post-waitForScan progress check with a 1s poller. waitForScan() also resolves on timeout, so a single check could leave a stale footer forever. The interval is unref'd and cleared on session_shutdown and in destroyFinder(). - Footer text now reads "Agent is indexing $HOME, this can lead to high CPU".
f83f9f2 to
9327556
Compare
|
@gustav-fff rebase |
…$HOME (#743) Expose home-dir scanning as --fff-enable-home-scan flag + FFF_ENABLE_HOME_SCAN env, default true. resolveBoolOpt takes a fallback and accepts 0/false. Threaded through the main finder and AuxFinderPool. Cache os.homedir() once per process in src/paths.ts. AuxOpts.onHomeDirScan fires whenever the agent spawns an aux picker rooted at or above $HOME. On session start from $HOME, notify the user and track scan progress with a 1s poller that clears the footer once the scan settles; the interval is unref'd and cleared on shutdown and in destroyFinder().
9327556 to
2baa107
Compare
|
[triage-bot] DIRECTED: rebased onto Two commits squashed into one. Conflict was in
if (enableHomeDirScanning && rootCovers(root, HOME_DIR)) {
this.opts.onHomeDirScan?.(root);
}Tests: 55 pass, 0 fail (was 53; picked up #750's 2 aux-dedup tests). No new tsc errors — the 5 Honk-Honk 🪿 |
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: dmtrKovalenko <16926049+dmtrKovalenko@users.noreply.github.com>
Rebased onto |
Upstream (6 commits): rescan throttling for giant folders (dmtrKovalenko#751), configurable $HOME scanning (dmtrKovalenko#743/dmtrKovalenko#749), Lua-level fs-root/home guard (dmtrKovalenko#745/dmtrKovalenko#748), pi-fff SDK import cache (dmtrKovalenko#758), release 0.10.3. Conflict resolution: - Cargo.toml/Cargo.lock (all crates): keep fork's 0.17.2 version scheme over upstream's 0.10.3; preserve fff-mcp's fff-ipc/dirs/libc deps and upstream's new rescan-stats feature. - Makefile: union of fork's daemon/install targets and upstream's test-rescan/rescan-probe targets. - install-mcp.sh: keep fork's removal of the pinned-release SHA block (delivery is via Homebrew tap + apt, not pinned GitHub tarballs). - background_watcher.rs: adopt upstream's throttled try_trigger_full_rescan mechanism wholesale, keeping only the fork's per-root user_gi ignore filter; drop the obsolete need_full_rescan boolean.
Closes #743
Root cause
pi-fffhardcodedenableHomeDirScanning: true, overriding the core default guard, so launching pi from$HOMEalways indexed the whole home tree with no opt-out:packages/pi-fff/src/index.ts:370— main finderpackages/pi-fff/src/aux-finders.ts:77— aux finder poolOnly
fff-enable-root-scanwas configurable.@XWIlluDelutraced this to #589, which removed the home flag and forcedtrue. The maintainer's advice "do not start pi in$HOMEif you enable home indexing" was unfollowable — the extension always enabled it.Fix
Expose it as
--fff-enable-home-scanflag +FFF_ENABLE_HOME_SCANenv, defaulttrue(behavior unchanged).resolveBoolOptnow takes a fallback and accepts0/falseso the default can be turned off. Threaded through both the main finder andAuxFinderPool.On the alerts question: pi exposes
ctx.ui.notify(msg, "info" | "warning" | "error")andctx.ui.setStatus(id, text)(footer, persists across renders) — docsextensions.md:2177,tui.md:734. Wired both: awarningnotify when cwd is$HOMEwith scanning on, plus a footer status. After the 15swaitForScanreturns,getScanProgress()is polled once; if still scanning, the footer keeps showing the live file count instead of clearing, so a long background index over a big home tree is visible.Note: this only adds the opt-out and visibility. It does not address the other items in the report — no idle-stop, no size/count thresholds, no default excludes, no cross-process index sharing. @dmtrKovalenko those are design changes, out of scope for a triage fix.
Steps to reproduce
Pre-fix
main, home scanning cannot be disabled:No flag exists, so launching pi from
$HOMEindexes the whole tree:Behavioral check via the test suite:
On pre-fix
mainadd this test — it FAILS (Expected: false, Received: true):Post-fix it passes, and the opt-out works:
How verified
bun test test/inpackages/pi-fff— 46 pass, 0 fail.enableHomeDirScanningto hardcodedtruemakes it fail withExpected: false, Received: true.bun run lintandbun run format:checkproduce byte-identical output toorigin/main(3 warnings, 1 info, 8 format diffs — all pre-existing). No new lint/format regressions.ctx.ui.notify/ctx.ui.setStatus/getScanProgressverified against installed@earendil-works/pi-coding-agent0.79.3 docs andpackages/fff-node/src/fff-api.ts:603.setStatuscalled optionally (?.) since it is TUI/RPC-only.Automated triage via Gustav. Honk-Honk 🪿