The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { HighlightScheme } from "../../lib/highlights"; |
| 2 | |
| 3 | function hashReviewDiffKey(diff: string | null | undefined): string { |
| 4 | if (!diff) { |
| 5 | return "empty"; |
| 6 | } |
| 7 | |
| 8 | let hash = 5381; |
| 9 | for (let index = 0; index < diff.length; index += 1) { |
| 10 | hash = (hash * 33) ^ diff.charCodeAt(index); |
| 11 | } |
| 12 | |
| 13 | return `${diff.length}:${(hash >>> 0).toString(36)}`; |
| 14 | } |
| 15 | |
| 16 | export function buildNativeReviewTokensResetKey(input: { |
| 17 | readonly threadKey: string | null; |
| 18 | readonly sectionId: string | null; |
| 19 | readonly scheme: HighlightScheme; |
| 20 | readonly diff: string | null | undefined; |
| 21 | readonly fileCount: number; |
| 22 | readonly rowCount: number; |
| 23 | }): string { |
| 24 | return [ |
| 25 | input.threadKey ?? "none", |
| 26 | input.sectionId ?? "none", |
| 27 | input.scheme, |
| 28 | hashReviewDiffKey(input.diff), |
| 29 | input.fileCount, |
| 30 | input.rowCount, |
| 31 | ].join(":"); |
| 32 | } |