Skip to content

Commit d58afb0

Browse files
committed
PR feedback
1 parent be7f2bf commit d58afb0

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

packages/ipc/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ Resumes a task from history.
4141

4242
- `data`: Task ID to resume (string)
4343

44+
**Error Handling:**
45+
46+
- If the task ID is not found in history, the command will fail gracefully without crashing the IPC server
47+
- Errors are logged for debugging purposes but do not propagate to the client
48+
4449
## Usage Example
4550

4651
```typescript

packages/types/src/__tests__/ipc.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ describe("IPC Types", () => {
1515
expect(actualCommands).toContain(command)
1616
})
1717
})
18+
19+
describe("Error Handling", () => {
20+
it("should handle ResumeTask command gracefully when task not found", () => {
21+
// This test verifies the schema validation - the actual error handling
22+
// for invalid task IDs is tested at the API level, not the schema level
23+
const resumeTaskCommand = {
24+
commandName: TaskCommandName.ResumeTask,
25+
data: "non-existent-task-id",
26+
}
27+
28+
const result = taskCommandSchema.safeParse(resumeTaskCommand)
29+
expect(result.success).toBe(true)
30+
31+
if (result.success) {
32+
expect(result.data.commandName).toBe("ResumeTask")
33+
expect(result.data.data).toBe("non-existent-task-id")
34+
}
35+
})
36+
})
1837
})
1938

2039
describe("taskCommandSchema", () => {

src/extension/api.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@ export class API extends EventEmitter<RooCodeEvents> implements RooCodeAPI {
8080
break
8181
case TaskCommandName.ResumeTask:
8282
this.log(`[API] ResumeTask -> ${data}`)
83-
await this.resumeTask(data)
83+
try {
84+
await this.resumeTask(data)
85+
} catch (error) {
86+
const errorMessage = error instanceof Error ? error.message : String(error)
87+
this.log(`[API] ResumeTask failed for taskId ${data}: ${errorMessage}`)
88+
// Don't rethrow - we want to prevent IPC server crashes
89+
// The error is logged for debugging purposes
90+
}
8491
break
8592
}
8693
})

0 commit comments

Comments
 (0)