t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Feature]: MRU-based thread.last command for Ctrl+Tab (VS Code-style), distinct from sequential thread.next/previous

Open tbcarver opened this issue 2 months ago • 1 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I am describing a concrete problem or use case, not just a vague idea.

Area

apps/web (also applies to desktop)

Problem or use case

T3 Code exposes thread.next and thread.previous, which are keybindable and can be bound to Ctrl+Tab / Ctrl+Shift+Tab (see #6361, which closed these commands as the resolution for Ctrl+Tab thread switching). However, these commands cycle through threads in a fixed, sequential order — the same order threads appear in, e.g., the sidebar.

This does not match the behavior most users actually want from Ctrl+Tab, and does not match the established convention in VS Code, browsers, and similar tools: Ctrl+Tab there triggers an MRU (most-recently-used) switch, jumping to the previously active item, not the next item in list order. In VS Code specifically, a single Ctrl+Tab press toggles directly back to the last-focused editor tab; holding Ctrl and pressing Tab repeatedly cycles backward through recency-ordered history, and releasing Ctrl commits the selection.

With only sequential thread.next/thread.previous available, users who work with more than two or three threads open find that Ctrl+Tab does not reliably return them to the thread they were just on — it depends on where that thread happens to sit in list order relative to the current one. This defeats the primary use case that motivated #6361 and #4764 in the first place: quickly bouncing back and forth between two (or a handful of) threads without hunting through the sidebar.

Proposed solution

Add a new command, e.g. thread.last (or thread.mru.previous / thread.mru.next), that operates on recency order rather than list order:

  • Maintain an MRU stack of visited threads (similar in spirit to the history stack proposed for back/forward navigation in #6822/#7729, but scoped to thread focus events specifically rather than all app navigation).
  • A single invocation jumps to the most-recently-active thread before the current one (direct toggle between two threads on repeated presses, matching VS Code's simple Ctrl+Tab tap behavior).
  • Holding the modifier and pressing the trigger key repeatedly steps further back through the MRU stack; releasing the modifier commits the selection on the currently highlighted entry. A lightweight switcher UI (thread name/preview) while cycling would match VS Code's behavior, though a "just jump" v1 without a visible switcher is a reasonable minimal scope.
  • Keep thread.next / thread.previous as-is for users who want deterministic sequential cycling — this would be an additive command, not a replacement.
  • Default binding: Ctrl+Tab / Ctrl+Shift+Tab for thread.last (MRU), since that is the binding users will reach for based on convention. If thread.next/thread.previous already claim that binding by default, consider swapping the default so MRU is what Ctrl+Tab invokes out of the box, with sequential cycling available under a different default chord.

Why this matters

Anyone actively juggling multiple threads — the exact workflow described in #6361, #4764, and #3596 — relies on quickly returning to "the thread I was just on." Sequential next/previous only satisfies that reliably in the two-thread case where next and previous happen to coincide with recency. As soon as a third thread enters rotation, sequential cycling stops matching user intent, and the user falls back to sidebar hunting — the exact friction these prior requests were meant to eliminate.

This is a well-established, low-ambiguity interaction pattern (VS Code, most browsers' Ctrl+Tab, OS-level Alt+Tab) that users will expect by default.

Smallest useful scope

  • A thread.last command that jumps to the single most-recently-active thread on one press, toggling between two threads on repeated presses.
  • Bindable in Settings → Keybindings alongside existing thread commands.
  • No visible switcher UI required for v1; a full MRU list/holdable switcher can be a follow-up.

Alternatives considered

  • Bind Ctrl+Tab to existing thread.next/thread.previous (current state, per #6361) — works only incidentally for two threads, breaks down with three or more.
  • Numbered thread shortcuts (Cmd+1...Cmd+N) — useful for fixed slots, not recency-based switching.
  • General back/forward app navigation history (#6822/#7729) — covers broader app navigation (settings, other views) but is a separate, heavier-weight feature; thread-focused MRU switching is a narrower and more immediately achievable improvement that would still be valuable if #6822 lands later.

Risks or tradeoffs

  • Needs a clear rule for what counts as a "thread switch" event that pushes onto the MRU stack (e.g., does opening a thread via search/deep link count the same as clicking it in the sidebar?).
  • If the default binding for thread.last is Ctrl+Tab, this would change the default behavior of the binding that #6361 shipped, so it may need to be introduced as a new default rather than silently altering existing user keybindings.
  • MRU stack should evict closed/deleted threads gracefully and probably cap its depth.
  • Should be resolved in coordination with any future implementation of #6822 (general navigation history), so the two features share underlying history-tracking infrastructure rather than diverging.

Examples or references

  • VS Code: Ctrl+Tab toggles to the last-active editor tab; holding Ctrl and repeating Tab cycles backward through MRU history.
  • #6361 — closed as "completed" on the basis that thread.next/thread.previous are keybindable, but did not address MRU-based switching, which is what the underlying request was actually describing.
  • #4764 — original navigation history proposal that #6361 and #7729 both reference.
  • #6822 — Ideas discussion tracking general app navigation history (broader scope than thread-only MRU).

Contribution

  • [ ] I would be open to helping implement this.

tbcarver avatar Sep 20 '26 21:09 tbcarver

Duplicate of https://github.com/pingdotgg/t3code/discussions/9751 — same request for MRU / Alt+Tab-style thread switching alongside positional thread.next / thread.previous.

Open PR https://github.com/pingdotgg/t3code/pull/11072 already implements the smallest version (thread.cycleRecent, Ctrl+Tab by default).

juliusmarminge avatar Sep 20 '26 21:09 juliusmarminge