Skip to content

Commit fb652b8

Browse files
committed
🤖 fix: satisfy static-check
Signed-off-by: Thomas Kosiewski <tk@coder.com> --- _Generated with `codex cli` • Model: `gpt-5.2` • Thinking: `xhigh`_ <!-- mux-attribution: model=gpt-5.2 thinking=xhigh --> Change-Id: I1602bf485713861acc0901f8dda99ac45365be25
1 parent c2be176 commit fb652b8

File tree

10 files changed

+199
-141
lines changed

10 files changed

+199
-141
lines changed

‎src/browser/components/Settings/sections/TasksSection.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ export function TasksSection() {
6666

6767
const setMaxParallelAgentTasks = (rawValue: string) => {
6868
const parsed = Number(rawValue);
69-
setSettings((prev) =>
70-
normalizeTaskSettings({ ...prev, maxParallelAgentTasks: parsed })
71-
);
69+
setSettings((prev) => normalizeTaskSettings({ ...prev, maxParallelAgentTasks: parsed }));
7270
};
7371

7472
const setMaxTaskNestingDepth = (rawValue: string) => {
@@ -129,4 +127,3 @@ export function TasksSection() {
129127
</div>
130128
);
131129
}
132-

‎src/browser/utils/ui/workspaceFiltering.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,12 @@ describe("buildSortedWorkspacesByProject", () => {
310310
};
311311

312312
const result = buildSortedWorkspacesByProject(projects, metadata, recency);
313-
expect(result.get("/project/a")?.map((w) => w.id)).toEqual(["root", "child1", "grand", "child2"]);
313+
expect(result.get("/project/a")?.map((w) => w.id)).toEqual([
314+
"root",
315+
"child1",
316+
"grand",
317+
"child2",
318+
]);
314319
});
315320

