Strip the unused .input(z.object({ lastEventId })) from all 6 subscription
procedures — the parameter was never consumed by eventBusIterable. Remove the
now-unused zod import. Add at-most-once delivery JSDoc to the EventBus interface
to make the real guarantee explicit. Add compliance comment above
onConversationUpdate noting what to wire when a conversation view is built.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
/**
|
|
* Subscription Router — SSE event streams
|
|
*/
|
|
|
|
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
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, ALL_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onAgentUpdate: publicProcedure
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, AGENT_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onTaskUpdate: publicProcedure
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, TASK_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onPageUpdate: publicProcedure
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, PAGE_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
onPreviewUpdate: publicProcedure
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, PREVIEW_EVENT_TYPES, signal);
|
|
}),
|
|
|
|
// NOTE: No frontend view currently displays inter-agent conversation data.
|
|
// When a conversation view is added, add to its useLiveUpdates call:
|
|
// { prefix: 'conversation:', invalidate: ['<query-key>'] }
|
|
// and add the relevant mutation(s) to INVALIDATION_MAP in apps/web/src/lib/invalidation.ts.
|
|
onConversationUpdate: publicProcedure
|
|
.subscription(async function* (opts) {
|
|
const signal = opts.signal ?? new AbortController().signal;
|
|
yield* eventBusIterable(opts.ctx.eventBus, CONVERSATION_EVENT_TYPES, signal);
|
|
}),
|
|
};
|
|
}
|