The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): update browser tab titles without navigation (#29452)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Lakshmi Tanmay committed
Nov 13, 2026 at 09:00 UTC
d6fc871b5875df01c1e4cc7c2c6cac5d5cb6e246
2 files changed
+49
-5
apps/web/src/components/preview/usePreviewBridge.test.ts
+37
-2
@@ -1,9 +1,9 @@
1
-import type { DesktopPreviewTabState } from "@t3tools/contracts";
1
+import { ThreadId, type DesktopPreviewTabState } from "@t3tools/contracts";
2
import { describe, expect, it } from "vite-plus/test";
3
4
import { useBrowserSurfaceStore } from "~/browser/browserSurfaceStore";
5
6
-import { createCaptureActivity, projectDesktopState } from "./usePreviewBridge";
6
+import { buildReportInput, createCaptureActivity, projectDesktopState } from "./usePreviewBridge";
7
8
const favicon = {
9
dataUrl: "data:image/png;base64,AAAA",
@@ -30,6 +30,41 @@ function state(navStatus: DesktopPreviewTabState["navStatus"]): DesktopPreviewTa
30
};
31
}
32
33
+describe("buildReportInput", () => {
34
+ it("reports title changes at the same URL without repeating unrelated desktop updates", () => {
35
+ const threadId = ThreadId.make("thread-1");
36
+ const tabId = "tab-1";
37
+ const url = "http://localhost:3000/app";
38
+ let lastReport = {
39
+ lastReportedUrl: null as string | null,
40
+ lastReportedKind: null as DesktopPreviewTabState["navStatus"]["kind"] | null,
41
+ lastReportedTitle: null as string | null,
42
+ };
43
+ const report = (nextState: DesktopPreviewTabState) => {
44
+ const result = buildReportInput({ threadId, tabId, state: nextState, ...lastReport });
45
+ if (result) {
46
+ lastReport = result;
47
+ }
48
+ return result?.input.navStatus ?? null;
49
+ };
50
+
51
+ const loaded = state({ kind: "Success", url, title: "Original title" });
52
+ expect(report(loaded)).toEqual({ _tag: "Success", url, title: "Original title" });
53
+ expect(report(loaded)).toBeNull();
54
+
55
+ const retitled = state({ kind: "Success", url, title: "Updated title" });
56
+ expect(report(retitled)).toEqual({ _tag: "Success", url, title: "Updated title" });
57
+ expect(
58
+ report({
59
+ ...retitled,
60
+ audible: true,
61
+ controller: "human",
62
+ updatedAt: "2026-08-09T00:00:01.000Z",
63
+ }),
64
+ ).toBeNull();
65
+ });
66
+});
67
+
68
describe("projectDesktopState", () => {
69
it("shows a retained icon only while the current document has the captured origin", () => {
70
expect(
apps/web/src/components/preview/usePreviewBridge.ts
+12
-3
@@ -54,6 +54,7 @@ export function usePreviewBridge(input: {
54
55
const lastReportedUrl = useRef<string | null>(null);
56
const lastReportedKind = useRef<DesktopPreviewTabState["navStatus"]["kind"] | null>(null);
57
+ const lastReportedTitle = useRef<string | null>(null);
58
const lastDesktopNavStatus = useRef<DesktopPreviewTabState["navStatus"] | null>(null);
59
const captureActivity = useRef<ReturnType<typeof createCaptureActivity> | null>(null);
60
const handleStateChange = useEffectEvent(
@@ -74,10 +75,12 @@ export function usePreviewBridge(input: {
75
state,
76
lastReportedUrl: lastReportedUrl.current,
77
lastReportedKind: lastReportedKind.current,
78
+ lastReportedTitle: lastReportedTitle.current,
79
});
80
if (!reported || serverDriven) return;
81
lastReportedUrl.current = reported.lastReportedUrl;
82
lastReportedKind.current = reported.lastReportedKind;
83
+ lastReportedTitle.current = reported.lastReportedTitle;
84
void reportStatus({
85
environmentId: stableThreadRef.environmentId,
86
input: reported.input,
@@ -89,6 +92,7 @@ export function usePreviewBridge(input: {
92
if (!previewBridge || typeof window === "undefined") return;
93
lastReportedUrl.current = null;
94
lastReportedKind.current = null;
95
+ lastReportedTitle.current = null;
96
lastDesktopNavStatus.current = null;
97
const activity = createCaptureActivity(runtimeTabId);
98
captureActivity.current = activity;
@@ -134,25 +138,28 @@ export function projectDesktopState(state: DesktopPreviewTabState): DesktopPrevi
138
};
139
}
140
137
-function buildReportInput(args: {
141
+export function buildReportInput(args: {
142
readonly threadId: ThreadId;
143
readonly tabId: string;
144
readonly state: DesktopPreviewTabState;
145
readonly lastReportedUrl: string | null;
146
readonly lastReportedKind: DesktopPreviewTabState["navStatus"]["kind"] | null;
147
+ readonly lastReportedTitle: string | null;
148
}): {
149
readonly input: PreviewReportStatusInput;
150
readonly lastReportedUrl: string;
151
readonly lastReportedKind: DesktopPreviewTabState["navStatus"]["kind"];
152
+ readonly lastReportedTitle: string;
153
} | null {
148
- const { threadId, tabId, state, lastReportedUrl, lastReportedKind } = args;
154
+ const { threadId, tabId, state, lastReportedUrl, lastReportedKind, lastReportedTitle } = args;
155
const status = state.navStatus;
156
if (status.kind === "Idle") return null;
157
158
const sameAsLast =
159
status.kind !== "LoadFailed" &&
160
status.kind === lastReportedKind &&
155
- status.url === lastReportedUrl;
161
+ status.url === lastReportedUrl &&
162
+ status.title === lastReportedTitle;
163
if (sameAsLast) return null;
164
165
const base = {
@@ -175,6 +182,7 @@ function buildReportInput(args: {
182
},
183
lastReportedUrl: status.url,
184
lastReportedKind: "LoadFailed",
185
+ lastReportedTitle: status.title,
186
};
187
}
188
return {
@@ -184,5 +192,6 @@ function buildReportInput(args: {
192
},
193
lastReportedUrl: status.url,
194
lastReportedKind: status.kind,
195
+ lastReportedTitle: status.title,
196
};
197
}