Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 3 additions & 14 deletions apps/web/src/components/ChatView.logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,15 +1043,16 @@ 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,
activeThreadKey: "env-1:thread-b",
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", () => {
Expand Down Expand Up @@ -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"] });
Expand Down
11 changes: 0 additions & 11 deletions apps/web/src/components/ChatView.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>"),
Expand Down
Loading