fix(jcode): read the bare title tail only in a Jcode pane

The activity tail on conversation and SSH titles is too generic to prove an
agent, so title-only readers must not treat it as one. Gate it on the pane's
agent, as Hermes markers are, keep identity titles self-describing, narrow the
server segment, and keep the title strip linear.
This commit is contained in:
Kelvin Amoaba
2026-11-11 18:26:13 +00:00
parent 5bc01b86b5
commit 0ae9ca7aa0
5 changed files with 44 additions and 24 deletions
@@ -7,6 +7,7 @@ import { terminalTitleBlocksExplicitAgentStatus } from '../../workspaces/process
import type { ClaudeTerminalEvidence } from '../../../../shared/claude-terminal-interrupt'
import { agentStatusTakesTypedInput } from '../../orchestration/mailbox/routing/mailbox-owner'
import { hermesNativeTitleStatus } from '../../../../shared/agent-status/title/providers/hermes-terminal-title'
import { jcodePaneTitleStatus } from '../../../../shared/agent-status/title/providers/jcode-terminal-title'
export abstract class OrcaRuntimeWithApplyTrackedPtyTitle extends OrcaRuntimeWithGetUnpersistedTrackedTitleForPty {
protected abstract collectPaneKeysForPty(ptyId: string): Set<string>
@@ -53,9 +54,11 @@ export abstract class OrcaRuntimeWithApplyTrackedPtyTitle extends OrcaRuntimeWit
/** The PTY's agent status under this title: the program's own OSC 7501 activity while it
* reports one, else what the title glyph says. */
protected classifyPtyTitleStatus(ptyId: string, rawTitle: string): AgentStatus | null {
const agent = this.getPaneTerminalAgent(ptyId)
return (
this.ptyTitleTrackersByPtyId.get(ptyId)?.programActivity ??
hermesNativeTitleStatus(rawTitle, this.getPaneTerminalAgent(ptyId)) ??
hermesNativeTitleStatus(rawTitle, agent) ??
jcodePaneTitleStatus(rawTitle, agent) ??
detectAgentStatusFromTitle(rawTitle)
)
}
@@ -8,6 +8,7 @@ import {
import { detectAgentStatusFromTitle } from '../../../../../../shared/agent-status/title/agent-title-status'
import { getAgentLabel } from '../../../../../../shared/agent-status/title/agent-title-identity'
import { jcodePaneTitleStatus } from '../../../../../../shared/agent-status/title/providers/jcode-terminal-title'
import { tabHasLivePty } from '../../../../../../shared/tab-has-live-pty'
import type {
AgentStatusEntry,
@@ -182,7 +183,7 @@ function buildTitleDerivedAgentRow(args: {
return null
}
// Why: the title sets activity only; a plain title on a process-identified pane is idle.
const status = titleStatus ?? 'idle'
const status = titleStatus ?? jcodePaneTitleStatus(title, agentType) ?? 'idle'
const rowLabel =
agentType === titleAgentType &&
label &&
@@ -1,6 +1,6 @@
import { getDeepSeekBuildTitleStatus } from './providers/dsb-terminal-title'
import { qoderTitleStatus } from './providers/qoder-terminal-title'
import { jcodeTitleStatus } from './providers/jcode-terminal-title'
import { jcodeIdentityTitleStatus } from './providers/jcode-terminal-title'
import { cursorTitleStatus } from './providers/cursor-terminal-title'
import {
AGY_AGENT_NAME_RE,
@@ -280,7 +280,7 @@ function computeAgentStatusFromTitle(title: string): AgentStatus | null {
if (title.startsWith(`${CLAUDE_IDLE} `) || title === CLAUDE_IDLE) {
return 'idle'
}
const jcodeStatus = jcodeTitleStatus(title)
const jcodeStatus = jcodeIdentityTitleStatus(title)
if (jcodeStatus) {
return jcodeStatus
}
@@ -2,36 +2,46 @@ import { CLAUDE_IDLE } from '../agent-title-glyphs'
// jcode updates emoji/session/diff/duration titles about once a second (terminal_title.rs); generated codenames are identity, not conversation names.
// Captured provenance: docs/reference/jcode-hook-events.md.
// (?<!\s) starts each separator at its whitespace run so long space runs stay linear.
const JCODE_TITLE_STATUS_RE =
/^[\p{Extended_Pictographic}\u{FE0F}\u{200D}]+\s*|\s+·\s+(?:\+\d+\s+-\d+|(?:work|last)\s+~\S+|working)(?=\s+·\s+|$)/gu
/^[\p{Extended_Pictographic}\u{FE0F}\u{200D}]+\s*|(?<!\s)\s+·\s+(?:\+\d+\s+-\d+|(?:work|last)\s+~\S+|working)(?=\s+·\s+|$)/gu
/** The jcode title with its per-session emoji and live diff/duration segments removed. */
export function stripJcodeTitleStatus(title: string): string {
return title.replace(JCODE_TITLE_STATUS_RE, '').trim()
}
// jcode, jcode Puppy and self-dev jcode/creek Puppy are identity; user work labels contain more.
const JCODE_IDENTITY_TITLE_RE = /^jcode(?:\/[^\s·]+)?(?:\s+[^\s·]+)?$/iu
// 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
/** 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 {
// Claude's ✳ is also an emoji; `✳ Jcode hooks` is a Claude task title.
return (
Boolean(title) &&
/jcode/i.test(title ?? '') &&
!title?.trimStart().startsWith(CLAUDE_IDLE) &&
JCODE_IDENTITY_TITLE_RE.test(stripJcodeTitleStatus(title ?? ''))
)
}
// title_with_metrics: `<emoji> <label> · work ~2m05s` (or `· working`) mid-turn, `· last ~2m05s` after it.
const JCODE_SESSION_TITLE_RE =
/^[\p{Extended_Pictographic}\u{FE0F}\u{200D}]+\s.*\s·\s(?:(work|last)\s~(?:\d+h\d{2}m|\d+m\d{2}s|\d+s)|working)$/u
// 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
/** Activity from jcode's own title; conversation-titled sessions carry only the tail, so identity comes from the process. */
export function jcodeTitleStatus(title: string): 'working' | 'idle' | null {
const tail = title.trimStart().startsWith(CLAUDE_IDLE) ? null : JCODE_SESSION_TITLE_RE.exec(title)
if (tail) {
return tail[1] === 'last' ? 'idle' : 'working'
}
return isJcodeIdentityTerminalTitle(title) ? 'idle' : null
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. */
export function jcodePaneTitleStatus(
title: string,
agent: string | null | undefined
): 'working' | 'idle' | null {
return agent === 'jcode' ? jcodeTitleActivity(title) : null
}
+13 -7
View File
@@ -5,6 +5,7 @@ import {
} from './agent-status/process/agent-process-recognition'
import { detectAgentStatusFromTitle } from './agent-status/title/agent-title-status'
import { resolveExplicitTerminalTitleAgentType } from './agent-status/title/terminal-title-agent-type'
import { jcodePaneTitleStatus } from './agent-status/title/providers/jcode-terminal-title'
describe('Jcode pane identity and title status', () => {
it('recognizes the platform binary the Linux release wrapper execs', () => {
@@ -18,19 +19,24 @@ describe('Jcode pane identity and title status', () => {
expect(recognizeAgentProcessFromCommandLine('jcode-helper')).toBeNull()
})
it('reads working and idle from the tail Jcode appends to its title', () => {
it('reads working and idle from the tail of its identity title', () => {
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck · work ~2s')).toBe('working')
expect(detectAgentStatusFromTitle('🦊 Improve session tabs · +12 -3 · work ~2m05s')).toBe(
'working'
)
expect(detectAgentStatusFromTitle('🦊 Improve session tabs · working')).toBe('working')
expect(detectAgentStatusFromTitle('🐩 jcode Poodle · +3 -1 · working')).toBe('working')
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck · last ~1m05s')).toBe('idle')
expect(detectAgentStatusFromTitle('🌐 jcode/fountain Duck')).toBe('idle')
expect(detectAgentStatusFromTitle('✳ Fix jcode · work ~2s')).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()
expect(jcodePaneTitleStatus('jcode SSH devbox fox · last ~1h05m', 'jcode')).toBe('idle')
})
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')
})
})