Skip to content

Commit 0add9ff

Browse files
jalehmanclaude
andcommitted
fix(gateway): cover isVisibleInTranscriptOnly harness rows; absorb provenance helper
Claude Code groups isMeta, isCompactSummary, and isVisibleInTranscriptOnly as its own "not a real operator turn" predicate (verified in the v2.1.246 bundle); import all three through one canonical predicate. Inline the one-use provenance literal at the importer, returning input-provenance.ts to its main state. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent 63b6739 commit 0add9ff

4 files changed

Lines changed: 38 additions & 18 deletions

File tree

‎src/gateway/cli-session-history.claude-snapshot.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const OVERSIZED_ENTRY_WORKER_SOURCE = `
4444
isSidechain: entry.isSidechain === true,
4545
isMeta: entry.isMeta === true,
4646
isCompactSummary: entry.isCompactSummary === true,
47+
isVisibleInTranscriptOnly: entry.isVisibleInTranscriptOnly === true,
4748
message: {
4849
role: type,
4950
content: ${JSON.stringify(OVERSIZED_HISTORY_PLACEHOLDER)},
@@ -82,6 +83,7 @@ function normalizeOversizedEntry(value: unknown): ClaudeCliProjectEntry | null {
8283
...(value.isSidechain === true ? { isSidechain: true } : {}),
8384
...(value.isMeta === true ? { isMeta: true } : {}),
8485
...(value.isCompactSummary === true ? { isCompactSummary: true } : {}),
86+
...(value.isVisibleInTranscriptOnly === true ? { isVisibleInTranscriptOnly: true } : {}),
8587
message: {
8688
role: value.type,
8789
content: OVERSIZED_HISTORY_PLACEHOLDER,

‎src/gateway/cli-session-history.claude.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
getCliSessionBinding,
2323
normalizeCliSessionReseedReceipt,
2424
} from "../config/sessions/cli-session-binding.js";
25-
import { buildCliHarnessContextInputProvenance } from "../sessions/input-provenance.js";
2625
import { attachOpenClawTranscriptMeta } from "./session-transcript-readers.js";
2726

2827
export const CLAUDE_CLI_PROVIDER = "claude-cli";
@@ -35,6 +34,7 @@ export type ClaudeCliProjectEntry = {
3534
isSidechain?: unknown;
3635
isMeta?: unknown;
3736
isCompactSummary?: unknown;
37+
isVisibleInTranscriptOnly?: unknown;
3838
message?: {
3939
role?: unknown;
4040
content?: unknown;
@@ -275,11 +275,24 @@ type ClaudeCliPromptTextCandidate = {
275275
blockIndex?: number;
276276
};
277277

278+
// Claude marks harness-written user turns with isMeta (skill instruction
279+
// bodies, injected notices), isCompactSummary (compaction summaries), and
280+
// isVisibleInTranscriptOnly (transcript-only synthetic rows); its own UI
281+
// groups these flags as "not a real operator turn" (verified against the
282+
// v2.1.246 bundle). The operator never typed these rows.
283+
function isClaudeCliHarnessInjectedEntry(entry: ClaudeCliProjectEntry): boolean {
284+
return (
285+
entry.isMeta === true ||
286+
entry.isCompactSummary === true ||
287+
entry.isVisibleInTranscriptOnly === true
288+
);
289+
}
290+
278291
export function resolveClaudeCliPromptTextCandidates(
279292
entry: ClaudeCliProjectEntry,
280293
content: string | unknown[],
281294
): ClaudeCliPromptTextCandidate[] {
282-
if (entry.isMeta === true || entry.isCompactSummary === true) {
295+
if (isClaudeCliHarnessInjectedEntry(entry)) {
283296
return [];
284297
}
285298
if (typeof content === "string") {
@@ -397,16 +410,16 @@ export function parseClaudeCliHistoryEntry(
397410
}
398411
}
399412
}
400-
// Claude marks harness-written user turns (skill instruction bodies,
401-
// continuation summaries) with isMeta/isCompactSummary. Record that
402-
// provenance here, where the native flag is known, so downstream display
403-
// never has to infer operator authorship from message text.
404-
const harnessInjected = entry.isMeta === true || entry.isCompactSummary === true;
413+
// Record provenance here, where the native flags are known, so downstream
414+
// display never has to infer operator authorship from message text.
415+
const harnessInjected = isClaudeCliHarnessInjectedEntry(entry);
405416
return attachOpenClawTranscriptMeta(
406417
{
407418
role: "user",
408419
content,
409-
...(harnessInjected ? { provenance: buildCliHarnessContextInputProvenance() } : {}),
420+
...(harnessInjected
421+
? { provenance: { kind: "internal_system", sourceTool: "cli_harness_context" } }
422+
: {}),
410423
...(timestamp !== undefined ? { timestamp } : {}),
411424
},
412425
baseMeta,

‎src/gateway/cli-session-history.test.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,16 @@ describe("cli session history", () => {
452452
content: "This session is being continued from a previous conversation.",
453453
},
454454
},
455+
{
456+
type: "user",
457+
uuid: "transcript-only-1",
458+
isVisibleInTranscriptOnly: true,
459+
timestamp: "2026-03-26T16:29:57.000Z",
460+
message: {
461+
role: "user",
462+
content: "Transcript-only synthetic context row.",
463+
},
464+
},
455465
]
456466
.map((line) => JSON.stringify(line))
457467
.join("\n"),
@@ -460,7 +470,7 @@ describe("cli session history", () => {
460470

461471
const messages = readClaudeCliSessionMessages({ cliSessionId: sessionId, homeDir });
462472

463-
expect(messages).toHaveLength(3);
473+
expect(messages).toHaveLength(4);
464474
// The operator-authored turn stays free of injected provenance.
465475
expectFields(messages[0], { role: "user" });
466476
expect(readRecord(messages[0]).provenance).toBeUndefined();
@@ -473,6 +483,10 @@ describe("cli session history", () => {
473483
kind: "internal_system",
474484
sourceTool: "cli_harness_context",
475485
});
486+
expectFields(readRecord(messages[3]).provenance, {
487+
kind: "internal_system",
488+
sourceTool: "cli_harness_context",
489+
});
476490
});
477491
});
478492

‎src/sessions/input-provenance.ts‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ export type InputProvenance = {
1919

2020
export const MAIN_SESSION_RESTART_RECOVERY_SOURCE_TOOL = "main_session_restart_recovery" as const;
2121

22-
/**
23-
* Provenance for user-role turns a CLI harness wrote into its own native
24-
* transcript (skill instruction bodies, continuation summaries). The operator
25-
* never typed them.
26-
*/
27-
export function buildCliHarnessContextInputProvenance(): InputProvenance {
28-
return { kind: "internal_system", sourceTool: "cli_harness_context" };
29-
}
30-
3122
export const INTER_SESSION_PROMPT_PREFIX_BASE = "[Inter-session message]";
3223
const AGENT_MEDIATED_COMPLETION_SOURCE_TOOLS = [
3324
"agent_harness_task",

0 commit comments

Comments
 (0)