mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +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.
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { createAgentStatusTracker } from './agent-title-status'
|
|
|
|
function tracker() {
|
|
const events: string[] = []
|
|
const instance = createAgentStatusTracker(
|
|
(title) => events.push(`idle:${title}`),
|
|
() => events.push('working'),
|
|
() => events.push('exited')
|
|
)
|
|
return { instance, events }
|
|
}
|
|
|
|
describe('createAgentStatusTracker with OSC 7501 activity', () => {
|
|
it('drives edges from the program while its titles carry no status glyph', () => {
|
|
// Claude Code drops its ⠂/✳ prefix once the terminal answers the OSC 7501 probe.
|
|
const { instance, events } = tracker()
|
|
instance.handleProgramActivity('idle')
|
|
instance.handleTitle('Claude Code')
|
|
instance.handleProgramActivity('working')
|
|
instance.handleTitle('Fix the parser')
|
|
instance.handleProgramActivity('permission')
|
|
instance.handleProgramActivity('working')
|
|
instance.handleProgramActivity('idle')
|
|
expect(events).toEqual(['working', 'idle:Fix the parser', 'working', 'idle:Fix the parser'])
|
|
})
|
|
|
|
it('never reads a glyph-less title as an exit while the program reports', () => {
|
|
const { instance, events } = tracker()
|
|
instance.handleProgramActivity('idle')
|
|
instance.handleTitle('some topic title the detector cannot classify ⟂')
|
|
expect(events).toEqual([])
|
|
})
|
|
|
|
it('hands classification back to titles once the program stops reporting', () => {
|
|
const { instance, events } = tracker()
|
|
instance.handleProgramActivity('idle')
|
|
instance.handleProgramActivity(null)
|
|
instance.handleTitle('')
|
|
expect(events).toEqual(['exited'])
|
|
})
|
|
|
|
it('leaves agents that never report OSC 7501 on title glyphs', () => {
|
|
const onIdle = vi.fn()
|
|
const instance = createAgentStatusTracker(onIdle)
|
|
instance.handleTitle('⠂ Claude Code')
|
|
instance.handleTitle('✳ Claude Code')
|
|
expect(onIdle).toHaveBeenCalledWith('✳ Claude Code', 'idle')
|
|
})
|
|
})
|