TypeScript
fix(web): thread switches show only selected thread messages (#21560)
Julius Marminge79b14831cb59
diff --git a/apps/web/src/components/ChatView.logic.test.ts b/apps/web/src/components/ChatView.logic.test.tsindex 330ab771c3f..0ce4d137414 100644--- a/apps/web/src/components/ChatView.logic.test.ts+++ b/apps/web/src/components/ChatView.logic.test.ts@@ -1043,7 +1043,8 @@ describe("resolveThreadSwitchTimeline", () => {const held = { threadKey: "env-1:thread-a", entries: ["a1", "a2"] };- it("keeps the previous thread's entries while the next thread is loading", () => {+ it("leaves an uncached destination empty while its history loads", () => {+ rememberReadyThreadTimeline(held);expect(resolveThreadSwitchTimeline({loading: true,@@ -1051,7 +1052,7 @@ describe("resolveThreadSwitchTimeline", () => {nextEntries: [],lastReady: held,}),- ).toEqual({ entries: ["a1", "a2"], displayThreadKey: "env-1:thread-a" });+ ).toEqual({ entries: [], displayThreadKey: "env-1:thread-b" });});it("shows the new thread once its detail is ready", () => {@@ -1089,18 +1090,6 @@ describe("resolveThreadSwitchTimeline", () => {});});- it("survives a ChatView remount by remembering the last ready timeline", () => {- rememberReadyThreadTimeline(held);- expect(peekHeldThreadTimeline<string[]>()).toEqual(held);- expect(- resolveThreadSwitchTimeline({- loading: true,- activeThreadKey: "env-1:thread-b",- nextEntries: [],- }),- ).toEqual({ entries: ["a1", "a2"], displayThreadKey: "env-1:thread-a" });- });-it("paints a remembered destination instead of the last-viewed thread", () => {rememberReadyThreadTimeline(held);rememberReadyThreadTimeline({ threadKey: "env-1:thread-b", entries: ["b1", "b2"] });diff --git a/apps/web/src/components/ChatView.logic.ts b/apps/web/src/components/ChatView.logic.tsindex 65807d965af..7479a289d8f 100644--- a/apps/web/src/components/ChatView.logic.ts+++ b/apps/web/src/components/ChatView.logic.ts@@ -423,17 +423,6 @@ export function resolveThreadSwitchTimeline<T extends readonly unknown[]>(input:return { entries: rememberedForActive, displayThreadKey: input.activeThreadKey };}- const lastReady = input.lastReady ?? peekHeldThreadTimeline<T>();- if (- input.loading &&- lastReady !== null &&- lastReady.threadKey !== null &&- lastReady.threadKey !== input.activeThreadKey &&- lastReady.entries.length > 0 &&- threadKeysShareEnvironment(lastReady.threadKey, input.activeThreadKey)- ) {- return { entries: lastReady.entries, displayThreadKey: lastReady.threadKey };- }return { entries: input.nextEntries, displayThreadKey: input.activeThreadKey };}diff --git a/apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsx b/apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsxindex e9ac0d4dca2..8f28e93b008 100644--- a/apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsx+++ b/apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsx@@ -5,6 +5,7 @@ import { createRoot, type Root } from "react-dom/client";import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";import "~/index.css";+import { getSyntaxHighlighterPromise } from "../../lib/syntaxHighlighting";import { AppAtomRegistryProvider } from "../../rpc/atomRegistry";import { MarkdownFindContext } from "./markdownFindContext";@@ -109,6 +110,9 @@ const foldToggle = () =>it("shows a short script as highlighted code with nothing to open", async () => {await render(SHORT_SCRIPT);+ await act(async () => {+ await getSyntaxHighlighterPromise("javascript");+ });expect(host.querySelector('[data-language="javascript"]')?.textContent).toContain("SCRIPTONLY");await vi.waitFor(() => expect(host.querySelector(".chat-markdown-shiki")).not.toBeNull());expect(foldToggle()).toBeUndefined();diff --git a/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx b/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsxindex 1f3f1742ac2..3ae2c3d998a 100644--- a/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx+++ b/apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx@@ -69,6 +69,9 @@ describe("attachment HTML preview recovery", () => {expect(container.querySelector("iframe")?.getAttribute("src")).toBe(originalUrl);now = 61 * 60_000;await toggleMode("Show HTML source");+ await act(async () => {+ await import("./ReadOnlySourcePreview");+ });expect(fetch).toHaveBeenCalledExactlyOnceWith(renewedUrl, expect.any(Object));await vi.waitFor(() =>expect(container.querySelector("pre")?.textContent).toBe("<p>Captured HTML</p>"),