Fix Chat/Imagine back navigation loops in TUI#122
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 45acfb9546
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if choice is None: | ||
| print(f"{RED}No active Ollama servers available{RESET}") | ||
| get_input(f"{CYAN}Press Enter to return to the main menu{RESET}") |
There was a problem hiding this comment.
Distinguish back-out from missing server in chat flow
When _choose_server_for_api(..., allow_back=True) returns None, this branch always reports "No active Ollama servers available" even if the user simply pressed Esc/[Back] in select_server. Since _choose_server_for_api also returns None for a deliberate back action, the chat flow now shows a false error and extra confirmation prompt instead of quietly returning to the main menu; the same ambiguity also affects run_image_mode.
Useful? React with 👍 / 👎.
Motivation
Escor selecting[Back]from the Chat model selector or the InvokeAI action menu instead of returning to the main menu.Description
run_chat_modeto use the preferred-server helper (_choose_server_for_api) and changed the model-selection Back path toreturnso backing out goes to the main menu instead of re-entering the server/model loop.run_image_modeandrun_automatic1111_modeto return when the InvokeAI/Automatic1111 submenu returns[Back], preventing the submenu from looping._load_menu_state,_save_menu_state,_remember_server_selection,_forget_server_selection,_get_preferred_server,_choose_server_for_api) and wired them into server selection paths so preferred servers are reused and stale selections are cleared on failures.scripts/launcher.py) top-level options to dispatchTerminalAI.pywith--modeoverrides forchat,imagine, andconfigureto align launcher behavior with the main TUI.tests/test_terminalai_modes.pythat assert Back/escape from Chat model selection and InvokeAI submenus return to the main menu after a single cycle and that server-choice persistence behaves as expected.Testing
pytest -q tests/test_terminalai_modes.pyand observed10 passed.python -m py_compile scripts/TerminalAI.py scripts/launcher.pyand the files compiled without syntax errors.Codex Task