mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-25 09:41:04 +01:00
25 lines
692 B
TypeScript
25 lines
692 B
TypeScript
import { pollUntil } from "./api.js";
|
|
import type { Row } from "./first-task-scoring.js";
|
|
|
|
/** The composer clears optimistically, before its user comment is persisted. */
|
|
export async function waitForFirstTaskReply(input: {
|
|
load: () => Promise<Row[]>;
|
|
previousIds: ReadonlySet<string>;
|
|
message: string;
|
|
deadlineAt: number;
|
|
}) {
|
|
return pollUntil({
|
|
label: "first-task user reply persisted",
|
|
deadlineAt: input.deadlineAt,
|
|
intervalMs: 100,
|
|
load: input.load,
|
|
accept: (comments) =>
|
|
comments.some(
|
|
(comment) =>
|
|
!input.previousIds.has(comment.id) &&
|
|
!comment.authorAgentId &&
|
|
comment.body === input.message,
|
|
),
|
|
});
|
|
}
|