Skip to content

Commit f6d0fe9

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

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
@@ -408,6 +408,9 @@ export class Config {
408408
title: workspace.title,
409409
projectName,
410410
projectPath,
411+
parentWorkspaceId: workspace.parentWorkspaceId,
412+
agentType: workspace.agentType,
413+
taskStatus: workspace.taskStatus,
411414
// GUARANTEE: All workspaces must have createdAt (assign now if missing)
412415
createdAt: workspace.createdAt ?? new Date().toISOString(),
413416
// GUARANTEE: All workspaces must have runtimeConfig (apply default if missing)
@@ -454,6 +457,9 @@ export class Config {
454457

455458
// Preserve any config-only fields that may not exist in legacy metadata.json
456459
metadata.aiSettings ??= workspace.aiSettings;
460+
metadata.parentWorkspaceId ??= workspace.parentWorkspaceId;
461+
metadata.agentType ??= workspace.agentType;
462+
metadata.taskStatus ??= workspace.taskStatus;
457463

458464
// Migrate to config for next load
459465
workspace.id = metadata.id;
@@ -474,6 +480,9 @@ export class Config {
474480
name: workspaceBasename,
475481
projectName,
476482
projectPath,
483+
parentWorkspaceId: workspace.parentWorkspaceId,
484+
agentType: workspace.agentType,
485+
taskStatus: workspace.taskStatus,
477486
// GUARANTEE: All workspaces must have createdAt
478487
createdAt: new Date().toISOString(),
479488
// GUARANTEE: All workspaces must have runtimeConfig
@@ -499,6 +508,9 @@ export class Config {
499508
name: workspaceBasename,
500509
projectName,
501510
projectPath,
511+
parentWorkspaceId: workspace.parentWorkspaceId,
512+
agentType: workspace.agentType,
513+
taskStatus: workspace.taskStatus,
502514
// GUARANTEE: All workspaces must have createdAt (even in error cases)
503515
createdAt: new Date().toISOString(),
504516
// GUARANTEE: All workspaces must have runtimeConfig (even in error cases)

0 commit comments

Comments
 (0)