| author | |
| committer | |
| log | c2aff911c37f94558ab273ca3d44bb4854d01714 |
| tree | c80a21ecdcb007096a4b04bb043ef20f9a0e39ea |
| parent | 56a2f42b8ce27f5deefaa85a02ae9c1d3b61f309 |
| signature | Signed by PGP key B5690EEEBB952194 |
3 files changed, 10 insertions(+), 13 deletions(-)
apps/mobile/src/features/review/reviewDiffBridgeKeys.test.ts+8-11| ... | @@ -1,9 +1,9 @@ | ... | @@ -1,9 +1,9 @@ |
| 1 | import { describe, expect, it } from "vite-plus/test"; | 1 | import { describe, expect, it } from "vite-plus/test"; |
| 2 | 2 | ||
| 3 | import { buildNativeReviewTokensResetKey, hashReviewDiffKey } from "./reviewDiffBridgeKeys"; | 3 | import { buildNativeReviewTokensResetKey } from "./reviewDiffBridgeKeys"; |
| 4 | 4 | ||
| 5 | describe("native review diff bridge", () => { | 5 | describe("native review diff bridge", () => { |
| 6 | it("builds stable reset keys from the rendered diff identity", () => { | 6 | it("changes reset keys when the rendered diff identity changes", () => { |
| 7 | const input = { | 7 | const input = { |
| 8 | threadKey: "env:thread", | 8 | threadKey: "env:thread", |
| 9 | sectionId: "turn:2", | 9 | sectionId: "turn:2", |
| ... | @@ -13,15 +13,12 @@ describe("native review diff bridge", () => { | ... | @@ -13,15 +13,12 @@ describe("native review diff bridge", () => { |
| 13 | rowCount: 4, | 13 | rowCount: 4, |
| 14 | }; | 14 | }; |
| 15 | 15 | ||
| 16 | expect(buildNativeReviewTokensResetKey(input)).toBe(buildNativeReviewTokensResetKey(input)); | 16 | const resetKey = buildNativeReviewTokensResetKey(input); |
| 17 | expect(buildNativeReviewTokensResetKey({ ...input, rowCount: 5 })).not.toBe( | ||
| 18 | buildNativeReviewTokensResetKey(input), | ||
| 19 | ); | ||
| 20 | expect(buildNativeReviewTokensResetKey({ ...input, diff: null })).toContain(":empty:"); | ||
| 21 | }); | ||
| 22 | 17 | ||
| 23 | it("includes diff length in the hash key to reduce accidental collisions", () => { | 18 | expect( |
| 24 | expect(hashReviewDiffKey("abc")).toMatch(/^3:/); | 19 | buildNativeReviewTokensResetKey({ ...input, diff: "diff --git a/b.ts b/b.ts" }), |
| 25 | expect(hashReviewDiffKey("abcd")).toMatch(/^4:/); | 20 | ).not.toBe(resetKey); |
| 21 | expect(buildNativeReviewTokensResetKey({ ...input, rowCount: 5 })).not.toBe(resetKey); | ||
| 22 | expect(buildNativeReviewTokensResetKey({ ...input, diff: null })).not.toBe(resetKey); | ||
| 26 | }); | 23 | }); |
| 27 | }); | 24 | }); |
apps/mobile/src/features/review/reviewDiffBridgeKeys.ts+1-1| ... | @@ -3,7 +3,7 @@ import type { NativeReviewDiffHighlightScheme } from "../diffs/nativeReviewDiffH | ... | @@ -3,7 +3,7 @@ import type { NativeReviewDiffHighlightScheme } from "../diffs/nativeReviewDiffH |
| 3 | // Pure key-derivation helpers for the native review diff bridge. Kept free of | 3 | // Pure key-derivation helpers for the native review diff bridge. Kept free of |
| 4 | // react-native / hook imports so they stay unit-testable in node. | 4 | // react-native / hook imports so they stay unit-testable in node. |
| 5 | 5 | ||
| 6 | export function hashReviewDiffKey(diff: string | null | undefined): string { | 6 | function hashReviewDiffKey(diff: string | null | undefined): string { |
| 7 | if (!diff) { | 7 | if (!diff) { |
| 8 | return "empty"; | 8 | return "empty"; |
| 9 | } | 9 | } |
apps/mobile/src/features/review/useNativeReviewDiffBridge.ts+1-1| ... | @@ -8,7 +8,7 @@ import { useNativeReviewDiffHighlighting } from "./useNativeReviewDiffHighlighti | ... | @@ -8,7 +8,7 @@ import { useNativeReviewDiffHighlighting } from "./useNativeReviewDiffHighlighti |
| 8 | import { buildNativeReviewTokensResetKey } from "./reviewDiffBridgeKeys"; | 8 | import { buildNativeReviewTokensResetKey } from "./reviewDiffBridgeKeys"; |
| 9 | import { useUniwindTheme } from "../../lib/useUniwindTheme"; | 9 | import { useUniwindTheme } from "../../lib/useUniwindTheme"; |
| 10 | 10 | ||
| 11 | export { buildNativeReviewTokensResetKey, hashReviewDiffKey } from "./reviewDiffBridgeKeys"; | 11 | export { buildNativeReviewTokensResetKey } from "./reviewDiffBridgeKeys"; |
| 12 | 12 | ||
| 13 | export function useNativeReviewDiffBridge(input: { | 13 | export function useNativeReviewDiffBridge(input: { |
| 14 | readonly threadKey: string | null; | 14 | readonly threadKey: string | null; |