Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

A harness is called what its engine calls the session, until the person renames it

deeb6b4d91e1962
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index f0972c6d2..b6c7d3f39 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -39,6 +39,7 @@ import { MachineListCache, machineListCachePath, withStaleMarker } from './devic
import { DeviceLink } from './device/deviceLink.js'
import { DeviceFleet } from './device/deviceFleet.js'
import { registry, projectDisplayName, type RegisteredSession } from './lib/registry.js'
+import { engineSessionTitle } from './lib/sessionTitle.js'
import { installAmpPlugin, installCodexHooks, installCommandCodeHooks, installCursorHooks, installDevinHooks, installGrokHooks, installAgyHooks, installCopilotHooks, installHermesHooks, installKiloPlugin, installOpencodePlugin, installPiExtension, installSessionHooks } from './lib/hooks.js'
import { installOpencodeHarnessComputeSkill } from './lib/harnessComputeSkill.js'
import { PID_FILE, daemonPort, isAlive, readPid } from './lib/daemonState.js'
@@ -1506,7 +1507,8 @@ async function runForeground(session: AuthSession): Promise<void> {
const titles = await terminals.titles()
if (titles.size === 0) return
for (const session of registry.list()) {
- const title = terminals.titleFor(session, titles)
+ // Codex's own thread name when it has one; otherwise what the engine put on its terminal.
+ const title = engineSessionTitle(session, terminals.titleFor(session, titles))
if (!title) continue
const before = projectDisplayName(session)
const updated = registry.updateTitle(session.sessionId, title)
diff --git a/cli/src/lib/agentFrame.ts b/cli/src/lib/agentFrame.ts
index e966a55c4..ceff1bda5 100644
--- a/cli/src/lib/agentFrame.ts
+++ b/cli/src/lib/agentFrame.ts
@@ -22,7 +22,7 @@ import { stat } from 'node:fs/promises'
import { agentProject, type AgentProject } from './agentProject.js'
import type { GridAssignment } from './gridAssignment.js'
import type { GridWebSearchStatus } from './gridLaunch.js'
-import { projectDisplayName, type RegisteredSession, titleDisplayName } from './registry.js'
+import { projectDisplayName, sessionDisplayTitle, type RegisteredSession } from './registry.js'
import type { DshVerdict } from '../dsh/verdict.js'
/**
@@ -99,7 +99,7 @@ export interface AgentFrameContext {
* transcript falls back to the registry, never to "now".
*/
function frameTitle(s: RegisteredSession): string | null {
- const title = titleDisplayName(s.title)
+ const title = sessionDisplayTitle(s)
return title && title !== projectDisplayName(s) ? title : null
}
diff --git a/cli/src/lib/registry.spec.ts b/cli/src/lib/registry.spec.ts
index 75edbe8df..a6183f9fe 100644
--- a/cli/src/lib/registry.spec.ts
+++ b/cli/src/lib/registry.spec.ts
@@ -1048,7 +1048,7 @@ describe('agent identity: the process owns the agent, the session is bound to it
expect(names.every((name) => typeof name === 'string' && name.length > 0)).toBe(true)
})
- it('gives new agents stable numbered names across binding and reload without changing custom names', async () => {
+ it('gives new agents stable numbered names until their session has a title, and a rename fixes a name', async () => {
const { registry } = await loadRegistryModule()
registry.load()
const first = registry.openPendingAgent({ engine: 'opencode', runtimes: [{ backend: 'tmux', paneId: '%7' }], cwd: '/tmp/demo' })!
@@ -1056,11 +1056,16 @@ describe('agent identity: the process owns the agent, the session is bound to it
expect(registry.displayName(first)).toBe('harness-1')
expect(registry.displayName(second)).toBe('harness-2')
const bound = registry.register({ engine: 'opencode', sessionId: 'session-numbered', tmuxPane: '%7', title: 'OC | Greeting' })!.entry
- expect(registry.displayName(bound)).toBe('harness-1')
+ expect(registry.displayName(bound)).toBe('Greeting')
+ expect(bound.defaultName).toBe('harness-1')
+ registry.updateTitle('session-numbered', 'OC | Plan the launch')
+ expect(registry.displayName(bound)).toBe('Plan the launch')
registry.rename(second.agentId, 'My project')
+ registry.updateTitle(second.agentId, 'OC | Something else')
+ expect(registry.displayName(registry.byAgent(second.agentId)!)).toBe('My project')
const { registry: reloaded } = await loadRegistryModule()
reloaded.load()
- expect(reloaded.displayName(reloaded.byAgent(first.agentId)!)).toBe('harness-1')
+ expect(reloaded.displayName(reloaded.byAgent(first.agentId)!)).toBe('Plan the launch')
expect(reloaded.displayName(reloaded.byAgent(second.agentId)!)).toBe('My project')
const third = reloaded.openPendingAgent({ engine: 'codex', runtimes: [{ backend: 'tmux', paneId: '%9' }], cwd: '/tmp/demo' })!
expect(reloaded.displayName(third)).toBe('harness-3')
diff --git a/cli/src/lib/registry.ts b/cli/src/lib/registry.ts
index 1bc0a46ac..d3e595606 100644
--- a/cli/src/lib/registry.ts
+++ b/cli/src/lib/registry.ts
@@ -15,6 +15,7 @@
import { DSH_ID_RE } from '../dsh/manifest.js'
import { AGENT_NAME_RE } from './engineLaunch.js'
+import { namingTitle } from './sessionTitle.js'
import {
closeSync,
constants,
@@ -206,10 +207,24 @@ export interface RegisterInput {
}
/** Display name for a session's "project" tab/tile. A user rename (persisted override) is
- * authoritative and FIXED. Harness-created agents start with a numbered name;
- * discovered sessions retain their title/folder fallback. */
+ * authoritative and FIXED. Until there is one, a session is called what its engine calls it — the
+ * conversation title Claude Code puts on its terminal, Codex's thread name (sessionTitle.ts) — which
+ * moves as the engine retitles it, and says what the agent is doing where harness-43 does not. The
+ * numbered name a harness is created with stands in until the engine has a title, a name its creator
+ * chose is kept like a rename, and a discovered session falls back to its folder. */
export function projectDisplayName(s: RegisteredSession): string {
- return NAME_OVERRIDES.get(s.sessionId) || NAME_OVERRIDES.get(s.agentId) || s.defaultName || titleDisplayName(s.title) || defaultProjectDisplayName(s)
+ // A name the creator chose ("Local model") is fixed like a rename; only a numbered default gives way.
+ const chosen = s.defaultName && !NUMBERED_DEFAULT_NAME.test(s.defaultName) ? s.defaultName : null
+ return NAME_OVERRIDES.get(s.sessionId) || NAME_OVERRIDES.get(s.agentId) || chosen
+ || sessionDisplayTitle(s) || s.defaultName || defaultProjectDisplayName(s)
+}
+
+/** The names a daemon numbers agents with: `harness-N`, and `agent-N` from before the rename. */
+const NUMBERED_DEFAULT_NAME = /^(?:harness|agent)-[1-9]\d*$/
+
+/** The engine's own name for this session, or null while it has none worth showing. */
+export function sessionDisplayTitle(s: RegisteredSession): string | null {
+ return namingTitle(titleDisplayName(s.title), { engine: s.engine, cwd: s.cwd, defaultName: s.defaultName })
}
const FILE = join(env.ADAPTER_DATA_DIR, 'registry.json')
diff --git a/cli/src/lib/sessionTitle.spec.ts b/cli/src/lib/sessionTitle.spec.ts
new file mode 100644
index 000000000..e1c4767de
--- /dev/null
+++ b/cli/src/lib/sessionTitle.spec.ts
@@ -0,0 +1,125 @@
+import { afterEach, beforeEach, describe, expect, it } from 'vitest'
+import { appendFileSync, mkdirSync, mkdtempSync, rmSync, utimesSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join } from 'node:path'
+import { cleanCodexTitle, codexThreadName, engineSessionTitle, namingTitle, resetCodexThreadNames } from './sessionTitle.js'
+
+describe('namingTitle: the engine’s title, when it names the session', () => {
+ const harness = { engine: 'claude', cwd: '/Users/example/harnesses/harness-43', defaultName: 'harness-43' }
+
+ it('takes a conversation title as it is', () => {
+ expect(namingTitle('Unitree Go2 squats and wave', harness)).toBe('Unitree Go2 squats and wave')
+ })
+
+ it('is no name while the title is only the engine, the folder or the default name', () => {
+ for (const title of ['Claude Code', 'claude', 'CODEX', 'harness-43', 'Harness-43', ' ', '', null, undefined]) {
+ expect(namingTitle(title, harness)).toBeNull()
+ }
+ expect(namingTitle('harness-43', { engine: 'claude', cwd: '/elsewhere/x', defaultName: 'harness-43' })).toBeNull()
+ expect(namingTitle('project', { engine: 'claude', cwd: '/Users/example/project' })).toBeNull()
+ expect(namingTitle('Something', {})).toBe('Something')
+ })
+
+ it('drops OpenCode’s and Kilo’s short-name prefix', () => {
+ expect(namingTitle('OC | Greeting', { engine: 'opencode' })).toBe('Greeting')
+ expect(namingTitle('Kilo | Refactor the parser', { engine: 'kilo' })).toBe('Refactor the parser')
+ expect(namingTitle('OC | opencode', { engine: 'opencode' })).toBeNull()
+ })
+
+ it('reads a Codex title without its status words and folder', () => {
+ const codex = { engine: 'codex', cwd: '/Users/example/harnesses/harness-36' }
+ expect(namingTitle('Action Required | Build 555 LED flasher | harness-36', codex)).toBe('Build 555 LED flasher')
+ expect(namingTitle('Build brick breaker game | harness-36', codex)).toBe('Build brick breaker game')
+ expect(namingTitle('Working | harness-36', codex)).toBeNull()
+ expect(namingTitle('codex | Ready', codex)).toBeNull()
+ })
+})
+
+describe('cleanCodexTitle', () => {
+ it('keeps every part that is not a status word, the banner, the app name or the folder', () => {
+ expect(cleanCodexTitle('[ ! ] Action Required | Fix the flaky test | repo', '/src/repo')).toBe('Fix the flaky test')
+ expect(cleanCodexTitle('[ . ] Action Required | Fix it', null)).toBe('Fix it')
+ expect(cleanCodexTitle('Starting | Thinking | Waiting | Ready | Working', undefined)).toBe('')
+ expect(cleanCodexTitle('Compare A | B options | main', '/src/other')).toBe('Compare A | B options | main')
+ })
+})
+
+describe('codexThreadName: Codex’s own name for a thread', () => {
+ let home: string
+ const savedHome = process.env.CODEX_HOME
+ beforeEach(() => {
+ home = mkdtempSync(join(tmpdir(), 'codex-home-'))
+ resetCodexThreadNames()
+ })
+ afterEach(() => {
+ rmSync(home, { recursive: true, force: true })
+ if (savedHome === undefined) delete process.env.CODEX_HOME
+ else process.env.CODEX_HOME = savedHome
+ resetCodexThreadNames()
+ })
+ const index = (lines: string[]) => writeFileSync(join(home, 'session_index.jsonl'), lines.join('\n') + '\n')
+
+ it('reads the latest name for the session and skips torn or unnamed lines', () => {
+ index([
+ JSON.stringify({ id: 't1', thread_name: 'First name' }),
+ '{"id":"t2","thread_na',
+ JSON.stringify({ id: 't3', thread_name: ' ' }),
+ JSON.stringify({ id: 't4' }),
+ '',
+ JSON.stringify({ id: 't1', thread_name: ' Renamed thread ' }),
+ ])
+ expect(codexThreadName('t1', home)).toBe('Renamed thread')
+ expect(codexThreadName('t2', home)).toBeNull()
+ expect(codexThreadName('t3', home)).toBeNull()
+ expect(codexThreadName('t9', home)).toBeNull()
+ })
+
+ it('rereads the index only when it changes', () => {
+ index([JSON.stringify({ id: 't1', thread_name: 'Before' })])
+ expect(codexThreadName('t1', home)).toBe('Before')
+ appendFileSync(join(home, 'session_index.jsonl'), JSON.stringify({ id: 't1', thread_name: 'After /rename' }) + '\n')
+ const later = new Date(Date.now() + 5_000)
+ utimesSync(join(home, 'session_index.jsonl'), later, later)
+ expect(codexThreadName('t1', home)).toBe('After /rename')
+ })
+
+ it('uses CODEX_HOME when the agent has no profile folder, and is no name without a file or a session', () => {
+ index([JSON.stringify({ id: 't1', thread_name: 'From the env home' })])
+ process.env.CODEX_HOME = home
+ expect(codexThreadName('t1')).toBe('From the env home')
+ expect(codexThreadName(null, home)).toBeNull()
+ expect(codexThreadName('t1', join(home, 'missing'))).toBeNull()
+ })
+
+ it('is no name when the index cannot be read', () => {
+ mkdirSync(join(home, 'session_index.jsonl')) // stat succeeds, reading a directory fails
+ expect(codexThreadName('t1', home)).toBeNull()
+ })
+
+ it('falls back to ~/.codex when neither the agent nor the environment names a Codex home', () => {
+ const savedUserHome = process.env.HOME
+ delete process.env.CODEX_HOME
+ process.env.HOME = home
+ try {
+ mkdirSync(join(home, '.codex'))
+ writeFileSync(join(home, '.codex', 'session_index.jsonl'), JSON.stringify({ id: 't1', thread_name: 'Default home' }) + '\n')
+ expect(codexThreadName('t1')).toBe('Default home')
+ } finally {
+ process.env.HOME = savedUserHome
+ }
+ })
+})
+
+describe('engineSessionTitle: what the terminal sweep records', () => {
+ let home: string
+ beforeEach(() => { home = mkdtempSync(join(tmpdir(), 'codex-home-')); resetCodexThreadNames() })
+ afterEach(() => { rmSync(home, { recursive: true, force: true }); resetCodexThreadNames() })
+
+ it('prefers Codex’s thread name, then the terminal title, for Codex; the terminal title for everyone else', () => {
+ writeFileSync(join(home, 'session_index.jsonl'), JSON.stringify({ id: 's1', thread_name: 'Design a cable clip' }) + '\n')
+ expect(engineSessionTitle({ engine: 'codex', sessionId: 's1', codexHome: home }, 'Working | harness-40')).toBe('Design a cable clip')
+ expect(engineSessionTitle({ engine: 'codex', sessionId: 's2', codexHome: home }, 'Working | harness-40')).toBe('Working | harness-40')
+ expect(engineSessionTitle({ engine: 'codex', sessionId: 's2', codexHome: home }, undefined)).toBeNull()
+ expect(engineSessionTitle({ engine: 'claude', sessionId: 's1', codexHome: home }, '✳ Plan the launch')).toBe('✳ Plan the launch')
+ })
+})
diff --git a/cli/src/lib/sessionTitle.ts b/cli/src/lib/sessionTitle.ts
new file mode 100644
index 000000000..cece7484b
--- /dev/null
+++ b/cli/src/lib/sessionTitle.ts
@@ -0,0 +1,114 @@
+/**
+ * The name an engine gives its own session — which is what a harness is called until the person
+ * names it (registry.ts, projectDisplayName). "Unitree Go2 squats and wave" says what the agent is
+ * doing; harness-43 says only that it was the forty-third.
+ *
+ * - Claude Code titles its terminal after the conversation, once there is one ("✳ Harness Store
+ * launch video"; the leading glyph is its activity marker and is cleaned off by titleDisplayName).
+ * - OpenCode titles it "OC | <session title>"; the prefix is dropped.
+ * - Codex keeps a thread name per session in `$CODEX_HOME/session_index.jsonl`, updated when it
+ * names a thread and on `/rename`. Its terminal title carries the same name between status words
+ * and the folder — "[ ! ] Action Required | Build 555 LED flasher | harness-36" — so that is the
+ * fallback, with the status words and the folder taken out.
+ *
+ * What is left after cleaning can still be no name at all: an engine's own name before the first
+ * prompt ("Claude Code"), or just the folder. Those fall through to the numbered default.
+ */
+import { readFileSync, statSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { basename, join } from 'node:path'
+import { ENGINES } from '../engines/types.js'
+
+/** An engine's own name, which is what a session is titled before it is about anything. */
+const ENGINE_TITLES: ReadonlySet<string> = new Set([
+ ...ENGINES,
+ 'claude code', 'openai codex', 'codex cli', 'cursor agent', 'gemini', 'gemini cli', 'hermes agent',
+ 'command code', 'devin', 'amp', 'kilo code', 'grok', 'github copilot', 'copilot cli', 'antigravity',
+])
+
+/** OpenCode (and Kilo, its fork) put their short name in front: "OC | Greeting". */
+const OPENCODE_PREFIX = /^(?:oc|opencode|kilo)\s+\|\s+/i
+
+/** Codex's run-state words (run_state_status_text) and its action-required banner. */
+const CODEX_STATUS = /^(?:\[\s*[!.]\s*\]\s*)?(?:starting|ready|working|waiting|thinking|action required)$/i
+
+/**
+ * A title that names the session, or null when it only names the engine, the folder or the default.
+ * `title` is already cleaned of leading glyphs (titleDisplayName).
+ */
+export function namingTitle(
+ title: string | null | undefined,
+ context: { engine?: string | null; cwd?: string | null; defaultName?: string | null },
+): string | null {
+ if (!title) return null
+ const cleaned = context.engine === 'codex'
+ ? cleanCodexTitle(title, context.cwd)
+ : title.trim().replace(OPENCODE_PREFIX, '').trim()
+ if (!cleaned) return null
+ const lower = cleaned.toLowerCase()
+ if (ENGINE_TITLES.has(lower)) return null
+ if (context.cwd && lower === basename(context.cwd).toLowerCase()) return null
+ if (context.defaultName && lower === context.defaultName.toLowerCase()) return null
+ return cleaned
+}
+
+/** Codex's terminal title without its status words and its folder item. */
+export function cleanCodexTitle(title: string, cwd?: string | null): string {
+ const folder = cwd ? basename(cwd).toLowerCase() : null
+ return title
+ .split(' | ')
+ .map((part) => part.trim())
+ .filter((part) => part && !CODEX_STATUS.test(part) && part.toLowerCase() !== folder && part.toLowerCase() !== 'codex')
+ .join(' | ')
+}
+
+interface IndexCache { path: string; mtimeMs: number; size: number; names: Map<string, string> }
+let codexIndexCache: IndexCache | null = null
+
+/**
+ * Codex's own name for a thread, from `session_index.jsonl` under the agent's CODEX_HOME. The file is
+ * small (one line per named thread, later lines win) and re-read only when it changes; a missing or
+ * unreadable file is simply no name.
+ */
+export function codexThreadName(sessionId: string | null | undefined, codexHome?: string | null): string | null {
+ if (!sessionId) return null
+ const home = codexHome || process.env.CODEX_HOME || join(homedir(), '.codex')
+ const path = join(home, 'session_index.jsonl')
+ let stat
+ try { stat = statSync(path) } catch { return null }
+ if (!codexIndexCache || codexIndexCache.path !== path || codexIndexCache.mtimeMs !== stat.mtimeMs || codexIndexCache.size !== stat.size) {
+ const names = new Map<string, string>()
+ try {
+ for (const line of readFileSync(path, 'utf8').split('\n')) {
+ if (!line.trim()) continue
+ try {
+ const row = JSON.parse(line) as { id?: unknown; thread_name?: unknown }
+ if (typeof row.id === 'string' && typeof row.thread_name === 'string' && row.thread_name.trim()) {
+ names.set(row.id, row.thread_name.trim())
+ }
+ } catch { /* one torn line (Codex mid-append) costs that line, not the index */ }
+ }
+ } catch { return null }
+ codexIndexCache = { path, mtimeMs: stat.mtimeMs, size: stat.size, names }
+ }
+ return codexIndexCache.names.get(sessionId) ?? null
+}
+
+/** Test seam. */
+export function resetCodexThreadNames(): void { codexIndexCache = null }
+
+/**
+ * The title the terminal sweep records for a session: Codex's thread name when it has one, else the
+ * terminal title as the engine wrote it. Cleaning for display happens in namingTitle, so a title
+ * recorded before this existed is read the same way.
+ */
+export function engineSessionTitle(
+ session: { engine?: string | null; sessionId?: string | null; codexHome?: string | null },
+ terminalTitle: string | null | undefined,
+): string | null {
+ if (session.engine === 'codex') {
+ const named = codexThreadName(session.sessionId, session.codexHome)
+ if (named) return named
+ }
+ return terminalTitle ?? null
+}