Files
PiAgentUI/src/utils/ptyProtocol.test.ts
T
Evandro b3489e1ede
Build & Push Frontend Docker Image / build-and-push (push) Canceled after 0s
Build Validation / validate (push) Canceled after 6s
Build & Push Backend Docker Image / build-and-push (push) Failing after 10m10s
Build & Push Gateway Docker Image / build-and-push (push) Failing after 10m9s
🎉 Initial commit: PiAgentUI — AI Agent Desktop & Web UI
A professional workspace for AI coding agents with:
- Real-time streaming chat with SSE
- Session management (fork, clone, tree navigation)
- MCP tools browser & metadata panel
- Skills browser (global, project, package sources)
- Voice input & STT provider configuration
- Integrated terminal & file explorer
- Model selector with capability metadata
- Keyboard-first UI with command palette
- 8 languages (en, pt-BR, es, ja, zh-CN, ar, bn, hi)
- Tauri 2 desktop app
- React 19 + TypeScript + Vite 8 + Tailwind CSS 4
- Pi Agent extension runtime

Originally forked from OpenCodeUI, now an independent project.
License: GPL-3.0-only
2026-06-01 00:50:06 -03:00

31 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { parsePtyFrame } from './ptyProtocol'
describe('parsePtyFrame', () => {
it('returns text frames unchanged', () => {
expect(parsePtyFrame('hello\r\n')).toEqual({ kind: 'data', data: 'hello\r\n' })
})
it('parses websocket binary control frames', () => {
const payload = new TextEncoder().encode('{"cursor":73}')
const bytes = new Uint8Array(payload.length + 1)
bytes[0] = 0
bytes.set(payload, 1)
expect(parsePtyFrame(bytes.buffer)).toEqual({ kind: 'control', cursor: 73 })
})
it('parses tauri bridge control frames with leading null byte', () => {
expect(parsePtyFrame('\0{"cursor":73}')).toEqual({ kind: 'control', cursor: 73 })
})
it('decodes binary text frames', () => {
const bytes = new TextEncoder().encode('ls\n')
expect(parsePtyFrame(bytes.buffer)).toEqual({ kind: 'data', data: 'ls\n' })
})
it('ignores malformed control frames', () => {
expect(parsePtyFrame('\0{"cursor":"oops"}')).toBeNull()
})
})