Merge 44f9ef8b24 into da71eaebd2
This commit is contained in:
commit
1628773796
@ -113,9 +113,9 @@ export function renderChatControls(state: AppViewState) {
|
|||||||
aria-pressed=${showThinking}
|
aria-pressed=${showThinking}
|
||||||
title=${disableThinkingToggle
|
title=${disableThinkingToggle
|
||||||
? "Disabled during onboarding"
|
? "Disabled during onboarding"
|
||||||
: "Toggle assistant thinking/working output"}
|
: "Show/hide debug info (tool calls, heartbeats)"}
|
||||||
>
|
>
|
||||||
${icons.brain}
|
${icons.bug}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
class="btn btn--sm btn--icon ${focusActive ? "active" : ""}"
|
class="btn btn--sm btn--icon ${focusActive ? "active" : ""}"
|
||||||
|
|||||||
@ -93,4 +93,44 @@ describe("chat view", () => {
|
|||||||
expect(onNewSession).toHaveBeenCalledTimes(1);
|
expect(onNewSession).toHaveBeenCalledTimes(1);
|
||||||
expect(container.textContent).not.toContain("Stop");
|
expect(container.textContent).not.toContain("Stop");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("filters debug messages when showThinking is false", () => {
|
||||||
|
const container = document.createElement("div");
|
||||||
|
render(
|
||||||
|
renderChat(
|
||||||
|
createProps({
|
||||||
|
showThinking: false,
|
||||||
|
messages: [
|
||||||
|
{ role: "user", content: "hello", timestamp: 1 },
|
||||||
|
{ role: "toolresult", content: "debug info", timestamp: 2 },
|
||||||
|
{ role: "assistant", content: "world", timestamp: 3 },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
container,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(container.textContent).toContain("hello");
|
||||||
|
expect(container.textContent).toContain("world");
|
||||||
|
expect(container.textContent).not.toContain("debug info");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("shows debug messages when showThinking is true", () => {
|
||||||
|
const container = document.createElement("div");
|
||||||
|
render(
|
||||||
|
renderChat(
|
||||||
|
createProps({
|
||||||
|
showThinking: true,
|
||||||
|
messages: [
|
||||||
|
{ role: "user", content: "hello", timestamp: 1 },
|
||||||
|
{ role: "toolresult", content: "debug info", timestamp: 2 },
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
container,
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(container.textContent).toContain("hello");
|
||||||
|
expect(container.textContent).toContain("debug info");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -434,7 +434,7 @@ function buildChatItems(props: ChatProps): Array<ChatItem | MessageGroup> {
|
|||||||
const msg = history[i];
|
const msg = history[i];
|
||||||
const normalized = normalizeMessage(msg);
|
const normalized = normalizeMessage(msg);
|
||||||
|
|
||||||
if (!props.showThinking && normalized.role.toLowerCase() === "toolresult") {
|
if (!props.showThinking && isDebugMessage(msg)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,3 +484,34 @@ function messageKey(message: unknown, index: number): string {
|
|||||||
if (timestamp != null) return `msg:${role}:${timestamp}:${index}`;
|
if (timestamp != null) return `msg:${role}:${timestamp}:${index}`;
|
||||||
return `msg:${role}:${index}`;
|
return `msg:${role}:${index}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractTextContent(m: Record<string, unknown>): string {
|
||||||
|
if (typeof m.content === "string") return m.content;
|
||||||
|
if (Array.isArray(m.content)) {
|
||||||
|
return m.content
|
||||||
|
.filter((c: unknown) => (c as Record<string, unknown>).type === "text")
|
||||||
|
.map((c: unknown) => (c as Record<string, string>).text ?? "")
|
||||||
|
.join(" ");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDebugMessage(message: unknown): boolean {
|
||||||
|
const m = message as Record<string, unknown>;
|
||||||
|
const role = typeof m.role === "string" ? m.role.toLowerCase() : "";
|
||||||
|
|
||||||
|
// Filter tool results
|
||||||
|
if (role === "toolresult" || role === "tool_result" || role === "tool") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter system debug messages (heartbeats, context compaction, etc.)
|
||||||
|
if (role === "system") {
|
||||||
|
const content = extractTextContent(m);
|
||||||
|
if (/heartbeat|scheduled|context (compacted|trimmed)/i.test(content)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user