fix(chat): show revert after network_error - #7983
Draft
ImBIOS wants to merge 3 commits into
Draft
Conversation
…tored agent selections opencode <=1.18 writes ESC ]0;<cwd>: ready BEL to stdout for every non-help command even when stdout is a pipe (agent list, models --verbose, debug skill). T3's ChildProcessSpawner captures that stdout via collectStreamAsString and the parsers stored a polluted agent id like "\x1b]0;imbios: ready\x07build" in model_selection_json. Later sendTurn used that polluted id and opencode rejected it with "Agent not found: \"\x1b]0;imbios: ready\x07build\"" which was surfaced as session.error UnknownError + a generic SessionPrompt UnknownError wrapper (the stack the user pasted). Fix: - packages/shared/src/stripTerminalEscapes.ts: shared OSC/CSI sanitizer - apps/server/src/provider/opencodeRuntime.ts: strip before parseModels/Agent/Skills and via parse* entry points; keeps skills from silently degrading to [] when polluted - apps/server/src/provider/Layers/OpenCodeProvider.ts: sanitize inventory agent names/variants and --version parsing; build clean capability option ids - apps/server/src/provider/Layers/OpenCodeAdapter.ts & textGeneration/OpenCodeTextGeneration.ts: sanitize stored getModelSelectionStringOptionValue values before promptAsync - packages/shared/src/model.ts: sanitize persisted option values and model slugs on read (repairs 3 polluted threads without DB migration) - tests: add OSC/ANSI regression cases for both parsers Polluted threads still read as clean via model.ts sanitizer; no migration needed but DB can be cleaned with stripTerminalEscapes. Fixes the reported UnknownError at SessionPrompt.createUserMessage and the earlier "Agent not found" session.error.
When provider fails with finish_reason network_error the failed turn
still creates a checkpoint (status error) but has no assistant_message
or a synthetic assistant:${turnId} id that never appears in
timelineEntries. The revertTurnCount derivation only scanned assistant
messages, so the last user row showed only copy.
Add fallback: map nth user message to nth checkpoint sorted by
completedAt, preserving existing assistant-message scan.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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.
Fixes #7982
When provider fails with finish_reason network_error the failed turn still creates a checkpoint (status error) but has no assistant_message or a synthetic id that never appears in timelineEntries. The revert derivation only scanned assistant messages, so last user row showed only copy.
Add fallback: map nth user message to nth checkpoint sorted by completedAt, preserving existing scan.
Managed via forkhub patch fix-chat-show-revert-after-network-error-vq3yckjy.
Note
Fix revert indicator after
network_errorand sanitize terminal escapes from CLI outputstripTerminalEscapesandsanitizeTerminalValueutilities in stripTerminalEscapes.ts to remove OSC, ANSI CSI, charset, and single-char ESC sequences from stringsnetwork_error)sanitizeTerminalValueis now applied to all string option values viagetProviderOptionStringSelectionValueandtrimOrNull; any caller relying on raw escape sequences in those fields will see them strippedMacroscope summarized aae06e7.