What happens
pi-fff resolves its startup options and registers its tools while the extension is loading. At that point Pi has registered the extension flags, but has not populated their values yet. Saved fff-mode entries arrive later, in session_start, after the tool names have already been chosen.
On current main (be2dd8d), an isolated Pi session shows both sides of the problem:
$ pi --fff-mode override
/fff-mode
Current mode: 'tools-and-ui' (flag: override)
The active extension tools are still ffgrep and fffind, rather than the expected grep and find overrides.
A session with a saved override selection has the opposite mismatch:
Current mode: 'override' (flag: unset)
Active extension tools: ffgrep, fffind
This is the mismatch noted in the review of #790: #790 (comment)
The timing also affects the other public CLI flags. The database paths and scan options call the same getConfigValue() helper before Pi makes flag values available, so their CLI values are skipped during initial construction.
Suggested fix
Keep flag registration where it is, but defer startup resolution and tool registration until session_start:
- Resolve the five startup options after Pi has populated the flags.
- Restore the saved session mode, preserving the current session-persistence behavior.
- Create the finder factories and register the tools from that final state.
- Explicitly activate the dynamically registered tool names.
For /fff-mode, switches between tools-and-ui and tools-only can remain immediate because their tool names are identical. A switch to or from override should save the selection but leave the reported active mode unchanged until /reload; that avoids another transient mismatch.
I have a focused patch ready on a fork. It keeps the tool definitions in place, queues only their final registration, and covers CLI precedence, saved-mode restoration, tool names, prompt guidelines, and the reload boundary. It passes the 74 pi-fff tests, type checking, formatting, and isolated Pi RPC checks. Happy to open the PR if this direction looks right.
What happens
pi-fffresolves its startup options and registers its tools while the extension is loading. At that point Pi has registered the extension flags, but has not populated their values yet. Savedfff-modeentries arrive later, insession_start, after the tool names have already been chosen.On current
main(be2dd8d), an isolated Pi session shows both sides of the problem:The active extension tools are still
ffgrepandfffind, rather than the expectedgrepandfindoverrides.A session with a saved
overrideselection has the opposite mismatch:This is the mismatch noted in the review of #790: #790 (comment)
The timing also affects the other public CLI flags. The database paths and scan options call the same
getConfigValue()helper before Pi makes flag values available, so their CLI values are skipped during initial construction.Suggested fix
Keep flag registration where it is, but defer startup resolution and tool registration until
session_start:For
/fff-mode, switches betweentools-and-uiandtools-onlycan remain immediate because their tool names are identical. A switch to or fromoverrideshould save the selection but leave the reported active mode unchanged until/reload; that avoids another transient mismatch.I have a focused patch ready on a fork. It keeps the tool definitions in place, queues only their final registration, and covers CLI precedence, saved-mode restoration, tool names, prompt guidelines, and the reload boundary. It passes the 74
pi-ffftests, type checking, formatting, and isolated Pi RPC checks. Happy to open the PR if this direction looks right.