Files
paseo/packages/website/e2e/i18n.spec.ts
T
77798b2e46 Show and stop agent background work (#6220)
* feat(server): add an in-memory store for agent background work

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(claude): report background tasks as background work

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(server): track agent background work in the agent manager

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(protocol): add agent background work messages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(server): serve and push agent background work

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(client): expose agent background work on agent handles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(sdk): document agent background work

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(claude): cover background shells in background work end to end

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(client): resync background work subscriptions on every snapshot

subscribe() now lists the agent's background work each time the event
observation is established, so the listener starts with the current list
and catches up after a reconnect. A list answered after a newer update
is dropped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(server): answer background work lists without loading dormant agents

Background work lives only in memory, so a stored agent that is not
loaded has none. The list handler now answers [] from storage instead of
resuming the agent, and still rejects unknown, internal, and archived
agents. A new test pins that old apps never receive
agent.background_work.update.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(server): read Claude background tasks defensively

The user's claude binary can differ from the SDK typings, so a task's
description is read as unknown and an empty or missing one becomes null.
Drop the monitor kind: Claude Monitor watches report as local_bash, so
kind is "shell" or "other" today. The store now copies only the wire
fields of each input.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(server): prove internal background work was emitted before checking globals

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(sdk): describe background work resync and feature gating

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(claude): cover background work reported by a retired query

The daemon stops reading a Claude query it no longer owns, so work that a
retired process still had queued cannot reach the background work list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(client): let background work subscribers handle a failed list read

When the list read that follows each subscription snapshot failed, the
error was only logged and the caller got neither the list nor a failure.
subscribe() now takes an optional onError that receives it; without one
the error is still logged. The read is not retried, since the next
reconnect reads the list again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(agents): show background work as active

Keep background activity visible after a foreground turn ends while preserving independent send and interrupt behavior.

* fix(agents): protect background work subscriptions

Keep internal work out of public updates and restore observation after a subscription failure.

* feat(agents): show Codex and OpenCode background work

Keep provider-owned shell activity visible after a turn ends while leaving foreground turn controls independent.

* feat(agents): stop individual background work

Wait for provider confirmation so stopping one background item leaves sibling work and foreground turn controls independent.

* refactor(agents): name background stop parameters

* test(website): isolate browser tests from live metadata

* test(agents): clarify background stop journeys

* fix(sdk): report background work subscription failures

Report setup failures so subscribers can replace an observation that the host released.

* fix(app): restore background work after reconnect

Wait for the host handshake before selecting the retained client so an offline pane starts observing when the connection returns.

* fix(agents): retain background shells across rewind

Preserve known live shell ownership when conversation history is rewound, and revoke it when the provider runtime exits.

* fix(website): launch test seeder across platforms

Invoke Wrangler through Node so local website test startup does not depend on an executable npm command shim.

* feat(agents): clarify background task details and tracks

Keep launch descriptions and commands distinct so background work remains identifiable, and allow composer tracks to scroll when space is limited.

* fix(agents): preserve active background work during archive

Keep background-running children out of bulk cleanup and warn before an individual archive. Preserve first taps on composer tracks while the keyboard is open.

* fix(codex): retain background terminals across rewind

Keep live terminal inventories attached to their originating threads so a fork does not hide or misroute their stop actions.

* fix(codex): scope background terminal identities to threads

Prevent commands on separate threads with the same provider process ID from sharing a stop target.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mohamed Boudra <boudra.moha@gmail.com>
2026-11-06 19:49:49 +07:00

186 lines
7.3 KiB
TypeScript

import { expect, test, type Page } from "./fixtures";
function languageButton(page: Page) {
return page.getByRole("button", { name: /^(Language|语言)/ }).first();
}
async function chooseLanguage(page: Page, language: string) {
await languageButton(page).click();
await page.getByRole("menuitemradio", { name: language }).click();
}
function describeAlternates(links: Element[]): string[] {
return links.map((link) => `${link.getAttribute("hreflang")} ${link.getAttribute("href")}`);
}
test.describe("server-rendered Chinese pages", () => {
test.use({ javaScriptEnabled: false });
test("render in Chinese with matching language metadata before any script runs", async ({
page,
}) => {
await page.goto("/zh-CN/docs/cli");
await expect(page.locator("html")).toHaveAttribute("lang", "zh-CN");
await expect(page).toHaveTitle("CLI 参考 - Paseo 文档");
await expect(page.getByRole("heading", { level: 1 })).toHaveText(/CLI 参考$/);
await expect(page.locator('link[rel="canonical"]')).toHaveAttribute(
"href",
"https://paseo.sh/zh-CN/docs/cli",
);
const alternates = await page
.locator('link[rel="alternate"][hreflang]')
.evaluateAll(describeAlternates);
expect(alternates).toEqual([
"en https://paseo.sh/docs/cli",
"zh-CN https://paseo.sh/zh-CN/docs/cli",
"x-default https://paseo.sh/docs/cli",
]);
await expect(page.locator('meta[property="og:locale"]')).toHaveAttribute("content", "zh_CN");
});
test("keep English pages at their unprefixed URLs", async ({ page }) => {
await page.goto("/docs/cli");
await expect(page.locator("html")).toHaveAttribute("lang", "en");
await expect(page.getByRole("heading", { level: 1 })).toHaveText(/CLI reference$/);
});
test("land translated anchors on the English section ids", async ({ page }) => {
await page.goto("/zh-CN/docs/cli#running-agents");
await expect(page.locator("#running-agents")).toHaveText(/运行 Agent/);
await expect(page.locator("main")).not.toContainText("{#");
});
test("show the app's Chinese labels in the homepage mockup", async ({ page }) => {
await page.goto("/zh-CN");
const mockup = page.getByRole("img", {
name: "Paseo 桌面应用,并排打开了编程 Agent、一段对话和一份代码 diff",
});
await expect(mockup).toContainText("新建工作区");
await expect(mockup).toContainText("待查看");
await expect(mockup).toContainText("给 Agent 发消息");
await expect(mockup).not.toContainText("Ready to review");
});
test("keep no space after full-width punctuation in the homepage subtitle", async ({ page }) => {
await page.goto("/zh-CN");
await expect(page.getByText(/^同时运行多个编程 Agent/)).toHaveText(
"同时运行多个编程 Agent,在任何机器上。在桌前,也在手机上。",
);
});
});
test("switches language on the same page, keeping the query and then every link", async ({
page,
}) => {
await page.goto("/plugins/all?q=dark");
await chooseLanguage(page, "简体中文");
await expect(page).toHaveURL(/\/zh-CN\/plugins\/all\?q=dark$/);
await expect(page.locator("html")).toHaveAttribute("lang", "zh-CN");
await expect(page.getByRole("searchbox", { name: "搜索插件" })).toHaveValue("dark");
await page.getByRole("link", { name: "文档", exact: true }).first().click();
await expect(page).toHaveURL(/\/zh-CN\/docs$/);
await chooseLanguage(page, "English");
await expect(page).toHaveURL(/\/docs$/);
await expect(page.locator("html")).toHaveAttribute("lang", "en");
});
test("shows the language as an abbreviation and lists every language by name", async ({ page }) => {
await page.goto("/docs/cli#running-agents");
const button = languageButton(page);
await expect(button).toHaveText("EN");
await expect(button).toHaveAccessibleName("Language: English");
await button.click();
await expect(page.getByRole("menuitemradio", { name: "English" })).toHaveAttribute(
"aria-checked",
"true",
);
const chinese = page.getByRole("menuitemradio", { name: /简体中文/ });
await expect(chinese).toHaveAttribute("aria-checked", "false");
await expect(page.getByRole("menu")).toBeInViewport({ ratio: 1 });
await expect(chinese).toHaveAttribute("href", "/zh-CN/docs/cli#running-agents");
await page.mouse.click(5, 400);
await expect(page.getByRole("menu")).toHaveCount(0);
});
test("switches language from the keyboard", async ({ page }) => {
await page.goto("/");
await languageButton(page).focus();
await page.keyboard.press("Enter");
await expect(page.getByRole("menuitemradio", { name: "English" })).toBeFocused();
await page.keyboard.press("Escape");
await expect(page.getByRole("menu")).toHaveCount(0);
await expect(languageButton(page)).toBeFocused();
await page.keyboard.press("ArrowDown");
await page.keyboard.press("ArrowDown");
await expect(page.getByRole("menuitemradio", { name: /简体中文/ })).toBeFocused();
await page.keyboard.press("Enter");
await expect(page).toHaveURL(/\/zh-CN$/);
await expect(languageButton(page)).toHaveText("ZH");
await expect(languageButton(page)).toBeFocused();
});
test.describe("on a phone", () => {
test.use({ viewport: { width: 390, height: 844 }, hasTouch: true });
const cases = [
{ from: "/", choose: "简体中文", to: "/zh-CN", abbreviation: "ZH" },
{ from: "/zh-CN", choose: "English", to: "/", abbreviation: "EN" },
{ from: "/docs/cli", choose: "简体中文", to: "/zh-CN/docs/cli", abbreviation: "ZH" },
];
for (const { from, choose, to, abbreviation } of cases) {
test(`switches from ${from} to ${to} with taps`, async ({ page, baseURL }) => {
await page.goto(from);
await languageButton(page).tap();
await expect(page.getByRole("menu")).toBeInViewport({ ratio: 1 });
await page.getByRole("menuitemradio", { name: choose }).tap();
await expect(page).toHaveURL(new URL(to, baseURL).href);
await expect(languageButton(page)).toHaveText(abbreviation);
});
}
});
test("finds plugins by their Chinese and English listing text", async ({ page }) => {
await page.goto(`/zh-CN/plugins/all?q=${encodeURIComponent("深色")}`);
await expect(page.getByRole("link", { name: /Dracula/ })).toBeVisible();
await page.goto(`/zh-CN/plugins/all?q=${encodeURIComponent("传令官")}`);
await expect(page.getByRole("link", { name: /传令官/ })).toBeVisible();
await page.goto("/zh-CN/plugins/all?q=herald");
await expect(page.getByRole("link", { name: /传令官/ })).toBeVisible();
});
test("shows a translated plugin overview, or the English one under a notice", async ({ page }) => {
await page.goto("/zh-CN/plugins/omercnet/dracula");
await expect(page.getByRole("heading", { name: "行为" })).toBeVisible();
await expect(page.getByRole("note")).toHaveCount(0);
await page.goto("/zh-CN/plugins/gpambrozio/herald");
await expect(page.getByRole("heading", { level: 1 })).toHaveText("传令官");
await expect(page.getByRole("note")).toHaveText(
"该插件的概览尚未翻译为你的语言,因此以英文显示。",
);
await expect(page.getByRole("heading", { name: "Behavior" })).toBeVisible();
});
test("shows the changelog in Chinese", async ({ page }) => {
await page.goto("/zh-CN/changelog");
await expect(page.getByRole("heading", { name: "新增" }).first()).toBeVisible();
await expect(page.getByRole("note")).toHaveCount(0);
});