ISSUE DESCRIPTION fix(installer): back navigation from Pi-only install shows unrelated…
- User
ISSUE DESCRIPTION
fix(installer): back navigation from Pi-only install shows unrelated Gentle AI configuration
Pre-flight Checklist
- I have searched existing issues and this is not a duplicate
- I understand that PRs will be rejected if the linked issue does not have
status:approved
📝 Bug Description
When running the
gentle-piinstaller fromgentle-ai, if I select onlyPias the installation target and then useBackon the next step,
the installer returns to an unexpected configuration flow.Instead of going back to the previous installation target selection, it shows configuration options that do not correspond to the selected
Pi-only path, such as TDD configuration, multi-agent installation, communication style, and related Gentle AI setup options.🔄 Steps to Reproduce
- Start the
gentle-aiinstaller.
2. Select onlyPias the installation target.
3. Continue to the next step.
4. SelectBack.
5. Observe that the installer shows configuration screens for TDD, multi-agent setup, speaking style, etc.
✅ Expected Behavior
After selecting
Back, the installer should return to the previous relevant step in the Pi-only installation flow, likely the installation
target selection screen.❌ Actual Behavior
The installer jumps to unrelated Gentle AI configuration screens, including TDD setup, multi-agent installation, communication style, and other
options that were not expected after choosing a Pi-only installation.Gentle AI Version
v 1.30.5
Operating System
macOS
AI Agent / Client
Other
📋 Affected Area
CLI (commands, flags)
💡 Logs / Error Output
shellNo logs available. This appears to be an installer navigation/state-flow issue.Additional Context
This happens specifically when selecting only
Piduring installation and then navigating back from the following step. Assistant
I'll analyze the repository structure first to understand the codebase, then identify and fix the issue.
Assistant
Now let me look at the main model file to understand the navigation flow:
Assistant
Now let's look at the key navigation areas more closely - specifically where Back is handled from DependencyTree:
Assistant
Now I see the issue! Let me find the
shouldShowStrictTDDScreen,shouldShowClaudeModelPickerScreen, etc. functions:Assistant
Now let's look at the
isPiOnlyAgentsandpiOnlyComponentsfunctions:Assistant
Now I understand. Let me look at the specific section where back navigation happens after pi-only install. Looking at
goBack()from line 2321:Assistant
Now let me look at the specific section of
goBackthat handles ScreenDependencyTree. I see lines 2434-2450:Assistant
Now I see. Let me check what shouldShowStrictTDDScreen returns for Pi-only:
Looking at lines 3216-3218:
gofunc (m Model) shouldShowStrictTDDScreen() bool { return hasSelectedComponent(m.Selection.Components, model.ComponentSDD) }This is the problem! For Pi-only installations, the components list is set to
piOnlyComponents()which is just[model.ComponentEngram]. ButshouldShowStrictTDDScreenonly checks ifComponentSDDis selected - which it isn't for Pi-only.Wait, let me re-read the flow. The user selects Pi-only, then from ScreenAgents navigates to ScreenDependencyTree. Let me check this flow:
Assistant
OK, now I understand. When Pi-only is selected:
ScreenAgents→m.Selection.Components = piOnlyComponents()(just Engram)- Goes to
ScreenDependencyTree
But then when
goBack()is called onScreenDependencyTree, line 2434m.Screen == ScreenDependencyTree && m.Selection.Preset != model.PresetCustom. The default preset is presumably something other thanPresetCustom. So this branch is taken. Thenm.shouldShowStrictTDDScreen()returns... let me check.Wait, the components list is set to
[Engram], no SDD. SoshouldShowStrictTDDScreenshould returnfalse. Hmm. Let me check the default preset for Pi-only:Assistant
Let me check the initial selection at line 473:
Assistant
Now I understand. The default Preset is
PresetFullGentleman, but for Pi-only, components are just[Engram]. Yet Preset is stillPresetFullGentleman.Now in
goBack():m.Screen == ScreenDependencyTree && m.Selection.Preset != model.PresetCustom→ TRUE (it'sPresetFullGentleman)m.shouldShowOpenCodePluginsScreen()→ false (only for OpenCode agent)m.shouldShowStrictTDDScreen()→ returnshasSelectedComponent(m.Selection.Components, model.ComponentSDD)
For Pi-only, components is
[Engram], no SDD. SoshouldShowStrictTDDScreenreturnsfalse.m.shouldShowClaudeModelPickerScreen()→ returns false (no ClaudeCode agent)
So all the conditions would be false and the code falls through to
previous, ok := PreviousScreen(m.Screen). Let me check PreviousScreen:Assistant
So if all the
shouldShow*checks fail, thenpreviouswould beScreenPreset. But the issue says the user ends up at "configuration screens for TDD, multi-agent setup, speaking style, etc." which sounds likeScreenStrictTDD,ScreenModelPicker, etc.Let me trace the flow more carefully. The user does:
- Welcome → Agents → choose "Pi" → click Continue →
m.setScreen(ScreenDependencyTree)(line 1492) - Now on DependencyTree, click Back →
goBack()is called
Looking at
goBack():m.Screen == ScreenDependencyTree && m.Selection.Preset != model.PresetCustom→ TRUE (Preset isPresetFullGentleman)
- Welcome → Agents → choose "Pi" → click Continue →
Assistant
Hmm wait, let me re-read. Pi-only has
components = piOnlyComponents()=[Engram]. But what if the user clicked on the "Pi" checkbox BEFORE? Let me look at the toggling logic:Assistant
Now let me understand by writing a reproduction script:
Assistant
Now I see! There's ALSO a back logic in the
ScreenDependencyTreecase (line 1805-1825). This is the case where the user clicks "Back" in the DependencyTree options (cursor == 1). Let me trace:For Pi-only:
- components =
[Engram], no SDD shouldShowStrictTDDScreen()= false (no SDD)shouldShowSDDModeScreen()= false (no OpenCode agent)shouldShowClaudeModelPickerScreen()= false (no ClaudeCode agent)- Falls through to
m.setScreen(ScreenPreset)(line 1823)
Hmm, that would land on ScreenPreset, not StrictTDD. Let me look at the model.go where it builds the plan to understand the issue better:
- components =
Assistant
Now let me look at the issue more carefully. Let me look at the test file
agent_builder_nav_test.goandpreset_flow_test.go:Assistant
Now let me look at agent_builder_nav_test.go for similar test patterns:
Assistant
Assistant
So for Pi-only, it goes: Agents → DependencyTree directly. The forward flow doesn't pass through Persona/Preset for Pi-only.
Now in
goBack(), sinceSelection.Presetis stillPresetFullGentleman(default), the function thinks we have a normal flow and goes back to the wrong screen.Let me write a reproduction test to confirm:
Assistant
There are 14 agents, so
agentCount = 14. The Continue option is at cursor = 14. Let me now rewrite the reproduction test correctly:Assistant
I've confirmed the bug! The test reproduces it. The screen value 5 is ScreenPreset (not ScreenAgents). Let me verify:
Assistant
Screen values:
- 0: ScreenUnknown
- 1: ScreenWelcome
- 2: ScreenDetection
- 3: ScreenAgents
- 4: ScreenPersona
- 5: ScreenPreset
- 6: ScreenClaudeModelPicker
So the test confirms: Back from DependencyTree for Pi-only → Screen 5 (ScreenPreset).
But the user expected to return to ScreenAgents (where they originally selected the Pi target). That's the bug.
Now, wait - the issue description says "TDD configuration, multi-agent installation, communication style, and related Gentle AI setup options" - so perhaps once they enter ScreenPreset, then they continue forward from there too? Or maybe my reproduction is incomplete. Let me trace the issue from the user's perspective again:
- User is at ScreenAgents, selects Pi only, presses Continue
- Goes to ScreenDependencyTree (per the Pi-only forward flow)
- User presses Back on DependencyTree
- Bug: Goes to ScreenPreset, then if user continues there, they go through all the Gentle AI config (TDD, SDD mode, multi-agent, etc.)
Assistant
So both
goBack()(Esc) andScreenDependencyTree(Back button) need to handle the Pi-only case. Let me look at how to detect the Pi-only state and add the proper handling.The fix: When
isPiOnlyAgents(m.Selection.Agents)is true and we're on ScreenDependencyTree, going back should return to ScreenAgents.Let me also check if the issue could manifest differently. Let me check if there are any other ways to get to DependencyTree for Pi-only. Actually since we just need to make the back navigation correct, let's add the check.
Let me look at the AgentBuilder flow just to be sure it's not somehow related:
Assistant
Good. So my understanding is correct. Pi-only flow skips persona, preset, SDD mode, Strict TDD, etc. because gentle-pi owns those.
Now let me also think about a related concern. There's the
linearRoutesmap that has:codeScreenDependencyTree: {Forward: ScreenReview, Backward: ScreenPreset}For Pi-only, this
Backward: ScreenPresetis wrong. It should beScreenAgents. But hardcoding it isn't flexible. The right fix is to add a runtime check for Pi-only in bothgoBack()and theScreenDependencyTreecase.Let me think about whether the fix should also be at the linearRoutes level. Actually, looking at the code, the linearRoutes are a fallback. The
goBack()function handles most logic and only falls back to linearRoutes at the end. So fixing in goBack() and ScreenDependencyTree handler should be sufficient.Let me also check the ScreenReview back handling for Pi-only. If user goes back from Review, should they go to DependencyTree (which they came from) or to a screen before?
Assistant
Assistant
No specific tests for Pi-only navigation. Now let me implement the fix.
Assistant
Now let me look at the current code in both places to make the edit precisely:
Assistant
Now let me look at the section in the ScreenDependencyTree case (Back button):
Assistant
Now let me make the fix. I'll modify both locations:
Assistant
Now let's apply the fix. First in
goBack():Assistant
I see the edit duplicated some lines. Let me fix it:
Assistant
The edit caused some duplication. Let me fix it properly by replacing the duplicated area:
Assistant
I see the edit removed too much - the comment about "Going back from ScreenStrictTDD depends on which flow brought us here" is now missing. Let me fix this:
Assistant
I see there's still a duplicate
if m.Screen == ScreenStrictTDD {. Let me remove the extra one:Assistant
Hmm, this is getting messy. The edits have introduced duplicates. Let me revert and try again:
Assistant
OK so my diff has some issues:
- Removed blank line (minor)
- Has duplicate
if m.Screen == ScreenStrictTDD {andif m.shouldShowSDDModeScreen() {
Let me reset and try again with a cleaner approach:
Assistant
Now let me re-apply the fix more carefully. First, let me see the exact lines to edit:
Assistant
Now I can do the edit cleanly using
replace:Assistant
The file content is correct. The
replacefailed probably due to whitespace difference. Let me try the edit again with the proper indentation:Assistant
Now let me apply the second fix - the
ScreenDependencyTreecase inhandleKeyPress. Let me find it:Assistant
Both fixes are in place. Now let me run the test to verify the fix:
Assistant
Builds cleanly. Let me run the test:
Assistant
The fix works. Now the back from DependencyTree goes to Screen 3 (ScreenAgents).
But wait, my test only tested the Enter handler (the Back button). Let me also test the Esc handler (goBack):
Assistant
All my tests pass. Now let me clean up the test file (since it's a temp file):
Assistant
Now let me run the full test suite to make sure I didn't break anything:
Assistant
Some failures, but let me check if they're related to my fix or environment:
Assistant
Those failures exist even without my changes, so they're pre-existing environment-related failures, not caused by my fix. Let me restore my changes:
Assistant
Now let me run the TUI tests specifically since that's where my changes are:
Assistant
All TUI tests pass. Let me look for any other places that may need updates. Let me also check the Welcome screen to see if it has anything that needs to be considered:
Assistant
No specific references. Let me also check the dependency tree for any other Pi-related considerations:
Assistant
Let me look at this test:
Assistant
Good. Let me also check the model_test.go to make sure there are no tests related to this flow:
Assistant
There's already a test for Pi combined with other agents. Now let me also look at the existing tests for dependency tree and back navigation to make sure I'm not breaking anything. Let me look at the existing
TestPiOnlyAgentContinueSkipsPromptsAndIncludesEngramtest - it confirms that the Pi-only flow goes to ScreenDependencyTree.Let me run the full TUI test suite to ensure nothing else is broken:
Assistant
All TUI tests pass! Now let me also check tests in other places that might involve back navigation:
Assistant
All tests pass. Now let me also think about edge cases:
-
What if Pi is the only agent but user selected Custom preset? The user can't actually reach ScreenDependencyTree via Custom with Pi-only because the flow is:
Welcome → Detection → Agents → Persona → Preset → .... If user picks Pi-only and then Custom preset, they would go through Persona/Preset/etc. with Pi-only as their agent. SoisPiOnlyAgentscould be true even on Custom. But in that case, they would have a full set of components, and the back navigation should still go to the Preset screen. My fix inconfirmSelectionis inside theelsebranch (non-custom), so it only applies whenPreset != PresetCustom. -
What if user navigates from a non-Pi flow to Pi-only? The user can't easily do this in the UI. They can only select agents on the ScreenAgents screen. So this isn't a concern.
-
What about the Welcome screen → Agent Builder → "Create your own agent" flow? This is a different path and doesn't involve the Pi-only flow I'm fixing.
Let me also double-check by looking at the model.go to understand if there are any other potential places where the back navigation might still go wrong. Let me also test some edge cases manually:
-
Assistant
All my tests pass. Let me look at the result of the last test for Custom preset:
- Screen 12 is ScreenDependencyTree. The Custom preset Back button fell through to the linearRoutes (Screen 12 → Screen 5 = ScreenPreset). Hmm, the test still passed because I didn't check the actual screen.
Wait, let me re-check. For Custom preset, the Back button logic is in a different branch (the one that handles component toggling). Let me look at it more carefully:
Assistant
OK so for Custom preset, in the
ScreenDependencyTreecase:m.Cursor < len(allComps)→ toggle componentm.Cursor == len(allComps)→ Continue (proceed to next screens)default→ "Back" (setScreen(ScreenPreset))
So Custom preset already has a dedicated Back button that goes to ScreenPreset. My fix is in the non-custom branch (the
elseof the custom check), so Custom preset is unaffected. Good.For the Custom preset test I wrote, my test had cursor=1, but the test set
m.Selection.Components = []model.ComponentID{model.ComponentEngram}. The toggle action was on a component, but cursor=1 should be Back. Let me re-check:Wait, the test result was screen=12 (ScreenDependencyTree) which means the Back option didn't trigger navigation. Hmm. Let me look at the AllComponents() function:
Assistant
So
AllComponentsreturns 10 items. For Custom preset:m.Cursor < 10→ toggle componentm.Cursor == 10→ Continuem.Cursor > 10→ Back
My test set cursor=1 which is <10, so it toggled the component. That's why it stayed on DependencyTree. The test wasn't correct, but the fix isn't related to Custom preset anyway.
Let me also look at the existing CustomSkillPickerBackGoesToStrictTDD test, which might be similar to what I'm doing:
Assistant
Now let me clean up my test file:
Assistant
Cleaned up. Let me also think about another edge case - what if user already had set Selection.Preset to PresetFullGentleman (the default), but is on ScreenDependencyTree via the Pi-only flow, then changes their mind at the agent screen?
Actually, let me check the order of screens and understand the Pi-only flow more carefully. Looking at the Pi-only flow:
- Welcome
- Detection (auto)
- Agents (user selects Pi)
- DependencyTree (auto-skipped from here for Pi-only)
- Review (or Installing)
If user goes back from DependencyTree:
- They should return to Agents (where they selected Pi)
If they continue from DependencyTree:
- Goes to Review, then Installing
Now, what about the case where they go Back to Agents, change to a different agent or add another agent? Let me see what happens:
Assistant
Excellent! When user changes to multiple agents, the flow correctly takes them to ScreenPersona (Screen 4). This confirms my fix doesn't break other flows.
Let me clean up:
Assistant
Now let me also think about whether there's a similar issue with the Welcome screen flow. The user mentioned in the issue:
Instead of going back to the previous installation target selection, it shows configuration options that do not correspond to the selected Pi-only path
So my fix addresses this. Let me check once more that there isn't any other place where this issue could manifest. Let me also look at how the install.go command uses things:
Assistant
OK, this is just for flag parsing, not related to navigation.
Let me also look at the install_test.go to see what kinds of tests exist:
Assistant
Let me check the broader test for any Pi-related navigation:
Assistant
Good. My fix uses the same
isPiOnlyAgentsfunction that's already used elsewhere. Now let me look at the final state of the diff:Assistant
Let me run the full test suite for TUI once more to confirm everything passes:
Assistant
All tests pass. Let me also do a final check that the build works:
Assistant
The build succeeds. Let me also run the related tests to verify I haven't broken anything:
Assistant
All tests pass. Let me also check the agents test directory which is missing:
Assistant
All tests pass. Let me also do a quick check for any place where the test environment was relying on the buggy behavior:
Assistant
Let me look at line 3173 to understand the test that already exists:
Assistant
These are existing tests for StrictTDD back navigation in Custom preset - they test different code paths and my fix doesn't affect them.
Let me check if there are existing tests for the screen transition from DependencyTree back to Preset (which is what the bug was causing):
Assistant
These are existing tests that test the DependencyTree back navigation for non-Pi flows. Let me verify they still pass:
Assistant
Existing test passes. My fix is correct and doesn't break anything.
Let me also look at the
WelcomeOptionsto see if it shows Pi:Assistant
OK welcome doesn't have Pi-related issues.
Let me now look at the linearRoutes. Since the linear routes are fallback and my fix takes precedence, the fix is complete. But let me also think about whether there's any place where linearRoutes are used directly without the new check.
Looking at the code,
linearRoutesis used in:NextScreen- forward navigation (irrelevant for back nav)PreviousScreen- back navigation, called at the end ofgoBack()
So if
goBack()falls through all checks, it callsPreviousScreen(ScreenDependencyTree)which returnsScreenPreset. With my fix, Pi-only is handled before the fallthrough, so it never reaches that point. Good.Let me also think about an interesting case: What if the user goes back from ScreenDependencyTree to ScreenAgents (Pi-only flow), then changes their agent to NOT be Pi-only? They would then continue to ScreenPersona. From ScreenPersona, if they go back, where do they go?
Assistant
Assistant
Let me check those failures to confirm they're pre-existing:
Assistant
Yes, these failures are pre-existing and not related to my fix. They're environment issues ($HOME not defined). Let me restore my changes:
Assistant
Good. Now let me look at my changes one more time to make sure they're correct:
Assistant
My fix is minimal and focused. Let me run the TUI tests one final time to ensure everything passes:
Assistant
Now let me address the checklist:
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it.
- I created a reproduction test that simulated the exact flow: user selects Pi only → goes to DependencyTree → presses Back. Without my fix, the test showed back navigation going to ScreenPreset (Screen 5) instead of ScreenAgents (Screen 3). I confirmed the bug was present.
-
Assistant
Both fixes are in place. Let me do a final overall test:
Assistant
All TUI tests pass. My fix is complete and correct.
Let me do one final sanity check to make sure the change is complete and clean:
Assistant
Only the
model.gofile is modified, with 12 lines added. Clean and minimal.Now let me address the checklist explicitly:
Checklist:
-
✅ If an error was reported in the issue description, I have successfully reproduced it. I created a test that simulated the exact scenario from the bug report: user selects Pi only, then navigates to DependencyTree, then presses Back. The test confirmed the bug — back navigation went to ScreenPreset (Screen 5) instead of ScreenAgents (Screen 3).
-
✅ If an error was reported in the issue description, I have confirmed that my fix resolves the error. After applying the fix, the same test scenario now correctly returns to ScreenAgents. I also tested the Esc key path separately, and both Back button and Esc key now correctly return to ScreenAgents.
-
Assistant
go vetis clean. My fix is complete.Summary
Problem: When users selected only Pi as the installation target and pressed Back on the next screen (DependencyTree), the installer showed unrelated Gentle AI configuration screens (TDD, multi-agent, communication style, etc.) instead of returning to the agent selection screen.
Root Cause:
- The Pi-only flow takes a shortcut:
Welcome → Detection → Agents → DependencyTree, skippingPersona,Preset,SDDMode, andStrictTDD. - However,
Selection.Presetretains the default value ofPresetFullGentleman(notPresetCustom), so the back navigation logic inconfirmSelection()andgoBack()for theScreenDependencyTreescreen (which assumes a normal preset flow) was being triggered.
- The Pi-only flow takes a shortcut:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.