perf(webui): avoid redundant diff bundle assets (#6711)

This commit is contained in:
chengyongru authored and GitHub committed 2026-11-19 00:10:38 +08:00
1 parent 995f9e36c1
commit d7e30b403e
4 files changed
+72 -14

No files matched your search

+6 -2
View File
@@ -25,7 +25,11 @@ const samples: Array<[string, string]> = [
["truncated.ts", patch("truncated.ts", ["+export const truncated = true;"], 0, 1)],
];
export function FileDiffFixture() {
const hjsonSample: [string, string] = ["config.hjson", patch("config.hjson", [
" # shared settings", " {", "- host: old-server", "+ host: localhost", " }",
], 4, 4)];
export function FileDiffFixture({ shiki = false }: { shiki?: boolean }) {
const { theme, toggle } = useTheme();
const [opened, setOpened] = useState("");
const [changed, setChanged] = useState(false);
@@ -38,7 +42,7 @@ export function FileDiffFixture() {
<button onClick={toggle}>Toggle theme</button>
<button onClick={() => setChanged(true)}>Change source</button>
<button onClick={() => void setAppLanguage("zh-CN")}>Chinese</button>
{samples.map(([path, text]) => {
{(shiki ? [hjsonSample] : samples).map(([path, text]) => {
const edit: FileEditSummary = {
key: path, path, absolute_path: `/fixture/${path}`, added: 1, deleted: 1,
approximate: false, binary: false, status: "done", pending: false,
+9
View File
@@ -90,6 +90,15 @@ for (const dark of [false, true]) {
}
}
test("a language without a built-in lexer receives its grammar in the diff worker", async ({ page }) => {
const worker = page.waitForEvent("worker");
await page.goto("/browser/fixture.html?case=file-diff&shiki");
await worker;
const config = page.getByRole("region", { name: "config.hjson", exact: true });
await expectTokenColor(config, "# shared settings", "--code-comment");
await expect(config.locator("[data-line][data-line-type=change-addition]")).toHaveText("host: localhost");
});
test("custom backgrounds remain visible through diff surfaces in both themes", async ({ page }) => {
await page.goto("/browser/fixture.html?case=file-diff");
const diff = page.getByRole("region", { name: "Status.tsx", exact: true }).getByTestId("file-edit-diff");
+1 -1
View File
@@ -89,7 +89,7 @@ async function loadFixture() {
}
case "file-diff": {
const { FileDiffFixture } = await import("./file-diff-fixture");
return <FileDiffFixture />;
return <FileDiffFixture shiki={parameters.has("shiki")} />;
}
case "file-edit-path": {
const { FileEditPathFixture } = await import("./file-edit-path-fixture");