@phnx-labs/agents-cli 1.23.30 → 1.23.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.32
4
+
5
+ - **A session row lists every PR the session opened (#3989).** The session index records each PR a Claude or Codex session created (`pr_urls`, schema v53), not only the first, and live and ended rows read it as `prs`, so a long session whose PR creations scrolled out of its transcript tail still lists them all. Upgrading re-parses only the transcripts of sessions that already have a PR. Source: cli/src/lib/session/discover.ts, cli/src/lib/session/db.ts, cli/src/lib/session/active.ts
6
+
7
+ ## 1.23.31
8
+
9
+ - **A session row's `title` is the one name to show, and a fork says it is one.** `title` on `agents ps --json`, `agents ps watch --json` and `agents feed watch --json` (live and history rows) is never Claude's `<folder>-<n>` placeholder such as "agents-92" or "agents-1f", never the `[host/<device>]` fallback, and never an injected note, sub-agent hand-back or bare slash command; it falls through to the next usable name instead of going empty. A session started by `agents fork` carries `forkOf` (the source session id) and, until it has a name of its own, the source's name as its `title` instead of "fork of …". `agents fork` no longer launches an unnamed fork with `--name "fork of …"`, so the harness's own title takes over once it writes one; `--name` still names it. Source: `cli/src/lib/session/title.ts`, `cli/src/lib/session/fork.ts`, `cli/src/lib/session/active.ts`, `cli/src/lib/session/remote/watch.ts`, `cli/src/commands/fork.ts`.
10
+
3
11
  ## 1.23.30
4
12
 
5
13
  - **Session rows tell the truth about questions, replies, PRs and limits (#3989).** A permission prompt no longer replaces the open question a Claude session is asking, and an `AskUserQuestion` permission request opens nothing of its own, so the question's choices stay answerable. A question the user rejects clears (`PostToolUseFailure`), so the next permission prompt shows. `agents feed answer` types into the terminal the watchdog resolves (a VSCodium tab, or a tmux pane) when the session has no reply rail; VSCodium cannot confirm delivery, so that answer reports `unknown` and resolves when the session moves on. Live rows carry `prs` when a session opened more than one PR (rows of ended sessions keep the newest `pr`). With `@phnx-labs/sessions-cli` 0.8.7, a session reads as rate-limited only when it is stopped on a limit (not when its tool output mentions 429), a transcript ending in a large compaction line still reads, and pages rewritten under `.agents/artifacts/`, `plans/` or `reports/` count as artifacts. Source: cli/src/lib/feed/feed.ts, cli/src/lib/answer-router.ts, cli/src/lib/session/active.ts
@@ -40,6 +40,8 @@ const FORK_HELP = {
40
40
  - The recap carries the source id — the sibling can run '/continue <id>' for the
41
41
  full history if it needs more than the recap.
42
42
  - Resolve the source the same way as resume: an exact or prefix id fragment.
43
+ - Without --name the fork's row carries forkOf (the source id) and the source's
44
+ name as its title until the harness gives the fork a name of its own.
43
45
  `,
44
46
  };
45
47
  export async function runFork(sessionArg, options, deps = defaultDeps()) {
@@ -81,7 +83,9 @@ export async function runFork(sessionArg, options, deps = defaultDeps()) {
81
83
  lastAssistant: digest?.lastAssistant,
82
84
  changes: digest?.changes,
83
85
  });
84
- const runArgs = ['run', source.agent, recap, '-i', '--strategy', 'balanced', '--name', options.name || `fork of ${label}`];
86
+ const runArgs = ['run', source.agent, recap, '-i', '--strategy', 'balanced'];
87
+ if (options.name)
88
+ runArgs.push('--name', options.name);
85
89
  const sourceIsHere = !source.machine || isSelfHost(source.machine);
86
90
  const landsOnSource = !options.device
87
91
  ? sourceIsHere
@@ -106,7 +110,7 @@ export function registerForkCommand(program) {
106
110
  const cmd = program
107
111
  .command('fork <session>')
108
112
  .description('Branch a session into a new same-harness sibling, seeded with a recap so it continues the work. The original is untouched.')
109
- .option('--name <label>', 'Session label for the fork (default: "fork of <original>")')
113
+ .option('--name <label>', 'Session label for the fork (default: the source\'s name until the fork names itself)')
110
114
  .option('--device <host>', 'Place the sibling on a fleet device (name or "auto"); defaults to here')
111
115
  .option('--terminal [backend]', 'Open the sibling in a real terminal tab (iterm | ghostty | terminal | tmux | vscodium-agent) instead of in-place');
112
116
  setHelpSections(cmd, FORK_HELP);
@@ -21,7 +21,8 @@ export declare function unattributedFullRescanCountForTest(): number;
21
21
  export declare function attributedSetLostPids(prev: Set<number>, next: Set<number>): boolean;
22
22
  export declare function filterCachedUnattributed(sessions: ActiveSession[], attributed: Set<number>, alive: (pid: number, processStartedAtMs?: number) => boolean, ppidMap?: Map<number, number>): ActiveSession[];
23
23
  export type ActiveContext = 'terminal' | 'teams' | 'cloud' | 'headless';
24
- type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
24
+ type BackfillMeta = Pick<SessionMeta, 'version' | 'account' | 'accountId' | 'accountKey' | 'timestamp' | 'label' | 'firstUserMessage' | 'lastUserMessage' | 'generatedTitle' | 'ticketId' | 'prUrl' | 'prNumber' | 'prUrls' | 'harness' | 'tokenCount' | 'durationMs' | 'subAgentCount' | 'lastActivity'>;
25
+ export declare function prsFromUrls(urls: string[]): DetectedPr[];
25
26
  export declare function backfillActiveRowsFromMeta(sessions: ActiveSession[], metaById: Map<string, BackfillMeta>): void;
26
27
  export declare function applySessionNames(sessions: ActiveSession[]): void;
27
28
  export declare function sessionAccountLabel(kind: string, session: Pick<SessionMeta, 'accountId' | 'accountKey' | 'account'>, accounts?: import("../account-registry.js").NativeAccount[]): string | undefined;
@@ -43,7 +44,7 @@ export declare function serializeActiveSessionsForJson(sessions: ActiveSession[]
43
44
  export declare function serializeSessionsJson(sessions: SessionMeta[]): string;
44
45
  export type ActiveStatus = 'running' | 'idle' | 'queued' | 'input_required' | 'closed' | 'abandoned' | 'orphaned' | 'crashed' | 'unknown';
45
46
  export type SessionPhase = 'running' | 'waiting' | 'failed' | 'done' | 'idle';
46
- export type RecapSource = 'label' | 'generated' | 'prompt';
47
+ export type RecapSource = 'label' | 'generated' | 'fork' | 'prompt';
47
48
  export type ImportantMessageKind = 'question' | 'needs_you' | 'activity';
48
49
  export interface SessionImportantMessage {
49
50
  text: string;
@@ -80,6 +81,7 @@ export interface ActiveSession {
80
81
  lastUserMessage?: string;
81
82
  generatedTitle?: string;
82
83
  title?: string;
84
+ forkOf?: string;
83
85
  startedAs?: string;
84
86
  recap?: SessionRecap;
85
87
  recapSource?: RecapSource;
@@ -265,8 +267,9 @@ export declare function foldExecutionMachine(rows: ActiveSession[], machineOf: (
265
267
  export declare function sessionProcessIsLocal(s: Pick<ActiveSession, 'machine' | 'offloadedFrom'>, self: string): boolean;
266
268
  export declare function sessionProcessHost(s: Pick<ActiveSession, 'machine' | 'offloadedFrom'>, self: string): string | undefined;
267
269
  export declare function foldHostLink(rows: ActiveSession[]): void;
268
- export declare function deriveSessionRecap(row: Pick<ActiveSession, 'label' | 'generatedTitle' | 'topic' | 'tail' | 'firstUserMessage' | 'lastUserMessage' | 'attachments' | 'request'>): {
270
+ export declare function deriveSessionRecap(row: Pick<ActiveSession, 'label' | 'generatedTitle' | 'topic' | 'tail' | 'firstUserMessage' | 'lastUserMessage' | 'attachments' | 'request' | 'cwd' | 'startedAs'>): {
269
271
  title?: string;
272
+ forkOf?: string;
270
273
  recapSource?: RecapSource;
271
274
  userPromptClean?: string;
272
275
  userPromptKind?: UserPromptKind;
@@ -16,11 +16,12 @@ import { readSessionActorRecord, writeSessionAliasRecord } from './actor-sidecar
16
16
  import { loadHookSessionIndex, resolveHookSessionRecord, readStateSessionRecord } from './hook-sessions.js';
17
17
  import { extractClaudeUserText, getAgentSessionDirs, readClaudeLiveNames } from './discover.js';
18
18
  import { buildRunNameMap } from './run-names.js';
19
- import { resolveSessionName, startedAsFromUserTurn } from './title.js';
19
+ import { cleanDisplayTitle, isPlaceholderSessionName, resolveSessionName, startedAsFromUserTurn } from './title.js';
20
+ import { forkSourceOf } from './fork.js';
20
21
  import { getIndexedSessionNames, latestSessionFileForCwd, indexedSessionIdForFile, findSessionsByShortIds, findSessionMachinesByIds, getSessionById } from './db.js';
21
22
  import { extractSessionTopic, classifyUserPrompt, tidyRequest } from '@phnx-labs/sessions-cli/reader';
22
23
  import { readSessionTailWithRaw } from '@phnx-labs/sessions-cli/reader';
23
- import { parseSession } from '@phnx-labs/sessions-cli/reader';
24
+ import { parseSession, extractPrUrl } from '@phnx-labs/sessions-cli/reader';
24
25
  import { computeTokPerSec } from './throughput.js';
25
26
  import { inferSessionState, readHarnessStatus } from '@phnx-labs/sessions-cli/reader';
26
27
  import { isSessionTrackedAgent, SESSION_AGENTS, AG_TMUX_NAME_RE } from '@phnx-labs/sessions-cli/reader';
@@ -84,6 +85,9 @@ export function filterCachedUnattributed(sessions, attributed, alive, ppidMap) {
84
85
  return alive(s.pid, s.processStartedAtMs);
85
86
  });
86
87
  }
88
+ export function prsFromUrls(urls) {
89
+ return urls.map((url) => extractPrUrl(url) ?? { url });
90
+ }
87
91
  export function backfillActiveRowsFromMeta(sessions, metaById) {
88
92
  const accounts = listNativeAccounts(readMeta());
89
93
  for (const s of sessions) {
@@ -109,6 +113,8 @@ export function backfillActiveRowsFromMeta(sessions, metaById) {
109
113
  s.ticket = { id: m.ticketId, url: linearIssueUrl(m.ticketId) };
110
114
  if (!s.pr && m.prUrl)
111
115
  s.pr = { url: m.prUrl, number: m.prNumber };
116
+ if (m.prUrls && m.prUrls.length > (s.prs?.length ?? 0))
117
+ s.prs = prsFromUrls(m.prUrls);
112
118
  if (!s.startedAtMs && m.timestamp) {
113
119
  const ts = new Date(m.timestamp).getTime();
114
120
  if (!Number.isNaN(ts))
@@ -1445,25 +1451,29 @@ export function deriveSessionRecap(row) {
1445
1451
  });
1446
1452
  const userPromptClean = tidied?.headline ?? fallback?.clean;
1447
1453
  const userPromptKind = tidied?.kind ?? fallback?.kind;
1448
- const label = recapLine(row.label);
1449
- const generated = recapLine(row.generatedTitle);
1450
- const prompt = recapLine(userPromptClean || row.topic);
1454
+ const fork = forkSourceOf(row.firstUserMessage ?? row.topic);
1455
+ const ownLabel = row.label && !(fork && row.label.trim() === `fork of ${fork.label}`) ? row.label : undefined;
1456
+ const rungs = [
1457
+ ['label', ownLabel],
1458
+ ['fork', fork?.label],
1459
+ ['generated', row.generatedTitle],
1460
+ ['prompt', userPromptClean],
1461
+ ['prompt', row.topic],
1462
+ ['prompt', row.startedAs],
1463
+ ];
1451
1464
  let title;
1452
1465
  let recapSource;
1453
- if (label) {
1454
- title = label;
1455
- recapSource = 'label';
1456
- }
1457
- else if (generated) {
1458
- title = generated;
1459
- recapSource = 'generated';
1460
- }
1461
- else if (prompt) {
1462
- title = prompt;
1463
- recapSource = 'prompt';
1466
+ for (const [source, candidate] of rungs) {
1467
+ const clean = isPlaceholderSessionName(candidate, row.cwd) ? undefined : recapLine(cleanDisplayTitle(candidate));
1468
+ if (clean) {
1469
+ title = clean;
1470
+ recapSource = source;
1471
+ break;
1472
+ }
1464
1473
  }
1465
1474
  return {
1466
1475
  title,
1476
+ ...(fork?.id ? { forkOf: fork.id } : {}),
1467
1477
  recapSource,
1468
1478
  userPromptClean: recapLine(userPromptClean),
1469
1479
  userPromptKind,
@@ -1495,9 +1505,10 @@ export function deriveImportantMessage(row) {
1495
1505
  return undefined;
1496
1506
  }
1497
1507
  function applyRecap(s) {
1508
+ s.startedAs ??= s.firstUserMessage ? startedAsFromUserTurn(s.firstUserMessage) : undefined;
1498
1509
  const recap = deriveSessionRecap(s);
1499
1510
  s.title = recap.title;
1500
- s.startedAs ??= s.firstUserMessage ? startedAsFromUserTurn(s.firstUserMessage) : undefined;
1511
+ s.forkOf = recap.forkOf;
1501
1512
  s.recapSource = recap.recapSource;
1502
1513
  s.userPromptClean = recap.userPromptClean;
1503
1514
  s.userPromptKind = recap.userPromptKind;
@@ -4,7 +4,7 @@ import type { SessionRecap } from './title.js';
4
4
  import { type IndexedToolCall } from '@phnx-labs/sessions-cli/reader';
5
5
  import { type ToolScanResumePoint } from './tool-store.js';
6
6
  import { type TimelineState } from '@phnx-labs/sessions-cli/reader';
7
- export declare const SCHEMA_VERSION = 52;
7
+ export declare const SCHEMA_VERSION = 53;
8
8
  export declare const CONTENT_INDEX_VERSION = 8;
9
9
  export declare const INSIGHTS_EXTRACTOR_VERSION = 7;
10
10
  export declare const SESSION_SUMMARY_EXTRACTOR_VERSION = 1;
@@ -18,7 +18,7 @@ import { firstUserMessageFromEvents, lastUserMessageFromEvents } from '@phnx-lab
18
18
  import { emptyTimelineState, TIMELINE_EXTRACTOR_VERSION } from '@phnx-labs/sessions-cli/reader';
19
19
  const SESSIONS_DIR = getSessionsDir();
20
20
  const DB_PATH = getSessionsDbPath();
21
- export const SCHEMA_VERSION = 52;
21
+ export const SCHEMA_VERSION = 53;
22
22
  export const CONTENT_INDEX_VERSION = 8;
23
23
  const RESOURCE_INDEX_VERSION = 2;
24
24
  function canonicalLedgerKey(filePath) {
@@ -74,6 +74,7 @@ CREATE TABLE IF NOT EXISTS sessions (
74
74
  is_team_origin INTEGER DEFAULT 0,
75
75
  pr_url TEXT,
76
76
  pr_number INTEGER,
77
+ pr_urls TEXT,
77
78
  worktree_slug TEXT,
78
79
  ticket_id TEXT,
79
80
  spawned_team TEXT,
@@ -1031,6 +1032,15 @@ function migrateSchema(db, fromVersion) {
1031
1032
  `);
1032
1033
  db.exec(`DELETE FROM session_resource_usage WHERE plugin IS NOT NULL AND plugin <> '' AND instr(name, ':') = 0`);
1033
1034
  }
1035
+ if (fromVersion < 53) {
1036
+ const cols = db.prepare(`PRAGMA table_info(sessions)`).all();
1037
+ if (!cols.some(c => c.name === 'pr_urls'))
1038
+ db.exec(`ALTER TABLE sessions ADD COLUMN pr_urls TEXT`);
1039
+ const withPr = db.prepare(`SELECT file_path FROM sessions WHERE pr_url IS NOT NULL AND file_path IS NOT NULL`).all();
1040
+ const dropLedger = db.prepare(`DELETE FROM scan_ledger WHERE file_path = ?`);
1041
+ for (const { file_path } of withPr)
1042
+ dropLedger.run(canonicalLedgerKey(file_path));
1043
+ }
1034
1044
  }
