feat: configure subject attachment on worker launch

This commit is contained in:
2026-10-04 08:40:30 +09:00
parent 1bbc48dad0
commit f7b722246d
25 changed files with 831 additions and 303 deletions
@@ -358,6 +358,38 @@ Deno.serve({ hostname: "127.0.0.1", port }, async (request) => {
if (url.pathname === `/api/w/${workspaceId}/working-directories`) {
return json({ workspace_id: workspaceId, items: [], diagnostics: [] });
}
if (url.pathname === `/api/w/${workspaceId}/workers/launch-options`) {
return json({
workspace_id: workspaceId,
runtimes: [{
runtime_id: "embedded-worker-runtime",
display_name: "Embedded Runtime",
built_in: true,
worker_creation_available: true,
working_directory_required: false,
status: "active",
diagnostics: [],
}],
default_profile: "builtin:companion",
profiles: [
{
id: "builtin:companion",
label: "Companion",
description: "General Workspace assistance with explicit subject Memory support.",
feature_connections: { subjektiv: true },
},
{
id: "builtin:standalone",
label: "Standalone",
description: "Independent Worker without Workspace subject Memory support.",
feature_connections: { subjektiv: false },
},
],
repositories: [],
working_directories: [],
diagnostics: [],
});
}
const subjectsPath = `/api/w/${workspaceId}/subjektiv/subjects`;
if (url.pathname === subjectsPath) {
@@ -146,7 +146,7 @@ async function swipeMainToEnd(page: Page): Promise<void> {
throw new Error("touch input did not reach the end of the resident Memory surface");
}
Deno.test("production subject Memory shell renders exact states, safe Markdown, provenance, and one scroll owner", async () => {
Deno.test("production subject Memory and Worker launch shells preserve exact scoped behavior", async () => {
const build = await new Deno.Command(Deno.execPath(), {
args: ["task", "build"],
cwd: workspaceRoot,
@@ -407,6 +407,49 @@ Deno.test("production subject Memory shell renders exact states, safe Markdown,
await page.close();
}
await stateContext.close();
const launchContext = await browser.newContext({ viewport: { width: 768, height: 900 } });
const launchPage = await launchContext.newPage();
await launchPage.goto(`${baseUrl}/w/${workspaceId}/workers/new`);
await launchPage.getByRole("heading", { name: "New Worker", level: 1 }).waitFor();
const subjectConnection = launchPage.locator(
'[data-worker-feature-connection="subjektiv"]',
);
await subjectConnection.waitFor();
const subjectSelect = launchPage.getByRole("combobox", {
name: "Subject Memory connection",
});
assertEquals(await subjectSelect.locator('option[value="error-subject"]').count(), 0);
assertEquals(await subjectSelect.locator('option[value="paged-subject"]').count(), 0);
await launchPage.getByRole("button", { name: "Load more subjects" }).click();
await subjectSelect.locator('option[value="paged-subject"]').waitFor({ state: "attached" });
await subjectSelect.selectOption(subjectId);
assertEquals(await subjectSelect.inputValue(), subjectId);
assertEquals(
await subjectConnection.locator("code", { hasText: subjectId }).count(),
1,
);
const profileSelect = launchPage.getByRole("combobox", { name: "Profile" });
await profileSelect.selectOption("builtin:standalone");
assertEquals(await subjectConnection.count(), 0);
await profileSelect.selectOption("builtin:companion");
await subjectConnection.waitFor();
assertEquals(await subjectSelect.inputValue(), "");
await subjectSelect.selectOption(subjectId);
const createRequestPromise = launchPage.waitForRequest((request) =>
request.method() === "POST" &&
new URL(request.url()).pathname === `/api/w/${workspaceId}/workers`
);
await launchPage.getByRole("button", { name: "Start Worker" }).click();
const createRequest = await createRequestPromise;
const createPayload = createRequest.postDataJSON();
assertEquals(createPayload.profile, "builtin:companion");
assertEquals(createPayload.feature_connections, {
subjektiv: { subject_id: subjectId },
});
await launchContext.close();
} finally {
await browser.close();
}
@@ -0,0 +1,42 @@
{
"schemaVersion": 1,
"id": "worker-launch-dark",
"title": "Ordinary Worker launch with optional subject connection — dark",
"baseUrl": "http://127.0.0.1:15288",
"colorScheme": "dark",
"reducedMotion": "reduce",
"personas": [{
"id": "fixture",
"label": "Authorized Workspace member fixture",
"auth": { "kind": "anonymous" }
}],
"viewports": [
{ "label": "desktop", "width": 1440, "height": 900 },
{ "label": "narrow", "width": 768, "height": 900 },
{ "label": "mobile", "width": 390, "height": 844 },
{ "label": "compact", "width": 320, "height": 700 }
],
"routes": [{
"id": "representative",
"label": "Worker launch",
"path": "/w/memory-review/workers/new",
"goal": "Start an ordinary Worker with a compatible Profile and optionally connect an authorized existing subject.",
"dataState": "Compatible and incompatible Profiles with active, retired, long-identity, and paginated subjects.",
"ready": { "kind": "selector", "selector": "form.worker-launch-form" },
"capturePoints": [{ "id": "initial", "label": "Worker launch form" }]
}],
"processes": [{
"id": "worker-launch-fixture",
"command": "deno",
"cwd": "..",
"args": [
"run",
"--allow-net",
"--allow-read",
"browser-tests/memory_document_fixture_server.ts",
"15288",
"../../web/workspace/build"
],
"readyUrl": "http://127.0.0.1:15288/health"
}]
}
@@ -0,0 +1,42 @@
{
"schemaVersion": 1,
"id": "worker-launch-light",
"title": "Ordinary Worker launch with optional subject connection — light",
"baseUrl": "http://127.0.0.1:15287",
"colorScheme": "light",
"reducedMotion": "reduce",
"personas": [{
"id": "fixture",
"label": "Authorized Workspace member fixture",
"auth": { "kind": "anonymous" }
}],
"viewports": [
{ "label": "desktop", "width": 1440, "height": 900 },
{ "label": "narrow", "width": 768, "height": 900 },
{ "label": "mobile", "width": 390, "height": 844 },
{ "label": "compact", "width": 320, "height": 700 }
],
"routes": [{
"id": "representative",
"label": "Worker launch",
"path": "/w/memory-review/workers/new",
"goal": "Start an ordinary Worker with a compatible Profile and optionally connect an authorized existing subject.",
"dataState": "Compatible and incompatible Profiles with active, retired, long-identity, and paginated subjects.",
"ready": { "kind": "selector", "selector": "form.worker-launch-form" },
"capturePoints": [{ "id": "initial", "label": "Worker launch form" }]
}],
"processes": [{
"id": "worker-launch-fixture",
"command": "deno",
"cwd": "..",
"args": [
"run",
"--allow-net",
"--allow-read",
"browser-tests/memory_document_fixture_server.ts",
"15287",
"../../web/workspace/build"
],
"readyUrl": "http://127.0.0.1:15287/health"
}]
}