fix(ui): preserve question queue order when upserting duplicate requests#479
Open
JDis03 wants to merge 1 commit into
Open
fix(ui): preserve question queue order when upserting duplicate requests#479JDis03 wants to merge 1 commit into
JDis03 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.
|
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
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