(text: string)
| 34 | * Find positions of "ultrathink" keyword in text (for UI highlighting/notification) |
| 35 | */ |
| 36 | export function findThinkingTriggerPositions(text: string): Array<{ |
| 37 | word: string |
| 38 | start: number |
| 39 | end: number |
| 40 | }> { |
| 41 | const positions: Array<{ word: string; start: number; end: number }> = [] |
| 42 | // Fresh /g literal each call — String.prototype.matchAll copies lastIndex |
| 43 | // from the source regex, so a shared instance would leak state from |
| 44 | // hasUltrathinkKeyword's .test() into this call on the next render. |
| 45 | const matches = text.matchAll(/\bultrathink\b/gi) |
| 46 | |
| 47 | for (const match of matches) { |
| 48 | if (match.index !== undefined) { |
| 49 | positions.push({ |
| 50 | word: match[0], |
| 51 | start: match.index, |
| 52 | end: match.index + match[0].length, |
| 53 | }) |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | return positions |
| 58 | } |
| 59 | |
| 60 | const RAINBOW_COLORS: Array<keyof Theme> = [ |
| 61 | 'rainbow_red', |
no outgoing calls
no test coverage detected