- Tasks keyed by {taskType}-{repo}-{issue} for deduplication
- Duplicate requests (pending or running) are dropped
- Configurable concurrency via QUEUE_CONCURRENCY env (default 2)
- Workspace names now {taskType}-{repo}-{issue} for observability
- GET /queue endpoint shows pending/running tasks
- All handlers route through the queue instead of calling Coder directly
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
6062d1b518
commit
f23fb4e2e0
@@ -1,7 +1,6 @@
|
||||
import type { Context } from "hono";
|
||||
import type { IssueEvent, TaskRequest } from "../types.js";
|
||||
import type { CoderClient } from "../services/coder.js";
|
||||
import type { GiteaClient } from "../services/gitea.js";
|
||||
import type { TaskQueue } from "../queue.js";
|
||||
import type { Config } from "../config.js";
|
||||
|
||||
/**
|
||||
@@ -9,7 +8,7 @@ import type { Config } from "../config.js";
|
||||
*
|
||||
* Replaces: gitea-issue-triage.json
|
||||
*/
|
||||
export function issueTriage(config: Config, coder: CoderClient, gitea: GiteaClient) {
|
||||
export function issueTriage(config: Config, queue: TaskQueue) {
|
||||
return async (c: Context) => {
|
||||
const event = await c.req.json<IssueEvent>();
|
||||
|
||||
@@ -32,18 +31,11 @@ export function issueTriage(config: Config, coder: CoderClient, gitea: GiteaClie
|
||||
giteaToken: config.giteaDevToken,
|
||||
};
|
||||
|
||||
console.log(`[issue-triage] #${task.issueNumber} → ${taskType}`);
|
||||
const queued = queue.enqueue(task, {
|
||||
useReviewAccount: false,
|
||||
body: `🤖 Issue received. Starting **${taskType}** stage.`,
|
||||
});
|
||||
|
||||
const workspace = await coder.createWorkspace(task);
|
||||
console.log(`[issue-triage] workspace created: ${workspace.name}`);
|
||||
|
||||
await gitea.commentOnIssue(
|
||||
org,
|
||||
repo,
|
||||
event.issue.number,
|
||||
`🤖 Issue received. Starting **${taskType}** stage.`,
|
||||
);
|
||||
|
||||
return c.json({ ok: true, workspace: workspace.name });
|
||||
return c.json({ ok: true, queued });
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user