Skip to content

Commit f3f7987

Browse files
committed
fix: preserve agent task metadata in workspace metadata
Change-Id: Ica5e52194ee198aa869557db564856e47eb1738b Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent 6eaf0e2 commit f3f7987

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/node/config.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,41 @@ describe("Config", () => {
147147
expect(workspace.name).toBe(workspaceName);
148148
expect(workspace.createdAt).toBe("2025-01-01T00:00:00.000Z");
149149
});
150+
151+
it("should include agent task fields for config-native workspaces", async () => {
152+
const projectPath = "/fake/project";
153+
154+
const parentWorkspacePath = path.join(config.srcDir, "project", "main");
155+
const childWorkspacePath = path.join(config.srcDir, "project", "agent-task");
156+
157+
fs.mkdirSync(parentWorkspacePath, { recursive: true });
158+
fs.mkdirSync(childWorkspacePath, { recursive: true });
159+
160+
await config.editConfig((cfg) => {
161+
cfg.projects.set(projectPath, {
162+
workspaces: [
163+
{ path: parentWorkspacePath, id: "parent-id", name: "main" },
164+
{
165+
path: childWorkspacePath,
166+
id: "child-id",
167+
name: "agent-task",
168+
parentWorkspaceId: "parent-id",
169+
agentType: "research",
170+
taskStatus: "queued",
171+
},
172+
],
173+
});
174+
return cfg;
175+
});
176+
177+
const allMetadata = await config.getAllWorkspaceMetadata();
178+
179+
const childMetadata = allMetadata.find((metadata) => metadata.id === "child-id");
180+
expect(childMetadata).toBeDefined();
181+
expect(childMetadata!.parentWorkspaceId).toBe("parent-id");
182+
expect(childMetadata!.agentType).toBe("research");
183+
expect(childMetadata!.taskStatus).toBe("queued");
184+
});
150185
});
151186

152187
describe("workspace MCP overrides", () => {

src/node/config.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ export class Config {
371371
title: workspace.title,
372372
projectName,
373373
projectPath,
374+
parentWorkspaceId: workspace.parentWorkspaceId,
375+
agentType: workspace.agentType,
376+
taskStatus: workspace.taskStatus,
374377
// GUARANTEE: All workspaces must have createdAt (assign now if missing)
375378
createdAt: workspace.createdAt ?? new Date().toISOString(),
376379
// GUARANTEE: All workspaces must have runtimeConfig (apply default if missing)
@@ -417,6 +420,9 @@ export class Config {
417420

418421
// Preserve any config-only fields that may not exist in legacy metadata.json
419422
metadata.aiSettings ??= workspace.aiSettings;
423+
metadata.parentWorkspaceId ??= workspace.parentWorkspaceId;
424+
metadata.agentType ??= workspace.agentType;
425+
metadata.taskStatus ??= workspace.taskStatus;
420426

421427
// Migrate to config for next load
422428
workspace.id = metadata.id;
@@ -437,6 +443,9 @@ export class Config {
437443
name: workspaceBasename,
438444
projectName,
439445
projectPath,
446+
parentWorkspaceId: workspace.parentWorkspaceId,
447+
agentType: workspace.agentType,
448+
taskStatus: workspace.taskStatus,
440449
// GUARANTEE: All workspaces must have createdAt
441450
createdAt: new Date().toISOString(),
442451
// GUARANTEE: All workspaces must have runtimeConfig
@@ -462,6 +471,9 @@ export class Config {
462471
name: workspaceBasename,
463472
projectName,
464473
projectPath,
474+
parentWorkspaceId: workspace.parentWorkspaceId,
475+
agentType: workspace.agentType,
476+
taskStatus: workspace.taskStatus,
465477
// GUARANTEE: All workspaces must have createdAt (even in error cases)
466478
createdAt: new Date().toISOString(),
467479
// GUARANTEE: All workspaces must have runtimeConfig (even in error cases)

0 commit comments

Comments
 (0)