@devries-cameron20 / t3code Mirror · read-only / commits / 79b14831cb
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 23, 00:30 UTC

fix(web): thread switches show only selected thread messages (#21560)

Julius Marminge committed Oct 19, 2026 at 16:22 UTC 79b14831cb5922cfa70022cc159a5ac33873ef59
4 files changed +10 -25
apps/web/src/components/ChatView.logic.test.ts
+3 -14
@@ -1043,7 +1043,8 @@ describe("resolveThreadSwitchTimeline", () => {
1043
1044 const held = { threadKey: "env-1:thread-a", entries: ["a1", "a2"] };
1045
1046 - it("keeps the previous thread's entries while the next thread is loading", () => {
1046 + it("leaves an uncached destination empty while its history loads", () => {
1047 + rememberReadyThreadTimeline(held);
1048 expect(
1049 resolveThreadSwitchTimeline({
1050 loading: true,
@@ -1051,7 +1052,7 @@ describe("resolveThreadSwitchTimeline", () => {
1052 nextEntries: [],
1053 lastReady: held,
1054 }),
1054 - ).toEqual({ entries: ["a1", "a2"], displayThreadKey: "env-1:thread-a" });
1055 + ).toEqual({ entries: [], displayThreadKey: "env-1:thread-b" });
1056 });
1057
1058 it("shows the new thread once its detail is ready", () => {
@@ -1089,18 +1090,6 @@ describe("resolveThreadSwitchTimeline", () => {
1090 });
1091 });
1092
1092 - it("survives a ChatView remount by remembering the last ready timeline", () => {
1093 - rememberReadyThreadTimeline(held);
1094 - expect(peekHeldThreadTimeline<string[]>()).toEqual(held);
1095 - expect(
1096 - resolveThreadSwitchTimeline({
1097 - loading: true,
1098 - activeThreadKey: "env-1:thread-b",
1099 - nextEntries: [],
1100 - }),
1101 - ).toEqual({ entries: ["a1", "a2"], displayThreadKey: "env-1:thread-a" });
1102 - });
1103 -
1093 it("paints a remembered destination instead of the last-viewed thread", () => {
1094 rememberReadyThreadTimeline(held);
1095 rememberReadyThreadTimeline({ threadKey: "env-1:thread-b", entries: ["b1", "b2"] });
apps/web/src/components/ChatView.logic.ts
-11
@@ -423,17 +423,6 @@ export function resolveThreadSwitchTimeline<T extends readonly unknown[]>(input:
423 return { entries: rememberedForActive, displayThreadKey: input.activeThreadKey };
424 }
425
426 - const lastReady = input.lastReady ?? peekHeldThreadTimeline<T>();
427 - if (
428 - input.loading &&
429 - lastReady !== null &&
430 - lastReady.threadKey !== null &&
431 - lastReady.threadKey !== input.activeThreadKey &&
432 - lastReady.entries.length > 0 &&
433 - threadKeysShareEnvironment(lastReady.threadKey, input.activeThreadKey)
434 - ) {
435 - return { entries: lastReady.entries, displayThreadKey: lastReady.threadKey };
436 - }
426 return { entries: input.nextEntries, displayThreadKey: input.activeThreadKey };
427 }
428
apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsx
+4
@@ -5,6 +5,7 @@ import { createRoot, type Root } from "react-dom/client";
5 import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
6
7 import "~/index.css";
8 +import { getSyntaxHighlighterPromise } from "../../lib/syntaxHighlighting";
9
10 import { AppAtomRegistryProvider } from "../../rpc/atomRegistry";
11 import { MarkdownFindContext } from "./markdownFindContext";
@@ -109,6 +110,9 @@ const foldToggle = () =>
110
111 it("shows a short script as highlighted code with nothing to open", async () => {
112 await render(SHORT_SCRIPT);
113 + await act(async () => {
114 + await getSyntaxHighlighterPromise("javascript");
115 + });
116 expect(host.querySelector('[data-language="javascript"]')?.textContent).toContain("SCRIPTONLY");
117 await vi.waitFor(() => expect(host.querySelector(".chat-markdown-shiki")).not.toBeNull());
118 expect(foldToggle()).toBeUndefined();
apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx
+3
@@ -69,6 +69,9 @@ describe("attachment HTML preview recovery", () => {
69 expect(container.querySelector("iframe")?.getAttribute("src")).toBe(originalUrl);
70 now = 61 * 60_000;
71 await toggleMode("Show HTML source");
72 + await act(async () => {
73 + await import("./ReadOnlySourcePreview");
74 + });
75 expect(fetch).toHaveBeenCalledExactlyOnceWith(renewedUrl, expect.any(Object));
76 await vi.waitFor(() =>
77 expect(container.querySelector("pre")?.textContent).toBe("<p>Captured HTML</p>"),