Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
23ed151
docs: define workspace control CLI requirements
yansfil Sep 26, 2026
3c2e8aa
Add pane-scoped workspace info and view queries
yansfil Sep 26, 2026
fa57f1b
Add pane-scoped View commands with retry receipts
yansfil Sep 26, 2026
c664e6b
Open files and working diffs from pane-scoped CLI
yansfil Sep 26, 2026
6df0b40
Report pane-scoped Browser View load state
yansfil Sep 26, 2026
915d0a2
Add SSH workspace control and remote Browser routes
yansfil Sep 26, 2026
3b6bd64
Add conditional Workspace guidance and remote Browser verification
yansfil Sep 26, 2026
ed4ee36
Close Workspace browser routing and credential lifetime gaps
yansfil Sep 26, 2026
4f3ad97
Harden Workspace browser routing and credential cleanup
yansfil Sep 26, 2026
018a461
Stabilize Workspace credentials and browser routes
yansfil Sep 26, 2026
1068b12
Secure Workspace bootstrap and remote browser forwarding
yansfil Sep 26, 2026
3122d6a
Close remote browser forwards during pending SSH opens
yansfil Sep 26, 2026
b79f26e
Release browser routes during stalled SSH connections
yansfil Sep 26, 2026
acbf2bf
Bound and cancel pending browser route builds
yansfil Sep 26, 2026
8772330
Close SSH sockets canceled during key exchange
yansfil Sep 26, 2026
b78ddbf
Open Projects before web shell measurement
yansfil Sep 26, 2026
3dbfabe
Stabilize isolated web shell measurement
yansfil Sep 26, 2026
f725db2
Select measured checkout and scope cleanup evidence
yansfil Sep 26, 2026
d5a6156
Isolate performance fixture sockets and browser control
yansfil Sep 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ jobs:
runs-on: macos-15
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
- run: pnpm install --frozen-lockfile
- name: Set up Swift 6 toolchain
uses: swift-actions/setup-swift@v3
with:
Expand Down
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

105 changes: 105 additions & 0 deletions agents/prd/workspace-control-cli/prd.md

Large diffs are not rendered by default.