1035
1045
  function backfillClaudeAccounts(db, scope = 'all') {
1036
1046
  const where = scope === 'all'
@@ -1440,7 +1450,7 @@ const upsertSessionStmt = (db) => db.prepare(`
1440
1450
  output_tokens, input_tokens, cache_read_tokens, cache_write_tokens,
1441
1451
  cost_usd, cost_usd_nocache, duration_ms, model, tool_call_count,
1442
1452
  file_path, file_mtime_ms, file_size, scanned_at, is_team_origin,
1443
- pr_url, pr_number, worktree_slug, ticket_id, spawned_team,
1453
+ pr_url, pr_number, pr_urls, worktree_slug, ticket_id, spawned_team,
1444
1454
  sub_agent_count, background_shell_count, plan, todos,
1445
1455
  recent_directories_touched, linear_project, linear_project_url, machine,
1446
1456
  actor, initiated_by, phoenix_id, used_browser, used_computer
@@ -1451,7 +1461,7 @@ const upsertSessionStmt = (db) => db.prepare(`
1451
1461
  @output_tokens, @input_tokens, @cache_read_tokens, @cache_write_tokens,
1452
1462
  @cost_usd, @cost_usd_nocache, @duration_ms, @model, @tool_call_count,
1453
1463
  @file_path, @file_mtime_ms, @file_size, @scanned_at, @is_team_origin,
1454
- @pr_url, @pr_number, @worktree_slug, @ticket_id, @spawned_team,
1464
+ @pr_url, @pr_number, @pr_urls, @worktree_slug, @ticket_id, @spawned_team,
1455
1465
  @sub_agent_count, @background_shell_count, @plan, @todos,
1456
1466
  @recent_directories_touched, @linear_project, @linear_project_url, @machine,
1457
1467
  @actor, @initiated_by, @phoenix_id, @used_browser, @used_computer
@@ -1517,6 +1527,7 @@ const upsertSessionStmt = (db) => db.prepare(`
1517
1527
  is_team_origin = excluded.is_team_origin,
1518
1528
  pr_url = excluded.pr_url,
1519
1529
  pr_number = excluded.pr_number,
1530
+ pr_urls = excluded.pr_urls,
1520
1531
  worktree_slug = excluded.worktree_slug,
1521
1532
  ticket_id = excluded.ticket_id,
1522
1533
  spawned_team = excluded.spawned_team,
@@ -1749,6 +1760,7 @@ export function upsertSession(meta, content, scan, assistantContent = '') {
1749
1760
  is_team_origin: meta.isTeamOrigin ? 1 : 0,
1750
1761
  pr_url: meta.prUrl ?? null,
1751
1762
  pr_number: meta.prNumber ?? null,
1763
+ pr_urls: meta.prUrls ? JSON.stringify(meta.prUrls) : null,
1752
1764
  worktree_slug: meta.worktreeSlug ?? null,
1753
1765
  ticket_id: meta.ticketId ?? null,
1754
1766
  spawned_team: meta.spawnedTeam ?? null,
@@ -1922,6 +1934,7 @@ export function upsertSessionsBatch(entries) {
1922
1934
  is_team_origin: meta.isTeamOrigin ? 1 : 0,
1923
1935
  pr_url: meta.prUrl ?? null,
1924
1936
  pr_number: meta.prNumber ?? null,
1937
+ pr_urls: meta.prUrls ? JSON.stringify(meta.prUrls) : null,
1925
1938
  worktree_slug: meta.worktreeSlug ?? null,
1926
1939
  ticket_id: meta.ticketId ?? null,
1927
1940
  spawned_team: meta.spawnedTeam ?? null,
@@ -2115,6 +2128,7 @@ function rowToMeta(row) {
2115
2128
  isTeamOrigin: row.is_team_origin === 1,
2116
2129
  prUrl: row.pr_url ?? undefined,
2117
2130
  prNumber: row.pr_number ?? undefined,
2131
+ prUrls: parseJsonColumn(row.pr_urls),
2118
2132
  worktreeSlug: row.worktree_slug ?? undefined,
2119
2133
  ticketId: row.ticket_id ?? undefined,
2120
2134
  spawnedTeam: row.spawned_team ?? undefined,
@@ -58,6 +58,7 @@ interface ClaudeSessionScan {
58
58
  assistantText?: string;
59
59
  prUrl?: string;
60
60
  prNumber?: number;
61
+ prUrls?: string[];
61
62
  worktreeSlug?: string;
62
63
  ticketId?: string;
63
64
  createdTickets?: string[];
@@ -99,6 +100,7 @@ interface CodexSessionScan {
99
100
  assistantText?: string;
100
101
  prUrl?: string;
101
102
  prNumber?: number;
103
+ prUrls?: string[];
102
104
  worktreeSlug?: string;
103
105
  ticketId?: string;
104
106
  createdTickets?: string[];
@@ -201,9 +203,10 @@ interface ClaudeParseState {
201
203
  seenAssistantIds: Set<string>;
202
204
  userTexts: string[];
203
205
  assistantTexts: string[];
204
- sawPrCreate: boolean;
206
+ pendingPrCreates: Set<string>;
205
207
  prUrl?: string;
206
208
  prNumber?: number;
209
+ prUrls: string[];
207
210
  createdTickets: Set<string>;
208
211
  pendingTicketTools: Set<string>;
209
212
  spawnedTeam?: string;
@@ -253,9 +256,10 @@ export interface ClaudeParserState {
253
256
  costUsdNoCache: number;
254
257
  seenIdsSize: number;
255
258
  seenIdsRecent: string[];
256
- sawPrCreate: boolean;
259
+ pendingPrCreates?: string[];
257
260
  prUrl?: string;
258
261
  prNumber?: number;
262
+ prUrls?: string[];
259
263
  pendingTicketTools: string[];
260
264
  createdTickets: string[];
261
265
  spawnedTeam?: string;
@@ -304,9 +308,10 @@ interface CodexParseState {
304
308
  lastTsMs?: number;
305
309
  userTexts: string[];
306
310
  assistantTexts: string[];
307
- sawPrCreate: boolean;
311
+ pendingPrCreates: Set<string>;
308
312
  prUrl?: string;
309
313
  prNumber?: number;
314
+ prUrls: string[];
310
315
  createdTickets: Set<string>;
311
316
  pendingTicketTools: Set<string>;
312
317
  spawnedTeam?: string;
@@ -317,6 +322,8 @@ interface CodexParseState {
317
322
  slashCommandEvents: SessionEvent[];
318
323
  }
319
324
  export declare function initCodexParseState(): CodexParseState;
325
+ export declare function applyCodexLine(state: CodexParseState, parsed: any): void;
326
+ export declare function finalizeCodexScan(state: CodexParseState): CodexSessionScan;
320
327
  export interface CodexParserState {
321
328
  v: 4;
322
329
  offset: number;
@@ -334,9 +341,10 @@ export interface CodexParserState {
334
341
  lastTotalTokenUsage?: any;
335
342
  firstTsMs?: number;
336
343
  lastTsMs?: number;
337
- sawPrCreate: boolean;
344
+ pendingPrCreates?: string[];
338
345
  prUrl?: string;
339
346
  prNumber?: number;
347
+ prUrls?: string[];
340
348
  pendingTicketTools: string[];
341
349
  createdTickets: string[];
342
350
  spawnedTeam?: string;
@@ -348,6 +356,7 @@ export interface CodexParserState {
348
356
  toolCalls: ToolCallCollectorSnapshot;
349
357
  }
350
358
  export declare function serializeCodexParserState(state: CodexParseState, offset: number, jsonlDroppingOversizedLine?: boolean): CodexParserState;
359
+ export declare function hydrateCodexParseState(prior: CodexParserState): CodexParseState;
351
360
  export declare function scanCodexSessionIncremental(filePath: string, fromOffset: number, prior: CodexParserState): Promise<{
352
361
  scan: CodexSessionScan;
353
362
  newState: CodexParserState;
@@ -799,6 +799,7 @@ async function readClaudeMeta(filePath, sessionId, scanStamp, priorRow, names =
799
799
  isTeamOrigin,
800
800
  prUrl: scan.prUrl,
801
801
  prNumber: scan.prNumber,
802
+ prUrls: scan.prUrls,
802
803
  worktreeSlug: scan.worktreeSlug,
803
804
  ticketId: scan.ticketId,
804
805
  createdTickets: scan.createdTickets,
@@ -841,6 +842,7 @@ async function readClaudeMeta(filePath, sessionId, scanStamp, priorRow, names =
841
842
  isTeamOrigin,
842
843
  prUrl: scan.prUrl,
843
844
  prNumber: scan.prNumber,
845
+ prUrls: scan.prUrls,
844
846
  worktreeSlug: scan.worktreeSlug,
845
847
  ticketId: scan.ticketId,
846
848
  createdTickets: scan.createdTickets,
@@ -1082,6 +1084,7 @@ export async function readCodexMeta(filePath, resolveAccount, currentVersion, sc
1082
1084
  account: resolveAccount?.(),
1083
1085
  prUrl: scan.prUrl,
1084
1086
  prNumber: scan.prNumber,
1087
+ prUrls: scan.prUrls,
1085
1088
  worktreeSlug: scan.worktreeSlug,
1086
1089
  ticketId: scan.ticketId,
1087
1090
  createdTickets: scan.createdTickets,
@@ -2146,9 +2149,10 @@ export function initClaudeParseState() {
2146
2149
  seenAssistantIds: new Set(),
2147
2150
  userTexts: [],
2148
2151
  assistantTexts: [],
2149
- sawPrCreate: false,
2152
+ pendingPrCreates: new Set(),
2150
2153
  prUrl: undefined,
2151
2154
  prNumber: undefined,
2155
+ prUrls: [],
2152
2156
  createdTickets: new Set(),
2153
2157
  pendingTicketTools: new Set(),
2154
2158
  spawnedTeam: undefined,
@@ -2234,27 +2238,21 @@ export function applyClaudeLine(state, parsed) {
2234
2238
  state.createdTickets.add(t);
2235
2239
  }
2236
2240
  }
2237
- if (!state.prUrl) {
2238
- if (!state.sawPrCreate && parsed.type === 'assistant' && Array.isArray(parsed.message?.content)) {
2239
- for (const b of parsed.message.content) {
2240
- if (b?.type === 'tool_use' && typeof b?.input?.command === 'string' && isPrCreateCommand(b.input.command)) {
2241
- state.sawPrCreate = true;
2242
- }
2241
+ if (parsed.type === 'assistant' && Array.isArray(parsed.message?.content)) {
2242
+ for (const b of parsed.message.content) {
2243
+ if (b?.type === 'tool_use' && typeof b?.id === 'string' && typeof b?.input?.command === 'string' && isPrCreateCommand(b.input.command)) {
2244
+ state.pendingPrCreates.add(b.id);
2243
2245
  }
2244
2246
  }
2245
- if (state.sawPrCreate && parsed.type === 'user' && Array.isArray(parsed.message?.content)) {
2246
- for (const b of parsed.message.content) {
2247
- if (b?.type !== 'tool_result')
2248
- continue;
2249
- const text = typeof b.content === 'string'
2250
- ? b.content
2251
- : Array.isArray(b.content) ? b.content.map((c) => c?.text || '').join('\n') : '';
2252
- const pr = extractPrUrl(text);
2253
- if (pr) {
2254
- state.prUrl = pr.url;
2255
- state.prNumber = pr.number;
2256
- }
2257
- }
2247
+ }
2248
+ if (state.pendingPrCreates.size > 0 && parsed.type === 'user' && Array.isArray(parsed.message?.content)) {
2249
+ for (const b of parsed.message.content) {
2250
+ if (b?.type !== 'tool_result' || !state.pendingPrCreates.delete(b.tool_use_id))
2251
+ continue;
2252
+ const text = typeof b.content === 'string'
2253
+ ? b.content
2254
+ : Array.isArray(b.content) ? b.content.map((c) => c?.text || '').join('\n') : '';
2255
+ recordCreatedPr(state, extractPrUrl(text));
2258
2256
  }
2259
2257
  }
2260
2258
  if (typeof parsed.timestamp === 'string') {
@@ -2389,6 +2387,7 @@ export function finalizeClaudeScan(state, sessionFile) {
2389
2387
  assistantText: state.assistantTexts.length > 0 ? state.assistantTexts.join('\n') : undefined,
2390
2388
  prUrl: state.prUrl,
2391
2389
  prNumber: state.prNumber,
2390
+ prUrls: state.prUrls.length > 1 ? [...state.prUrls] : undefined,
2392
2391
  worktreeSlug: worktree?.slug,
2393
2392
  ticketId: ticket?.id,
2394
2393
  createdTickets: state.createdTickets.size > 0 ? [...state.createdTickets] : undefined,
@@ -2466,9 +2465,10 @@ export function serializeClaudeParserState(state, offset, jsonlDroppingOversized
2466
2465
  costUsdNoCache: state.costUsdNoCache,
2467
2466
  seenIdsSize: state.seenAssistantIds.size,
2468
2467
  seenIdsRecent,
2469
- sawPrCreate: state.sawPrCreate,
2468
+ pendingPrCreates: [...state.pendingPrCreates],
2470
2469
  prUrl: state.prUrl,
2471
2470
  prNumber: state.prNumber,
2471
+ prUrls: state.prUrls,
2472
2472
  pendingTicketTools: [...state.pendingTicketTools],
2473
2473
  createdTickets: [...state.createdTickets],
2474
2474
  spawnedTeam: state.spawnedTeam,
@@ -2520,9 +2520,10 @@ export function hydrateClaudeParseState(prior) {
2520
2520
  assistantTexts: prior.assistantContentText !== undefined && prior.assistantContentText.length > 0
2521
2521
  ? [prior.assistantContentText]
2522
2522
  : [],
2523
- sawPrCreate: prior.sawPrCreate,
2523
+ pendingPrCreates: new Set(prior.pendingPrCreates),
2524
2524
  prUrl: prior.prUrl,
2525
2525
  prNumber: prior.prNumber,
2526
+ prUrls: prior.prUrls ?? (prior.prUrl ? [prior.prUrl] : []),
2526
2527
  createdTickets: new Set(prior.createdTickets),
2527
2528
  pendingTicketTools: new Set(prior.pendingTicketTools),
2528
2529
  spawnedTeam: prior.spawnedTeam,
@@ -2593,6 +2594,16 @@ async function claudeSessionIdentityAt(filePath, maxBytes = 1_048_576) {
2593
2594
  }
2594
2595
  return state.timestamp;
2595
2596
  }
2597
+ function recordCreatedPr(state, pr) {
2598
+ if (!pr)
2599
+ return;
2600
+ if (!state.prUrl) {
2601
+ state.prUrl = pr.url;
2602
+ state.prNumber = pr.number;
2603
+ }
2604
+ if (!state.prUrls.includes(pr.url))
2605
+ state.prUrls.push(pr.url);
2606
+ }
2596
2607
  function parsePriorClaudeState(row) {
2597
2608
  if (!row?.parserState)
2598
2609
  return null;
@@ -2632,9 +2643,10 @@ export function initCodexParseState() {
2632
2643
  lastTsMs: undefined,
2633
2644
  userTexts: [],
2634
2645
  assistantTexts: [],
2635
- sawPrCreate: false,
2646
+ pendingPrCreates: new Set(),
2636
2647
  prUrl: undefined,
2637
2648
  prNumber: undefined,
2649
+ prUrls: [],
2638
2650
  createdTickets: new Set(),
2639
2651
  pendingTicketTools: new Set(),
2640
2652
  spawnedTeam: undefined,
@@ -2645,7 +2657,7 @@ export function initCodexParseState() {
2645
2657
  slashCommandEvents: [],
2646
2658
  };
2647
2659
  }
2648
- function applyCodexLine(state, parsed) {
2660
+ export function applyCodexLine(state, parsed) {
2649
2661
  collectCodexToolCalls(state.toolCollector, parsed);
2650
2662
  if (parsed.type === 'response_item') {
2651
2663
  const p = parsed.payload || {};
@@ -2661,8 +2673,8 @@ function applyCodexLine(state, parsed) {
2661
2673
  type: 'tool_use', agent: 'codex', timestamp: parsed.timestamp || '', tool: p.name, args,
2662
2674
  path: args.file_path || args.path, command: cmd || undefined,
2663
2675
  });
2664
- if (!state.prUrl && !state.sawPrCreate && isPrCreateCommand(cmd))
2665
- state.sawPrCreate = true;
2676
+ if (typeof p.call_id === 'string' && isPrCreateCommand(cmd))
2677
+ state.pendingPrCreates.add(p.call_id);
2666
2678
  if (!state.spawnedTeam) {
2667
2679
  const team = detectSpawnedTeam(cmd);
2668
2680
  if (team)
@@ -2673,13 +2685,8 @@ function applyCodexLine(state, parsed) {
2673
2685
  }
2674
2686
  }
2675
2687
  if (p.type === 'function_call_output') {
2676
- if (!state.prUrl && state.sawPrCreate) {
2677
- const pr = extractPrUrl(String(p.output || ''));
2678
- if (pr) {
2679
- state.prUrl = pr.url;
2680
- state.prNumber = pr.number;
2681
- }
2682
- }
2688
+ if (typeof p.call_id === 'string' && state.pendingPrCreates.delete(p.call_id))
2689
+ recordCreatedPr(state, extractPrUrl(String(p.output || '')));
2683
2690
  if (typeof p.call_id === 'string' && state.pendingTicketTools.has(p.call_id)) {
2684
2691
  state.pendingTicketTools.delete(p.call_id);
2685
2692
  const t = extractCreatedTicket(String(p.output || ''));
@@ -2752,7 +2759,7 @@ function applyCodexLine(state, parsed) {
2752
2759
  state.model = parsed.payload.info.model;
2753
2760
  }
2754
2761
  }
2755
- function finalizeCodexScan(state) {
2762
+ export function finalizeCodexScan(state) {
2756
2763
  const snap = state.lastTotalTokenUsage;
2757
2764
  const outputTokens = snap
2758
2765
  ? (snap.output_tokens ?? 0) + (snap.reasoning_output_tokens ?? 0)
@@ -2806,6 +2813,7 @@ function finalizeCodexScan(state) {
2806
2813
  assistantText: state.assistantTexts.length > 0 ? state.assistantTexts.join('\n') : undefined,
2807
2814
  prUrl: state.prUrl,
2808
2815
  prNumber: state.prNumber,
2816
+ prUrls: state.prUrls.length > 1 ? [...state.prUrls] : undefined,
2809
2817
  worktreeSlug: worktree?.slug,
2810
2818
  ticketId: ticket?.id,
2811
2819
  createdTickets: state.createdTickets.size > 0 ? [...state.createdTickets] : undefined,
@@ -2857,9 +2865,10 @@ export function serializeCodexParserState(state, offset, jsonlDroppingOversizedL
2857
2865
  lastTotalTokenUsage: state.lastTotalTokenUsage,
2858
2866
  firstTsMs: state.firstTsMs,
2859
2867
  lastTsMs: state.lastTsMs,
2860
- sawPrCreate: state.sawPrCreate,
2868
+ pendingPrCreates: [...state.pendingPrCreates],
2861
2869
  prUrl: state.prUrl,
2862
2870
  prNumber: state.prNumber,
2871
+ prUrls: state.prUrls,
2863
2872
  pendingTicketTools: [...state.pendingTicketTools],
2864
2873
  createdTickets: [...state.createdTickets],
2865
2874
  spawnedTeam: state.spawnedTeam,
@@ -2871,7 +2880,7 @@ export function serializeCodexParserState(state, offset, jsonlDroppingOversizedL
2871
2880
  toolCalls: state.toolCollector.snapshot(),
2872
2881
  };
2873
2882
  }
2874
- function hydrateCodexParseState(prior) {
2883
+ export function hydrateCodexParseState(prior) {
2875
2884
  return {
2876
2885
  sessionId: prior.sessionId,
2877
2886
  timestamp: prior.timestamp,
@@ -2890,9 +2899,10 @@ function hydrateCodexParseState(prior) {
2890
2899
  assistantTexts: prior.assistantContentText !== undefined && prior.assistantContentText.length > 0
2891
2900
  ? [prior.assistantContentText]
2892
2901
  : [],
2893
- sawPrCreate: prior.sawPrCreate,
2902
+ pendingPrCreates: new Set(prior.pendingPrCreates),
2894
2903
  prUrl: prior.prUrl,
2895
2904
  prNumber: prior.prNumber,
2905
+ prUrls: prior.prUrls ?? (prior.prUrl ? [prior.prUrl] : []),
2896
2906
  createdTickets: new Set(prior.createdTickets),
2897
2907
  pendingTicketTools: new Set(prior.pendingTicketTools),
2898
2908
  spawnedTeam: prior.spawnedTeam,
@@ -15,6 +15,11 @@ interface ForkRecapInput {
15
15
  lastAssistant?: string;
16
16
  changes?: ForkRecapChanges;
17
17
  }
18
- export declare function forkLabelFor(session: Pick<SessionMeta, 'label' | 'generatedTitle' | 'topic' | 'shortId'>): string;
18
+ export declare function forkLabelFor(session: Pick<SessionMeta, 'label' | 'generatedTitle' | 'topic' | 'shortId' | 'cwd'>): string;
19
+ export interface ForkSource {
20
+ label: string;
21
+ id?: string;
22
+ }
23
+ export declare function forkSourceOf(firstUserMessage: string | null | undefined): ForkSource | undefined;
19
24
  export declare function buildForkRecap(input: ForkRecapInput): string;
20
25
  export {};
@@ -9,6 +9,15 @@ function trimLastLine(text) {
9
9
  export function forkLabelFor(session) {
10
10
  return sessionHeadline(session) || session.shortId;
11
11
  }
12
+ const FORK_OPENING_RE = /^Continue a prior \S+ session \("(.+)"\)\. Pick up where it left off/;
13
+ const FORK_SOURCE_RE = /run `\/continue ([^`\s]+)` if you need the full transcript\.$/m;
14
+ export function forkSourceOf(firstUserMessage) {
15
+ const label = firstUserMessage ? FORK_OPENING_RE.exec(firstUserMessage)?.[1] : undefined;
16
+ if (!label)
17
+ return undefined;
18
+ const id = FORK_SOURCE_RE.exec(firstUserMessage)?.[1];
19
+ return id ? { label, id } : { label };
20
+ }
12
21
  export function buildForkRecap(input) {
13
22
  const lines = [];
14
23
  lines.push(`Continue a prior ${input.agent} session ("${input.label}"). Pick up where it left off — do not restart it.`);
@@ -10,7 +10,7 @@ import { machineId, normalizeHost } from '../../machine-id.js';
10
10
  import { shellQuote } from '../../ssh-exec.js';
11
11
  import { streamFromPeer } from './peer-stream.js';
12
12
  import { buildWindowsAgentsCommand, remoteShellFor } from '../../hosts/remote-cmd.js';
13
- import { artifactKind, deriveImportantMessage, deriveSessionRecap, isReapableOrphan, sessionAccountLabel } from '../active.js';
13
+ import { artifactKind, deriveImportantMessage, deriveSessionRecap, isReapableOrphan, prsFromUrls, sessionAccountLabel } from '../active.js';
14
14
  import { loadSessionPreviewDigest, readCachedPreviewDigest } from '../preview-digest.js';
15
15
  import { indexArtifactSidecars, mergeArtifacts } from '@phnx-labs/sessions-cli/reader';
16
16
  import { listNativeAccounts } from '../../account-registry.js';
@@ -73,9 +73,6 @@ function epochMs(value) {
73
73
  function previousSessionWatchRowKey(scope, sessionId) {
74
74
  return createHash('sha256').update(`${scope}\0previous\0${sessionId}`).digest('base64url').slice(0, 22);
75
75
  }
76
- function previousRowTitle(session, foldedHeadline) {
77
- return session.label || session.generatedTitle || foldedHeadline || session.topic || undefined;
78
- }
79
76
  function previousRowCard(session, request, attachments) {
80
77
  const digest = readCachedPreviewDigest(session);
81
78
  const recap = deriveSessionRecap({
@@ -89,6 +86,8 @@ function previousRowCard(session, request, attachments) {
89
86
  const todos = digest?.todos ?? session.todos;
90
87
  const importantMessage = deriveImportantMessage({ status: 'closed', lastAgentLine: recap.lastAgentLine });
91
88
  return {
89
+ ...(recap.title ? { title: recap.title } : {}),
90
+ ...(recap.forkOf ? { forkOf: recap.forkOf } : {}),
92
91
  ...(recap.lastAgentLine ? { lastAgentLine: recap.lastAgentLine } : {}),
93
92
  ...(recap.request ? { request: recap.request } : {}),
94
93
  ...(recap.userPromptClean ? { userPromptClean: recap.userPromptClean } : {}),
@@ -116,7 +115,6 @@ export function toPreviousSessionWatchRow(scope, session, accounts = listNativeA
116
115
  : readSessionSummaryAny(session.id);
117
116
  const folded = readSessionTimelineAny(session.id);
118
117
  const model = folded?.model ?? session.model;
119
- const title = previousRowTitle(session, folded?.request?.headline);
120
118
  const card = previousRowCard(session, folded?.request, folded?.attachments);
121
119
  return {
122
120
  context: 'recent',
@@ -129,13 +127,13 @@ export function toPreviousSessionWatchRow(scope, session, accounts = listNativeA
129
127
  confirmedProject: confirmedProjectForCwd(session.cwd) ?? null,
130
128
  ...(session.label ? { label: session.label } : {}),
131
129
  ...(session.generatedTitle ? { generatedTitle: session.generatedTitle } : {}),
132
- ...(title ? { title } : {}),
133
130
  ...(session.topic ? { topic: session.topic } : {}),
134
131
  ...(session.firstUserMessage ? { firstUserMessage: session.firstUserMessage } : {}),
135
132
  ...(session.version ? { version: session.version } : {}),
136
133
  ...(session.account ? { account: session.account } : {}),
137
134
  accountLabel: sessionAccountLabel(session.agent, session, accounts),
138
135
  ...(session.prUrl ? { pr: { url: session.prUrl, number: session.prNumber } } : {}),
136
+ ...(session.prUrls ? { prs: prsFromUrls(session.prUrls) } : {}),
139
137
  ...(worktree ? { worktree } : {}),
140
138
  ...(session.gitBranch ? { branch: session.gitBranch } : {}),
141
139
  ...(session.ticketId ? { ticket: { id: session.ticketId, url: linearIssueUrl(session.ticketId) } } : {}),
@@ -25,7 +25,10 @@ export declare function sessionHeadline<T extends {
25
25
  label?: string | null;
26
26
  generatedTitle?: string | null;
27
27
  topic?: string | null;
28
+ cwd?: string | null;
28
29
  }>(row: CarriesTitleRung<T>): string | undefined;
30
+ export declare function isPlaceholderSessionName(name: string | null | undefined, cwd?: string | null): boolean;
31
+ export declare function cleanDisplayTitle(raw: string | null | undefined): string | undefined;
29
32
  export interface SessionRecap {
30
33
  text: string;
31
34
  at: string;
@@ -69,7 +69,38 @@ export function sanitizeGeneratedTitle(raw) {
69
69
  return title || undefined;
70
70
  }
71
71
  export function sessionHeadline(row) {
72
- return row.label || row.generatedTitle || row.topic || undefined;
72
+ const label = isPlaceholderSessionName(row.label, row.cwd) ? undefined : row.label;
73
+ return label || row.generatedTitle || row.topic || undefined;
74
+ }
75
+ const HOST_FALLBACK_LABEL_RE = /^\[host\/[^\]]+\]$/;
76
+ const PLACEHOLDER_SUFFIX_RE = /^(?:\d+|(?=[0-9a-f]*\d)[0-9a-f]{1,4})$/i;
77
+ export function isPlaceholderSessionName(name, cwd) {
78
+ const n = name?.trim();
79
+ if (!n)
80
+ return false;
81
+ if (HOST_FALLBACK_LABEL_RE.test(n))
82
+ return true;
83
+ const dir = cwd?.replace(/[/\\]+$/, '').split(/[/\\]/).pop();
84
+ if (!dir || n.length <= dir.length + 1)
85
+ return false;
86
+ return n.slice(0, dir.length + 1).toLowerCase() === `${dir.toLowerCase()}-` && PLACEHOLDER_SUFFIX_RE.test(n.slice(dir.length + 1));
87
+ }
88
+ const INJECTED_NOTE_RE = /^another \w+ session sent a message:?\s*/i;
89
+ export function cleanDisplayTitle(raw) {
90
+ if (!raw || /^\s*<(?:task-notification|system-reminder)/i.test(raw))
91
+ return undefined;
92
+ const t = raw
93
+ .replace(/<\/?agent-message[^>]*>/gi, ' ')
94
+ .replace(INJECTED_NOTE_RE, '')
95
+ .replace(/\[([^\]]+)\]\([^)]*(?:\)|$)/g, '$1')
96
+ .replace(/[`*]+/g, '')
97
+ .replace(/^[#>\s]+/, '')
98
+ .replace(/\s+/g, ' ')
99
+ .trim()
100
+ .replace(/^[…. ]+$/, '');
101
+ if (!t || /^\[subagent hand-back\]/i.test(t) || /^\/[\w:-]+(?:\s|$)/.test(t))
102
+ return undefined;
103
+ return t;
73
104
  }
74
105
  const CLAUDE_RECAP_HINT_RE = /\s*\(disable recaps in \/config\)\s*$/i;
75
106
  export function claudeRecapFromLine(parsed) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.30",
3
+ "version": "1.23.32",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -89,7 +89,7 @@
89
89
  "@fontsource/jetbrains-mono": "^5.3.0",
90
90
  "@inquirer/prompts": "8.5.2",
91
91
  "@phnx-labs/secrets-cli": "0.4.0",
92
- "@phnx-labs/sessions-cli": "0.8.7",
92
+ "@phnx-labs/sessions-cli": "0.8.9",
93
93
  "@resvg/resvg-wasm": "^2.6.2",
94
94
  "@types/proper-lockfile": "4.1.4",
95
95
  "@zed-industries/agent-client-protocol": "0.4.5",