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
No 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.Interface
No new interfaces are introduced.
Assistant
Let me start by exploring the repository structure to understand the codebase and find the relevant installer code.
Assistant
This is a Go project. Let me explore the cmd directory and internal directory to find the installer code.
<tool_call> <function=bash_terminal> <parameter=command> find . -type f -name "*.go" | xargs grep -l "installer|gentle-pi" 2>/dev/null | head -20 </tool_call>
Assistant
The command didn't execute properly. Let me try again with proper command execution.
Assistant
Let me look for the gentle-pi installer specifically. Let me search more broadly.
<tool_call> <function=bash_terminal> <parameter=command> find . -type f -name "*.go" | xargs grep -l "gentle-pi" 2>/dev/null | head -20 </tool_call>
Assistant
I need to format my command properly to execute it.
Assistant
Let me explore the cmd/gentle-ai directory to understand the structure of the main application.
Assistant
Let me look at the main.go file to understand how the application starts and where the installer logic is.
Assistant
The main entry point is in the internal/app package. Let me explore that to find the installer logic. Let me find the installer-related files and the installation target selection logic.
<tool_call> <function=bash_terminal> <parameter=command> ls -la internal/app/ </tool_call>
Assistant
Let me run the command properly to explore the app directory.
Assistant
The app.go file is the main file for the app. Let me look at it to find the installer logic.
Assistant
Now I can see the app.go file. I need to look at the TUI model and understand the installer flow. Let me look at the tui package to find where the installer is implemented.
<tool_call> <function=bash_terminal> <parameter=command> ls -la internal/tui/ </tool_call>
Assistant
Let me run the command properly to list the tui directory.
Assistant
Let me look at the model.go file which is likely where the TUI model is defined. It's a large file (121KB), so I need to search for the installer-related parts.
Assistant
Let me search for "gentle-pi" or "gentle-pi" references and look for the installation target selection flow.
Assistant
Let me look for the installation target selection flow or "installation target" and "go back" logic in the model.go file.
Assistant
Let me search for the goBack function to understand how back navigation works.
Assistant
Let me look at the goBack function to understand how back navigation works.
Assistant
I need to continue reading the goBack function to understand the full navigation logic.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2420,2520p' internal/tui/model.go </tool_call>
Assistant
The command didn't execute properly again. Let me try again to read more of the goBack function.
Assistant
Let me continue reading the goBack function to see if there is specific logic for the installation target screen.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2520,2620p' internal/tui/model.go </tool_call>
Assistant
I need to continue reading the model.go file to understand the navigation logic, especially around installation targets. Let me try again with the proper command.
Assistant
Let me search for "ScreenInstallTarget" or related screen definitions. Let me also look at the screens directory to find the installation-related screens. Let me first look at the screens directory to understand what screens exist.
<tool_call> <function=bash_terminal> <parameter=command> ls -la internal/tui/screens/ </tool_call>
Assistant
Let me try a different approach to list the screens directory. I'll run the command properly.
Assistant
I see there are screens related to agents, preset, dependency_tree, etc. Let me search for how installation targets are determined. The issue mentions "Pi-only install" and back navigation. Let me look at the agents.go file and the preset.go file to understand the flow better.
Assistant
This looks like the agents selection screen. Now let me look at the preset.go file to see how presets work.
Assistant
Now let me search for the "gentle-pi" or "Pi" installation logic. I need to find where the Pi-only installation target is configured. Let me search for Pi-related code in the repository.
<tool_call> <function=bash_terminal> <parameter=command> grep -rn "pi|Pi" --include="*.go" internal/tui/ | grep -v "_test.go" | grep -i "install|target" | head -20 </tool_call>
Assistant
Let me try running a simpler command to search for Pi-related code.
Assistant
Let me try to find where gentle-pi is mentioned or used as a selection. Let me search more broadly for gentle-pi.
Assistant
Let me look at the dependency_tree.go file to understand how the installation works.
Assistant
I can see that the
hasPiAgentInInstallPlanfunction checks formodel.AgentPi. Now let me look for whereAgentPiis defined and how the installation flow works for the Pi agent. I also see that there's a specific flow for Pi agent support. Let me search for the model file where AgentPi is defined.<tool_call> <function=bash_terminal> <parameter=command> grep -rn "AgentPi" --include="*.go" internal/ | grep -v "_test.go" | head -20 </tool_call>
Assistant
I need to fix my command formatting. Let me try running the grep command again properly.
Assistant
Now I understand. There's an
isPiOnlyInstallcheck. Let me look at the relevant code around line 3135 in model.go to understand the back navigation issue.Assistant
Now let me look at the goBack function more carefully to understand how it handles the back navigation, especially for the Pi-only case. Let me also look at the confirmSelection function and the PreviousScreen function to understand the navigation logic. Let me search for the
PreviousScreenfunction.<tool_call> <function=bash_terminal> <parameter=command> grep -n "PreviousScreen" internal/tui/model.go | head -20 </tool_call>
Assistant
The command didn't execute. Let me try again.
Assistant
Let me look at the router.go file to understand the navigation routing.
Assistant
Now I understand the navigation flow. According to the router.go file:
- ScreenPreset -> ScreenDependencyTree -> ScreenReview
The issue says that when selecting "Pi-only" (only AgentPi) and then using Back from the next step (ScreenDependencyTree or ScreenReview), the installer shows unrelated configuration screens.
Let me look at the goBack function again to see how it handles back navigation. I noticed that there's special handling for Custom preset in the goBack function, but there might not be special handling for Pi-only installs.
Let me search for where the issue might be - in the goBack function or confirmSelection function.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "goBack|confirmSelection" internal/tui/model.go | head -30 </tool_call>
Assistant
The command didn't execute. Let me try again.
Assistant
Now let me look at the confirmSelection function and the goBack function more carefully to understand the issue.
Let me first look at the confirmSelection function. Let me search for the confirmSelection function definition.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1137,1300p' internal/tui/model.go </tool_call>
Assistant
The command didn't execute. Let me try again properly.
Assistant
Let me continue reading the confirmSelection function. Let me read more of the confirmSelection function.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1300,1500p' internal/tui/model.go </tool_call>
Assistant
I need to continue reading the confirmSelection function to understand how it handles back navigation. Let me try again with the proper command formatting.
Assistant
Now I can see the issue! In the
confirmSelectionfunction forScreenAgents:case m.Cursor == agentCount && len(m.Selection.Agents) > 0: if isPiOnlyAgents(m.Selection.Agents) { m.Selection.Components = piOnlyComponents() m.buildDependencyPlan() m.setScreen(ScreenDependencyTree) return m, nil } m.setScreen(ScreenPersona)When selecting Pi-only, it goes directly from
ScreenAgentstoScreenDependencyTree, skippingScreenPersonaandScreenPreset. This is the issue - the back navigation doesn't account for this special case.Let me look at the goBack function to see how it handles going back from
ScreenDependencyTree:Assistant
Now I understand the issue! Let me look at the
shouldShow*functions and how they determine which screens to show when going back fromScreenDependencyTree:Assistant
Let me look at the shouldShow* functions to understand how they determine which screens to show:
Assistant
Let me look at these shouldShow functions to understand the logic:
Assistant
Now I understand the issue! When the user selects only the Pi agent:
-
In
confirmSelectionforScreenAgents, whenisPiOnlyAgents(m.Selection.Agents)is true, it setsm.Selection.Components = piOnlyComponents()and goes directly toScreenDependencyTree, skippingScreenPersonaandScreenPreset. -
The issue is that when going back from
ScreenDependencyTree, thegoBackfunction has this logic:
if m.Screen == ScreenDependencyTree && m.Selection.Preset != model.PresetCustom { if m.shouldShowOpenCodePluginsScreen() { m.setScreen(ScreenOpenCodePlugins) return m } if m.shouldShowStrictTDDScreen() { m.setScreen(ScreenStrictTDD) return m } if m.shouldShowClaudeModelPickerScreen() { m.setScreen(ScreenClaudeModelPicker) return m } }Since Pi-only doesn't set
m.Selection.Presetto anything specific (it stays as the default/empty),m.Selection.Preset != model.PresetCustomis true. The functions return false for Pi-only since they check for specific agents and components.-
Assistant
Let me run the grep command properly to find the preset definitions.
Assistant
So the default preset is an empty string. When the user selects Pi-only, the preset is not set, so
m.Selection.Preset != model.PresetCustomis true (since"" != "custom").The issue is that when going back from ScreenDependencyTree with Pi-only selection, the code falls through to the
PreviousScreenfunction in router.go, which returns ScreenPreset as the backward screen. But ScreenPreset is not appropriate for Pi-only since we skipped the Persona and Preset screens.Let me look at what happens when the user presses Back from ScreenDependencyTree with Pi-only selected:
- The
goBackfunction is called m.Screen == ScreenDependencyTreeis truem.Selection.Preset != model.PresetCustomis true (preset is empty)shouldShowOpenCodePluginsScreen()- checks for OpenCode agent, returns false for Pi-onlyshouldShowStrictTDDScreen()- checks for SDD component, returns false for Pi-only- - checks for ClaudeCode agent, returns false for Pi-only
- The
Assistant
Let me search for the correct lines in the goBack function where we need to add the Pi-only back navigation fix.
Assistant
I need to find the exact line number where I should add the Pi-only back navigation fix. The fix should be added in the
goBackfunction after checking for OpenCodePlugins, StrictTDD, and ClaudeModelPicker, but before falling through to thePreviousScreencall. Let me look for the PreviousScreen call in goBack:<tool_call> <function=bash_terminal> <parameter=command> grep -n "PreviousScreen|goBack|ScreenDependencyTree" internal/tui/model.go | head -20 </tool_call>
Assistant
Let me try a different approach to find the line numbers:
Assistant
Now I understand the flow. The
goBackfunction has:- Special handling for
ScreenDependencyTreewithm.Selection.Preset != model.PresetCustom - Falls through to
PreviousScreen(m.Screen)at line 2584
For Pi-only, after the special
ScreenDependencyTreecheck (lines 2435-2450), it falls through toPreviousScreen(ScreenDependencyTree)which returnsScreenPreset.I need to add a check for Pi-only before falling through to
PreviousScreen. The fix should be:if m.Screen == ScreenDependencyTree && isPiOnlyAgents(m.Selection.Agents) { m.setScreen(ScreenAgents) return m }But I need to add it in the right place. Looking at the code:
- Line 2435-2450: Handle DependencyTree for non-custom presets with special screens
- After that, there's handling for ScreenStrictTDD, ScreenSDDMode, ScreenClaudeModelPicker, etc.
- Line 2584: Falls through to PreviousScreen
The best place to add the fix is at the beginning of the
ScreenDependencyTreecheck, before the existing checks. Let me look at the full DependencyTree handling again:- Special handling for
Assistant
I need to look at the full goBack function around the ScreenDependencyTree handling. Let me try a different command to view this section.
Assistant
Now I have a clear understanding of the issue:
-
When the user selects only Pi agent, the
confirmSelectionfunction skipsScreenPersonaandScreenPresetand goes directly toScreenDependencyTree. -
When going back from
ScreenDependencyTree, the current code falls through toPreviousScreen(ScreenDependencyTree)which returnsScreenPreset. But for Pi-only, this is incorrect because we skipped the Persona and Preset screens.
The fix needs to add a check for Pi-only in the
goBackfunction to send it back toScreenAgents.Let me first find the exact line numbers for the fix:
-
Assistant
Now I understand the issue completely. The fix should be added in the
goBackfunction to handle the Pi-only case when going back fromScreenDependencyTree. Currently, when the user selects only Pi agent, the flow skipsScreenPersonaandScreenPresetand goes directly toScreenDependencyTree. When going back, the code falls through toPreviousScreen(ScreenDependencyTree)which returnsScreenPreset, but this is incorrect for Pi-only.Let me implement the fix by adding a check for Pi-only after the existing
ScreenDependencyTreecheck:Assistant
Now I understand the issue and have identified the exact location for the fix. I need to add a check for Pi-only after the existing
ScreenDependencyTreecheck to send the user back toScreenAgentsinstead ofScreenPreset.Let me implement the fix:
Assistant
Now I need to add the fix. I'll add a check for Pi-only after the
ScreenDependencyTreecheck, before theScreenStrictTDDhandling. This will ensure that when going back fromScreenDependencyTreewith Pi-only selection, it goes back toScreenAgentsinstead of falling through toScreenPreset.Assistant
Now I understand the issue. I need to add a check for Pi-only in the
goBackfunction to redirect it back toScreenAgentswhen going back fromScreenDependencyTree.Assistant
The edit was successful. Now I need to verify that the fix is correct by:
- Checking that the code compiles
- Running any existing tests related to this functionality
- Understanding the edge cases
Let me first verify the code compiles:
<tool_call> <function=bash_terminal> <parameter=command> cd /gentle-ai && go build ./... 2>&1 | head -30 </tool_call>
Assistant
The command didn't execute. Let me try again with the proper command formatting.
Assistant
The command executed but there's a Go module cache issue. Let me try to set up the Go environment first.
Assistant
Let me set up the proper environment and try to build the project.
Assistant
The command executed but the output shows exit code 0 without any errors, which means the build succeeded. Let me verify this and then run the existing tests to ensure the fix doesn't break anything. Let me run the tests for the TUI model to ensure the fix doesn't break existing functionality.
<tool_call> <function=bash_terminal> <parameter=command> cd /gentle-ai && go test ./internal/tui/... 2>&1 | tail -50 </tool_call>
Assistant
Let me try running the tests again with the proper environment.
Assistant
All tests pass. Now let me also check if there are any tests specifically related to back navigation or Pi-only installs. Let me search for existing tests that might be affected by this change. Let me also verify that the fix handles edge cases properly. I should check:
- What happens when going back from ScreenReview with Pi-only selection
- What happens when going back from ScreenInstalling with Pi-only selection
- What happens when going back from ScreenComplete with Pi-only selection
Let me look at the code flow again to see if there are any other places that need to be updated. Let me check the
confirmSelectionfunction to see if there's any handling for Pi-only when going back from other screens likeScreenReview:<tool_call> <function=bash_terminal> <parameter=command> grep -n "ScreenReview|ScreenInstalling|ScreenComplete" internal/tui/model.go | head -30 </tool_call>
Assistant
Let me try running the grep command with proper command formatting.
Assistant
Let me look at the
goBackfunction to see how it handles going back fromScreenReview,ScreenInstalling, andScreenComplete. I need to ensure that Pi-only is handled correctly in all these cases. Let me look at how thegoBackfunction handles going back fromScreenReview:<tool_call> <function=bash_terminal> <parameter=command> sed -n '2548,2590p' internal/tui/model.go </tool_call>
Assistant
I need to look at the goBack function handling for ScreenReview to see if Pi-only is handled correctly there as well.
Assistant
Assistant
Let me update the fix to handle the case when
PresetCustomis selected with only Pi:Assistant
The fix needs to be updated to only apply when the preset is empty. Let me update the condition to also check for empty preset.
Assistant
The fix has been updated. Now let me verify that the code still compiles and the tests pass.
Assistant
The code compiles successfully. Now let me run the tests to ensure the fix doesn't break existing functionality. Let me run the TUI tests to ensure the fix doesn't break existing functionality.
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=HOME/.cache/go-build && cd /gentle-ai && go test ./internal/tui/... -v 2>&1 | tail -100 </tool_call>
Assistant
The command didn't execute properly. Let me try again with the proper command formatting.
Assistant
The tests pass. Let me also run all the TUI tests to make sure everything is working correctly. Let me also run the model tests to ensure the fix doesn't break existing functionality.
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=HOME/.cache/go-build && cd /gentle-ai && go test ./internal/tui/... 2>&1 | tail -10 </tool_call>
Assistant
The command didn't execute. Let me try again with the proper command formatting.
Assistant
All tests pass. Now let me verify if there are any existing tests related to the Pi-only back navigation or the goBack function.
Assistant
Let me check if there are any existing tests for the goBack function that I need to update or verify. Let me look at the model_test.go file to find any tests related to the goBack function and Pi-only selection.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "goBack|back|Back" internal/tui/model_test.go | head -30 </tool_call>
Assistant
I need to run a grep command to find tests related to the goBack function.
Assistant
The test file has a test called
TestNavigationBackWithEscapeat line 196. Let me look at this test to understand the existing back navigation tests.<tool_call> <function=bash_terminal> <parameter=command> sed -n '196,300p' internal/tui/model_test.go </tool_call>
Assistant
I need to view the test file around line 196 to understand the existing back navigation tests. Let me run the sed command properly.
Assistant
Now I can see the existing tests for Pi-only selection. The test
TestPiOnlyAgentContinueSkipsPromptsAndIncludesEngramat line 241 verifies that selecting only Pi agent skips toScreenDependencyTree.However, there's no existing test for the back navigation from
ScreenDependencyTreewhen Pi-only is selected. I should add a test to verify that the fix works correctly.But first, let me verify that the fix is correct by creating a simple test script to reproduce the issue. Let me create a test to verify that the back navigation from ScreenDependencyTree with Pi-only selection returns to ScreenAgents.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '310,350p' internal/tui/model_test.go </tool_call>
Assistant
Let me look for where I should add a test for the back navigation from ScreenDependencyTree with Pi-only selection. I need to find a good place in the test file to add this test. Let me look at the end of the test file to find a good place to add the test.
Assistant
Now I understand the test file structure. I should add a test for the back navigation from ScreenDependencyTree with Pi-only selection. Let me add this test after the existing Pi-only tests. Let me add a test to verify that the back navigation from ScreenDependencyTree with Pi-only selection returns to ScreenAgents. I'll add this test after the
TestPiOnlyAgentContinueSkipsPromptsAndIncludesEngramtest. Let me look for the line number where theTestPiOnlyAgentContinueSkipsPromptsAndIncludesEngramtest ends so I can add the new test after it.<tool_call> <function=bash_terminal> <parameter=command> sed -n '275,295p' internal/tui/model_test.go </tool_call>
Assistant
I need to continue investigating the issue with back navigation from Pi-only install. Let me run the grep command properly to find the test.
Assistant
Let me run all the tests to ensure my fix doesn't break existing functionality:
Assistant
The tests show that:
- My fix in the TUI model passes (cached)
- There are some failing tests in other packages (internal/cli, internal/opencode) but these are unrelated to my fix - they appear to be environment-specific tests related to go bin directory and cache path
Let me verify that the TUI tests specifically pass and check if there's any test related to the back navigation issue I'm fixing. Let me run just the TUI tests to confirm my fix works:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=HOME/.cache/go-build && cd /gentle-ai && go test ./internal/tui/... -v 2>&1 | grep -E "PASS|FAIL|RUN.*Back|RUN.*Pi" </tool_call>
Assistant
Let me run the TUI tests with grep to see if the back navigation and Pi-related tests pass.
Assistant
All TUI tests pass. Now let me verify that the fix handles the edge cases correctly and create a simple test script to reproduce the issue and verify the fix.
Let me first check if the existing test file has any tests for the back navigation from ScreenDependencyTree with Pi-only:
Assistant
Let me look for the exact test line in model_test.go:
Assistant
Now let me look at the TestDependencyTreeEnterBackNavigatesToStrictTDD test to understand how back navigation from ScreenDependencyTree is tested:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '2812,2850p' internal/tui/model_test.go </tool_call>
Assistant
The command didn't execute. Let me try again with proper command formatting.
Assistant
Now I understand how the back navigation tests are structured. Let me also check if the fix needs to handle the case when the user presses Esc from ScreenDependencyTree vs. pressing Enter on the "Back" option.
Looking at the code in confirmSelection:
case ScreenDependencyTree: options := screens.DependencyTreeOptions() switch { case m.Cursor < len(options): if m.Cursor == 0 { // Continue m.buildDependencyPlan() m.setScreen(ScreenReview) } else if m.Cursor == 1 { // Back m = m.goBack() } }So both Esc and Enter on the "Back" option should call
goBack(), which my fix handles.Now let me verify that my fix is correct by reviewing the logic again:
- For Pi-only selection:
m.Selection.Preset == ""andisPiOnlyAgents(m.Selection.Agents) == true - My fix checks:
m.Screen == ScreenDependencyTree && isPiOnlyAgents(m.Selection.Agents) && m.Selection.Preset == "" - If true, returns to ScreenAgents
- For Pi-only selection:
Assistant
Let me run the git diff command to see the changes I made.
Assistant
The diff shows the fix I made. Let me now verify that all the TUI tests pass and the build is successful before submitting. Let me run the TUI tests one more time to ensure my fix works correctly:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=HOME/.cache/go-build && cd /gentle-ai && go test ./internal/tui/... 2>&1 </tool_call>
Assistant
The command didn't execute properly. Let me try again with the proper command formatting.
Assistant
The tests pass. Let me now verify that the code still builds correctly after the fix:
<tool_call> <function=bash_terminal> <parameter=command> export GOMODCACHE=HOME/.cache/go-build && cd /gentle-ai && go build ./... 2>&1 </tool_call>
Assistant
The command didn't execute properly. Let me try again with the proper command formatting.
Assistant
The build succeeds. Now let me verify the fix one more time by understanding the issue and my solution:
Summary of the Issue
The issue is that when running the
gentle-piinstaller:- User selects only
Pias the installation target - The flow skips
ScreenPersonaandScreenPreset, going directly toScreenDependencyTree - When the user presses
BackfromScreenDependencyTree, the code falls through toPreviousScreen(ScreenDependencyTree)which returnsScreenPreset - This is incorrect because
ScreenPresetwas never shown in the Pi-only flow
My Fix
I added a check in the function to handle the Pi-only case:
- User selects only
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.