Skip to content

Commit a20f809

Browse files
garthvhclaude
andcommitted
dashboard: strip <system-reminder> blocks from the user-message preview
Claude Code wraps every user turn with injected <system-reminder>…</system-reminder> context (email, date, tool notes), which the LAST USER MESSAGE column was showing instead of what was actually typed. Add humanText(): strip those blocks for the preview so the column reads e.g. "hello claude", falling back to the raw text for turns that are only injected content. The detail overlay still keeps the full message. Applies to both the live path and the mock echo. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 3ed28fc commit a20f809

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

server.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function track(body, inputTokens) {
277277
id: genId("act"), ts: Date.now(), model: body.model, ollamaModel: null,
278278
stream: !!body.stream, status: "active", inputTokens, outputTokens: 0,
279279
durationMs: null, stopReason: null, error: null,
280-
preview: blockText(lastUser?.content ?? "").replace(/\s+/g, " ").slice(0, 200),
280+
preview: humanText(lastUser?.content).slice(0, 200),
281281
userMessage: blockText(lastUser?.content ?? "").slice(0, BODY_CAP),
282282
responseText: "",
283283
_start: Date.now(), _lastPush: 0, _cacheFraction: fraction, _cacheHit: hit,
@@ -316,6 +316,19 @@ function blockText(content) {
316316
return JSON.stringify(content);
317317
}
318318

319+
// The human's actual text for the dashboard preview. Claude Code wraps each user
320+
// turn with injected <system-reminder>…</system-reminder> context blocks; strip
321+
// them so the column shows what was typed, not the boilerplate. Falls back to the
322+
// raw text for turns that are only injected content (e.g. tool-result turns).
323+
function humanText(content) {
324+
const raw = blockText(content ?? "");
325+
const stripped = raw
326+
.replace(/<system-reminder>[\s\S]*?<\/system-reminder>/gi, " ")
327+
.replace(/\s+/g, " ")
328+
.trim();
329+
return stripped || raw.replace(/\s+/g, " ").trim();
330+
}
331+
319332
function anthropicToOllamaMessages(body) {
320333
const out = [];
321334
const sys = systemToString(body.system);
@@ -619,7 +632,7 @@ const MOCK_WORDS = ("the quick brown fox jumps over the lazy dog while testing "
619632
async function handleMock(res, body, claudeModel, msgId, inputTokens, rec) {
620633
rec.ollamaModel = "mock";
621634
const lastUser = [...(body.messages || [])].reverse().find((m) => m.role === "user");
622-
const preview = blockText(lastUser?.content ?? "").slice(0, 80);
635+
const preview = humanText(lastUser?.content).slice(0, 80);
623636
const intro = `[mock:${claudeModel}] Echoing your request ("${preview}"). `;
624637
const words = [intro, ...Array.from({ length: MOCK_TOKENS }, (_, i) => MOCK_WORDS[i % MOCK_WORDS.length] + " ")];
625638
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

0 commit comments

Comments
 (0)