Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(transcripts): skip Claude Code Remote Control state files (#5597, #5702)
garrytanf68650fafa12
diff --git a/src/commands/transcripts.ts b/src/commands/transcripts.tsindex 09e20bcfda..1a7829fa19 100644--- a/src/commands/transcripts.ts+++ b/src/commands/transcripts.ts@@ -25,6 +25,7 @@ import { isGrokSessionSidecarStrict } from '../core/transcripts/grok.ts';import {isClaudeCodeSubagentFile,isClaudeCodeWorkflowArtifactFile,+ isClaudeCodeRemoteControlStateFile,} from '../core/transcripts/claude-code.ts';interface RecentOpts {@@ -248,7 +249,10 @@ const IMPORTABLE_EXTENSIONS = ['.jsonl', '.db', '.json'];* via the STRICT (evidence-checked) grok predicate: these are user-supplied* paths with no format scope, and the broad bare-UUID heuristic silently* dropped explicit sessions that merely lived under a UUID-named directory.- * Exported for tests.+ * Claude Code Remote Control state files (`<uuid>.ccr-tip.json`,+ * `bridge-pointer.json`) are excluded the same way (#5597): they match the+ * `.json` importable extension, are not transcripts, and would otherwise+ * fail every run with `unknown format`. Exported for tests.*//*** Shell-style tilde expansion for a user path spec: a bare `~` or a leading@@ -298,7 +302,8 @@ export async function expandPaths(specs: string[]): Promise<string[]> {!isOpenclawCheckpointFile(p) &&!isGrokSessionSidecarStrict(p) &&!isClaudeCodeSubagentFile(p) &&- !isClaudeCodeWorkflowArtifactFile(p),+ !isClaudeCodeWorkflowArtifactFile(p) &&+ !isClaudeCodeRemoteControlStateFile(p),);}diff --git a/src/core/transcripts/claude-code.ts b/src/core/transcripts/claude-code.tsindex e886d8aca1..389e2a7db9 100644--- a/src/core/transcripts/claude-code.ts+++ b/src/core/transcripts/claude-code.ts@@ -81,6 +81,20 @@ export function isClaudeCodeWorkflowArtifactFile(path: string): boolean {return i !== -1 && segs[i + 1] === 'workflows' && segs.length > i + 2;}+/**+ * Claude Code Remote Control state files written next to session JSONL+ * (`<session-uuid>.ccr-tip.json`, `bridge-pointer.json`). They match the+ * importable `.json` extension but are never transcripts (#5597).+ */+const CCR_TIP_SUFFIX = '.ccr-tip.json';+const CCR_BRIDGE_POINTER = 'bridge-pointer.json';++/** True for Claude Code Remote Control state files (never transcripts). */+export function isClaudeCodeRemoteControlStateFile(path: string): boolean {+ const base = path.split(/[/\\]/).pop() ?? '';+ return base.endsWith(CCR_TIP_SUFFIX) || base === CCR_BRIDGE_POINTER;+}+/** Keys that mark a Claude Code project transcript. */function looksLikeClaudeLine(obj: Record<string, unknown>): boolean {if (diff --git a/test/transcripts-expand-paths.test.ts b/test/transcripts-expand-paths.test.tsindex a2b2c73d51..639881aac1 100644--- a/test/transcripts-expand-paths.test.ts+++ b/test/transcripts-expand-paths.test.ts@@ -17,6 +17,7 @@ import { tmpdir } from 'node:os';import { expandPaths, expandTilde } from '../src/commands/transcripts.ts';import { homedir } from 'node:os';import { isGrokSessionSidecarStrict } from '../src/core/transcripts/grok.ts';+import { isClaudeCodeRemoteControlStateFile } from '../src/core/transcripts/claude-code.ts';const UUID = '123e4567-e89b-42d3-a456-426614174000';@@ -95,6 +96,52 @@ describe('expandPaths grok-sidecar scoping', () => {});});+describe('expandPaths Claude Code Remote Control state files (#5597)', () => {+ const SESSION = '18c0ffee-1234-4321-9999-abcdefabcdef';++ test('the predicate claims the two Remote Control names on either path separator', () => {+ expect(isClaudeCodeRemoteControlStateFile(`/home/u/.claude/projects/proj/${SESSION}.ccr-tip.json`)).toBe(true);+ expect(isClaudeCodeRemoteControlStateFile(`C:\\Users\\u\\.claude\\projects\\proj\\bridge-pointer.json`)).toBe(true);+ // A session file, and a consumer export, are never claimed.+ expect(isClaudeCodeRemoteControlStateFile(`/home/u/.claude/projects/proj/${SESSION}.jsonl`)).toBe(false);+ expect(isClaudeCodeRemoteControlStateFile('/home/u/exports/conversations.json')).toBe(false);+ // Near-miss names stay legitimate.+ expect(isClaudeCodeRemoteControlStateFile('/home/u/.claude/projects/proj/ccr-tip.json')).toBe(false);+ expect(isClaudeCodeRemoteControlStateFile('/home/u/.claude/projects/proj/bridge-pointer.jsonl')).toBe(false);+ });++ test('directory expansion drops ccr-tip.json + bridge-pointer.json and keeps sessions + exports', async () => {+ const d = tdir();+ const proj = join(d, '.claude', 'projects', 'proj-slug');+ mkdirSync(proj, { recursive: true });+ const session = join(proj, `${SESSION}.jsonl`);+ writeFileSync(+ session,+ JSON.stringify({ sessionId: 's1', type: 'user', message: { role: 'user', content: 'hi' } }) + '\n',+ );+ const tip = join(proj, `${SESSION}.ccr-tip.json`);+ writeFileSync(tip, '{"tip":true}');+ const bridge = join(proj, 'bridge-pointer.json');+ writeFileSync(bridge, '{"bridge":true}');+ const exportJson = join(proj, 'conversations.json');+ writeFileSync(exportJson, '[]');+ // Glob order is filesystem order — compare as sets.+ expect((await expandPaths([proj])).sort()).toEqual([session, exportJson].sort());+ });++ test('even when named explicitly, a Remote Control state file never imports', async () => {+ const d = tdir();+ const proj = join(d, '.claude', 'projects', 'proj-slug');+ mkdirSync(proj, { recursive: true });+ const tip = join(proj, `${SESSION}.ccr-tip.json`);+ writeFileSync(tip, '{"tip":true}');+ const bridge = join(proj, 'bridge-pointer.json');+ writeFileSync(bridge, '{"bridge":true}');+ expect(await expandPaths([tip])).toEqual([]);+ expect(await expandPaths([bridge])).toEqual([]);+ });+});+describe('expandPaths tilde expansion', () => {test('expandTilde: bare ~ and ~/x resolve to the home dir; a mid-string ~ is untouched', () => {expect(expandTilde('~')).toBe(homedir());