* Reject all pending suggestions for a PR.
(prUrl: string)
| 240 | * Reject all pending suggestions for a PR. |
| 241 | */ |
| 242 | async function rejectChecks(prUrl: string): Promise<void> { |
| 243 | const response = await get<ChecksStatusResponse>( |
| 244 | `api/checks/status?pullRequestUrl=${encodeURIComponent(prUrl)}`, |
| 245 | ); |
| 246 | const { checks } = response.data; |
| 247 | |
| 248 | const pending = checks.filter( |
| 249 | (c) => c.suggestionStatus === "pending" && c.commitMessage, |
| 250 | ); |
| 251 | |
| 252 | if (pending.length === 0) { |
| 253 | console.log(chalk.dim("No pending suggestions to reject.")); |
| 254 | return; |
| 255 | } |
| 256 | |
| 257 | console.log( |
| 258 | chalk.bold(`Rejecting ${pending.length} pending suggestion(s)...\n`), |
| 259 | ); |
| 260 | |
| 261 | for (const check of pending) { |
| 262 | try { |
| 263 | await post(`agents/${check.sessionId}/reject`); |
| 264 | console.log(chalk.red(`\u2716 Rejected: ${check.name}`)); |
| 265 | } catch (err) { |
| 266 | const msg = err instanceof Error ? err.message : String(err); |
| 267 | console.error( |
| 268 | chalk.red(`\u2716 Failed to reject ${check.name}: ${msg}`), |
| 269 | ); |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Main entry point for `cn checks` command. |