fix(server): handle OpenCode text response format in commit message g…#2202
Conversation
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
ApprovabilityVerdict: Approved This is a focused bug fix that adapts OpenCode response parsing from structured output to text format, moving a shared utility and adding error handling helpers. Changes are limited to text generation layers with comprehensive test coverage, no runtime behavior changes beyond fixing the response format handling. You can customize Macroscope's approvability policy. Learn more. |
| format: { | ||
| type: "json_schema", | ||
| schema: toJsonSchemaObject(input.outputSchemaJson) as Record<string, unknown>, | ||
| }, |
Upstream additions: - fix(web): restore manual sort drag and keep per-group expand state (pingdotgg#2221) - fix: Change right panel sheet to be below title bar / action bar (pingdotgg#2224) - Refactor OpenCode lifecycle and structured output handling (pingdotgg#2218) - effect-codex-app-server (pingdotgg#1942) - Redesign model picker with favorites and search (pingdotgg#2153) - fix(server): prevent probeClaudeCapabilities from wasting API requests (pingdotgg#2192) - fix(server): handle OpenCode text response format in commit message gen (pingdotgg#2202) - Devcontainer / IDE updates (pingdotgg#2208) - Expand leading ~ in Codex home paths before exporting CODEX_HOME (pingdotgg#2210) - fix(release): use v<semver> tag format for nightly releases (pingdotgg#2186) Fork adaptations: - Took upstream's redesigned model picker with favorites and search - Removed deleted codexAppServerManager (replaced by effect-codex-app-server) - Stubbed fetchCodexUsage (manager-based readout no longer available) - Extended PROVIDER_ICON_BY_PROVIDER for all 8 fork providers - Extended modelOptionsByProvider test fixtures for all 8 providers - Inline ClaudeSlashCommand type (not yet re-exported from SDK) - Updated SettingsPanels imports for new picker module structure - Preserved fork's CI customizations (ubuntu-24.04 not Blacksmith)
What Changed
info.structured.apps/server/src/git/Utils.tsas shared logic so OpenCode and Cursor parse provider output the same way.apps/server/src/git/Layers/OpenCodeTextGeneration.test.tsto cover the failing OpenCode response shapes: empty output, JSON returned inside plain text parts, and upstream structured-output errors.Why
OpenCode is currently returning the generated payload as plain text parts rather than populating
info.structured, so the existing implementation treated valid responses as failures and broke commit message generation.Parsing the returned text locally and decoding it against the existing schema keeps the validation path intact while matching the response shape OpenCode actually sends.
UI Changes
Before
After
Checklist
Closes #2199
Note
Fix OpenCode text response parsing in commit message generation
json_schemastructured output format from OpenCode requests; instead reads raw text parts and extracts JSON locally usingextractJsonObjectfrom Utils.ts.getOpenCodeTextResponseto concatenate text parts into a single string, andgetOpenCodePromptErrorMessageto surface upstreaminfo.errordetails as thrown errors.'OpenCode returned empty output.'error when no text parts are present, and mapsinfo.errorwithStructuredOutputErrorto a readable message.extractJsonObjectto Utils.ts and shares it with CursorTextGeneration.ts.Macroscope summarized 2a12331.