Skip to content

Fix Chat/Imagine back navigation loops in TUI#122

Open
neednotapply wants to merge 1 commit into
mainfrom
codex/restructure-tui-menu-vupsm5
Open

Fix Chat/Imagine back navigation loops in TUI#122
neednotapply wants to merge 1 commit into
mainfrom
codex/restructure-tui-menu-vupsm5

Conversation

@neednotapply

Copy link
Copy Markdown
Owner

Motivation

  • Users were looped back into the same provider/model submenu when pressing Esc or selecting [Back] from the Chat model selector or the InvokeAI action menu instead of returning to the main menu.
  • Make the top-level launcher and TUI flows behave predictably so a Back/escape action exits the flow rather than re-entering the same menu repeatedly.

Description

  • Updated run_chat_mode to use the preferred-server helper (_choose_server_for_api) and changed the model-selection Back path to return so backing out goes to the main menu instead of re-entering the server/model loop.
  • Updated run_image_mode and run_automatic1111_mode to return when the InvokeAI/Automatic1111 submenu returns [Back], preventing the submenu from looping.
  • Added menu state helpers (_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.
  • Adjusted the launcher (scripts/launcher.py) top-level options to dispatch TerminalAI.py with --mode overrides for chat, imagine, and configure to align launcher behavior with the main TUI.
  • Added regression tests in tests/test_terminalai_modes.py that 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

  • Ran pytest -q tests/test_terminalai_modes.py and observed 10 passed.
  • Ran python -m py_compile scripts/TerminalAI.py scripts/launcher.py and the files compiled without syntax errors.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread scripts/TerminalAI.py
Comment on lines +3792 to 3794
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}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant