Repository navigation
feat(members): watch a Bot worker's browser in the Bot page side panel - #39074
jingchaodev wants to merge 1 commit into
Conversation
|
The capture harness behind the screenshots and the Real-machine verification section. It is kept out of the diff: To run it, save the three files below into
|
b3f3a01 to
a1020cb
Compare
|
Rebased: main conflicted with this PR in |
A Bot's thread draws no row for a worker's browsing, and a worker's pane in the Sessions tab draws no browser card, so a worker's live browser view showed only in that worker's own chat on the chat page. The Bot page registers as the browser stage host and hands its Preview tab the Bot's own sessions. Agent browser opens on the session that is browsing now, else on the turn that started last, and the tab keeps one big view at a time. A Sessions row whose session is browsing offers Live, which opens that browser big in the Preview tab. Expand or Replay on the Bot's own live card opens the same tab instead of a full-screen sheet; a phone keeps the sheet, and so does the card when the panel cannot show the tab. The chat page passes no follow keys, so its Preview tab is unchanged. Refs kirodotdev#33089
a1020cb to
fc88f5c
Compare
|
Rebased: main conflicted with this PR in |
Problem / Motivation
Goal: On a Bot's page, the person can watch a worker session's live browser in the side panel, without opening that worker session.
A Bot hands browsing to its worker sessions. The Bot's thread draws no row for a worker's work, and a worker's pane in the Bot page's Sessions tab draws no browser card either (a
ChatPanenames no session toTurnBlock). So a worker's live browser view shows only in that worker's own chat on the chat page, and the person has to leave the Bot's page to watch it, take over, or answer its sign-in ask. The Bot page's Preview tab shows only the Bot thread's own browser, and the page hosts no big view, so Expand on the Bot's own card opens a full-screen sheet over the thread.Why it matters
The person talks to the Bot, but the browsing happens in a worker. Nothing on the Bot's page says that a worker is browsing now, and nothing there can show its page, so a sign-in the worker waits on is answered only by leaving for that worker's chat.
Not a goal
What changed (motivation → approach → change)
A worker's live browser showed only in that worker's own chat on the chat page, so watching it meant leaving the Bot's page. The Bot page shows it in its own side panel instead, by reusing the chat page's big view (the stage store,
PreviewTabBody,BrowserLiveStage) and pointing it at the Bot's sessions.mate_root; Agent browser opens on the one browsing now, else on the turn that started lastuseMembersPageSidePanelregisters the page as the browser stage host (registerBrowserStageHost) while its thread is confirmed, and passes the Bot's open session keys to the panel (SidePanel.browserFollowKeys, thenPreviewTabBody.followKeys). When the panel cannot show the Preview tab at that moment (the thread re-confirming, or a docked Profile keeping its schedule draft), the Bot's own card falls back to the full-screen sheet and any other stage is dropped, so no card says it is showing in the side panel.components/PreviewTabBody.tsxshows the newest panel stage among its sessions (usePanelBrowserStage,hooks/useBrowserLive.stage.ts), one at a time, and opens Agent browser onuseBrowserLiveNewest(hooks/useBrowserLive.ts). With no follow keys, as on the chat page, it works as before.MateSessionsListtakes an optionalonWatch, and only the side panel's Sessions tab passes it, while the thread is confirmed. Live reuses the card's own strings ("Live", "Expand the live view"), so no catalog key is added.crew-mode.md,browser.mdand the feature map describe the Bot page's Preview tab and the Live button.A card in the Bot's thread was the other option. The recorded decision on what a Bot's chat draws rules it out.
Backwards compatibility
Compatible: the chat page passes no follow keys, so its Preview tab is unchanged, and both new props are optional.
Behavior change for existing users: on a Bot's page on desktop, Expand or Replay on the Bot's own live browser card opens the side panel's Preview tab, as on the chat page, instead of a full-screen sheet over the thread. A phone keeps the full-screen sheet, and so does the card while the panel cannot show the tab. No entry in
docs/decisions/sets the full-screen behavior on this page.Removes nothing: no route, key, setting or row is removed, and the full-screen sheet stays for phones and for pages with no host.
Tests
BrowserLiveStage.test.tsx: a Preview tab withfollowKeysshows a followed session's browser (its stream visibility and takeover go to that session's key), opens on the session browsing now, else on the turn that started last, shows no stage of a session it does not follow, keeps one big view when another of its sessions opens one, and closes the stage when the tab is left.MateSessionsList.test.tsx: Live shows only on a row whose session is browsing now, hands that worker toonWatch, and goes away when the turn ends; with noonWatchthere is no Live.MembersPage.sidePanel.test.tsx: a Sessions row's Live opens a panel stage for the worker and the Preview tab in Agent browser mode; while the thread re-confirms, Live is withheld, the Bot's own card falls back to the sheet, and a worker's stage is dropped.MembersPage.schedules.test.tsx: the big view asks before a docked Profile's schedule draft goes; kept, the Bot's card opens the full-screen sheet; discarded, the Preview tab opens on it.Each new test fails with its production change reverted. Determinism: the four touched test files ran 20 times together on vitest's parallel workers, each run in a shuffled order with its own seed (
--sequence.shuffle --sequence.seed=<1000 + 7919k>, k = 1..20): 20 of 20 green.Manual verification
The real Members page ran in headless Chromium on a Vite dev server, with the API answered from fixtures and one worker browse turn (an event and a frame) fed into the live-browser store. The harness is in a PR comment. The browsing worker's row shows Live, a click opens the Preview tab on the worker's live page, and the Bot's thread draws no browser card, in light and dark. An end-to-end run with a real worker browsing through the gateway was not done.
Real-machine verification
Machine: the author's Linux host, x86_64, 48 vCPU / 186 GiB, Node 24.22, Playwright Chromium (headless)
Before (main be1ce64):
cd website && node scripts/capture-bot-worker-browser.mjs <out>with the harness from the PR comment ->locator.waitFor: Timeout 15000ms exceededwaiting forgetByTestId('mate-session-watch'): the browsing worker's row offers no LiveAfter (head fc88f5c): the same command ->
all frames verified(light and dark: one Live row, the stage live, no browser card in the Bot's thread)Cleanup: own computer; the script stops its Vite server and Chromium, and the scratch worktree and its output are deleted
Screenshots / video
A fork without write access cannot use
gh --attach, so the frames are committed undertemp-screenshots/bot-worker-browser/. A maintainer removes that folder before merging. They come from the harness in Manual verification.The Sessions tab: the worker that is browsing offers Live.
After Live: the Preview tab shows the worker's live page, and the Bot's thread is unchanged.
Dark
Related Issues
Refs #33089
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.