| 207 | } |
| 208 | |
| 209 | function parseRaisedReason(text: string): string | undefined { |
| 210 | const prefix = [ANDON_RAISED_PREFIX, SLACK_ANDON_RAISED_PREFIX].find( |
| 211 | candidate => text.startsWith(candidate) |
| 212 | ); |
| 213 | if (!prefix) { |
| 214 | return undefined; |
| 215 | } |
| 216 | const reasonStart = text.indexOf(": ", prefix.length); |
| 217 | if (reasonStart === -1) return undefined; |
| 218 | // Reason lives on the first line of the message. The CLI appends an |
| 219 | // observability footer (`<https://...|view>`) on its own line; keep it out |
| 220 | // of the parsed reason so it never bleeds into state.json. |
| 221 | return ( |
| 222 | text |
| 223 | .slice(reasonStart + 2) |
| 224 | .split("\n")[0] |
| 225 | ?.trim() || undefined |
| 226 | ); |
| 227 | } |
| 228 | |
| 229 | function compareSlackTsDesc(a: string, b: string): number { |
| 230 | return Number(b) - Number(a); |