ReviewOS

also looking at this

stacks/buddy

feat(touch): post the checkboxes the finishing-touch flow waits on

#1424
Merged glennmichael123 wants to merge fix/touch-offer into main
7 files +149 -5
src/agent/tasks.tsmodified+36-1
Changes to src/agent/tasks.ts
@@ -144,6 +144,9 @@ export function getFinishingTouch(name: string): FinishingTouch {
144144 return touch
145145}
146146
147/** Opens the offer block, so it can be found and replaced rather than repeated. */
148export const TOUCH_OFFER_MARKER = '<!-- buddy:touches -->'
149
147150/**
148151 * Render the offer of available touches as checkbox markers.
149152 *
@@ -161,7 +164,39 @@ export function renderTouchOffer(names: string[] = Object.keys(FINISHING_TOUCHES
161164 if (lines.length === 0)
162165 return ''
163166
164 return `<details><summary>Finishing touches</summary>\n\nTick one to have it run:\n\n${lines.join('\n')}\n\n</details>`
167 return `${TOUCH_OFFER_MARKER}\n<details><summary>Finishing touches</summary>\n\nTick one to have it run:\n\n${lines.join('\n')}\n\n</details>`
168}
169
170/**
171 * Whether a pull request body already carries the offer.
172 *
173 * Checked before appending, because the job that posts it runs on more than
174 * one event and a body that accumulated the block twice would show a second
175 * set of boxes that tick independently of the first.
176 *
177 * @param body - Pull request body
178 */
179export function hasTouchOffer(body: string | null | undefined): boolean {
180 return Boolean(body?.includes(TOUCH_OFFER_MARKER))
181}
182
183/**
184 * Append the offer to a pull request body, once.
185 *
186 * @param body - Current body
187 * @param names - Touches to offer
188 * @returns The body with the offer, or unchanged when it already has one
189 */
190export function withTouchOffer(body: string | null | undefined, names?: string[]): string {
191 const current = body ?? ''
192 if (hasTouchOffer(current))
193 return current
194
195 const offer = renderTouchOffer(names)
196 if (!offer)
197 return current
198
199 return `${current.trimEnd()}\n\n${offer}\n`
165200}
166201
167202/** Parse which touches a maintainer ticked. */