mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 00:03:20 +00:00
Fix stale binary image fallback for empty modified diffs and relay reads
- mobileDiffImageDataUri now distinguishes a true deletion (modified side absent) from a modify whose binary bytes arrived empty (relay/size-cap cases), returning null instead of the stale pre-change image - readWorkingDiffFile passes the file path to bufferToBlob so relay working-tree reads can detect previewable image extensions instead of always reporting empty binary content - add mobile-file-tab-doc.test.ts covering diff/image/binary/text resolution paths
This commit is contained in:
@@ -35,4 +35,16 @@ describe('readWorkingDiffFile', () => {
|
||||
isBinary: true
|
||||
})
|
||||
})
|
||||
|
||||
it('base64-encodes a previewable image by its extension', async () => {
|
||||
tmpDir = await mkdtemp(path.join(tmpdir(), 'relay-working-file-'))
|
||||
const filePath = path.join(tmpDir, 'icon.png')
|
||||
const pngBytes = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x01])
|
||||
await writeFile(filePath, pngBytes)
|
||||
|
||||
await expect(readWorkingDiffFile(filePath)).resolves.toEqual({
|
||||
content: pngBytes.toString('base64'),
|
||||
isBinary: true
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -16,7 +16,9 @@ export async function readWorkingDiffFile(
|
||||
return { content: '', isBinary: true }
|
||||
}
|
||||
const buffer = await readFile(absPath)
|
||||
return bufferToBlob(buffer)
|
||||
// Why: bufferToBlob needs the path's extension to know an image is
|
||||
// previewable; omitting it made every relay-side binary diff empty.
|
||||
return bufferToBlob(buffer, absPath)
|
||||
} catch {
|
||||
return { content: '', isBinary: false }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user