mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 11:07:42 +00:00
Programs can tell Orca what they are doing through the Program Status Protocol (OSC 7501); Claude Code, Codex, Grok, pi and oh-my-pi already do. Orca answers the protocol's feature-detection probe (visible xterm and the hidden-pane emulator), parses reports from PTY output on the execution host (src/shared/program-status/), and keeps two lanes: - Lifecycle state keeps one owner per pane. Hooks win; OSC 7501 drives the row when hooks are off, missing, or silent on a state the program has left (server/program-status/hook-precedence). - The program's own report (progress, its one-line message, blocks such as sign-in) is a live-only `programStatus` facet kept per pane (server/program-status/facet-store), stitched onto rows at publish time and carried to the renderer store, mobile, paired clients and `worktree ps`. Facet-only changes patch just the facet. Title-driven readers (idle edges, delivery, tui-idle, exit inference) classify by the program's OSC 7501 activity while it reports one and fall back to title glyphs only for agents that report nothing explicit, so they keep working when Claude stops painting its title glyph after the probe.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { Terminal } from '@xterm/headless'
|
|
import { installProgramStatusQueryResponder } from './query-responder'
|
|
import { PROGRAM_STATUS_QUERY_REPLY } from './protocol'
|
|
|
|
function write(terminal: Terminal, data: string): Promise<void> {
|
|
return new Promise((resolve) => terminal.write(data, resolve))
|
|
}
|
|
|
|
describe('installProgramStatusQueryResponder', () => {
|
|
it('answers the query ahead of the DA1 sentinel that follows it', async () => {
|
|
const terminal = new Terminal({ allowProposedApi: true })
|
|
const replies: string[] = []
|
|
terminal.onData((data) => replies.push(data))
|
|
installProgramStatusQueryResponder({
|
|
parser: terminal.parser,
|
|
emitReply: (reply) => replies.push(reply)
|
|
})
|
|
await write(terminal, '\x1b]7501;?\x1b\\\x1b[c')
|
|
expect(replies[0]).toBe(PROGRAM_STATUS_QUERY_REPLY)
|
|
expect(replies[1].startsWith('\x1b[?')).toBe(true)
|
|
terminal.dispose()
|
|
})
|
|
|
|
it('swallows reports without replying and stays silent while replaying', async () => {
|
|
const terminal = new Terminal({ allowProposedApi: true })
|
|
const replies: string[] = []
|
|
installProgramStatusQueryResponder({
|
|
parser: terminal.parser,
|
|
emitReply: (reply) => replies.push(reply),
|
|
shouldReply: () => false
|
|
})
|
|
await write(terminal, '\x1b]7501;state=working\x07\x1b]7501;?\x07')
|
|
expect(replies).toEqual([])
|
|
terminal.dispose()
|
|
})
|
|
})
|