58 changes: 57 additions & 1 deletion contracts/hided-ws.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"oneOf": [
{ "$ref": "#/$defs/handshake" },
{ "$ref": "#/$defs/serverFrame" },
{ "$ref": "#/$defs/clientEvent" }
{ "$ref": "#/$defs/clientEvent" },
{ "$ref": "#/$defs/workspaceQuery" },
{ "$ref": "#/$defs/workspaceAction" },
{ "$ref": "#/$defs/workspaceResult" }
],
"$defs": {
"handshake": {
Expand All @@ -16,10 +19,63 @@
"properties": {
"token": { "type": "string", "minLength": 64, "maxLength": 64, "pattern": "^[0-9a-f]+$" },
"schema_version": { "type": "integer", "const": 2 },
"client_kind": { "type": "string", "enum": ["web", "desktop"] },
"have_revision": { "type": "integer", "minimum": 0 },
"have_terminal_sequence": { "type": "integer", "minimum": 0 }
}
},
"workspaceQuery": {
"description": "A pane-scoped query on a capability-authenticated WebSocket. The daemon derives device, pane, and Workspace from the credential and current core projection.",
"type": "object",
"additionalProperties": false,
"required": ["type", "request_id", "query"],
"properties": {
"type": { "const": "workspace_query" },
"request_id": { "$ref": "#/$defs/workspaceRequestId" },
"query": { "enum": ["info", "view_list"] }
}
},
"workspaceAction": {
"description": "One pane-scoped document or View transition. Repeating the same request ID and command returns its recorded result within the ten-minute retry window.",
"type": "object",
"additionalProperties": false,
"required": ["type", "request_id", "command"],
"properties": {
"type": { "const": "workspace_action" },
"request_id": { "$ref": "#/$defs/workspaceRequestId" },
"command": { "$ref": "#/$defs/workspaceCommand" }
}
},
"workspaceRequestId": {
"type": "string",
"minLength": 3,
"maxLength": 64,
"pattern": "^[0-9]+-[A-Za-z0-9_-]+$"
},
"workspaceCommand": {
"oneOf": [
{ "type": "object", "additionalProperties": false, "required": ["action", "path", "beside", "reveal"], "properties": { "action": { "const": "open_file" }, "path": { "type": "string" }, "beside": { "type": "boolean" }, "reveal": { "type": "boolean" } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "path", "beside", "reveal"], "properties": { "action": { "const": "open_diff" }, "path": { "type": "string" }, "beside": { "type": "boolean" }, "reveal": { "type": "boolean" } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "url", "reveal"], "properties": { "action": { "const": "open_browser" }, "url": { "type": "string" }, "reveal": { "type": "boolean" } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "view_id", "reveal"], "properties": { "action": { "const": "select" }, "view_id": { "type": "string" }, "reveal": { "type": "boolean" } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "view_id"], "properties": { "action": { "const": "close" }, "view_id": { "type": "string" } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "view_id", "area_id", "edge"], "properties": { "action": { "const": "split" }, "view_id": { "type": "string" }, "area_id": { "type": "string" }, "edge": { "enum": ["left", "right", "up", "down"] } } },
{ "type": "object", "additionalProperties": false, "required": ["action", "view_id", "area_id", "index"], "properties": { "action": { "const": "move" }, "view_id": { "type": "string" }, "area_id": { "type": "string" }, "index": { "type": "integer", "minimum": 0 } } }
]
},
"workspaceResult": {
"description": "A pane-scoped request outcome. A successful action result includes context, request_id, changed, view_id, and optionally area_id; a refusal names reason and next_action.",
"type": "object",
"required": ["type", "ok"],
"properties": {
"type": { "const": "workspace_result" },
"request_id": { "$ref": "#/$defs/workspaceRequestId" },
"ok": { "type": "boolean" },
"result": { "type": "object" },
"reason": { "type": "string" },
"next_action": { "type": "string" }
}
},
"serverFrame": {
"description": "snapshot/delta carry the core state; error answers a malformed client event; directory_list answers a `remote_file_list` for the `local` target or a `file_list`, and path_refused answers any event whose path failed its boundary - the $HOME line for `remote_file_list` and `create_workspace`, the checkout-root line for `file_list`, `file_open`, `reveal_path`, `file_save`, `file_create`, `dir_create`, `path_rename`, `path_move`, `path_trash` and `file_bytes` (see directoryList and pathRefused). A `file_list`, `file_open`, `reveal_path`, `file_save`, `file_create`, `dir_create`, `path_rename`, `path_move` or `path_trash` that names an SSH device in `device_id` never meets this machine's checkout roots: the core accepts it only for the checkout in front on that device and the device's helper confines every path to that checkout's opened root. file_bytes_error answers a `file_bytes` read the daemon could not serve as bytes (see fileBytes). directory_unavailable answers a `file_list` for a checkout on an SSH device that its helper could not list (see directoryUnavailable). directory_changed announces that a watched folder changed, so the client re-reads that one folder (see directoryChanged). attachment_refused answers an `attachment_stage` or `attachment_commit` that could not be staged (see attachments). file_index_result answers a `file_index` query with the ranked checkout paths (see fileIndex). daemon is the first frame after a valid handshake and describes the daemon itself (see daemonInfo). A `file_bytes` read that succeeds is answered with one or more binary frames on the same socket, not a text frame (see fileBytes).",
"type": "object",
Expand Down
77 changes: 64 additions & 13 deletions desktop/e2e/browser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { AddressInfo } from "node:net";
import path from "node:path";
import { startHerdr, type HerdrFixture } from "../../web/e2e/herdr-fixture";
import { enterWorkspace } from "../../web/e2e/wire";
import { hostLog, isolate, launch, screenshot, type Isolated } from "./fixture";
import { hostLog, isolate, launch, relaunch, screenshot, type Isolated } from "./fixture";

test.describe.configure({ timeout: 240_000 });
test.use({ actionTimeout: 15_000 });
Expand All @@ -24,6 +24,7 @@ let run: Isolated;
let app: ElectronApplication | null = null;
let server: http.Server;
let origin: string;
let cliSequence = 0;

const PAGES: Record<string, string> = {
"/a.html": '<!doctype html><meta charset="utf-8"><title>Page A</title><body style="background:lavender"><h1>Page A</h1><input id="q" aria-label="query">',
Expand All @@ -32,7 +33,7 @@ const PAGES: Record<string, string> = {
};

test.beforeAll(async () => {
herdr = await startHerdr();
herdr = await startHerdr({ agents: false });
server = http.createServer((request, response) => {
const body = PAGES[request.url ?? ""];
response.writeHead(body ? 200 : 404, { "content-type": "text/html; charset=utf-8" });
Expand Down Expand Up @@ -120,12 +121,43 @@ async function windowShot(name: string): Promise<void> {
const dir = process.env.HIDE_E2E_SCREENSHOT_DIR;
if (!dir) return;
const source = await app!.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows()[0]!.getMediaSourceId());
spawnSync("/usr/sbin/screencapture", ["-x", "-o", "-l", source.split(":")[1]!, path.join(dir, `${name}.png`)]);
const shot = spawnSync("/usr/sbin/screencapture", ["-x", "-o", "-l", source.split(":")[1]!, path.join(dir, `${name}.png`)], { encoding: "utf8" });
if (shot.status !== 0) {
const png = await app!.evaluate(async ({ BrowserWindow }) => (await BrowserWindow.getAllWindows()[0]!.capturePage()).toPNG().toString("base64"));
fs.writeFileSync(path.join(dir, `${name}.png`), Buffer.from(png, "base64"));
}
expect(fs.existsSync(path.join(dir, `${name}.png`)), "native window capture is missing").toBe(true);
}

/** Capture the candidate's live native page when macOS denies window capture. */
async function nativePageShot(url: string, name: string): Promise<void> {
const dir = process.env.HIDE_E2E_SCREENSHOT_DIR;
if (!dir) return;
const png = await app!.evaluate(async ({ BrowserWindow }, target) => {
const child = BrowserWindow.getAllWindows()[0]!.contentView.children.find(
(view) => (view as { webContents?: Electron.WebContents }).webContents?.getURL() === target,
) as unknown as { webContents: Electron.WebContents } | undefined;
if (!child) throw new Error(`native page missing: ${target}`);
return (await child.webContents.capturePage()).toPNG().toString("base64");
}, url);
fs.writeFileSync(path.join(dir, `${name}.png`), Buffer.from(png, "base64"));
}

function quote(value: string): string { return `'${value.replaceAll("'", "'\\''")}'`; }

async function cliFromPane(args: string[]): Promise<Record<string, unknown>> {
const sequence = ++cliSequence;
const output = path.join(herdr.root, `desktop-cli-${sequence}.json`);
const status = path.join(herdr.root, `desktop-cli-${sequence}.status`);
const command = `HIDE_STATE_DIR=${quote(run.env.HIDE_STATE_DIR!)} ${[path.resolve("..", "target", "debug", "hide"), ...args].map(quote).join(" ")} > ${quote(output)}; printf '%s' "$?" > ${quote(status)}\n`;
const sent = spawnSync(herdr.bin, ["pane", "send-text", herdr.panes[0], command], { env: herdr.env, encoding: "utf8", timeout: 10_000 });
expect(sent.status, sent.stderr).toBe(0);
await expect.poll(() => fs.existsSync(status) ? fs.readFileSync(status, "utf8") : null, { timeout: 20_000 }).not.toBeNull();
return { status: Number(fs.readFileSync(status, "utf8")), ...(JSON.parse(fs.readFileSync(output, "utf8").trim().split("\n").at(-1) || "{}") as Record<string, unknown>) };
}

function openFromCli(target: string, extra: string[] = []): Record<string, unknown> {
const answer = run.hide(["browser", "open", target, ...extra]);
return { status: answer.status, ...(JSON.parse(answer.stdout.trim().split("\n").at(-1) || "{}") as Record<string, unknown>) };
function openFromCli(target: string, extra: string[] = []): Promise<Record<string, unknown>> {
return cliFromPane(["browser", "open", target, ...extra]);
}

/** Waits until the view showing `url` covers its display's slot as the shell lays it out now. */
Expand Down Expand Up @@ -162,8 +194,9 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou

// `hide browser open` from an agent's pane opens the page in that pane's
// Workspace and answers with the core's receipt.
const opened = openFromCli(`${origin}/a.html`, ["--pane", herdr.panes[0]]);
expect(opened).toMatchObject({ status: 0, ok: true, device_id: "local", path: checkout });
const opened = await openFromCli(`${origin}/a.html`, ["--reveal", "--wait"]);
expect(opened).toMatchObject({ status: 0, ok: true, result: { context: { device_id: "local", checkout_path: checkout } }, page: { state: "loaded" } });
expect(await cliFromPane(["view", "status", (opened.result as { view_id: string }).view_id])).toMatchObject({ status: 0, ok: true, view: { page: { state: "loaded" } } });
const a = await displayIdOf(page, "Page A");
let pageA = await viewOf(`${origin}/a.html`);
await expect.poll(async () => (await viewOf(`${origin}/a.html`)).visible).toBe(true);
Expand All @@ -178,8 +211,8 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou
}, `${origin}/a.html`);
expect(await inPage(`${origin}/a.html`, "document.getElementById('q').value")).toBe("한글 입력");

// A second page, without a pane, opens in the Workspace in front.
expect(openFromCli(`${origin}/b.html`)).toMatchObject({ status: 0, ok: true });
// A second page opens in the calling pane's Workspace.
expect(await openFromCli(`${origin}/b.html`)).toMatchObject({ status: 0, ok: true });
const b = await displayIdOf(page, "Page B");
await inPage(`${origin}/b.html`, "window.__hideMarker = 'b'");
const pageB = await viewOf(`${origin}/b.html`);
Expand All @@ -204,6 +237,8 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou
expect((await viewOf(`${origin}/a.html`)).pid).toBe(pageA.pid);
expect((await viewOf(`${origin}/b.html`)).pid).toBe(pageB.pid);
await expectOnSlot(page, `${origin}/b.html`, b);
await nativePageShot(`${origin}/a.html`, "browser-native-page-a");
await nativePageShot(`${origin}/b.html`, "browser-native-page-b");

// A narrower window moves the pages with their slots.
await app.evaluate(({ BrowserWindow }) => {
Expand Down Expand Up @@ -249,7 +284,9 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou
expect(await app.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().length)).toBe(1);

// A page that cannot load says so in its area, with Reload.
expect(openFromCli("http://127.0.0.1:1/")).toMatchObject({ status: 0, ok: true });
const failed = await openFromCli("http://127.0.0.1:1/", ["--wait"]);
expect(failed).toMatchObject({ status: 2, ok: false, applied: "applied", reason: "page_failed", page: { state: "failed" } });
expect(await cliFromPane(["view", "status", failed.view_id as string])).toMatchObject({ status: 0, ok: true, view: { page: { state: "failed" } } });
await expect(page.locator('[data-area-empty="browser-failed"]')).toBeVisible({ timeout: 20_000 });
await expect(page.locator("[data-browser-retry]")).toBeVisible();
await windowShot("browser-load-failed");
Expand All @@ -263,7 +300,7 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou
// A file outside every checkout is refused by the daemon and never shown.
const outside = path.join(run.root, "outside.html");
fs.writeFileSync(outside, "<title>Outside</title>");
expect(openFromCli(outside)).toMatchObject({ ok: false, reason: "outside_checkout" });
expect(await openFromCli(outside)).toMatchObject({ ok: false, reason: "path_outside_checkout" });

// Closing B's display ends its renderer process. Without the Explorer both
// areas show again, B's among them.
Expand All @@ -286,7 +323,7 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou

// A relaunch brings the pages back at the addresses they last showed.
await app.close();
({ app } = await launch(run.env, { switches: PAINT_WHILE_OCCLUDED }));
app = await relaunch(run.env, { switches: PAINT_WHILE_OCCLUDED });
const again = await app.firstWindow();
await enterWorkspace(again, "fixture");
await expect(tab(again, "Page A")).toBeVisible({ timeout: 20_000 });
Expand All @@ -309,3 +346,17 @@ test("browser: a page opens from an agent's pane, follows its area, moves withou
await browser.close();
}
});

test("browser: waiting for a hidden page does not take the operator's keyboard target", async () => {
({ app } = await launch(run.env, { switches: PAINT_WHILE_OCCLUDED }));
const page = await app.firstWindow();
await enterWorkspace(page, "fixture");
const focused = await page.locator('[data-pane-view][data-focused="true"]').getAttribute("data-pane-view");
expect(focused).toBeTruthy();
const hidden = await openFromCli(`${origin}/b.html`, ["--wait"]);
expect(hidden).toMatchObject({ status: 2, ok: false, applied: "applied", reason: "page_wait_timeout", page: { state: "pending" } });
expect(await cliFromPane(["view", "status", hidden.view_id as string])).toMatchObject({ status: 0, ok: true, view: { page: { state: "pending" } } });
await expect(page.locator('[data-pane-view][data-focused="true"]')).toHaveAttribute("data-pane-view", focused!);
const revealed = await openFromCli(`${origin}/b.html`, ["--reveal", "--wait"]);
expect(revealed).toMatchObject({ status: 0, ok: true, page: { state: "loaded" } });
});
4 changes: 2 additions & 2 deletions desktop/e2e/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ export async function launch(
* (checked by reading the window through the main process when Playwright's
* page did not). The main process sees the window as the operator does.
*/
export async function relaunch(env: Record<string, string>, { appDir = DESKTOP_DIR }: { appDir?: string } = {}): Promise<ElectronApplication> {
export async function relaunch(env: Record<string, string>, { appDir = DESKTOP_DIR, switches = [] }: { appDir?: string; switches?: string[] } = {}): Promise<ElectronApplication> {
assertIsolated(env);
const app = await electron.launch({ args: [appDir], cwd: appDir, env });
const app = await electron.launch({ args: [appDir, ...switches], cwd: appDir, env });
await expect
.poll(
() =>
Expand Down
Loading
Loading