Repository navigation
fix(chat): stop showing one failed run's error three times (#335) - #434
Conversation
|
Caution Review failedThe pull request is closed.
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. |
| && typeof value.errorMessage === "string" && value.errorMessage.trim() === error) { | ||
| return { error, timestamp: value.timestamp }; | ||
| } | ||
| return null; |
There was a problem hiding this comment.
🔥 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:
| 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
| lastQuotaErrorRef.current = null; | ||
| lastRunErrorRef.current = null; | ||
| runErrorAssistantRef.current = null; | ||
| independentRunErrorRef.current = null; |
There was a problem hiding this comment.
🔥 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:
| 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)); |
There was a problem hiding this comment.
🔥 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
Code Review Roast 🔥Verdict: 3 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)
🏆 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 📊 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)
Fix these issues in Kilo Cloud Reviewed by free · Input: 93.1K · Output: 10.6K · Cached: 626.9K |
Lands #335 by @TianZishen, whose branch now conflicts with
mainafter #343 merged.1af36532squashed ontomain(0b34f526).CHANGELOG.mdconflict with fix(projects): validate OMP profile names before they reach the spawn #343's entry, resolved by keeping both entries.Verified locally:
hooks/useAgentSession.rpc.test.mjspasses 276/0,tsc --noEmitis clean.Will be rebase-merged, so the commit keeps the contributor's authorship. #335 will be closed with a link here.