PBI-55: update-job-status – NOTIFY payload-fix (kind/idea_id) + triggerPush on done/failed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4c476464ec
commit
ab32a72ce0
1 changed files with 30 additions and 19 deletions
|
|
@ -24,6 +24,7 @@ import { pushBranchForJob } from '../git/push.js'
|
||||||
import { createPullRequest, markPullRequestReady } from '../git/pr.js'
|
import { createPullRequest, markPullRequestReady } from '../git/pr.js'
|
||||||
import { cancelPbiOnFailure } from '../cancel/pbi-cascade.js'
|
import { cancelPbiOnFailure } from '../cancel/pbi-cascade.js'
|
||||||
import { propagateStatusUpwards } from '../lib/tasks-status-update.js'
|
import { propagateStatusUpwards } from '../lib/tasks-status-update.js'
|
||||||
|
import { triggerPush } from '../lib/push-trigger.js'
|
||||||
import { transition as prFlowTransition } from '../flow/pr-flow.js'
|
import { transition as prFlowTransition } from '../flow/pr-flow.js'
|
||||||
import { transition as sprintRunTransition } from '../flow/sprint-run.js'
|
import { transition as sprintRunTransition } from '../flow/sprint-run.js'
|
||||||
import { executeEffects } from '../flow/effects.js'
|
import { executeEffects } from '../flow/effects.js'
|
||||||
|
|
@ -887,30 +888,40 @@ export function registerUpdateJobStatusTool(server: McpServer) {
|
||||||
try {
|
try {
|
||||||
const pg = new Client({ connectionString: process.env.DATABASE_URL })
|
const pg = new Client({ connectionString: process.env.DATABASE_URL })
|
||||||
await pg.connect()
|
await pg.connect()
|
||||||
await pg.query(
|
const notifyPayload: Record<string, unknown> = {
|
||||||
`SELECT pg_notify('scrum4me_changes', $1)`,
|
type: 'claude_job_status',
|
||||||
[
|
job_id: updated.id,
|
||||||
JSON.stringify({
|
user_id: job.user_id,
|
||||||
type: 'claude_job_status',
|
product_id: job.product_id,
|
||||||
job_id: updated.id,
|
status: actualStatus,
|
||||||
task_id: job.task_id,
|
branch: updated.branch ?? undefined,
|
||||||
user_id: job.user_id,
|
pushed_at: updated.pushed_at?.toISOString() ?? undefined,
|
||||||
product_id: job.product_id,
|
pr_url: updated.pr_url ?? undefined,
|
||||||
status: actualStatus,
|
verify_result: updated.verify_result?.toLowerCase() ?? undefined,
|
||||||
branch: updated.branch ?? undefined,
|
summary: updated.summary ?? undefined,
|
||||||
pushed_at: updated.pushed_at?.toISOString() ?? undefined,
|
error: updated.error ?? undefined,
|
||||||
pr_url: updated.pr_url ?? undefined,
|
}
|
||||||
verify_result: updated.verify_result?.toLowerCase() ?? undefined,
|
if (job.task_id) notifyPayload.task_id = job.task_id
|
||||||
summary: updated.summary ?? undefined,
|
if (job.idea_id) {
|
||||||
error: updated.error ?? undefined,
|
notifyPayload.idea_id = job.idea_id
|
||||||
}),
|
notifyPayload.kind = job.kind
|
||||||
],
|
}
|
||||||
)
|
await pg.query(`SELECT pg_notify('scrum4me_changes', $1)`, [JSON.stringify(notifyPayload)])
|
||||||
await pg.end()
|
await pg.end()
|
||||||
} catch {
|
} catch {
|
||||||
// non-fatal — status is already persisted
|
// non-fatal — status is already persisted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (actualStatus === 'failed' || actualStatus === 'done') {
|
||||||
|
const isFailed = actualStatus === 'failed'
|
||||||
|
void triggerPush(job.user_id, {
|
||||||
|
title: isFailed ? 'Job gefaald' : 'Job klaar',
|
||||||
|
body: (updated.summary ?? updated.error ?? `Job ${updated.id}`).slice(0, 120),
|
||||||
|
url: updated.pr_url ?? '/dashboard',
|
||||||
|
tag: `job-${updated.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Best-effort worktree cleanup on terminal transitions (skip if push failed — worktree preserved)
|
// Best-effort worktree cleanup on terminal transitions (skip if push failed — worktree preserved)
|
||||||
if (
|
if (
|
||||||
(actualStatus === 'done' || actualStatus === 'failed' || actualStatus === 'skipped') &&
|
(actualStatus === 'done' || actualStatus === 'failed' || actualStatus === 'skipped') &&
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue