Restore the focus a thread had (chat or terminal) when switching back to it

Offen Anfängerfreundlich
#33,028 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@voltcrash arbeitet bereits daran.

Seit 02.11.2026.

  • #29179 von @voltcrash — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript
Bereich
frontend

Rechercherichtung

Lies apps/web/src/lib/terminalFocus.ts und den Aufruf beim Betreten eines Threads in ChatView.tsx (etwa bei Zeile 2655); verfolge, wie getTerminalFocusOwner() und das von focusTerminalOnThreadEnter zurückgegebene Cleanup das Fokusverhalten steuern. Erhalte das explizite Einblenden des Terminals über die Sidebar bei und überprüfe die Reproduktionsschritte: Beim Zurückkehren zu einem Thread wird der Fokus je nachdem, worauf er beim Verlassen lag, im Chat-Eingabefeld oder im Terminal wiederhergestellt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

via-triage
What happened

When I switch to a thread that has its terminal drawer open by clicking it in the sidebar, the terminal always takes focus. That happens even if I was typing in the chat input the last time I was in that thread. I have to click back into the chat input every time.

Request: when entering a thread, restore the focus it had when I left. If the terminal had focus, focus the terminal. If the chat input had focus, focus the chat input.

Diagnosis

ChatView.tsx (~L2655 at v0.1.7) calls focusTerminalOnThreadEnter (apps/web/src/lib/terminalFocus.ts ~L121) whenever a thread is entered. If the thread's drawer is open with an active terminal, that terminal is focused unconditionally. #25009 made this happen on every visit (before, it was officially limited to the first visit). The code is the same on main.

terminalFocus.ts already has getTerminalFocusOwner(), and focusTerminalOnThreadEnter returns a cleanup function that runs on thread leave. That cleanup could record per thread whether a terminal owned focus. On the next entry, the drawer terminal would be focused only if it did; otherwise the existing composer focus behaviour would apply. Explicit requests such as the sidebar terminal reveal (focusTerminalOnNavigation) would keep their current behaviour.

Steps to reproduce
  1. Open thread A and open its terminal drawer.
  2. Click into the chat input in thread A.
  3. Click thread B in the sidebar.
  4. Click thread A in the sidebar.
  5. Expected: the chat input has focus, as when I left. Actual: the terminal has focus.
Version

0.1.7 (desktop app)

Environment

Windows 10 Pro (10.0.19045) x64, T3 Code desktop app with its local server (0.1.7). Triage CLI 0.1.7.

Evidence
The behaviour comes from the code paths above; nothing relevant appears in the logs. The #25009 description says: "Entering a thread whose drawer is open focuses the drawer terminal on every visit."
Related issues
  • #25009: introduced the current every-visit behaviour.
  • #26407: thread shortcuts get swallowed when the terminal takes focus on entry. Same function; restoring the previous focus would also help there.
Fix applied or workaround

Close the terminal drawer before leaving the thread, or click into the chat input after switching.

Filed by

Claude Code (Claude Opus 5.5), via t3 triage

Vorherrschende Sprache
TypeScript
Sterne
24.8k
Forks
6.4k
Ø Merge
13 Std. 9 Min.
Gemergte PRs (30 T.)
187

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus pingdotgg/t3code

Alle Issues in pingdotgg/t3code

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.