Skip to content

fix(chat): stop showing one failed run's error three times (#335) - #434

Merged
andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:land/pr-335
Nov 9, 2026
Merged

andrebrait merged 1 commit into
ompweb-dev:mainfrom
andrebrait:land/pr-335

Conversation

@andrebrait

Copy link
Copy Markdown
Collaborator

Lands #335 by @TianZishen, whose branch now conflicts with main after #343 merged.

Verified locally: hooks/useAgentSession.rpc.test.mjs passes 276/0, tsc --noEmit is clean.

Will be rebase-merged, so the commit keeps the contributor's authorship. #335 will be closed with a link here.

Squashed from TianZishen/ompweb fix/duplicate-error-displays (1af3653) onto main 0b34f52; CHANGELOG conflict with #343 resolved by keeping both entries.

Co-authored-by: Andre Brait <andrebrait@gmail.com>
@coderabbitai

coderabbitai Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@andrebrait
andrebrait merged commit 9b4f8e1 into ompweb-dev:main Nov 9, 2026
4 of 5 checks passed
@andrebrait
andrebrait deleted the land/pr-335 branch November 9, 2026 10:43
@coderabbitai
coderabbitai Bot requested a review from kahme247 November 9, 2026 10:43
Comment thread hooks/useAgentSession.ts
&& typeof value.errorMessage === "string" && value.errorMessage.trim() === error) {
return { error, timestamp: value.timestamp };
}
return null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 The Roast: The early return null inside this loop is a classic off-by-one-logic error. You check the first error-carrying value in event.message/event.messages, and if it's not the assistant message you're looking for, you bail immediately — never giving event.messages a chance to contain the actual culprit. It's like a bouncer who checks the first person in line, sees they're not on the list, and shuts the door on everyone behind them.

🩹 The Fix:

Suggested change
return null;
if (isRecord(value) && value.role === "assistant" && typeof value.timestamp === "number"
&& typeof value.errorMessage === "string" && value.errorMessage.trim() === error) {
return { error, timestamp: value.timestamp };
}
// continue checking other values instead of returning null
}
return null;

📏 Severity: warning

Comment thread hooks/useAgentSession.ts
lastQuotaErrorRef.current = null;
lastRunErrorRef.current = null;
runErrorAssistantRef.current = null;
independentRunErrorRef.current = null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 The Roast: You reset runErrorAssistantRef and independentRunErrorRef when a new run starts, but unconfirmedErrorNoticeRef gets left behind like a forgotten gym membership. It's not a functional bug — the runId check in the history callback prevents it from matching future runs — but it's a stale reference sitting in memory, confusing the next developer who wonders "why is this still here?"

🩹 The Fix:

Suggested change
independentRunErrorRef.current = null;
runErrorAssistantRef.current = null;
independentRunErrorRef.current = null;
unconfirmedErrorNoticeRef.current = null;

📏 Severity: nitpick

case "remove": {
const visible = state.visible.filter((notice) => notice.id !== action.id);
return fillPendingNotices(visible, state.pending);
return fillPendingNotices(visible, state.pending.filter((notice) => notice.id !== action.id));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 The Roast: Finally, someone realized that removing a notice from visible while leaving it in pending is like taking the batteries out of a smoke detector but keeping it on the ceiling — it'll still scream at you later when fillPendingNotices promotes it back. This fix closes that loop.

🩹 The Fix: Already correct. The pending.filter((notice) => notice.id !== action.id) ensures dismissed notices stay dismissed.

📏 Severity: suggestion

@kilo-code-bot

kilo-code-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
🚨 critical 0
⚠️ warning 1
💡 suggestion 1
🤏 nitpick 1
Issue Details (click to expand)
File Line Roast
hooks/useAgentSession.ts 201 Early return null in loop skips checking event.messages for the actual assistant error
hooks/useAgentSession.ts 2385 unconfirmedErrorNoticeRef not cleared in agent_start — stale reference lingers
hooks/useAgentSession-notices.ts 74 Good fix: filtering pending notices on remove prevents zombie notices from respawning

🏆 Best part: The test coverage is genuinely impressive — 315 lines of new tests covering terminal errors, recovery flows, branch views, quota handling, and the exact deduplication scenarios this PR targets. I've seen entire codebases with less test discipline.

💀 Worst part: The terminalErrorAssistant function's early return is a logic bug waiting to bite. If event.message carries an error but isn't the assistant message (e.g., a user message with an error field), the function returns null without ever checking event.messages, where the real assistant message might live. The early return at line 193 (readAgentError(event.errorMessage) || readAgentError(event.error)) doesn't cover event.message, so this path is reachable.

📊 Overall: Like a skilled surgeon who washed their hands but forgot to sterilize one scalpel — the operation (deduplication logic) is sound and well-tested, but one instrument has a nick that could cause infection in production.

Files Reviewed (4 files)
  • CHANGELOG.md - 0 issues (changelog entry only)
  • hooks/useAgentSession-notices.ts - 1 issue (actually a good fix, flagged as suggestion for visibility)
  • hooks/useAgentSession.rpc.test.mjs - 0 issues (comprehensive test additions)
  • hooks/useAgentSession.ts - 2 issues (logic bug in terminalErrorAssistant, missing cleanup in agent_start)

Fix these issues in Kilo Cloud


Reviewed by free · Input: 93.1K · Output: 10.6K · Cached: 626.9K

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant