feat(KB-039): complete Step 2 — frontend API client and hook for usage data

This commit is contained in:
gsxdsm
2026-03-29 21:46:09 -07:00
parent 81cf41ba50
commit 63f530aac3
9 changed files with 890 additions and 150 deletions

View File

@@ -2871,7 +2871,7 @@ describe("TaskExecutor usage limit detection", () => {
);
expect(store.updateSettings).toHaveBeenCalledWith({ globalPause: true });
// Task should still be marked as failed
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed" });
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed", error: "rate_limit_error: Rate limit exceeded" });
expect(onError).toHaveBeenCalled();
});
@@ -2903,7 +2903,7 @@ describe("TaskExecutor usage limit detection", () => {
expect(onUsageLimitHitSpy).not.toHaveBeenCalled();
// Task should still be marked as failed
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed" });
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed", error: "connection refused" });
});
it("works without usageLimitPauser (backward compatible)", async () => {
@@ -2928,7 +2928,7 @@ describe("TaskExecutor usage limit detection", () => {
});
// Should not crash — just mark as failed
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed" });
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed", error: "rate_limit_error: Rate limit exceeded" });
expect(onError).toHaveBeenCalled();
});
@@ -2972,7 +2972,7 @@ describe("TaskExecutor usage limit detection", () => {
"rate_limit_error: Rate limit exceeded",
);
// Task should be marked as failed
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed" });
expect(store.updateTask).toHaveBeenCalledWith("KB-001", { status: "failed", error: "rate_limit_error: Rate limit exceeded" });
// onError callback should fire
expect(onError).toHaveBeenCalled();
});

View File

@@ -526,7 +526,7 @@ export class TaskExecutor {
}
executorLog.error(`${task.id} execution failed:`, err.message);
await this.store.logEntry(task.id, `Execution failed: ${err.message}`);
await this.store.updateTask(task.id, { status: "failed" });
await this.store.updateTask(task.id, { status: "failed", error: err.message });
this.options.onError?.(task, err);
}
} finally {