Skip to content

feat(tui): keyboard selection, path/preview toggles for session browser - #407

Open
alecuba16 wants to merge 1 commit into
Kuberwastaken:mainfrom
alecuba16:pr387-browser
Open

feat(tui): keyboard selection, path/preview toggles for session browser#407
alecuba16 wants to merge 1 commit into
Kuberwastaken:mainfrom
alecuba16:pr387-browser

Conversation

@alecuba16

Copy link
Copy Markdown

Summary

Split A of #387. Adds keyboard selection and display toggles to the session browser overlay.

Note: This PR supersedes the session-browser-toggles portion of #387. The keyboard text selection + copy features remain in a separate split B PR to keep scope tight.

Changes

Keyboard routing through keybindings.rs

  • New KeyContext::SessionBrowser variant with configurable default bindings:
    • / or j/k navigate (prevSession/nextSession)
    • PgDn/PgUp page navigation (nextSessionPage/prevSessionPage)
    • Enter resume session (resumeSession)
    • r rename session (renameSession)
    • a toggle paths (toggleSessionPaths)
    • p toggle preview (toggleSessionPreview)
    • Esc close (closeSessionBrowser)
  • All keys flow through the configurable keybinding system in crates/core/src/keybindings.rs — no inline hardcoded key checks.

Session browser rendering

  • SessionEntry gains a working_dir field, shown under each row when paths are toggled on.
  • render_session_browser rewritten with a fixed layout:
    • Windowed listlist_window helper keeps the selection centered in the visible window. No more scrolling past the viewport.
    • Preview panel — optional panel under the list showing the selected session's title, stats, and working directory. Toggled with p.
    • Hint bar — always visible at the bottom, shows current keybindings.

Toggles

  • show_paths (toggle with a): shows the working-directory path of each listed session. Does not reveal sessions from other projects — only the sessions already listed.
  • show_preview (toggle with p): shows a preview panel of the selected session.

Fix #382

The session browser opened empty because the session-loading code lived in dead App::run code that was never called. The load now happens in run_interactive via a session_list_tx/session_list_rx channel: when the browser opens, an async list_sessions task spawns and drains entries into the browser.

Session resume from browser

session_resume_pending drives resume from the browser, using the same swap logic as the /resume command: load messages, reset file history and turn bookkeeping, update working_dir.

Tests

  • 5 session_browser unit tests: toggle defaults, toggles flip flags, list_window windowing, render with paths+preview, render long list walks selection.
  • 2 TUI keybinding routing tests: toggles route through keybindings (not inline), rename stays inline (Esc cancels back to Browse).
  • All 22 session_browser tests pass. The 2 new TUI tests pass. Clippy clean.
  • Pre-existing failure settings_screen::tests::all_entries_returns_expected_settings (expects ≤20 settings, gets 21) is unrelated — it fails on main and this PR does not touch settings.

CRLF preservation

session_browser.rs, keybindings.rs, and docs/commands.md are CRLF files. All additions use \r\n. No LF churn on untouched lines.

Add keyboard selection and display toggles to the session browser overlay.

Key changes:
- KeyContext::SessionBrowser variant with configurable bindings (defaults:
  arrows/j/k navigate, Enter resume, r rename, a toggle paths, p toggle
  preview, Esc close). All keys route through keybindings.rs, not inline.
- SessionEntry gains working_dir field; render shows it under each row.
- render_session_browser rewritten with fixed layout: windowed list
  (list_window helper keeps selection centered), optional preview panel,
  always-visible hint bar showing keybindings.
- show_paths/show_preview state with toggle methods; 'a' shows the
  working-directory path of each listed session (does not reveal sessions
  from other projects), 'p' shows a preview panel of the selected session.
- Fix Kuberwastaken#382: session browser opened empty because session loading lived in
  dead App::run code. Moved into run_interactive via session_list_tx channel.
- session_resume_pending drives resume from the browser (same swap logic as
  /resume command: load messages, reset file history and turn bookkeeping,
  update working_dir).

Tests: 7 new (5 session_browser unit tests + 2 TUI keybinding routing tests).
CRLF preserved on session_browser.rs, keybindings.rs, commands.md.
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.

Sessions are not working

1 participant