Skip to content

fork: a viewer of a hidden tab opens at once and says why it's blank - #60

Merged
3mdistal merged 4 commits into
fork/mainfrom
t3/viewer-hidden-tab
Nov 19, 2026
Merged

3mdistal merged 4 commits into
fork/mainfrom
t3/viewer-hidden-tab

Conversation

@3mdistal

@3mdistal 3mdistal commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Problem

A "server" preview tab can live inside the T3 desktop app on one computer (for example Alice's Windows PC) and be viewed from another device (her MacBook, over the LAN). Electron composites no offscreen guest, so such a tab paints only while T3's window on the host computer is drawn. When that window was minimized or covered and the tab was opened from the other device, the browser panel showed the title, the URL, a progress bar and "Connecting..." on a blank canvas, and stayed that way until someone brought T3 into view on the host.

Cause

ServerBrowserStream upgrades the viewer's WebSocket only after ServerBrowser.attachViewer returns. attachViewer ended by awaiting the screencast's start and then an opening still: one Page.captureScreenshot taken under the tab's capture lock, with no time limit. A tab that can't paint never answers a screenshot, so attachViewer never returned, the upgrade never happened, and the client's socket stayed CONNECTING. The control message was already queued, but nothing was ever written, and "Connecting..." is the label a client shows until its first control message. The unanswered capture also held the tab's capture lock, so the agent's snapshots and recordings of that tab queued behind it.

What changes

  • The stream opens at once. attachViewer returns as soon as it has asked the screencast to start. The stream upgrades and sends the queued control message straight away, so the panel's label shows the real control state ("Read-only", "Agent has control", and so on).

  • The opening still can't block anything. It is taken in the background over a CDP session of its own, waits 5 seconds at most under the capture lock, and that session is detached afterwards. The Chrome DevTools Protocol (CDP) can't cancel a screenshot. Detaching ends the server's wait and gives the lock back, so the agent's snapshots and recordings go ahead and nothing is left pending on the viewer's own session. It doesn't stop the screenshot on the desktop (see below). This copies how fork PR fork: agent recordings keep a steady frame rate and fail fast on a hidden tab #55 bounded a recording's first frame.

  • A late still is dropped. A still that finishes after a screencast frame has arrived may be older than that frame, so the viewer never gets it and keeps the live frame.

  • The viewer learns why it's blank. If no frame (screencast or still) has been queued for a viewer 5 seconds after it attached, the server sends it one {"type":"unpainted"} message. The web viewer then shows:

    This tab can't draw while T3's window is minimized or covered on the computer it runs on. Bring T3 into view there and the page will appear here.

    The notice covers the page area below the control bar, so "Take control" and the other controls stay usable, and it hides with the page under the panel's empty state. A PDF tab draws in its own embed, so it never shows the notice. The notice clears on the first painted frame, when the stream disconnects, and when the surface stops.

What doesn't change

  • A tab that paints starts as it did: a screencast frame or the still arrives first, and no notice is sent.
  • The wire change is one new plain JSON message type. Clients ignore types they don't know, so older web builds and the mobile app keep working. The mobile viewer doesn't show the notice yet.
  • No persisted data, settings or events change, so stock T3 still opens the fork's data. Rolling back means reverting the commits.
  • The still taken after a burst of motion (the "settle" still) still uses the viewer's own session with no limit. It runs only after the tab has painted.

Does Page.startScreencast hang too?

Not by design. Chromium answers it without waiting for a frame: the browser side subscribes to frames and the renderer only records that a screencast is on. On the desktop relay it waits only for focus emulation, which also needs no frame. I couldn't watch this on a real hidden Electron window from this Linux host, so attachViewer doesn't await it either. If it ever did hang, the stream would still open and the notice would still appear; only the opening still would be skipped.

The desktop side is #61

This PR doesn't touch apps/desktop. #61 keeps a desktop tab drawing for its viewer while T3's window is hidden; the two can land in either order. The desktop's own queue still sends one screenshot at a time per tab, so on the PC an agent's screenshot can still wait behind a capture running there, even though the server's lock is freed after 5 seconds.

Testing

Each new test below fails on fork/main and passes here.

  • apps/server/src/preview/ServerBrowser.test.ts, new fork: tests using fake CDP sessions and Effect's TestClock:
    • In the first, every screenshot hangs and no screencast frame comes. The viewer gets its control message with no clock time passing (on fork/main, attachViewer never returns). The still goes over its own session, not the viewer's. An agent snapshot queued behind it finishes once the clock passes 5 s, the still's session has been detached, and the viewer has exactly one unpainted and no frame.
    • Two variants pass 5 s on a tab that paints, one starting with the still and one with a screencast frame while screenshots hang. Each gets the frame first and no unpainted. The screencast variant hangs on fork/main.
    • A still held until a screencast frame has arrived is dropped: the viewer gets only the live frame.
    • Upstream's read-only viewer test now waits for its opening still, because the still arrives after attachViewer returns. What it checks is unchanged.
  • packages/client-runtime/src/preview/serverBrowserStream.fork.test.ts: {"type":"unpainted"} calls onUnpainted once, and frames still flow.
  • apps/web/src/browser/ServerBrowserSurface.fork.browser.test.tsx: the notice appears on onUnpainted and goes away on a painted frame, on disconnect, and when the surface stops and restarts. A PDF tab gets no notice.
  • On the first commit, vp test run on the changed test files: 73 passed (ServerBrowser.test.ts, ServerBrowserStream.test.ts, ServerBrowserPage.fork.test.ts and both client-runtime stream tests). The two ServerBrowserSurface browser test files: 7 passed.
  • On the first commit, vp run check:changed origin/fork/main: format, lint, knip, graphql, typecheck (9 packages, including server, web, mobile and client-runtime), tests beside the changes and the React Compiler check all pass.
  • The later commits (the notice's placement, then the late still, the PDF case and the counted frame, from a review) were checked by CI on this PR only; the formatter passed on their files locally.

No before/after capture. On this Linux host, headless Chromium always paints, so the hidden-window state can't happen here. The notice's appearance and clearing are covered by the browser test above, and it can be seen for real on the PC with #61.

Review focus

  • Is 5 seconds right for both the still's limit and the notice? A slow tab that's still visible would get the notice briefly before its first frame clears it.
  • The notice text.

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

🤖 Generated with Claude Code

3mdistal and others added 2 commits November 18, 2026 22:14
A server tab hosted in the desktop app paints only while T3's window there is
drawn. Opening one from another device while that window was minimized or
covered showed "Connecting..." on a blank canvas forever: attachViewer awaited
its opening still before the WebSocket upgraded, and a tab that can't paint
never answers the screenshot. The hung capture also held the tab's capture
lock, so agent snapshots and recordings of the tab queued behind it.

attachViewer now returns once it has asked the screencast to start, so the
stream opens and sends control at once. The opening still follows in the
background over its own CDP session, waits 5 s at most under the capture lock,
and that session is then detached so an unanswered capture ends with it. A
viewer with no frame 5 s after attaching gets one {"type":"unpainted"}
message, which the web viewer shows as a notice until a frame paints, the
stream disconnects or the viewer stops. Older clients ignore it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The notice covered the whole panel, hiding "Agent has control" and
Take control, and showed over the empty state too. It now sits in the
page area, so it hides with the page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal and others added 2 commits November 18, 2026 19:46
An opening still that finishes after a screencast frame is dropped, since it
may be older than the frame. The unpainted notice no longer covers a PDF tab,
which draws in its own embed. Only a frame the viewer's queue takes counts as
painted. FORK.md and the comments now say what detaching the still's session
does: it ends the server's wait and frees the capture lock, but doesn't cancel
the desktop's own screenshot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@3mdistal

Copy link
Copy Markdown
Owner Author

Landing on Alice's yes. At Nov 19, 10:08 AM ET she switched this task's row on her Task Priorities board to Agent with no comment, which accepts the suggested answer to its question.

The question:

Land the fix that explains a blank tab and the fix that keeps it drawing? The decision page has more.

The suggested answer:

Land both, then I make a fork release, install it on the PC and check a hidden tab from the MacBook.

Before merging: all checks pass on this head, fork/main hasn't moved since (19d8b32), and #60 and #61 merge together cleanly.

Written by Claude Opus 5.5 in Claude Code, running in T3 Code.

@3mdistal
3mdistal merged commit 0ae59d2 into fork/main Nov 19, 2026
17 checks passed
3mdistal added a commit that referenced this pull request Nov 21, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 21, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 26, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
3mdistal added a commit that referenced this pull request Nov 30, 2026
A desktop tab paints only while T3's window on its computer is drawn.
Upstream v0.1.11 opens a viewer without waiting on the opening still
(pingdotgg#25381) and, 10 s after a viewer connects with no frame, says the
server's browser isn't drawing and to try reloading (pingdotgg#38865). A reload
doesn't help a desktop tab, so a viewer of one with no frame 5 s after
it attached gets one "unpainted" message, and the web viewer's notice
then says the tab can't draw while T3's window is minimized or covered.
An opening still that lands after a live frame is dropped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

1 participant