Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions web/src/chat/normalizeAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ function normalizeUserOutput(

const messageContent = message.content

// Skip system-injected messages that were logged as type:'user' but are
// not text the human actually typed (task notifications, command caveats, etc.)
if (typeof messageContent === 'string') {
const trimmed = messageContent.trimStart()
if (
trimmed.startsWith('<task-notification>') ||
trimmed.startsWith('<system-reminder>')
) {
return null
}
}

if (isSidechain && typeof messageContent === 'string') {
return {
id: messageId,
Expand Down
19 changes: 19 additions & 0 deletions web/src/chat/reducerTimeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,28 @@ export function reduceTimeline(
}

if (msg.role === 'agent') {
// When the message contains a Task tool_use, Claude often writes the
// prompt as a text block before the tool_use block. We only want to
// suppress that exact prompt text — not every text block in the message.
const taskToolCall = msg.content.find(
(c) => c.type === 'tool-call' && c.name === 'Task'
)
const taskPromptText: string | null = (() => {
if (!taskToolCall || taskToolCall.type !== 'tool-call') return null
const input = taskToolCall.input
if (typeof input === 'object' && input !== null && 'prompt' in input) {
const p = (input as { prompt: unknown }).prompt
if (typeof p === 'string') return p
}
return null
})()

for (let idx = 0; idx < msg.content.length; idx += 1) {
const c = msg.content[idx]
if (c.type === 'text') {
// Skip text blocks that are just the Task tool prompt (already shown in tool card)
if (taskPromptText && c.text.trim() === taskPromptText.trim()) continue

if (isCliOutputText(c.text, msg.meta)) {
blocks.push(createCliOutputBlock({
id: `${msg.id}:${idx}`,
Expand Down
Loading