summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorEric Guo <[email protected]>2026-01-06 19:22:47 +0800
committerGitHub <[email protected]>2026-01-06 05:22:47 -0600
commit4ecb305820b21c753b77b3d05e6baa2aa19d0bb9 (patch)
treef228c965a421f2041b12c44342d4dfe9d9656a81
parente5a868157e7ea89a632a43d6c15fd20128c71144 (diff)
downloadopencode-4ecb305820b21c753b77b3d05e6baa2aa19d0bb9.tar.gz
opencode-4ecb305820b21c753b77b3d05e6baa2aa19d0bb9.zip
Fix(app): @pierre/diffs will crash when a diff has undefined text (#7059)
-rw-r--r--packages/ui/src/components/diff.tsx8
1 files changed, 6 insertions, 2 deletions
diff --git a/packages/ui/src/components/diff.tsx b/packages/ui/src/components/diff.tsx
index bdbf1511e..7620f2bb5 100644
--- a/packages/ui/src/components/diff.tsx
+++ b/packages/ui/src/components/diff.tsx
@@ -19,6 +19,8 @@ export function Diff<T>(props: DiffProps<T>) {
const opts = options()
const workerPool = getWorkerPool(props.diffStyle)
const annotations = local.annotations
+ const beforeContents = typeof local.before?.contents === "string" ? local.before.contents : ""
+ const afterContents = typeof local.after?.contents === "string" ? local.after.contents : ""
instance?.cleanUp()
instance = new FileDiff<T>(opts, workerPool)
@@ -27,11 +29,13 @@ export function Diff<T>(props: DiffProps<T>) {
instance.render({
oldFile: {
...local.before,
- cacheKey: checksum(local.before.contents),
+ contents: beforeContents,
+ cacheKey: checksum(beforeContents),
},
newFile: {
...local.after,
- cacheKey: checksum(local.after.contents),
+ contents: afterContents,
+ cacheKey: checksum(afterContents),
},
lineAnnotations: annotations,
containerWrapper: container,