Skip to content

Commit a2dda68

Browse files
committed
Revert "fix(auto-reply): warn when /export-session only contains user messages (backend-delegated)"
This reverts commit 151b6f4.
1 parent 70bfb7d commit a2dda68

4 files changed

Lines changed: 3 additions & 94 deletions

File tree

src/auto-reply/reply/commands-export-session.test.ts

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,6 @@ function writtenHtml(): string {
164164
return value;
165165
}
166166

167-
function sessionDataFromHtml(html: string): Record<string, unknown> {
168-
const match = html.match(/id="session-data"[^>]*>([^<]+)</);
169-
if (!match) {
170-
throw new Error("Expected session-data script in exported HTML");
171-
}
172-
return JSON.parse(Buffer.from(match[1].trim(), "base64").toString("utf-8"));
173-
}
174-
175167
describe("buildExportSessionReply", () => {
176168
afterEach(() => {
177169
vi.useRealTimers();
@@ -369,54 +361,4 @@ describe("buildExportSessionReply", () => {
369361
);
370362
expect(reply.text).not.toMatch(/Unexpected|SyntaxError|position/i);
371363
});
372-
373-
it("warns when the session only contains user messages (backend-delegated transcript)", async () => {
374-
hoisted.sessionTranscriptContent = [
375-
JSON.stringify({ type: "session", version: 3, id: "session-1" }),
376-
JSON.stringify({
377-
type: "message",
378-
id: "entry-1",
379-
timestamp: "2026-05-16T00:00:00.000Z",
380-
message: { role: "user", content: "hello" },
381-
}),
382-
JSON.stringify({
383-
type: "message",
384-
id: "entry-2",
385-
timestamp: "2026-05-16T00:00:01.000Z",
386-
message: { role: "user", content: "world" },
387-
}),
388-
].join("\n");
389-
390-
const reply = await buildExportSessionReply(makeParams());
391-
392-
expect(reply.text).toContain("backend runtime");
393-
expect(reply.text).toContain("not included in this export");
394-
const data = sessionDataFromHtml(writtenHtml());
395-
expect(typeof data.warning).toBe("string");
396-
expect(data.warning).toContain("backend runtime");
397-
});
398-
399-
it("does not warn when the transcript includes assistant messages", async () => {
400-
hoisted.sessionTranscriptContent = [
401-
JSON.stringify({ type: "session", version: 3, id: "session-1" }),
402-
JSON.stringify({
403-
type: "message",
404-
id: "entry-1",
405-
timestamp: "2026-05-16T00:00:00.000Z",
406-
message: { role: "user", content: "hello" },
407-
}),
408-
JSON.stringify({
409-
type: "message",
410-
id: "entry-2",
411-
timestamp: "2026-05-16T00:00:01.000Z",
412-
message: { role: "assistant", content: "hi" },
413-
}),
414-
].join("\n");
415-
416-
const reply = await buildExportSessionReply(makeParams());
417-
418-
expect(reply.text).not.toContain("backend runtime");
419-
expect(reply.text).not.toContain("not included in this export");
420-
expect(sessionDataFromHtml(writtenHtml()).warning).toBeUndefined();
421-
});
422364
});

src/auto-reply/reply/commands-export-session.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
type FileEntry as SessionFileEntry,
99
type SessionEntry as AgentSessionEntry,
1010
type SessionHeader,
11-
type SessionMessageEntry,
1211
} from "../../agents/sessions/session-manager.js";
1312
import { pathExists } from "../../infra/fs-safe.js";
1413
import type { ReplyPayload } from "../types.js";
@@ -29,20 +28,6 @@ interface SessionData {
2928
leafId: string | null;
3029
systemPrompt?: string;
3130
tools?: Array<{ name: string; description?: string; parameters?: unknown }>;
32-
warning?: string;
33-
}
34-
35-
const BACKEND_DELEGATED_WARNING =
36-
"This session was handled by a backend runtime (e.g. CLI/ACP). Assistant replies, tool calls, and usage data are stored in the backend transcript and are not included in this export.";
37-
38-
function isBackendDelegatedSession(entries: AgentSessionEntry[]): boolean {
39-
if (entries.length === 0) {
40-
return false;
41-
}
42-
const messages = entries.filter(
43-
(entry): entry is SessionMessageEntry => entry.type === "message",
44-
);
45-
return messages.length > 0 && messages.every((entry) => entry.message.role === "user");
4631
}
4732

4833
type SessionExportJsonlWarning = {
@@ -298,7 +283,6 @@ export async function buildExportSessionReply(params: HandleCommandsParams): Pro
298283
});
299284

300285
// 4. Prepare session data
301-
const backendWarning = isBackendDelegatedSession(entries) ? BACKEND_DELEGATED_WARNING : undefined;
302286
const sessionData: SessionData = {
303287
header,
304288
entries,
@@ -309,7 +293,6 @@ export async function buildExportSessionReply(params: HandleCommandsParams): Pro
309293
description: t.description,
310294
parameters: t.parameters,
311295
})),
312-
warning: backendWarning,
313296
};
314297

315298
// 5. Generate HTML
@@ -347,7 +330,6 @@ export async function buildExportSessionReply(params: HandleCommandsParams): Pro
347330
`📄 File: ${displayPath}`,
348331
`📊 Entries: ${entries.length}`,
349332
...warnings.map(formatSessionExportWarning),
350-
...(backendWarning ? [`⚠️ ${backendWarning}`] : []),
351333
`🧠 System prompt: ${systemPrompt.length.toLocaleString()} chars`,
352334
`🔧 Tools: ${tools.length}`,
353335
].join("\n"),

src/auto-reply/reply/export-html/template.css

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,6 @@ body {
256256
border-color: var(--borderAccent);
257257
}
258258

259-
/* Export warnings */
260-
.export-warning {
261-
background: var(--userMsgBg);
262-
border: 1px solid var(--warning);
263-
border-radius: 4px;
264-
color: var(--warning);
265-
font-size: 12px;
266-
margin-bottom: var(--line-height);
267-
padding: var(--line-height);
268-
}
269-
270259
/* Header */
271260
.header {
272261
background: var(--container-bg);

src/auto-reply/reply/export-html/template.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
bytes[i] = binary.charCodeAt(i);
1414
}
1515
const data = JSON.parse(new TextDecoder("utf-8").decode(bytes));
16-
const { header, entries, leafId: defaultLeafId, systemPrompt, tools, renderedTools, warning } = data;
16+
const { header, entries, leafId: defaultLeafId, systemPrompt, tools, renderedTools } = data;
1717

1818
// ============================================================
1919
// URL PARAMETER HANDLING
@@ -1559,13 +1559,9 @@
15591559
msgParts.push(`${globalStats.branchSummaries} branch summaries`);
15601560
}
15611561

1562-
let html = "";
1563-
if (warning) {
1564-
html += `<div class="export-warning">${escapeHtml(warning)}</div>`;
1565-
}
1566-
html += `
1562+
let html = `
15671563
<div class="header">
1568-
<h1>Session: ${escapeHtml(header?.id || "unknown")}</h1>`
1564+
<h1>Session: ${escapeHtml(header?.id || "unknown")}</h1>
15691565
<div class="help-bar">
15701566
<span>Ctrl+T toggle thinking · Ctrl+O toggle tools</span>
15711567
<button class="download-json-btn" onclick="downloadSessionJson()" title="Download session as JSONL">↓ JSONL</button>

0 commit comments

Comments
 (0)