* Improve mobile terminal streaming performance Co-authored-by: Orca <help@stably.ai> * Add mobile clear terminal action Co-authored-by: Orca <help@stably.ai> * Fix terminal connection test mock Co-authored-by: Orca <help@stably.ai> * WIP: mobile markdown tabs before rebase Co-authored-by: Orca <help@stably.ai> * Add mobile markdown editing Co-authored-by: Orca <help@stably.ai> * Harden mobile tab and markdown sync Co-authored-by: Orca <help@stably.ai> * Fix mobile terminal reconnect loading race Co-authored-by: Orca <help@stably.ai> * Polish mobile terminal keyboard behavior Co-authored-by: Orca <help@stably.ai> * Simplify mobile markdown editor chrome Co-authored-by: Orca <help@stably.ai> * Move mobile markdown actions to top Co-authored-by: Orca <help@stably.ai> * Use app modals for markdown discard Co-authored-by: Orca <help@stably.ai> * Dismiss keyboard before markdown confirmations Co-authored-by: Orca <help@stably.ai> * Add mobile file explorer Co-authored-by: Orca <help@stably.ai> * Fix mobile file explorer type narrowing Co-authored-by: Orca <help@stably.ai> * Fix mobile files navigation param Co-authored-by: Orca <help@stably.ai> * Show mobile files connection wait state Co-authored-by: Orca <help@stably.ai> * Preview text files on mobile Co-authored-by: Orca <help@stably.ai> * Simplify mobile file previews Co-authored-by: Orca <help@stably.ai> * Clarify unavailable mobile file types Co-authored-by: Orca <help@stably.ai> * Fix mobile subscription and preview review issues Co-authored-by: Orca <help@stably.ai> * Keep fallback terminals visible on mobile Co-authored-by: Orca <help@stably.ai> * Keep mobile terminal tap active Co-authored-by: Orca <help@stably.ai> * Preserve mobile terminal fallback order Co-authored-by: Orca <help@stably.ai> * Fix mobile session tab authority Co-authored-by: Orca <help@stably.ai> * Run mobile tests in mobile CI lane Co-authored-by: Orca <help@stably.ai> * Bump mobile app version to 0.0.7 Co-authored-by: Orca <help@stably.ai> * Allow main window IPC wiring size Co-authored-by: Orca <help@stably.ai> --------- Co-authored-by: Orca <help@stably.ai>
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
TerminalStreamOpcode,
|
|
decodeTerminalStreamFrame,
|
|
decodeTerminalStreamJson,
|
|
decodeTerminalStreamText,
|
|
encodeTerminalStreamFrame,
|
|
encodeTerminalStreamJson,
|
|
encodeTerminalStreamText
|
|
} from './terminal-stream-protocol'
|
|
|
|
describe('terminal-stream-protocol', () => {
|
|
it('round-trips fixed-width binary frame headers and payloads', () => {
|
|
const payload = encodeTerminalStreamText('hello terminal')
|
|
const encoded = encodeTerminalStreamFrame({
|
|
opcode: TerminalStreamOpcode.Output,
|
|
streamId: 42,
|
|
seq: 9,
|
|
payload
|
|
})
|
|
|
|
const decoded = decodeTerminalStreamFrame(encoded)
|
|
|
|
expect(decoded?.opcode).toBe(TerminalStreamOpcode.Output)
|
|
expect(decoded?.streamId).toBe(42)
|
|
expect(decoded?.seq).toBe(9)
|
|
expect(decoded ? decodeTerminalStreamText(decoded.payload) : '').toBe('hello terminal')
|
|
})
|
|
|
|
it('round-trips snapshot metadata JSON payloads', () => {
|
|
const encoded = encodeTerminalStreamFrame({
|
|
opcode: TerminalStreamOpcode.SnapshotStart,
|
|
streamId: 7,
|
|
seq: 1,
|
|
payload: encodeTerminalStreamJson({ kind: 'scrollback', cols: 49, rows: 28 })
|
|
})
|
|
|
|
const decoded = decodeTerminalStreamFrame(encoded)
|
|
|
|
expect(decoded && decodeTerminalStreamJson(decoded.payload)).toEqual({
|
|
kind: 'scrollback',
|
|
cols: 49,
|
|
rows: 28
|
|
})
|
|
})
|
|
|
|
it('rejects unknown frame versions and opcodes', () => {
|
|
const encoded = encodeTerminalStreamFrame({
|
|
opcode: TerminalStreamOpcode.Output,
|
|
streamId: 1,
|
|
seq: 1,
|
|
payload: new Uint8Array()
|
|
})
|
|
|
|
const badVersion = encoded.slice()
|
|
badVersion[1] = 99
|
|
expect(decodeTerminalStreamFrame(badVersion)).toBeNull()
|
|
|
|
const badOpcode = encoded.slice()
|
|
badOpcode[2] = 99
|
|
expect(decodeTerminalStreamFrame(badOpcode)).toBeNull()
|
|
})
|
|
})
|