Skip to content

ui: support mouse back/forward (X1/X2) buttons to navigate between views #274

@domcyrus

Description

@domcyrus

Background

Today's mouse handling in src/main.rs (lines 695-789) only consumes MouseButton::Left, ScrollUp, and ScrollDown. Crossterm already emits MouseButton::X1 and MouseButton::X2 events on supported terminals — we just don't process them. A common workflow is: double-click a connection (jumps to Details), then mouse-back to return to Overview. Today that requires Esc or Shift+Tab.

We also have no view-history stack — selected_tab in UIState is a bare usize updated by direct assignment.

Scope

Two parts:

1. History stack

  • Add tab_history: VecDeque<usize> (bounded ~16) and optionally forward_stack: VecDeque<usize> to UIState in src/ui.rs (around line 495)
  • Push the previous tab on every tab change initiated by the user (Tab, click, Enter→Details, i/h/Esc, and any future view-switch hotkeys from ux: polish keyboard shortcuts for view switching (design discussion) #273)
  • Provide helpers go_back() / go_forward() that pop/push appropriately

2. Mouse plumbing

Acceptance criteria

The PR must include evidence of real-world end-to-end testing — actually plug in a mouse with X1/X2 buttons (or use a tool like xev to confirm), run rustnet, and demonstrate back/forward works. Mention the terminal and the mouse model in the PR description. A short screencast is ideal.

  • X1/X2 buttons move backward/forward through tab history on terminals that forward them — verified live in at least one terminal (kitty, foot, WezTerm, iTerm2, or Windows Terminal). Note in the PR which terminals were tested and which forwarded the events
  • Terminals that don't forward X1/X2 are silently unaffected (no error, no crash) — tested by running in a terminal that doesn't support them (e.g., basic xterm) and confirming nothing breaks
  • History stack bounded; doesn't grow unbounded on long sessions — include a quick sanity test (e.g., 100 tab switches, confirm memory doesn't grow)
  • Keyboard equivalents work and are documented in the Help tab and USAGE.md
  • Screencast or screenshots in the PR description demonstrating mouse back/forward in action

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededuiUI / UX (keyboard, mouse, layout)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions