fix(ui): preserve question queue order when upserting duplicate requests#479
fix(ui): preserve question queue order when upserting duplicate requests#479JDis03 wants to merge 1 commit into
Conversation
Fixes NeuralNomadsAI#448 - Questions can deadlock with "Waiting for earlier responses" when a question arrives first as a global entry and later resolves to a tool part with a newer enqueuedAt timestamp. Root cause: - upsertQuestion replaced the entire queue entry on duplicate request id, losing the original enqueuedAt value. - If question-1 arrived at t=1000 (global), then question-2 at t=1500, and question-1 resolved to a tool part at t=2000, the newer enqueuedAt (2000) would place question-1 behind question-2 in the sorted queue. - This broke the active interruption ordering, leaving both questions showing "Waiting for earlier responses." Fix: - Add mergeQuestionEntry mirroring mergePermissionEntry behavior. - Preserve original enqueuedAt using Math.min(existing, new). - Keep newer messageId/partId when resolving from global to tool part. - Clean up stale byMessage entries for the same request id. - Sort queue by enqueuedAt and recalculate active after each upsert. Validation: - npm run typecheck --workspace @codenomad/ui - node --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts - Added 3 regression tests covering duplicate resolution and ordering.
6636745 to
4dc05d3
Compare
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26034514624 Artifacts expire in 7 days.
|
|
PR builds are available as GitHub Actions artifacts: https://github.com/NeuralNomadsAI/CodeNomad/actions/runs/26035402900 Artifacts expire in 7 days.
|
|
I want you to perform the gatekeeper checks for latest PR state check for regressions |
|
Gatekeeper review complete for latest PR state. Request understood: perform a strict review for regressions, implementation quality, and whether this should pass as PR gatekeeper. Assumption: review-only, no code changes requested. Findings: none blocking. Review notes:
Validation run:
Environment note:
Non-blocking quality note:
Gatekeeper verdict: approve from code-quality and regression-risk perspective. -- |
|
I’m not sure this fully fixes #448. |
Summary
Root Cause
upsertQuestionreplaced the entire queue entry on duplicate request id, losing the originalenqueuedAtvalue. If question-1 arrived at t=1000 (global), then question-2 at t=1500, and question-1 resolved to a tool part at t=2000, the newerenqueuedAt(2000) would place question-1 behind question-2 in the sorted queue, breaking active interruption ordering.Fix
mergeQuestionEntrymirroringmergePermissionEntrybehaviorenqueuedAtusingMath.min(existing, new)messageId/partIdwhen resolving from global to tool partbyMessageentries for the same request idenqueuedAtand recalculate active after each upsertValidation
npm run typecheck --workspace @codenomad/uinode --import tsx --test packages/ui/src/stores/message-v2/instance-store.test.ts