Skip to content

fix(server): preserve explicit source control writer - #6087

Open
ehfreema wants to merge 7 commits into
pingdotgg:mainfrom
ehfreema:ba237394-pr
Open

fix(server): preserve explicit source control writer#6087
ehfreema wants to merge 7 commits into
pingdotgg:mainfrom
ehfreema:ba237394-pr

Conversation

@ehfreema

@ehfreema ehfreema commented Aug 11, 2026

Copy link
Copy Markdown

What Changed

  • Preserve an explicitly selected OpenCode source-control writer when persisted provider settings lag behind the healthy provider snapshot.
  • Keep the selected OpenCode model and options on the Create PR path.
  • Add regression coverage for the UI/server selection mismatch and the full create_pr flow.

Why

The Source control writer model picker could visibly show OpenCode while the server resolver rejected that selection using stale persisted provider settings. It then passed the global Codex selection to generatePrContent, producing Failed to spawn Codex CLI process.

The resolver now trusts a matching provider snapshot only when that instance is enabled and available. If it is not usable, the existing fallback behavior remains.

Related: #5359 is background on provider fallback, but does not cover this healthy OpenCode/Create PR routing bug.

Verification: 283 focused tests passed; server/shared typechecks, lint, and formatting passed.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No production UI changes; screenshots are not applicable
  • No animation or interaction changes; video is not applicable

Verified with gpt-5.6-luna via the T3 Code harness.

Note

Fix resolveSourceControlWriterModelSelection to preserve explicit writer when provider snapshot is healthy

  • When provider snapshots are supplied, resolveSourceControlWriterModelSelection now checks the live snapshot rather than persisted settings to determine if a selection is healthy, returning the explicit selection if the provider is enabled and available.
  • When no snapshots are supplied, it rejects a disabled selection and falls back to textGenerationModelSelection.
  • Behavioral Change: previously a settings-lagging disabled instance would always cause fallback to textGenerationModelSelection, even when the live provider was healthy.

Macroscope summarized f7ebeaa.


Note

Medium Risk
Changes model routing for commits/PRs when settings and provider health disagree; fallback paths remain for unavailable writers.

Overview
Fixes a mismatch where the source control writer picker could show OpenCode while the server routed PR generation through the global Codex selection because persisted providerInstances still had OpenCode disabled.

resolveSourceControlWriterModelSelection now treats a supplied provider snapshot as live routing state: when the explicit writer’s instance is enabled and available in that snapshot, the stored selection is kept even if settings lag. Without a snapshot, behavior is unchanged (settings-based enablement, then fallback to textGenerationModelSelection). Unhealthy or missing snapshots still fall back.

Regression tests cover shared resolver behavior, web resolveAppModelSelectionState for the same settings/snapshot lag, and a create_pr GitManager flow that asserts generatePrContent receives the OpenCode writer (model + options) instead of unavailable Codex.

Reviewed by Cursor Bugbot for commit f7ebeaa. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3501ecad-026b-476d-9193-f4b9f54dde47

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 11, 2026
@ehfreema
ehfreema marked this pull request as ready for review August 11, 2026 03:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 14f1dc4. Configure here.

Comment thread packages/shared/src/serverSettings.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 65bfe8f

This is a targeted bug fix (~10 lines of logic) that handles a race condition where settings can lag behind live provider state. The fix preserves explicit source control writer selections when the provider is healthy. Extensive test coverage is included.

No code changes detected at f7ebeaa. Prior analysis still applies.

You can customize Macroscope's approvability policy. Learn more.

@ehfreema
ehfreema marked this pull request as draft August 11, 2026 03:27
@ehfreema
ehfreema marked this pull request as ready for review August 11, 2026 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant