Skip to content

Commit f614fdb

Browse files
fix(web): keep sheet layouts and pending devices out of the device auto-float
Two review findings on the session-diff effect: on sheet layouts a new device session could still float a player, where the old code opened nothing, and a session that arrived before its device summary was baked into the baseline and never opened. Sheet layouts now bail before either branch, and only sessions with a known device enter the baseline. Also rewraps the devices doc paragraph the formatter left long. Co-Authored-By: Claude Code <[email protected]>
1 parent ae38f1a commit f614fdb

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4223,9 +4223,10 @@ export default function ChatView(props: ChatViewProps) {
42234223
}, [activeThreadRef, deviceState.onboardingCompleted, deviceState.hostStatus]);
42244224
// A device the agent opens floats over chat like an agent-driven browser,
42254225
// or becomes a panel tab when floating previews are off. Sessions opened by
4226-
// another client arrive the same way. The first snapshot is a baseline:
4227-
// persisted tabs restore themselves, and existing sessions must not
4228-
// resurrect closed tabs.
4226+
// another client arrive the same way; sheet layouts get neither. The first
4227+
// snapshot is a baseline: persisted tabs restore themselves, and existing
4228+
// sessions must not resurrect closed tabs. A session whose device summary
4229+
// has not arrived yet stays out of the baseline so a later snapshot opens it.
42294230
const autoShowFloatingPreview = useClientSettings(selectAutoShowFloatingPreview);
42304231
const previousDeviceSessions = useRef(new Map<string, Set<string>>());
42314232
useEffect(() => {
@@ -4235,14 +4236,19 @@ export default function ChatView(props: ChatViewProps) {
42354236
(session) => session.threadId === activeThreadRef.threadId,
42364237
);
42374238
const key = (session: (typeof sessions)[number]) => `${session.hostId}:${session.deviceId}`;
4238-
const previous = previousDeviceSessions.current.get(threadKey);
4239-
previousDeviceSessions.current.set(threadKey, new Set(sessions.map(key)));
4240-
if (!previous) return;
4241-
for (const session of sessions) {
4242-
if (previous?.has(key(session))) continue;
4243-
const device = deviceState.devices.find(
4239+
const deviceFor = (session: (typeof sessions)[number]) =>
4240+
deviceState.devices.find(
42444241
(entry) => entry.hostId === session.hostId && entry.id === session.deviceId,
42454242
);
4243+
const previous = previousDeviceSessions.current.get(threadKey);
4244+
previousDeviceSessions.current.set(
4245+
threadKey,
4246+
new Set(sessions.filter((session) => deviceFor(session) !== undefined).map(key)),
4247+
);
4248+
if (!previous || shouldUseRightPanelSheet) return;
4249+
for (const session of sessions) {
4250+
if (previous.has(key(session))) continue;
4251+
const device = deviceFor(session);
42464252
if (!device) continue;
42474253
const target = {
42484254
hostId: session.hostId,
@@ -4254,7 +4260,6 @@ export default function ChatView(props: ChatViewProps) {
42544260
usePreviewMiniPlayerStore.getState().open(activeThreadRef, { kind: "device", ...target });
42554261
continue;
42564262
}
4257-
if (shouldUseRightPanelSheet) continue;
42584263
const existing = useRightPanelStore
42594264
.getState()
42604265
.byThreadKey[scopedThreadKey(activeThreadRef)]?.surfaces.some(

‎docs/user/devices.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ back from the device after a change.
5555
When an agent opens a device, it floats over the chat in web and desktop clients
5656
connected to the thread, the same way an agent-driven browser does. Turn off
5757
**Auto-show floating preview** in **Settings → Integrations → Browser** to open a
58-
right-panel tab instead. Mobile clients show device activity in the thread timeline. Agents drive the device through the `agent-device` command line. T3
58+
right-panel tab instead. Mobile clients show device activity in the thread
59+
timeline. Agents drive the device through the `agent-device` command line. T3
5960
Code installs and starts it only after **Agent device access** is enabled. iOS
6061
taps build a small test runner on first use, which takes a couple of minutes
6162
once per server. Restart an existing agent session after granting access so it

0 commit comments

Comments
 (0)