mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-12-03 20:21:56 +08:00
* Give the browser code card the island design The code card shows the site, the value and Submit in one compact glass layout. A new island variant has no page preview, for the browser dock. OtpInput gets a compact size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Add the browser dock with the island, queue and composer The dock shows the step of the agent, the code card and the reply of the agent over the page, with the queue and the composer of the tab's agent. It uses the draft and the queue of the conversation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Let the user take control of a browser tab A person can take a tab from the agent and give it back. While the user holds the tab, the agent's browser tools wait for the release and then tell the agent to take a fresh snapshot. A window close, a session end or a member end releases only its own holds. The new optional capability browser-user-control adds the Team API routes and the browser-user-control-changed event. Protocols v1-v7 do not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Show the browser as a full view with tabs in the top row The full view replaces the expanded browser panel. It shows every tab of the agent as chips in the top row, an address field with suggestions from open tabs and the session history, a page menu, and the dock of the tab's agent over the page. A narrow window shows one tab switcher in place of the chips. - Tabs: drag to move, a tab menu (duplicate, move, close left, right or others), reopen a closed tab at its place, and middle click to close. - The keys of other browsers work in the full view and on the page. - The tab order, the closed tabs and the history stay in memory in the renderer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Show the browser dock over the native page A local tab is a native view above the renderer, so the dock now shows in a transparent overlay view above the page. The main renderer publishes what the dock shows and does the actions that the overlay sends back. Main draws a native blur under each glass shape of the dock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Translate the browser full view and add its release notes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix issues that the browser full view smoke found - An address typed quickly after a new tab no longer closes the tab: a failed first load closes the tab only when no later load started. - The narrow tab list is modal, so focus goes to the active tab and Escape closes the list, not the browser view. - Two effects read the tab order and the queue rows in their compute functions, so Solid no longer warns about untracked reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Keep the browser dock off the overlay seams in the web client The web client has no window.openbot, so the full view crashed when the dock subscribed to the overlay. Subscribe and publish only while the desktop overlay is in use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Hold the agent's tab list while the user controls a tab While the user controls a tab, the agent's open, list_tabs and status calls now wait for the release, as calls on the held tab do. Before, a tab list ran and the agent could read the page title during the hold. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Stop a loading page and show when a tab can go back or forward The address bar shows Stop in place of Reload while a page loads, and Back and Forward are off when the tab has no page to go to. A stop ends the load at once, before the queued tab operations, and the load that it ends counts as done. A joined server sends the history state through the new optional `browser-page-state-v1` capability, because the frozen tab event and list drop unknown keys. A client shows Stop only for a host that reports the page state; for an older host, Back and Forward stay enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Open the tab owner's chat when the user selects its tab The dock is the conversation's composer, so it acts on the active agent. A tab of a different agent now brings that agent's chat, and the full view stays open. A tab that an agent brings to the front still offers "Open {name}", which also keeps the page open. The reply marker is kept for each agent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Accept undefined on the optional browser dock props The type ratchet checks exactOptionalPropertyTypes. The dock, the island and the full view pass optional values through, so their props and the shared queue and editor props they fill now accept undefined. The baseline goes down. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * List the tabs of all agents in the browser full view The full view showed only the tabs of the active agent, so the user could not select a tab of another agent. The full view now lists all tabs of the server. A tab of another agent opens the chat of its owner, and that chat shows the selected tab. The side panel keeps the agent's tabs only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix the review findings of the browser full view - Release a user hold when the first load of a tab fails, and let a woken tab restore while it is held. - Show the dock overlay again when main publishes the same presentation after the view failed. - Find the owner of a tab from its thread when it has no agent id. - Release the tabs that the user took when the full view closes. - Clear the draft of the message that the answer was for, not the draft that is open when the answer arrives. - Keep IME input, menus and dialogs out of the full view shortcuts. - Decode "+" in a search address, and clear typed values in the inert dock copy. - Count a visit only once for each page of a tab. - Remove the dead "open agent" dock branch, the address editing state and the unused browser route keys. - Use the glossary term for a remote host in pt and tr. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Check that a session end gives back browser control in the Team API routes E2E Logout and session revoke now call releaseUserControlHeldBy. The stub threw, so two checks failed. The stub records the holders, and the checks assert the release of the ended session. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Fix the NorbiAI review findings of the browser full view - The last event socket of a session that closes gives back the browser control of that session, so the agent does not wait for a client that went away. team-session-revoke-e2e checks it on a real host. - The dock adapter cuts the deliveries, the skills, the step label and the reply body to the presentation limits, so main does not refuse the whole presentation. - Remove canOpenChat: it was always true. - Move forwardKeyToWindow and sendBrowserPageState above the doc comments of the methods that they split. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
146 lines
4.7 KiB
TypeScript
146 lines
4.7 KiB
TypeScript
import { spawn } from "node:child_process";
|
|
import { randomUUID } from "node:crypto";
|
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import { dirname, join } from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
import { z } from "zod";
|
|
import { withoutElectronRuntimeFlags } from "./electron-spawn-env";
|
|
|
|
class FixtureProcessTimeout extends Error {}
|
|
|
|
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
const buildRoot = await mkdtemp(join(tmpdir(), "openbot-user-control-"));
|
|
const reportPath = join(projectRoot, ".openbot-build/browser-user-control-e2e/report.json");
|
|
const runId = randomUUID();
|
|
let sourceSha: string | undefined;
|
|
try {
|
|
await mkdir(dirname(reportPath), { recursive: true });
|
|
const entry = join(buildRoot, "browser-user-control.mjs");
|
|
await run(process.execPath, [
|
|
"build",
|
|
join(projectRoot, "scripts/browser-user-control-electron.ts"),
|
|
"--target=node",
|
|
"--format=esm",
|
|
"--external=electron",
|
|
`--outfile=${entry}`,
|
|
]);
|
|
sourceSha = (await output("git", ["rev-parse", "HEAD"])).trim();
|
|
const bunVersion = await output(process.execPath, ["--version"]);
|
|
await run(
|
|
join(projectRoot, "node_modules/.bin/electron"),
|
|
[
|
|
...(process.platform === "linux" ? ["--no-sandbox"] : []),
|
|
entry,
|
|
`--fixture-root=${buildRoot}`,
|
|
`--report-path=${reportPath}`,
|
|
`--source-sha=${sourceSha}`,
|
|
`--run-id=${runId}`,
|
|
`--harness-runtime=${process.version}`,
|
|
`--bun-version=${bunVersion.trim()}`,
|
|
],
|
|
true,
|
|
);
|
|
const report = z
|
|
.object({
|
|
status: z.literal("passed"),
|
|
cases: z.array(z.string()).min(19),
|
|
runId: z.literal(runId),
|
|
sourceSha: z.literal(sourceSha),
|
|
})
|
|
.parse(JSON.parse(await readFile(reportPath, "utf8")));
|
|
// Machine-readable summary of the completed case count.
|
|
process.stdout.write(
|
|
`${JSON.stringify({ status: report.status, cases: report.cases.length, report: reportPath })}\n`,
|
|
);
|
|
} catch (error) {
|
|
let completedCases: string[] = [];
|
|
let nativeFailure = false;
|
|
try {
|
|
const current = z
|
|
.object({ runId: z.literal(runId), status: z.string(), cases: z.array(z.string()).optional() })
|
|
.parse(JSON.parse(await readFile(reportPath, "utf8")));
|
|
completedCases = current.cases ?? [];
|
|
nativeFailure = current.status === "failed";
|
|
} catch {
|
|
// This invocation owns no valid report yet. An earlier report cannot supply its result.
|
|
}
|
|
if (error instanceof FixtureProcessTimeout) {
|
|
await writeFile(
|
|
reportPath,
|
|
`${JSON.stringify(
|
|
{
|
|
status: "timed_out",
|
|
runId,
|
|
sourceSha,
|
|
cases: completedCases,
|
|
reason: "Owned fixture exceeded its 180-second process guard.",
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
} else if (!nativeFailure) {
|
|
await writeFile(
|
|
reportPath,
|
|
`${JSON.stringify(
|
|
{
|
|
status: "failed",
|
|
runId,
|
|
sourceSha,
|
|
cases: completedCases,
|
|
reason: "Fixture process completion or report verification failed.",
|
|
},
|
|
null,
|
|
2,
|
|
)}\n`,
|
|
);
|
|
}
|
|
throw error;
|
|
} finally {
|
|
await rm(buildRoot, { recursive: true, force: true });
|
|
}
|
|
|
|
async function run(command: string, args: string[], electron = false): Promise<void> {
|
|
await new Promise<void>((resolve, reject) => {
|
|
const child = spawn(command, args, {
|
|
cwd: projectRoot,
|
|
stdio: "inherit",
|
|
env: electron ? withoutElectronRuntimeFlags(process.env) : process.env,
|
|
});
|
|
let force: NodeJS.Timeout | undefined;
|
|
let timedOut = false;
|
|
const timeout = setTimeout(() => {
|
|
timedOut = true;
|
|
child.kill("SIGTERM");
|
|
force = setTimeout(() => child.kill("SIGKILL"), 3_000);
|
|
}, 180_000);
|
|
child.once("error", (error) => {
|
|
clearTimeout(timeout);
|
|
clearTimeout(force);
|
|
reject(error);
|
|
});
|
|
child.once("exit", (code, signal) => {
|
|
clearTimeout(timeout);
|
|
clearTimeout(force);
|
|
if (timedOut) reject(new FixtureProcessTimeout("Browser user control fixture timed out."));
|
|
else if (code === 0 && signal === null) resolve();
|
|
else reject(new Error(`Browser user control fixture process failed (${code}).`));
|
|
});
|
|
});
|
|
}
|
|
|
|
async function output(command: string, args: string[]): Promise<string> {
|
|
return new Promise((resolve, reject) => {
|
|
const child = spawn(command, args, { cwd: projectRoot, stdio: ["ignore", "pipe", "inherit"] });
|
|
let text = "";
|
|
child.stdout.on("data", (chunk: Buffer) => {
|
|
text += chunk.toString("utf8");
|
|
});
|
|
child.once("error", reject);
|
|
child.once("exit", (code) =>
|
|
code === 0 ? resolve(text) : reject(new Error("Unable to read fixture source SHA.")),
|
|
);
|
|
});
|
|
}
|