[Bug]: A new preview tab opens on another machine's window instead of the one showing the thread
Before submitting
- [x] I searched existing issues and did not find a duplicate. #13051 / #13064 made new sessions prefer the client that owns or shows the tab. This report is the case where no tab exists yet. #13540 covers a session moving after a timeout, which is a different path.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Run the T3 Code desktop app on machine A. The server runs there too.
- Open the desktop app on machine B and connect it to machine A's environment. Open any other thread there. Leave its browser panel closed.
- On machine A, open a thread that has no browser tab yet.
- Click into machine B's T3 window so it is the most recently focused window. Then return to machine A.
- Ask the agent in the machine A thread to open a browser tab (
preview_openwithreuseExistingTab: false).
Expected behavior
The tab opens in machine A's window, which is showing the thread.
Actual behavior
The tab opens on machine B, in a thread nobody is looking at. It uses machine B's network and browser profile, so local URLs such as http://127.0.0.1:<port> fail and the user's sign-ins from machine A are missing. The session then stays pinned to machine B until that client disconnects.
When no host owns a tab for the thread, the broker ranks hosts by focused and focusOrder only. Hosts do not report which thread they are showing, so the broker cannot prefer the window the user is watching.
Impact
Major degradation or frequent failure
Version or commit
T3 Code (Nightly) 0.0.43-nightly.20260925.2251
Environment
Machine A: Windows 11 x64, desktop app and server. Machine B: Windows 11 x64 VM, desktop app connected to machine A through T3 Connect. Agent provider: Claude Code.
Workaround
Click into the window showing the thread before the agent opens a new browser tab.
Open PR #13773 already targets this with Fixes #13771 (broker prefers hosts reporting the thread via activeThreadId when no tab exists yet). Leaving this open for that land.
Related but different path: #13540 (failover after automation timeout). Prior art for “prefer the visible client when a tab already exists”: #13051 / #13064.
Obsolete since #15328: desktop clients no longer act as preview automation hosts. The environment server's own browser is the only host, so there is nothing to route or re-rank between machines.