fix: four correctness and code-quality bugs from deep review - #200
Closed
dylanneve1 wants to merge 3 commits into
Closed
fix: four correctness and code-quality bugs from deep review#200dylanneve1 wants to merge 3 commits into
dylanneve1 wants to merge 3 commits into
Conversation
- sessions: fastestResponseMs migrated from Infinity→null (JSON.stringify serialises Infinity as null); the migration guard missed the null case so the field stayed null forever after a restart, causing the fastest-time tracker to never update - stream: remove duplicate normalizeForDedupe / isDuplicateOfDelivered implementations; re-export from the canonical shared/delivered-text module instead — eliminates the maintenance risk of two diverging copies (the stream.ts copy also had a weaker string[] vs readonly string[] signature) - terminal/input: close() now resolves and clears a pending waitForInput promise instead of leaving it hanging forever - handler: log swallowed onToolUse callback errors at warn level rather than silently discarding them, making debugging callback issues possible https://claude.ai/code/session_01L13ce8EKaoTNrjgw4HRvy3
One line in the Bug 4 fix exceeded prettier's print-width. Wrapped `logWarn(...)` call to match project style. No logic changes.
Collaborator
|
Heartbeat #305 pushed a format fix (commit The Bug 4 All other checks (Tests, Backend Live, Functional, Integration, Fuzz, etc.) already passed. CI Status should go green once the new run completes. |
Owner
Author
|
Superseded by #246. I reviewed the old changes and ported the valid/current fixes onto current main in the consolidated PR, while leaving out stale removed-backend changes and broad churn that no longer applies. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Deep review of the full codebase surfaced four verified bugs. Each fix is small and targeted.
Bug 1 —
fastestResponseMspermanently broken after process restart (sessions.ts)Severity: High
SessionUsage.fastestResponseMsis initialized toInfinity.JSON.stringifyserialisesInfinityasnull, so every persisted session file on disk contains"fastestResponseMs": null. On reload, the migration guard:…does not catch
null(null !== undefined,null !== 0). The field staysnull. All subsequent comparisons liketurn.durationMs < nullare alwaysfalse(null coerces to 0, all durations are positive), so the fastest-response tracker never updates after a restart.Fix: added
|| session.usage.fastestResponseMs === nullto the migration guard.Bug 2 — Duplicate
normalizeForDedupe/isDuplicateOfDeliveredinstream.ts(stream.ts)Severity: Medium
stream.tscontained full copies of both dedup helpers that already live inshared/delivered-text.ts. The copy instream.tshad a subtle signature difference (string[]instead ofreadonly string[]fordeliveredNorms), meaning a fix to the shared version wouldn't automatically fix the copy.Fix: removed the duplicate implementations and replaced them with a re-export from the shared module. Consumers that import from
stream.ts(includingend-turn.test.ts) continue to work unchanged, and there is now a single source of truth.Bug 3 —
close()leaves a pendingwaitForInputpromise hanging forever (terminal/input.ts)Severity: Low
waitForInput()stores apendingResolvecallback that is normally cleared when the user presses Enter or Escape.close()shuts down stdin but never calls or clearspendingResolve, so any caller awaitingwaitForInput()at the time of shutdown is leaked — the promise never settles.Fix:
close()now resolves the pending promise with an empty string (matching the Escape-cancel behaviour) before tearing down stdin.Bug 4 —
onToolUsecallback errors silently discarded inhandler.ts(handler.ts)Severity: Low
The
onToolUsecallback is marked non-fatal (correct — a broken observer must not abort the turn), but thecatchblock was empty, making callback exceptions completely invisible. Debugging a misbehavingonToolUsehook was impossible.Fix: the catch block now logs at
warnlevel with the tool name and error message.Test plan
npm test): 2365 tests pass, 0 regressions introducedend-turn.test.ts(which importsnormalizeForDedupe/isDuplicateOfDeliveredfromstream.js) continues to pass after the re-export refactorGenerated by Claude Code