From 6e4a3c6171b1fb7a5125a471dcaa245beddcb28e Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 17 Nov 2026 07:52:20 +0000 Subject: [PATCH 1/2] test(web): unsent PR review reply survives a light/dark switch (#37996) Fails on main: the Code tab's diff model is keyed by the rendered appearance, so switching it re-parses the files, folds them back and remounts their annotations, dropping any unsaved comment text. Co-Authored-By: Claude Opus 5.5 --- .../PullRequestCodeTab.browser.test.tsx | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx b/apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx index 21f5c099a54cb..4d305c4da66ed 100644 --- a/apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx +++ b/apps/web/src/components/pullRequest/PullRequestCodeTab.browser.test.tsx @@ -12,6 +12,7 @@ import { userEvent } from "vite-plus/test/browser"; import "~/index.css"; import { __setClientSettingsForTests } from "../../hooks/useSettings"; +import { setAppearanceMode } from "../../hooks/useTheme"; import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; const { diffAtom, pagedDiffAtom } = await vi.hoisted(async () => { @@ -499,3 +500,63 @@ it("hides a resolved conversation behind avatars on its line until they are clic .element(screen.getByRole("button", { name: "2 resolved conversations" })) .toBeVisible(); }); + +// regression: #37996 +it("keeps an unsent reply when the appearance switches between light and dark", async () => { + setup({ paged: false }); + __setClientSettingsForTests({ ...DEFAULT_CLIENT_SETTINGS, diffFilesCollapsed: false }); + setAppearanceMode("dark"); + using _preferences = { + [Symbol.dispose]() { + __setClientSettingsForTests(DEFAULT_CLIENT_SETTINGS); + setAppearanceMode("system"); + }, + }; + const container = document.createElement("div"); + container.className = "flex h-[700px] w-[900px]"; + await using screen = await render( + {}} + environmentId={EnvironmentId.make("environment")} + reference={detail} + detail={{ + ...detail, + capabilities: { + ...detail.capabilities, + review: { ...detail.capabilities.review, reply: true }, + }, + viewerPermissions: { ...detail.viewerPermissions, comment: true }, + reviewThreads: [ + { + id: "thread", + path: "a.ts", + line: 3, + side: "right", + isResolved: false, + isOutdated: false, + comments: [ + { + id: "comment", + author: { login: "reviewer", name: null, avatarUrl: null }, + body: "Rename this.", + createdAt: "2026-09-01T00:00:00Z", + url: null, + }, + ], + }, + ], + }} + selectedCommitOid={null} + onSelectedCommitChange={() => {}} + onRefresh={() => {}} + />, + { container }, + ); + const reply = () => screen.getByRole("textbox", { name: "Reply to this conversation" }); + await screen.getByRole("button", { name: "Reply", exact: true }).click(); + await reply().fill("Unsent"); + + setAppearanceMode("light"); + + await expect.element(reply()).toHaveValue("Unsent"); +}); From 9c7c3e4bf4b246114bb2edf15013246a81408fdb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 17 Nov 2026 08:01:14 +0000 Subject: [PATCH 2/2] fix(web): unsaved PR review comments survive a light/dark switch The Code tab keyed its parsed diff model by the rendered appearance, so a theme change re-parsed every file into new objects with new render keys. That folded the files again and remounted their annotations, discarding unsaved comment, reply and edit text. The diff worker pool already follows the appearance and re-highlights mounted diffs, so the theme is dropped from both parse keys. Fixes #37996 Co-Authored-By: Claude Opus 5.5 --- .../web/src/components/pullRequest/PullRequestCodeTab.tsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx index 454cdaafcbf3a..573a7bfb27988 100644 --- a/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx +++ b/apps/web/src/components/pullRequest/PullRequestCodeTab.tsx @@ -651,11 +651,7 @@ function PullRequestCodeTab({ parsedSlices, loadedFiles: pagedFiles, sourceFileStats, - } = diffModel( - loadedSlices, - `pull-request:${scopeKey}:${resolvedTheme}:${ignoreWhitespace}`, - ignoreWhitespace, - ); + } = diffModel(loadedSlices, `pull-request:${scopeKey}:${ignoreWhitespace}`, ignoreWhitespace); const withheldResults = useAtomValue( withheldFileDiffsAtom( JSON.stringify({ environmentId, input: withheldInput, paths: withheldPaths }), @@ -684,7 +680,7 @@ function PullRequestCodeTab({ nextCursor: null, omittedFileStats: [], }, - `pull-request:${scopeKey}:${resolvedTheme}:withheld:${path}`, + `pull-request:${scopeKey}:withheld:${path}`, // Cut lines can match up to the cut and differ after it; hiding them would drop changes. false, );