mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
* fix: render Kitty Unicode placeholder images with bounded ownership * Enable managed Claude plugin images and bounded host file transport * Preserve isolated Claude evidence and paired restart diagnostics * Resolve Windows workspace aliases before WSL image reads * Handle split remote terminal identities and improve WSL file-read diagnostics * Reuse native drive paths for WSL image files and preserve guest temporary roots * Apply native Windows path restrictions to mapped drive image sources * Preserve WSL participation evidence across image checks * Keep WSL drive directory containment case-sensitive after canonicalization * Negotiate managed Claude image support with the launching renderer * Make image repaint checks independent of display profile and shell output * Capture repaint diagnostics only after the pixel assertion fails * Allow floating terminal image reads from host temporary folders * Keep image stack independent of unrelated CI runner and mobile lint settings * Reuse worktree argument builder for terminal viewer context Remove duplicated mapping and keep the RPC method table within its existing line limit.
78 lines
2.4 KiB
TypeScript
78 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mkdtemp, open, rm, writeFile } from 'node:fs/promises'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { readNodeFileHandleWithinLimit } from './node-bounded-file-reader'
|
|
|
|
async function withFile(run: (path: string) => Promise<void>): Promise<void> {
|
|
const root = await mkdtemp(join(tmpdir(), 'orca-window-read-'))
|
|
const path = join(root, 'data')
|
|
await writeFile(path, 'prefix-IMAGE-trailer')
|
|
try {
|
|
await run(path)
|
|
} finally {
|
|
await rm(root, { recursive: true, force: true })
|
|
}
|
|
}
|
|
|
|
describe('bounded file read window', () => {
|
|
it('reads only the requested extent of a larger file', async () => {
|
|
await withFile(async (path) => {
|
|
const handle = await open(path, 'r')
|
|
try {
|
|
const result = await readNodeFileHandleWithinLimit(handle, 5, {
|
|
window: { offset: 7, length: 5 }
|
|
})
|
|
expect(result.buffer.toString()).toBe('IMAGE')
|
|
const tail = await readNodeFileHandleWithinLimit(handle, 8, { window: { offset: 12 } })
|
|
expect(tail.buffer.toString()).toBe('-trailer')
|
|
} finally {
|
|
await handle.close()
|
|
}
|
|
})
|
|
})
|
|
|
|
it.each([
|
|
{ offset: -1 },
|
|
{ offset: 1.5 },
|
|
{ offset: Number.MAX_SAFE_INTEGER + 1 },
|
|
{ offset: 0, length: -1 },
|
|
{ offset: 0, length: 1.5 },
|
|
{ offset: 0, length: 20 },
|
|
{ offset: 19, length: 2 },
|
|
{ offset: 21 }
|
|
])('rejects invalid or incomplete window %j', async (window) => {
|
|
await withFile(async (path) => {
|
|
const handle = await open(path, 'r')
|
|
try {
|
|
await expect(readNodeFileHandleWithinLimit(handle, 19, { window })).rejects.toThrow()
|
|
} finally {
|
|
await handle.close()
|
|
}
|
|
})
|
|
})
|
|
|
|
it('rejects bytes over the cap and honors cancellation before reading', async () => {
|
|
await withFile(async (path) => {
|
|
const handle = await open(path, 'r')
|
|
try {
|
|
await expect(
|
|
readNodeFileHandleWithinLimit(handle, 4, {
|
|
window: { offset: 7, length: 5 }
|
|
})
|
|
).rejects.toThrow('File too large')
|
|
const controller = new AbortController()
|
|
controller.abort(new Error('cancelled file'))
|
|
await expect(
|
|
readNodeFileHandleWithinLimit(handle, 19, {
|
|
window: { offset: 0 },
|
|
signal: controller.signal
|
|
})
|
|
).rejects.toThrow('cancelled file')
|
|
} finally {
|
|
await handle.close()
|
|
}
|
|
})
|
|
})
|
|
})
|