mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-11-26 10:41:50 +08:00
* Remove code comments and add the no-comments rule Remove the comments from first-party code and configuration files: TS/JS, JSX, CSS, SQL migrations, Swift, Kotlin, Gradle, shell, Docker, systemd, Nix, YAML, TOML, JSONC and GritQL. Keep only what a tool reads: license headers, shebangs, compiler and lint directives, JSDoc types in plain .js files, generated file headers, GritQL scope lines, the install-server.sh help text and the openbot-boat-pre-stop marker. Vendored code, fixtures and released schemas keep their comments. Add the rule to AGENTS.md, and change the docs that asked for comments. Add two i18n keys that only comments named to RELEASED_SOURCE_KEYS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep comments that are data in strings The benchmark task files in opencode-free-models-bench.ts tell the model what each function must do. The sample file and HTML page in the two stories are display content. Put their comments back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep released migrations and mobile native inputs unchanged check:migrations compares each released migration with v0.73.0 byte for byte, so restore src/backend/migrations. A change to a native build input of apps/mobile makes a new runtime version, so restore those files and the extra fingerprint sources. List these files and the comment markers that a tool reads in AGENTS.md. Remove the last requests for comments in src/renderer/AGENTS.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
4.4 KiB
TypeScript
104 lines
4.4 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
import { translateFor } from "@openbot/i18n";
|
|
import { chromium, type Page } from "playwright-core";
|
|
|
|
declare global {
|
|
interface Window {
|
|
scheduleCalendarRequests?: string[];
|
|
}
|
|
}
|
|
|
|
const OUT = resolve(import.meta.dirname, "../.openbot-build/schedule-server-switch-e2e");
|
|
const t = translateFor("en");
|
|
const storybook = process.argv.find((arg) => arg.startsWith("--storybook="))?.slice("--storybook=".length);
|
|
assert.ok(storybook, "Pass --storybook=<url> with the URL that `bun run storybook` reports.");
|
|
|
|
interface Report {
|
|
from?: string;
|
|
to?: string;
|
|
requests?: string[];
|
|
routinesBeforeSwitch?: string[];
|
|
routinesAfterSwitch?: string[];
|
|
passed: boolean;
|
|
}
|
|
|
|
const report: Report = { passed: false };
|
|
|
|
async function calendarReady(page: Page): Promise<void> {
|
|
const schedule = page.getByRole("region", { name: t("routine.calendar.title") });
|
|
await schedule.waitFor();
|
|
await schedule
|
|
.getByRole("status")
|
|
.filter({ hasText: t("routine.calendar.loading") })
|
|
.waitFor({ state: "detached" });
|
|
assert.equal(await schedule.getByText(t("routine.calendar.loadFailed")).count(), 0, "The calendar shows its error.");
|
|
}
|
|
|
|
async function visibleRoutines(page: Page): Promise<string[]> {
|
|
const runs = page
|
|
.getByRole("region", { name: t("routine.calendar.title") })
|
|
.getByRole("button", { name: /^Routine@/ });
|
|
const labels = await runs.evaluateAll((buttons) => buttons.map((button) => button.getAttribute("aria-label") ?? ""));
|
|
return [...new Set(labels.map((label) => label.split(",")[0] ?? ""))];
|
|
}
|
|
|
|
mkdirSync(OUT, { recursive: true });
|
|
const browser = await chromium.launch();
|
|
try {
|
|
const page = await browser.newPage({ viewport: { width: 1400, height: 900 } });
|
|
await page.goto(`${storybook}/iframe.html?id=app--playground&viewMode=story`);
|
|
await page.getByRole("button", { name: t("app.rail.schedule"), exact: true }).waitFor();
|
|
await page.evaluate(() => {
|
|
const agent = window.openbot.agent;
|
|
window.scheduleCalendarRequests = [];
|
|
agent.routineCalendar = async (_input, server) => {
|
|
const serverId = typeof server === "string" ? server : "local";
|
|
window.scheduleCalendarRequests?.push(serverId);
|
|
const at = new Date(Date.now() + 3_600_000).toISOString();
|
|
return {
|
|
routines: [
|
|
{
|
|
id: `routine-${serverId}`,
|
|
name: `Routine@${serverId}`,
|
|
owner: { kind: "agent", agentId: `agent-${serverId}` },
|
|
active: true,
|
|
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
schedule: { kind: "daily", time: "09:00" },
|
|
},
|
|
],
|
|
runs: [{ id: `run-${serverId}`, routineId: `routine-${serverId}`, at, status: "scheduled" }],
|
|
};
|
|
};
|
|
});
|
|
|
|
const servers = await page.evaluate(() => window.openbot.servers.list());
|
|
const from = servers.find((server) => server.active);
|
|
const to = servers.find((server) => !server.active && server.state === "online");
|
|
assert.ok(from && to, "The preview needs an active server and another online server.");
|
|
report.from = from.id;
|
|
report.to = to.id;
|
|
|
|
await page.getByRole("button", { name: t("app.rail.schedule"), exact: true }).click();
|
|
await calendarReady(page);
|
|
report.routinesBeforeSwitch = await visibleRoutines(page);
|
|
assert.deepEqual(report.routinesBeforeSwitch, [`Routine@${from.id}`], "The first server's calendar is wrong.");
|
|
|
|
await page.getByRole("button", { name: t("server.menu.open", { name: from.name }), exact: true }).click();
|
|
await page.getByRole("menuitem", { name: to.name, exact: true }).click();
|
|
await page.getByRole("button", { name: t("server.menu.open", { name: to.name }), exact: true }).waitFor();
|
|
await page.waitForFunction((serverId) => window.scheduleCalendarRequests?.includes(serverId), to.id);
|
|
await calendarReady(page);
|
|
|
|
report.requests = await page.evaluate(() => window.scheduleCalendarRequests ?? []);
|
|
report.routinesAfterSwitch = await visibleRoutines(page);
|
|
assert.equal(report.requests.at(-1), to.id, "The calendar did not ask the new server.");
|
|
assert.deepEqual(report.routinesAfterSwitch, [`Routine@${to.id}`], "The new server's calendar is wrong.");
|
|
await page.screenshot({ path: resolve(OUT, "after-switch.png") });
|
|
report.passed = true;
|
|
} finally {
|
|
writeFileSync(resolve(OUT, "report.json"), `${JSON.stringify(report, null, 2)}\n`);
|
|
await browser.close();
|
|
}
|