fix(pi-fff): persist fff-mode across /reload and session resume#593
Open
monotykamary wants to merge 2 commits into
Open
fix(pi-fff): persist fff-mode across /reload and session resume#593monotykamary wants to merge 2 commits into
monotykamary wants to merge 2 commits into
Conversation
The /fff-mode command only mutated an in-memory variable that was lost
on /reload and session restart. Now the selected mode is persisted using
two complementary mechanisms:
- process.env.PI_FFF_MODE: survives /reload (process stays alive, the
factory already reads this env var on init)
- pi.appendEntry('fff-mode', { mode }): survives process restart via
the session file; restored on session_start and used to set the env
var for subsequent reloads
The "requires restart" notice is updated to "requires /reload" since
that now actually works.
dmtrKovalenko
approved these changes
Jun 12, 2026
dmtrKovalenko
approved these changes
Jun 12, 2026
|
|
||
| // Persist so the mode survives /reload (process survives) and | ||
| // session resume (entry survives in the session file). | ||
| process.env.PI_FFF_MODE = newMode; |
Owner
There was a problem hiding this comment.
I don't think you need to set the env variables, they meant to be used as a persistent configuration layer
did you find that it doesn't work without env var? it should be safe to delete it
Author
There was a problem hiding this comment.
Just fixed it. It was a premature mutation to prevent the /reload from taking the env variable. Luckily, session_start and the appended entry should restore the currentMode just fine alone.
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.
Problem
/fff-mode overridedid nothing useful — the mode was only stored in an in-memory variable (currentMode) that was lost on/reloadand session restart. Tool names (ffgrep/fffindvsgrep/find) were computed once at factory init as aconst, so even a same-session mode change had no effect on registered tool names.Solution
pi.appendEntry("fff-mode", { mode })for session-level persistence. The mode is saved to the session file (does NOT pollute LLM context) and restored onsession_start. This handles:currentModeis updated in memory, affectingshouldEnableMentions()immediatelysession_startrestores the mode from session entries/reload:currentModeis restored bysession_start, but tool names are determined by the user-configured flag/env at factory init time — the/fff-modecommand notifies the user that a tool name change requires/reloadChanges
/fff-modecommand handler: Callspi.appendEntry("fff-mode", { mode })after mode change. Updated notice from "requires restart" → "requires /reload".session_starthandler: Restores mode from session entries (defensive: skips ifsessionManagerunavailable).appendEntrymock tocreatePi().Why not dynamic override tool registration?
I considered extracting tool definitions into factory functions for runtime registration, but:
pi.setActiveTools()replaces the entire active set, fragile to compose with other extensionsThe
/reloadpath is clean and already what the command was telling users to do.Test plan
bun test packages/pi-fff/test/— all 17 tests pass/fff-mode override→ notify shows/reloadrequired →/reload→ mode persists in memoryv2 update: Removed
process.env.PI_FFF_MODEmutations — env vars are a user-set config layer, not meant for runtime mutation.pi.appendEntryis the sole persistence mechanism.