mirror of
https://github.com/stablyai/orca.git
synced 2026-10-22 08:03:37 +00:00
perf(terminal): keep retained-tail fallback lazy
This commit is contained in:
@@ -2682,7 +2682,6 @@ export const TERMINAL_METHODS: RpcAnyMethod[] = [
|
||||
'initial-snapshot'
|
||||
)
|
||||
: null
|
||||
const retainedTail = read.tail.length > 0 ? `${read.tail.join('\r\n')}\r\n` : ''
|
||||
const snapshotPublication = sendSnapshotFrames(
|
||||
(opcode, payload) => sendFrame(request.streamId, opcode, payload),
|
||||
{
|
||||
@@ -2703,7 +2702,9 @@ export const TERMINAL_METHODS: RpcAnyMethod[] = [
|
||||
// tail, is a genuinely empty pane and must not be reported as a failure.
|
||||
unavailable:
|
||||
serialized || read.tail.length > 0 ? undefined : 'no-serializable-buffer',
|
||||
data: serializedContent?.data ?? retainedTail
|
||||
data:
|
||||
serializedContent?.data ??
|
||||
(read.tail.length > 0 ? `${read.tail.join('\r\n')}\r\n` : '')
|
||||
}
|
||||
)
|
||||
const replacement = stream.sourceRangeReplacement
|
||||
|
||||
@@ -142,6 +142,19 @@ describe('terminal multiplex initial snapshot fallback', () => {
|
||||
expect(snapshot.start.unavailable).toBeUndefined()
|
||||
})
|
||||
|
||||
it('does not rebuild the retained tail when serialized content is available', async () => {
|
||||
const tail = ['retained line']
|
||||
const tailJoin = vi.spyOn(tail, 'join')
|
||||
const snapshot = await subscribeSnapshot({
|
||||
connectionId: 'conn-serialized-snapshot-tail',
|
||||
serialized: { data: 'serialized screen', cols: 120, rows: 40 },
|
||||
tail
|
||||
})
|
||||
|
||||
expect(snapshot.data).toBe('serialized screen')
|
||||
expect(tailJoin).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('reports unavailable when neither serialized data nor a retained tail exists', async () => {
|
||||
const snapshot = await subscribeSnapshot({
|
||||
connectionId: 'conn-null-snapshot-no-tail',
|
||||
|
||||
Reference in New Issue
Block a user