316321
it("should not duplicate workspaces that exist in both config and have creating status", () => {

‎src/browser/utils/ui/workspaceFiltering.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ export function computeWorkspaceDepthMap(
8585
visiting.add(workspaceId);
8686
const workspace = byId.get(workspaceId);
8787
const parentId = workspace?.parentWorkspaceId;
88-
const depth =
89-
parentId && byId.has(parentId) ? Math.min(computeDepth(parentId) + 1, 32) : 0;
88+
const depth = parentId && byId.has(parentId) ? Math.min(computeDepth(parentId) + 1, 32) : 0;
9089
visiting.delete(workspaceId);
9190

9291
depths.set(workspaceId, depth);

‎src/common/orpc/schemas/project.ts‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ export const WorkspaceConfigSchema = z.object({
4545
description: "ISO 8601 timestamp for when an agent task reported completion (optional).",
4646
}),
4747
taskModelString: z.string().optional().meta({
48-
description:
49-
"Model string used to run this agent task (used for restart-safe resumptions).",
48+
description: "Model string used to run this agent task (used for restart-safe resumptions).",
5049
}),
5150
taskThinkingLevel: ThinkingLevelSchema.optional().meta({
52-
description:
53-
"Thinking level used for this agent task (used for restart-safe resumptions).",
51+
description: "Thinking level used for this agent task (used for restart-safe resumptions).",
5452
}),
5553
mcp: WorkspaceMCPOverridesSchema.optional().meta({
5654
description: "Per-workspace MCP overrides (disabled servers, tool allowlists)",

‎src/common/types/tasks.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function clampInt(value: unknown, fallback: number, min: number, max: number): n
2727
}
2828

2929
export function normalizeTaskSettings(raw: unknown): TaskSettings {
30-
const record =
31-
raw && typeof raw === "object" ? (raw as Record<string, unknown>) : ({} as const);
30+
const record = raw && typeof raw === "object" ? (raw as Record<string, unknown>) : ({} as const);
3231

3332
const maxParallelAgentTasks = clampInt(
3433
record.maxParallelAgentTasks,
@@ -59,4 +58,3 @@ export function normalizeTaskSettings(raw: unknown): TaskSettings {
5958

6059
return result;
6160
}
62-

‎src/node/services/agentPresets.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,3 @@ export function getAgentPreset(agentType: string | undefined): AgentPreset | nul
8080
const normalized = (agentType ?? "").trim().toLowerCase();
8181
return PRESETS_BY_AGENT_TYPE[normalized] ?? null;
8282
}
83-

‎src/node/services/taskService.test.ts‎

Lines changed: 77 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function initGitRepo(projectPath: string): void {
2020
execSync("git init -b main", { cwd: projectPath, stdio: "ignore" });
2121
execSync('git config user.email "test@example.com"', { cwd: projectPath, stdio: "ignore" });
2222
execSync('git config user.name "test"', { cwd: projectPath, stdio: "ignore" });
23-
execSync('bash -lc \'echo \"hello\" > README.md\'', { cwd: projectPath, stdio: "ignore" });
23+
execSync("bash -lc 'echo \"hello\" > README.md'", { cwd: projectPath, stdio: "ignore" });
2424
execSync("git add README.md", { cwd: projectPath, stdio: "ignore" });
2525
execSync('git commit -m "init"', { cwd: projectPath, stdio: "ignore" });
2626
}
@@ -45,17 +45,15 @@ describe("TaskService", () => {
4545
await fsPromises.rm(rootDir, { recursive: true, force: true });
4646
});
4747

48-
test(
49-
"enforces maxTaskNestingDepth",
50-
async () => {
48+
test("enforces maxTaskNestingDepth", async () => {
5149
const config = new Config(rootDir);
5250
await fsPromises.mkdir(config.srcDir, { recursive: true });
5351

5452
// Deterministic IDs for workspace names.
5553
const ids = ["aaaaaaaaaa", "bbbbbbbbbb", "cccccccccc"];
5654
let nextIdIndex = 0;
57-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
58-
(config as any).generateStableId = () => ids[nextIdIndex++] ?? "dddddddddd";
55+
const configWithStableId = config as unknown as { generateStableId: () => string };
56+
configWithStableId.generateStableId = () => ids[nextIdIndex++] ?? "dddddddddd";
5957

6058
const projectPath = path.join(rootDir, "repo");
6159
await fsPromises.mkdir(projectPath, { recursive: true });
@@ -104,30 +102,27 @@ describe("TaskService", () => {
104102

105103
const aiService: AIService = {
106104
isStreaming: mock(() => false),
107-
getWorkspaceMetadata: mock(async (workspaceId: string): Promise<Result<WorkspaceMetadata>> => {
108-
const all = await config.getAllWorkspaceMetadata();
109-
const found = all.find((m) => m.id === workspaceId);
110-
return found ? Ok(found) : Err("not found");
111-
}),
112-
// eslint-disable-next-line @typescript-eslint/no-empty-function
113-
on: mock(() => {}),
114-
// eslint-disable-next-line @typescript-eslint/no-empty-function
115-
off: mock(() => {}),
105+
getWorkspaceMetadata: mock(
106+
async (workspaceId: string): Promise<Result<WorkspaceMetadata>> => {
107+
const all = await config.getAllWorkspaceMetadata();
108+
const found = all.find((m) => m.id === workspaceId);
109+
return found ? Ok(found) : Err("not found");
110+
}
111+
),
112+
on: mock(() => undefined),
113+
off: mock(() => undefined),
116114
} as unknown as AIService;
117115

118116
const workspaceService: WorkspaceService = {
119117
sendMessage: mock(() => Promise.resolve(Ok(undefined))),
120118
resumeStream: mock(() => Promise.resolve(Ok(undefined))),
121119
remove: mock(() => Promise.resolve(Ok(undefined))),
122-
// eslint-disable-next-line @typescript-eslint/no-empty-function
123120
emit: mock(() => true),
124121
} as unknown as WorkspaceService;
125122

126123
const initStateManager: InitStateManager = {
127-
// eslint-disable-next-line @typescript-eslint/no-empty-function
128-
startInit: mock(() => {}),
129-
// eslint-disable-next-line @typescript-eslint/no-empty-function
130-
appendOutput: mock(() => {}),
124+
startInit: mock(() => undefined),
125+
appendOutput: mock(() => undefined),
131126
endInit: mock(() => Promise.resolve()),
132127
} as unknown as InitStateManager;
133128

@@ -159,20 +154,16 @@ describe("TaskService", () => {
159154
if (!second.success) {
160155
expect(second.error).toContain("maxTaskNestingDepth");
161156
}
162-
},
163-
20_000
164-
);
157+
}, 20_000);
165158

166-
test(
167-
"queues tasks when maxParallelAgentTasks is reached and starts them when a slot frees",
168-
async () => {
159+
test("queues tasks when maxParallelAgentTasks is reached and starts them when a slot frees", async () => {
169160
const config = new Config(rootDir);
170161
await fsPromises.mkdir(config.srcDir, { recursive: true });
171162

172163
const ids = ["aaaaaaaaaa", "bbbbbbbbbb", "cccccccccc", "dddddddddd"];
173164
let nextIdIndex = 0;
174-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
175-
(config as any).generateStableId = () => ids[nextIdIndex++] ?? "eeeeeeeeee";
165+
const configWithStableId = config as unknown as { generateStableId: () => string };
166+
configWithStableId.generateStableId = () => ids[nextIdIndex++] ?? "eeeeeeeeee";
176167

177168
const projectPath = path.join(rootDir, "repo");
178169
await fsPromises.mkdir(projectPath, { recursive: true });
@@ -234,15 +225,15 @@ describe("TaskService", () => {
234225

235226
const aiService: AIService = {
236227
isStreaming: mock(() => false),
237-
getWorkspaceMetadata: mock(async (workspaceId: string): Promise<Result<WorkspaceMetadata>> => {
238-
const all = await config.getAllWorkspaceMetadata();
239-
const found = all.find((m) => m.id === workspaceId);
240-
return found ? Ok(found) : Err("not found");
241-
}),
242-
// eslint-disable-next-line @typescript-eslint/no-empty-function
243-
on: mock(() => {}),
244-
// eslint-disable-next-line @typescript-eslint/no-empty-function
245-
off: mock(() => {}),
228+
getWorkspaceMetadata: mock(
229+
async (workspaceId: string): Promise<Result<WorkspaceMetadata>> => {
230+
const all = await config.getAllWorkspaceMetadata();
231+
const found = all.find((m) => m.id === workspaceId);
232+
return found ? Ok(found) : Err("not found");
233+
}
234+
),
235+
on: mock(() => undefined),
236+
off: mock(() => undefined),
246237
} as unknown as AIService;
247238

248239
const resumeStream = mock(() => Promise.resolve(Ok(undefined)));
@@ -251,15 +242,12 @@ describe("TaskService", () => {
251242
sendMessage: mock(() => Promise.resolve(Ok(undefined))),
252243
resumeStream,
253244
remove: mock(() => Promise.resolve(Ok(undefined))),
254-
// eslint-disable-next-line @typescript-eslint/no-empty-function
255245
emit: mock(() => true),
256246
} as unknown as WorkspaceService;
257247

258248
const initStateManager: InitStateManager = {
259-
// eslint-disable-next-line @typescript-eslint/no-empty-function
260-
startInit: mock(() => {}),
261-
// eslint-disable-next-line @typescript-eslint/no-empty-function
262-
appendOutput: mock(() => {}),
249+
startInit: mock(() => undefined),
250+
appendOutput: mock(() => undefined),
263251
endInit: mock(() => Promise.resolve()),
264252
} as unknown as InitStateManager;
265253

@@ -311,9 +299,7 @@ describe("TaskService", () => {
311299
.flatMap((p) => p.workspaces)
312300
.find((w) => w.id === queued.data.taskId);
313301
expect(started?.taskStatus).toBe("running");
314-
},
315-
20_000
316-
);
302+
}, 20_000);
317303

318304
test("agent_report posts report to parent, finalizes pending task tool output, and triggers cleanup", async () => {
319305
const config = new Config(rootDir);
@@ -386,10 +372,8 @@ describe("TaskService", () => {
386372

387373
const aiService: AIService = {
388374
isStreaming: mock(() => false),
389-
// eslint-disable-next-line @typescript-eslint/no-empty-function
390-
on: mock(() => {}),
391-
// eslint-disable-next-line @typescript-eslint/no-empty-function
392-
off: mock(() => {}),
375+
on: mock(() => undefined),
376+
off: mock(() => undefined),
393377
} as unknown as AIService;
394378

395379
const sendMessage = mock(() => Promise.resolve(Ok(undefined)));
@@ -405,10 +389,8 @@ describe("TaskService", () => {
405389
} as unknown as WorkspaceService;
406390

407391
const initStateManager: InitStateManager = {
408-
// eslint-disable-next-line @typescript-eslint/no-empty-function
409-
startInit: mock(() => {}),
410-
// eslint-disable-next-line @typescript-eslint/no-empty-function
411-
appendOutput: mock(() => {}),
392+
startInit: mock(() => undefined),
393+
appendOutput: mock(() => undefined),
412394
endInit: mock(() => Promise.resolve()),
413395
} as unknown as InitStateManager;
414396

@@ -422,17 +404,33 @@ describe("TaskService", () => {
422404
);
423405

424406
const internal = taskService as unknown as {
425-
handleAgentReport: (event: { type: "tool-call-end"; workspaceId: string; toolName: string }) => Promise<void>;
407+
handleAgentReport: (event: {
408+
type: "tool-call-end";
409+
workspaceId: string;
410+
toolName: string;
411+
}) => Promise<void>;
426412
};
427-
await internal.handleAgentReport({ type: "tool-call-end", workspaceId: childId, toolName: "agent_report" });
413+
await internal.handleAgentReport({
414+
type: "tool-call-end",
415+
workspaceId: childId,
416+
toolName: "agent_report",
417+
});
428418

429419
const parentHistory = await historyService.getHistory(parentId);
430420
expect(parentHistory.success).toBe(true);
431421
if (parentHistory.success) {
432422
const combined = parentHistory.data
433423
.filter((m) => m.role === "assistant")
434424
.flatMap((m) => m.parts)
435-
.map((p) => (p && typeof p === "object" && "type" in p && (p as { type?: unknown }).type === "text" && "text" in p ? (p as { text?: unknown }).text : ""))
425+
.map((p) =>
426+
p &&
427+
typeof p === "object" &&
428+
"type" in p &&
429+
(p as { type?: unknown }).type === "text" &&
430+
"text" in p
431+
? (p as { text?: unknown }).text
432+
: ""
433+
)
436434
.join("");
437435
expect(combined).toContain("Hello from child");
438436
}
@@ -441,7 +439,11 @@ describe("TaskService", () => {
441439
expect(updatedParentPartial).not.toBeNull();
442440
if (updatedParentPartial) {
443441
const toolPart = updatedParentPartial.parts.find(
444-
(p) => p && typeof p === "object" && "type" in p && (p as { type?: unknown }).type === "dynamic-tool"
442+
(p) =>
443+
p &&
444+
typeof p === "object" &&
445+
"type" in p &&
446+
(p as { type?: unknown }).type === "dynamic-tool"
445447
) as unknown as
446448
| {
447449
toolName: string;
@@ -529,10 +531,8 @@ describe("TaskService", () => {
529531

530532
const aiService: AIService = {
531533
isStreaming: mock(() => false),
532-
// eslint-disable-next-line @typescript-eslint/no-empty-function
533-
on: mock(() => {}),
534-
// eslint-disable-next-line @typescript-eslint/no-empty-function
535-
off: mock(() => {}),
534+
on: mock(() => undefined),
535+
off: mock(() => undefined),
536536
} as unknown as AIService;
537537

538538
const sendMessage = mock(() => Promise.resolve(Ok(undefined)));
@@ -548,10 +548,8 @@ describe("TaskService", () => {
548548
} as unknown as WorkspaceService;
549549

550550
const initStateManager: InitStateManager = {
551-
// eslint-disable-next-line @typescript-eslint/no-empty-function
552-
startInit: mock(() => {}),
553-
// eslint-disable-next-line @typescript-eslint/no-empty-function
554-
appendOutput: mock(() => {}),
551+
startInit: mock(() => undefined),
552+
appendOutput: mock(() => undefined),
555553
endInit: mock(() => Promise.resolve()),
556554
} as unknown as InitStateManager;
557555

@@ -585,7 +583,15 @@ describe("TaskService", () => {
585583
const combined = parentHistory.data
586584
.filter((m) => m.role === "assistant")
587585
.flatMap((m) => m.parts)
588-
.map((p) => (p && typeof p === "object" && "type" in p && (p as { type?: unknown }).type === "text" && "text" in p ? (p as { text?: unknown }).text : ""))
586+
.map((p) =>
587+
p &&
588+
typeof p === "object" &&
589+
"type" in p &&
590+
(p as { type?: unknown }).type === "text" &&
591+
"text" in p
592+
? (p as { text?: unknown }).text
593+
: ""
594+
)
589595
.join("");
590596
expect(combined).toContain("Final output without agent_report");
591597
expect(combined).toContain("fallback");
@@ -595,7 +601,11 @@ describe("TaskService", () => {
595601
expect(updatedParentPartial).not.toBeNull();
596602
if (updatedParentPartial) {
597603
const toolPart = updatedParentPartial.parts.find(
598-
(p) => p && typeof p === "object" && "type" in p && (p as { type?: unknown }).type === "dynamic-tool"
604+
(p) =>
605+
p &&
606+
typeof p === "object" &&
607+
"type" in p &&
608+
(p as { type?: unknown }).type === "dynamic-tool"
599609
) as unknown as
600610
| {
601611
toolName: string;

0 commit comments

Comments
 (0)