fix(desktop): preserve streamed text when provider sends empty completion - #41922
Open
liuhao1024 wants to merge 1 commit into
Open
liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…tion When a provider (e.g. NVIDIA NIM) sends a message.complete event with empty text/rendered fields after streaming content via message.delta, the replaceTextPart helper stripped all accumulated text parts without adding anything back — causing the rendered response to vanish. Fix: early-return the existing parts when finalText is empty, so streamed content is preserved. Also adjust shouldHydrate to skip the stored- session hydration fallback when streamed text already exists, preventing a stale snapshot from overwriting the visible response. Fixes NousResearch#41898
19 tasks
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for isolating the empty-completion path. The defect remains on current main: gateway-event.ts:334-335 passes an empty completion string through, while index.ts:363-377 removes all streamed text parts and adds none when the final text is empty. index.ts:432-457 then enables the hydration fallback for that same empty completion.
Problems
- The PR diff changes no tests. Current hook tests under
apps/desktop/src/app/session/hooks/use-message-stream/cover todo cleanup and utilities, not an emptymessage.completeafter streamed deltas.
Suggested changes
- Salvage the preservation guard into
apps/desktop/src/app/session/hooks/use-message-stream/index.ts, which replaced the old target in behavior-preserving refactor086343854dbf723acfc529d2580c260cc3713d0b. - Add a regression test for
message.deltatext followed by an emptymessage.complete, including the hydration outcome.
Automated hermes-sweeper review.
| // sends finish_reason:"stop" with no content), preserve the | ||
| // streamed text parts that were accumulated via message.delta. | ||
| // Otherwise the already-rendered response vanishes on completion. | ||
| if (!finalText) { |
Collaborator
There was a problem hiding this comment.
Please add a Desktop regression test for streamed message.delta text followed by an empty message.complete. This branch is the fix's essential behavior, and the PR currently changes no test files.
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.
What does this PR do?
Preserves streamed assistant text when a provider sends a
message.completeevent with emptytext/renderedfields. This fixes a bug where responses from NVIDIA NIM (and any provider that sendsfinish_reason: "stop"with no content in the final chunk) would flash briefly and then disappear from the Desktop UI.Related Issue
Fixes #41898
Type of Change
Changes Made
apps/desktop/src/app/session/hooks/use-message-stream.ts:replaceTextPart: early-return existing parts whenfinalTextis empty, preserving streamed text accumulated viamessage.deltaeventsshouldHydrate: skip stored-session hydration when streamed text already exists butfinalTextis empty, preventing stale snapshot from overwriting visible responseHow to Test
message.completechunk (e.g. NVIDIA NIM withnvidia/nemotron-3-ultra-550b-a55b)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
use-message-stream.ts→replaceTextPart,completeAssistantMessage,shouldHydratemessage.completeevent handler (line 803), streaming delta handlershydrateFromStoredSessionfallback (line 561),completeMessage(line 491)