The best way to control Claude Code, Codex and more from any computer or phone
fix(web): switching back to a thread no longer restores its tab's older title (#25521)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 26, 2026 at 07:51 UTC
3f9448747bb8848050dc2cacf83affa6f94a66a1
2 files changed
+23
-5
apps/web/src/browserHistoryStore.test.ts
+13
@@ -240,6 +240,19 @@ describe("useBrowserHistoryStore", () => {
240
).toBe("New");
241
});
242
243
+ it("keeps another thread's newer title when this thread's unchanged tab is re-sent", () => {
244
+ const otherThreadRef = { ...threadRef, threadId: ThreadId.make("thread-2") };
245
+ const store = useBrowserHistoryStore.getState();
246
+ store.registerThreadProject(threadRef, "proj-a");
247
+ store.registerThreadProject(otherThreadRef, "proj-a");
248
+ recordVisitForThread(threadRef, "http://a.test/", 1);
249
+ settle("http://a.test/", "Old", "tab_a", threadRef);
250
+ settle("http://a.test/", "New", "tab_a", otherThreadRef);
251
+ // A resize or a list reconcile replaces the session without a new page load.
252
+ settle("http://a.test/", "Old", "tab_a", threadRef);
253
+ expect(useBrowserHistoryStore.getState().byProjectKey["proj-a"]?.[0]?.title).toBe("New");
254
+ });
255
+
256
it("keeps another thread's newer title when this thread revisits the same url", () => {
257
const otherThreadRef = { ...threadRef, threadId: ThreadId.make("thread-2") };
258
const store = useBrowserHistoryStore.getState();
apps/web/src/browserHistoryStore.ts
+10
-5
@@ -421,10 +421,9 @@ export function recordVisitForThread(ref: ScopedThreadRef, url: string, at?: num
421
}
422
423
/**
424
- * Titles only update entries already in history, so they apply on settle and on
425
- * visit. History is shared across a project's threads and settled sessions stay
426
- * retained, so a visit only fills untitled entries: replaying this thread's
427
- * older settle would clobber a newer title. Settles apply what just changed.
424
+ * History is shared across a project's threads and settled sessions are retained,
425
+ * so replaying an old settle would clobber another thread's newer title. Visits
426
+ * only fill untitled entries; settles apply only pages that loaded or retitled.
427
*/
428
function recordPreviewTitles(
429
ref: ScopedThreadRef,
@@ -453,9 +452,15 @@ function recordPreviewTitles(
452
"urls" in only
453
? new Set(only.urls.map(titleKey).filter((key) => key !== null && !titled.has(key)))
454
: null;
455
+ // Resizes and list reconciles replace a session without loading a new page.
456
+ const settledAgain = (session: PreviewSessionSnapshot, previous?: PreviewSessionSnapshot) =>
457
+ previous?.navStatus._tag === "Success" &&
458
+ session.navStatus._tag === "Success" &&
459
+ previous.navStatus.url === session.navStatus.url &&
460
+ previous.navStatus.title === session.navStatus.title;
461
const include = (session: PreviewSessionSnapshot, url: string) =>
462
"changedSince" in only
458
- ? only.changedSince[session.tabId] !== session
463
+ ? !settledAgain(session, only.changedSince[session.tabId])
464
: (visitKeys?.has(titleKey(url)) ?? false);
465
// Tabs can share a URL; applying oldest first lets the newest settle win.
466
const sessions = Object.values(preview.sessions).toSorted((a, b) =>