Skip to content

Commit 79b1483

Browse files
fix(web): thread switches show only selected thread messages (#21560)
1 parent a81961d commit 79b1483

4 files changed

Lines changed: 10 additions & 25 deletions

File tree

‎apps/web/src/components/ChatView.logic.test.ts‎

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,15 +1043,16 @@ describe("resolveThreadSwitchTimeline", () => {
10431043

10441044
const held = { threadKey: "env-1:thread-a", entries: ["a1", "a2"] };
10451045

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);
10471048
expect(
10481049
resolveThreadSwitchTimeline({
10491050
loading: true,
10501051
activeThreadKey: "env-1:thread-b",
10511052
nextEntries: [],
10521053
lastReady: held,
10531054
}),
1054-
).toEqual({ entries: ["a1", "a2"], displayThreadKey: "env-1:thread-a" });
1055+
).toEqual({ entries: [], displayThreadKey: "env-1:thread-b" });
10551056
});
10561057

10571058
it("shows the new thread once its detail is ready", () => {
@@ -1089,18 +1090,6 @@ describe("resolveThreadSwitchTimeline", () => {
10891090
});
10901091
});
10911092

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-
11041093
it("paints a remembered destination instead of the last-viewed thread", () => {
11051094
rememberReadyThreadTimeline(held);
11061095
rememberReadyThreadTimeline({ threadKey: "env-1:thread-b", entries: ["b1", "b2"] });

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,6 @@ export function resolveThreadSwitchTimeline<T extends readonly unknown[]>(input:
423423
return { entries: rememberedForActive, displayThreadKey: input.activeThreadKey };
424424
}
425425

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-
}
437426
return { entries: input.nextEntries, displayThreadKey: input.activeThreadKey };
438427
}
439428

‎apps/web/src/components/chat/WorkflowOpeningBlock.browser.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createRoot, type Root } from "react-dom/client";
55
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
66

77
import "~/index.css";
8+
import { getSyntaxHighlighterPromise } from "../../lib/syntaxHighlighting";
89

910
import { AppAtomRegistryProvider } from "../../rpc/atomRegistry";
1011
import { MarkdownFindContext } from "./markdownFindContext";
@@ -109,6 +110,9 @@ const foldToggle = () =>
109110

110111
it("shows a short script as highlighted code with nothing to open", async () => {
111112
await render(SHORT_SCRIPT);
113+
await act(async () => {
114+
await getSyntaxHighlighterPromise("javascript");
115+
});
112116
expect(host.querySelector('[data-language="javascript"]')?.textContent).toContain("SCRIPTONLY");
113117
await vi.waitFor(() => expect(host.querySelector(".chat-markdown-shiki")).not.toBeNull());
114118
expect(foldToggle()).toBeUndefined();

‎apps/web/src/components/files/AttachmentFilePreview.browser.test.tsx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ describe("attachment HTML preview recovery", () => {
6969
expect(container.querySelector("iframe")?.getAttribute("src")).toBe(originalUrl);
7070
now = 61 * 60_000;
7171
await toggleMode("Show HTML source");
72+
await act(async () => {
73+
await import("./ReadOnlySourcePreview");
74+
});
7275
expect(fetch).toHaveBeenCalledExactlyOnceWith(renewedUrl, expect.any(Object));
7376
await vi.waitFor(() =>
7477
expect(container.querySelector("pre")?.textContent).toBe("<p>Captured HTML</p>"),

0 commit comments

Comments
 (0)