Files
PaperClipAI/server/src/services/queued-comment-steering.ts
T
Dotta 02ee538be9 feat(github): steer active reviews when new messages arrive (#22066)
Send compatible GitHub review updates to active native turns after normal admission. Preserve durable receipt fallback and recover acknowledgements without consuming unsent edits.

Keep legacy conversation batching and existing identity, source-trust, and attachment boundaries. Add PostgreSQL regressions for concurrency, restart recovery, and edited inputs.
2026-11-17 15:47:13 -06:00

25 lines
1.1 KiB
TypeScript

import type { Db } from "@paperclipai/db";
import { reconcileSteeredIdentity, storedSteeringAcknowledgement, type RunIdentityContext } from "./run-identity.js";
import { NativeSessionSteeringError, steerNativeSession } from "./native-runtime/native-session-executor.js";
export function steeringDeliveryIsUncertain(error: unknown, attempted: boolean): boolean {
return attempted && (!(error instanceof NativeSessionSteeringError) || error.code === "steering_timeout");
}
export async function deliverSteeredMessage(db: Db, input: {
executor?: Pick<Db, "select">;
companyId: string;
runId: string;
messageId: string;
message: string;
identity: RunIdentityContext | null;
onAcknowledged?: () => Promise<void>;
}) {
return await storedSteeringAcknowledgement(input.executor ?? db, input.identity ?? {
companyId: input.companyId, runId: input.runId, messageId: input.messageId,
}) ?? await steerNativeSession({
runId: input.runId, correlationId: input.messageId, message: input.message,
onAcknowledged: input.onAcknowledged ?? (input.identity ? () => reconcileSteeredIdentity(db, input.identity!) : undefined),
});
}