Skip to content

feat: session quick switch (Alt+1-9) and pinning #79

Description

@badchars

Summary

Add the ability to pin sessions and quickly switch between them using Alt+1 through Alt+9 keyboard shortcuts — similar to browser tab switching. Ported from upstream's session.quick_switch system.

Features

Session Pinning

  • Pin/unpin sessions from the /sessions dialog
  • Pinned sessions appear at the top of the session list under a "Pinned" category
  • Pin state persists across restarts (stored in ~/.local/share/cyberstrike/session.json)

Quick Switch (Alt+1-9)

  • First 9 pinned sessions get slot numbers 1-9
  • Alt+1 switches to slot 1, Alt+2 to slot 2, etc.
  • Slot numbers shown in the session list gutter
  • Works from anywhere in the TUI — no need to open session list first

Implementation plan

1. local.tsx — Session namespace

Add session namespace to useLocal with the same persist pattern as model:

  • session.pinned() — returns pinned session IDs
  • session.slots() — returns first 9 pinned IDs (slot 1-9)
  • session.togglePin(id) — pin/unpin a session
  • Persists to ~/.local/share/cyberstrike/session.json

2. keybind.tsx — Quick switch keybinds

Add 9 keybind definitions:

session_quick_switch_1: [{ key: "1", alt: true }]
...
session_quick_switch_9: [{ key: "9", alt: true }]

3. dialog-session-list.tsx — UI integration

  • Pinned sessions grouped under "Pinned" category at top
  • Slot numbers (1-9) shown in gutter
  • Pin/unpin keybind in dialog (e.g. ctrl+p)

4. routes/session/index.tsx — Keyboard handler

  • Listen for Alt+1-9 globally
  • Navigate to local.session.slots()[N-1] on match

References

  • Upstream: packages/tui/src/component/dialog-session-list.tsxlocal.session.pinned(), local.session.slots(), slotByID gutter rendering
  • Upstream: useCommandShortcut("session.quick_switch.1") through session.quick_switch.9

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions