ReviewOS

also looking at this

stacks/buddy

fix(review): persist review state where it is read back

#1405
Merged glennmichael123 wants to merge fix/persist-review-state into main
6 files +176 -14
src/review/marker.tsmodified+22-0
Changes to src/review/marker.ts
@@ -63,6 +63,28 @@ export function parseReviewState(body: string | null | undefined): ReviewState |
6363 }
6464}
6565
66/**
67 * Replace the review-state marker in a pull request body.
68 *
69 * The marker has to live on the pull request itself: `parseReviewState` reads
70 * `pr.body` and nothing else, so state written anywhere else — a review
71 * summary, a comment — is written and never read back.
72 *
73 * @param body - Current pull request body
74 * @param state - State to store
75 * @returns The body with exactly one, current, marker
76 * @example
77 * ```ts
78 * await provider.updatePullRequest(number, {
79 * body: upsertReviewState(pr.body, { reviewedSha, fingerprints, reviewedAt }),
80 * })
81 * ```
82 */
83export function upsertReviewState(body: string | null | undefined, state: Omit<ReviewState, 'schemaVersion'>): string {
84 const withoutMarker = (body ?? '').replace(MARKER_REGEX, '').trimEnd()
85 return `${withoutMarker}\n\n${serializeReviewState(state)}`
86}
87
6688/**
6789 * Whether a pull request needs reviewing.
6890 *