Skip to content

tui: compact tool selector with bidirectional cycle navigation#977

Merged
njbrake merged 3 commits intonjbrake:mainfrom
flowq-C:fix/tool-selector-cycle-display
May 8, 2026
Merged

tui: compact tool selector with bidirectional cycle navigation#977
njbrake merged 3 commits intonjbrake:mainfrom
flowq-C:fix/tool-selector-cycle-display

Conversation

@flowq-C
Copy link
Copy Markdown
Contributor

@flowq-C flowq-C commented May 8, 2026

Description

This PR fixes three issues affecting custom agents (defined via config.session.custom_agents) in the New Session dialog.


Fix 1: Tool selector overflow (render.rs)

The dialog renders all tools in a single horizontal line. With 5+ built-ins plus custom agents, the line overflows — custom agents become invisible and unreachable.

Before:

Tool: ● claude  ○ opencode  ○ codex  ○ gemini  ○ copilot  ○ cl-|
                                                            (truncated, unreachable)

After:

Tool: ← ● claude-gemma  [6/10]  →

Fix 2: Bidirectional navigation broken (mod.rs)

Both and performed the same action (forward increment). was effectively broken.

Split into two separate handlers: increments, decrements with wrap-around.


Fix 3: YOLO mode ignored for custom agents (instance.rs)

Custom agents are not in the built-in AGENTS list, so get_agent(&self.tool) returns None for them. This caused the YOLO flag to be silently skipped regardless of the YOLO toggle in the dialog — apply_yolo_mode was never called.

Fix: fall back to self.detect_as (already stored on the instance from agent_detect_as config) when the primary lookup returns None:

// Before:
let agent = crate::agents::get_agent(&self.tool);

// After:
let agent = crate::agents::get_agent(&self.tool)
    .or_else(|| crate::agents::get_agent(&self.detect_as));

This lets custom agents inherit the correct YoloMode from their declared agent_detect_as agent (e.g. --dangerously-skip-permissions for claude).


Changes

  • src/tui/dialogs/new_session/render.rs — compact selector display with counter
  • src/tui/dialogs/new_session/mod.rs — split Left/Right handler, fix direction
  • src/session/instance.rs — YOLO mode fallback via detect_as for custom agents

PR Type

  • New Feature
  • Bug Fix
  • Refactor
  • Documentation
  • Infrastructure / CI

Checklist

  • I understand the code I am submitting
  • New and existing tests pass
  • Documentation was updated where necessary
  • For UI changes: included screenshot or recording

AI Usage

  • No AI was used
  • AI was used for drafting/refactoring
  • This is fully AI-generated

AI Model/Tool used: Claude Sonnet 4.6 via Claude Code CLI

Any Additional AI Details you'd like to share: All three bugs were discovered while using custom Ollama cloud model aliases with AOE. Fixes were implemented, built locally, and tested before submitting.

  • I am an AI Agent filling out this form (check box if true)

Fixes two issues with the New Session dialog tool selector:

- Render: replace flat inline list (overflows on small terminals or with
  many custom agents) with a compact single-entry display showing the
  currently selected tool, a [current/total] counter, and ← → hints
- Navigate: split the combined Left|Right handler so ← moves backward
  (wrapping) and → moves forward, matching standard UX conventions

Before: Tool: ● claude  ○ opencode  ○ codex  ○ gemini  ○ copilot  ○ cl-|
After:  Tool: ← ● cl-ki  [6/10]  →
@Seluj78
Copy link
Copy Markdown
Contributor

Seluj78 commented May 8, 2026

Thanks for the PR ! Can you edit the body to follow the template ?

Otherwise the fix you are proposing sounds good, I am on my phone so I can't test it further right now

flowq-C and others added 2 commits May 8, 2026 11:45
Custom agents (defined in config.session.custom_agents) resolve to
agent = None in get_agent() since they are not built-in. This caused
the YOLO mode flag to be silently skipped for custom agents regardless
of the YOLO toggle in the New Session dialog.

Fix: fall back to detect_as (the agent_detect_as mapping already stored
on the instance) when the primary get_agent lookup returns None. This
lets custom agents inherit the correct YoloMode (e.g. CliFlag for
claude, EnvVar for opencode) from their declared detect_as agent.
Address review feedback on PR njbrake#977:

- mod.rs: collapse the duplicated Left / Right / Space tool-field arms
  into a single match arm with an inline direction switch, mirroring
  the neighboring profile_field handler.
- render.rs: only render the ← / → cycle hints when the tool field is
  focused, so the unfocused row is less visually noisy.
- tests.rs: add test_tool_selection_left_right_three_tools to actually
  exercise direction (the existing 2-tool test cannot distinguish
  forward from backward since wrap-around makes them look identical).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@njbrake njbrake merged commit b83023b into njbrake:main May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants