When all phases complete, the initiative now transitions to pending_review status instead of silently stopping. The user reviews the full initiative diff and chooses: - Push Branch: push cw/<name> to remote for PR workflows - Merge & Push: merge into default branch and push Changes: - Schema: Add pending_review to initiative status enum - BranchManager: Add pushBranch port + SimpleGit adapter - Events: initiative:pending_review, initiative:review_approved - Orchestrator: checkInitiativeCompletion + approveInitiative - tRPC: getInitiativeReviewDiff, getInitiativeReviewCommits, getInitiativeCommitDiff, approveInitiativeReview - Frontend: InitiativeReview component in ReviewTab - Subscriptions: Add initiative events + missing preview/conversation event types and subscription procedures
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
/**
|
|
* Subscription Router — SSE event streams
|
|
*/
|
|
|
|
import { z } from 'zod';
|
|
import type { ProcedureBuilder } from '../trpc.js';
|
|
import {
|
|
eventBusIterable,
|
|
ALL_EVENT_TYPES,
|
|
AGENT_EVENT_TYPES,
|
|
TASK_EVENT_TYPES,
|
|
PAGE_EVENT_TYPES,
|
|
PREVIEW_EVENT_TYPES,
|
|
CONVERSATION_EVENT_TYPES,
|
|
} from '../subscriptions.js';
|
|
|
|
export function subscriptionProcedures(publicProcedure: ProcedureBuilder) {
|
|
return {
|
|
onEvent: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, ALL_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onAgentUpdate: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, AGENT_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onTaskUpdate: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, TASK_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onPageUpdate: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, PAGE_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onPreviewUpdate: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, PREVIEW_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onConversationUpdate: publicProcedure
|
|
.input(z.object({ lastEventId: z.string().nullish() }).optional())
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, CONVERSATION_EVENT_TYPES, signal);
|
|
}),
|
|
};
|
|
}
|