mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(jcode): keep the turn tail out of title-only readers
Title-only readers (completion tracking) saw a turn from Jcode's identity title and then idle when Jcode switched to a conversation title naming another agent. Read the tail only through the pane-scoped reader, check it before generic title status in the sidebar row, and stop treating a bare jcode/<dir> as Jcode.
This commit is contained in:
+2
-1
@@ -183,7 +183,8 @@ function buildTitleDerivedAgentRow(args: {
|
||||
return null
|
||||
}
|
||||
// Why: the title sets activity only; a plain title on a process-identified pane is idle.
|
||||
const status = titleStatus ?? jcodePaneTitleStatus(title, agentType) ?? 'idle'
|
||||
// Jcode's own tail outranks agent names its conversation title happens to mention.
|
||||
const status = jcodePaneTitleStatus(title, agentType) ?? titleStatus ?? 'idle'
|
||||
const rowLabel =
|
||||
agentType === titleAgentType &&
|
||||
label &&
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import type { TerminalTab } from '../../../../../../shared/workspace-layout/terminal-tab-types'
|
||||
import { makePaneKey } from '../../../../../../shared/workspace-layout/stable-pane-id'
|
||||
import { buildTitleDerivedAgentRows } from './worktree-title-derived-agent-rows'
|
||||
|
||||
const LEAF_ID = '11111111-1111-4111-8111-111111111111'
|
||||
const PANE_KEY = makePaneKey('tab-1', LEAF_ID)
|
||||
|
||||
function jcodeRow(title: string) {
|
||||
const tab: TerminalTab = {
|
||||
id: 'tab-1',
|
||||
ptyId: 'pty-1',
|
||||
worktreeId: 'wt-1',
|
||||
title,
|
||||
customTitle: null,
|
||||
color: null,
|
||||
sortOrder: 0,
|
||||
createdAt: 0
|
||||
}
|
||||
const rows = buildTitleDerivedAgentRows({
|
||||
tabs: [tab],
|
||||
ptyIdsByTabId: { 'tab-1': ['pty-1'] },
|
||||
terminalLayoutsByTabId: {
|
||||
'tab-1': { root: null, activeLeafId: LEAF_ID, expandedLeafId: null }
|
||||
},
|
||||
// Linux reads jcode-linux-x86_64.bin; the foreground tracker publishes it as jcode.
|
||||
paneForegroundAgentByPaneKey: {
|
||||
[PANE_KEY]: { agent: 'jcode', agentEvidence: 'process-read', shellForeground: false }
|
||||
},
|
||||
seenPaneKeys: new Set(),
|
||||
now: 0
|
||||
})
|
||||
return rows.map((row) => ({ agentType: row.agentType, state: row.state }))
|
||||
}
|
||||
|
||||
describe('title-derived Jcode rows', () => {
|
||||
it('keeps the row through Jcode titles and follows its turn tail', () => {
|
||||
expect(jcodeRow('🐩 jcode/marsh Poodle')).toEqual([{ agentType: 'jcode', state: 'idle' }])
|
||||
expect(jcodeRow('🦊 Fix codex hooks · +3 -1 · work ~12s')).toEqual([
|
||||
{ agentType: 'jcode', state: 'working' }
|
||||
])
|
||||
expect(jcodeRow('🦊 Fix codex hooks · last ~2m05s')).toEqual([
|
||||
{ agentType: 'jcode', state: 'idle' }
|
||||
])
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,6 @@
|
||||
import { getDeepSeekBuildTitleStatus } from './providers/dsb-terminal-title'
|
||||
import { qoderTitleStatus } from './providers/qoder-terminal-title'
|
||||
import { jcodeIdentityTitleStatus } from './providers/jcode-terminal-title'
|
||||
import { isJcodeIdentityTerminalTitle } from './providers/jcode-terminal-title'
|
||||
import { cursorTitleStatus } from './providers/cursor-terminal-title'
|
||||
import {
|
||||
AGY_AGENT_NAME_RE,
|
||||
@@ -280,9 +280,9 @@ function computeAgentStatusFromTitle(title: string): AgentStatus | null {
|
||||
if (title.startsWith(`${CLAUDE_IDLE} `) || title === CLAUDE_IDLE) {
|
||||
return 'idle'
|
||||
}
|
||||
const jcodeStatus = jcodeIdentityTitleStatus(title)
|
||||
if (jcodeStatus) {
|
||||
return jcodeStatus
|
||||
// Activity comes from jcodePaneTitleStatus; the identity alone says Jcode is at rest.
|
||||
if (isJcodeIdentityTerminalTitle(title)) {
|
||||
return 'idle'
|
||||
}
|
||||
// Read π ! as blocked before generic idle or OMP user waits disappear.
|
||||
const piCompatibleSeparatorStatus = getPiCompatibleTitleSeparatorStatus(title)
|
||||
|
||||
@@ -11,8 +11,8 @@ export function stripJcodeTitleStatus(title: string): string {
|
||||
return title.replace(JCODE_TITLE_STATUS_RE, '').trim()
|
||||
}
|
||||
|
||||
// jcode, jcode Puppy and jcode/marsh Puppy (server name) are identity; user work labels contain more.
|
||||
const JCODE_IDENTITY_TITLE_RE = /^jcode(?:\/[\w-]+)?(?:\s+[^\s·]+)?$/iu
|
||||
// jcode, jcode Puppy and jcode/marsh Puppy (server name) are identity; a bare jcode/<dir> is a shell path.
|
||||
const JCODE_IDENTITY_TITLE_RE = /^jcode(?:(?:\/[\w-]+)?\s+[^\s·]+)?$/iu
|
||||
|
||||
/** True when a jcode title says only which jcode session this is, not what it is doing. */
|
||||
export function isJcodeIdentityTerminalTitle(title: string | null | undefined): boolean {
|
||||
@@ -28,20 +28,15 @@ export function isJcodeIdentityTerminalTitle(title: string | null | undefined):
|
||||
// title_with_metrics: `· work ~2m05s` (or `· working`) mid-turn, `· last ~2m05s` after it.
|
||||
const JCODE_ACTIVITY_TAIL_RE = /\s·\s(?:(work|last)\s~(?:\d+h\d{2}m|\d+m\d{2}s|\d+s)|working)$/u
|
||||
|
||||
function jcodeTitleActivity(title: string): 'working' | 'idle' | null {
|
||||
const tail = JCODE_ACTIVITY_TAIL_RE.exec(title)
|
||||
return tail ? (tail[1] === 'last' ? 'idle' : 'working') : null
|
||||
}
|
||||
|
||||
/** A jcode identity title carries its own activity; without a tail it is at rest. */
|
||||
export function jcodeIdentityTitleStatus(title: string): 'working' | 'idle' | null {
|
||||
return isJcodeIdentityTerminalTitle(title) ? (jcodeTitleActivity(title) ?? 'idle') : null
|
||||
}
|
||||
|
||||
/** Conversation and SSH titles carry only the tail, which is too generic to identify Jcode, so it counts only in a Jcode pane. */
|
||||
/** The tail is too generic to identify Jcode, and title-only readers must not see a turn that a
|
||||
* later conversation title drops, so it counts only in a pane already known to run Jcode. */
|
||||
export function jcodePaneTitleStatus(
|
||||
title: string,
|
||||
agent: string | null | undefined
|
||||
): 'working' | 'idle' | null {
|
||||
return agent === 'jcode' ? jcodeTitleActivity(title) : null
|
||||
if (agent !== 'jcode') {
|
||||
return null
|
||||
}
|
||||
const tail = JCODE_ACTIVITY_TAIL_RE.exec(title)
|
||||
return tail ? (tail[1] === 'last' ? 'idle' : 'working') : null
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@ describe('Jcode pane identity and title status', () => {
|
||||
expect(recognizeAgentProcessFromCommandLine('jcode-helper')).toBeNull()
|
||||
})
|
||||
|
||||
it('reads working and idle from the tail of its identity title', () => {
|
||||
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck · work ~2s')).toBe('working')
|
||||
expect(detectAgentStatusFromTitle('🐩 jcode Poodle · +3 -1 · working')).toBe('working')
|
||||
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck · last ~1m05s')).toBe('idle')
|
||||
expect(detectAgentStatusFromTitle('🐩 jcode/marsh Poodle')).toBe('idle')
|
||||
})
|
||||
|
||||
it('reads the tail of conversation and SSH titles only in a Jcode pane', () => {
|
||||
const conversation = '🦊 Improve session tabs · +12 -3 · work ~2m05s'
|
||||
expect(detectAgentStatusFromTitle(conversation)).toBeNull()
|
||||
expect(jcodePaneTitleStatus(conversation, 'jcode')).toBe('working')
|
||||
expect(jcodePaneTitleStatus(conversation, 'claude')).toBeNull()
|
||||
it('reads the turn tail only in a Jcode pane', () => {
|
||||
for (const title of [
|
||||
'🌐 jcode/fountain Duck · work ~2s',
|
||||
'🦊 Fix codex hooks · +12 -3 · work ~2m05s',
|
||||
'🐩 jcode Poodle · working'
|
||||
]) {
|
||||
expect(jcodePaneTitleStatus(title, 'jcode')).toBe('working')
|
||||
expect(jcodePaneTitleStatus(title, 'claude')).toBeNull()
|
||||
}
|
||||
expect(jcodePaneTitleStatus('jcode SSH devbox fox · last ~1h05m', 'jcode')).toBe('idle')
|
||||
// Title-only readers see the identity at rest, never a turn a later title would drop.
|
||||
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck · work ~2s')).toBe('idle')
|
||||
expect(detectAgentStatusFromTitle('🦊 Improve session tabs · work ~2m05s')).toBeNull()
|
||||
})
|
||||
|
||||
it('identifies Jcode from its server-qualified session title', () => {
|
||||
expect(resolveExplicitTerminalTitleAgentType('🌐 jcode/fountain Duck · work ~2s')).toBe('jcode')
|
||||
expect(resolveExplicitTerminalTitleAgentType('✳ Jcode hooks')).not.toBe('jcode')
|
||||
expect(resolveExplicitTerminalTitleAgentType('jcode/scripts/build.sh')).not.toBe('jcode')
|
||||
expect(resolveExplicitTerminalTitleAgentType('jcode/scripts')).not.toBe('jcode')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user