Skip to content

fix(source-control): let Pi use its configured default model - #15649

Closed
brennanb2025 wants to merge 11 commits into
mainfrom
brennanb2025/sta-4249-pi-model-default
Closed

brennanb2025 wants to merge 11 commits into
mainfrom
brennanb2025/sta-4249-pi-model-default

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​585 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​580
Prod 26 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​555 $\color{#cf222e}{\Huge{\mathbf{−}}}$​71 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​484

Pi source-control generation currently forces github-copilot/gpt-5.4-mini, overriding the provider/model configured in Pi. This change adds Pi default, which omits --model; explicit Orca choices continue to override Pi for commit messages, PR details, and branch names.

Fixes #14407. Preserves the original contributor history, merged onto current main and adapted to the extracted settings/planner modules.

Behavior and compatibility

  • No saved override: Pi selects its configured provider/model.
  • Explicit global, host-specific, operation, and repository model choices retain precedence.
  • Pi default remains the canonical modern settings value, so selecting Copilot → Pi default → Copilot round-trips correctly. Legacy projections retain a compatible model ID; generation requests carry optional configured-default intent.
  • Historical Copilot selections have no recorded provenance: an Orca-seeded value and a deliberate user selection are identical. Preserve those values rather than silently replacing an intentional selection. Existing affected profiles can use Git & Source Control → Saved Pi model choices → Use Pi’s configured model. This explicit reset applies only to the current execution host and preserves other hosts, agents, thinking choices, and recipe CLI arguments. The control also appears in settings search.
  • No new RPC opcode or execution-host routing changes. Mixed-version hosts ignoring optional intent retain their older model behavior until updated.

Runtime evidence

Actual Pi CLI 0.83.0 on macOS, production operation resolver and command planner, isolated settings/models.json, and a local OpenAI-compatible HTTP fixture:

Scenario Exit HTTP requests Model observed by server
Baseline forces Copilot 1 0 none; missing Copilot credentials
First-work branch-name Pi default 0 1 configured local
Commit-message Pi default 0 1 configured local
PR-details Pi default 0 1 configured local
Explicit Orca override 0 1 override

All successful cases return fixture-generated-commit. No real account credentials or paid model calls were needed. Reproduce with ORCA_BACKGROUND_LAUNCH=1 node tests/tools/pi-default-runtime-smoke.mjs /path/to/pi/dist/cli.js.

The added Pi configured default verification workflow repeats this actual CLI proof on Windows, Linux, and macOS with Pi 0.84.2. Its checks must pass before merging.

Compared against the checked-out Pi source: packages/coding-agent/src/core/model-resolver.ts, findInitialModel, explicitly gives CLI overrides precedence over saved defaults.

Validation

  • 163 tests passed across seven planner, discovery, persistence, settings, and dialog test files; five additional reset regressions cover local, SSH, WSL, runtime, and unresolved host scopes.
  • Round-trip regression tests cover local, SSH, and WSL host keys, all three operations, explicit choices, and legacy projection/reload.
  • Changed-file oxlint and formatting passed.
  • Full Node and Web typechecks passed; the reset UI also passed its final Web typecheck. After merging fix(pi): load extension providers for source control generation #20070, 97 focused tests and both actual CLI smoke scripts passed again. Both native macOS/Linux/Windows runtime matrices passed at 1cdf8bb, as did Windows packaging. Final test-only correction acbc136942b97b49d55016d38cd4272519981aba consolidates a duplicate test import caught by CI's native-plugin rule. Full native/type-aware audits, 17 affected tests, RPC catalog and max-lines checks pass locally; localization extraction/catalog/runtime/coverage and changed-code checks also passed. The final configured-default matrix, provider matrix, and full PR CI are pending. Merge remains blocked until all pass.
  • Current screenshots below show actual rendered reset behavior; CLI/HTTP assertions separately verify the resulting provider/model execution.

Current rendered proof

Hidden Electron instance identity verified as pi-default-provider-verify @ review/pi-default-provider, CDP 9339. No window activation. Inspected dark and light themes.

Three actual reset clicks passed: saved Copilot choices disappear, success toast renders, and settings retain the other agent, another SSH host’s Pi model, and recipe arguments. Reloaded the renderer and verified persisted settings. Then the real Pi CLI smoke test loaded the app’s saved settings and successfully generated through branch-name, commit-message, and PR-detail resolution.

Before reset (settings search finds the host-scoped control):

Saved Pi model reset control

After reset (saved override removed and success shown):

Pi configured-default reset completed

Agent skill upstream boundary

Not applicable; no skill source or bundle changes.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

Pi now uses default as its built-in model sentinel and omits --model for that selection. Discovery excludes the sentinel and provides a compatibility model when needed. Versioned state tracks host and operation defaults across migration and settings updates. Source-control resolution propagates configured-default intent through planning, RPC, and renderer parameters. Settings can reset saved host-specific Pi choices. Tests cover migration, reloads, overrides, and runtime behavior across three operating systems.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to acbc1

Pi configured-default settings can still ignore an explicit model choice or fail while loading persisted settings, and the intended runtime validation may be skipped for relevant changes. These should be resolved before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 32 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR meets the coding requirements in issue #14407. Pi defines a synthetic default choice and omits --model for that choice. Source Control AI resolution preserves configured-default intent and …
Out of Scope Changes check ✅ Passed The changes stay within issue #14407. Agent-spec, resolver, planner, persistence, migration, discovery, settings, localization, reset UI, and runtime-test changes support Pi configured-default behavio…
Title check ✅ Passed The title clearly and concisely describes the primary change: allowing Pi to use its configured default model.
Description check ✅ Passed The description provides detailed change context, rationale, linked issue, visual proof, testing evidence, compatibility notes, and the upstream-boundary statement. It omits several template headings …
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 32 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

…default

Orca seeded selectedModelByAgent.pi = github-copilot/gpt-5.4-mini the first
time a user picked Pi on a pre-fix build, and pi --list-models still lists
that id, so the resolution chain honoured it and STA-4249 kept reproducing
for every upgrading user. Every prior test started from an empty selection.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Codex revision complete.

What I kept:

  • The client-owned synthetic default / Pi default catalog entry and Pi's omission of --model for that configured-default choice.
  • The provider-neutral Pi recipe hint (--model provider/model).

What I changed:

  • Replaced the permanent resolver remap of github-copilot/gpt-5.4-mini with versioned, per-host provenance. Released automatic defaults migrate once, while a current explicit selection of that concrete model remains selectable and emits --model.
  • Persisted configured-default intent as the former concrete fallback plus an optional useConfiguredDefaultModel field. Current hosts validate the exact Pi/fallback/no-thinking invariant before suppressing --model; older hosts that ignore the optional field retain the concrete compatibility fallback.
  • Kept host discovery concrete-only and removed synthetic defaults from persisted discovery caches; the current client owns the synthetic presentation.
  • Split the Pi-specific planner/model and resolver coverage into focused modules to stay within the max-lines ratchets without suppressions.

Verification:

  • Focused Vitest: 6 suites / 122 tests passed; the planner/resolver subset was rerun after the file split (3 suites / 71 tests passed).
  • pnpm typecheck passed.
  • Changed-code quality: 0 findings; type-aware quality: 0; React Doctor: 0.
  • Electron/Playwright CDP validation attached to the intended revise-15649 dev instance and visibly confirmed the Commit Message recipe selected Pi with the --model provider/model placeholder. Pi is not installed in the isolated QA profile, so live Pi discovery was not exercised.

Non-vacuity proof (temporary mutations restored afterward):

  • Restoring the concrete planned Pi model made the acceptance test fail with expected [...] to not include '--model' at commit-message-plan.test.ts:16.
  • Disabling the provenance migration made the migration test fail because defaultsByHost.local was expected to be true but received undefined.

@coderabbitai coderabbitai 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.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/shared/pi-configured-default-model-state.ts (1)

155-158: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Document that this function mutates args.next.

applyPiConfiguredDefaultSelectionUpdate returns the new provenance state and also rewrites the caller's next settings object in place through normalizeChoice. settings-update.ts depends on that side effect, because it passes sanitizedUpdates.sourceControlAi and then persists it. A future caller that passes a live settings object would mutate it without noticing.

Add one short comment stating the in-place rewrite, or return the normalized settings alongside the state.

src/main/persistence-source-control-ai-migration.test.ts (1)

170-201: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the second half of the test name.

The test name says "without reinterpreting later concrete writes", but the body only asserts the seeding case. Add a case where the persisted state already exists and the selection is an explicit github-copilot/gpt-5.4-mini, then assert defaultsByHost.local stays absent. That case is the migration behavior most likely to regress, because it separates an automatic seed from an explicit user choice.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bb87856a-b28b-483a-a9ee-9bd4ac06ad9f

📥 Commits

Reviewing files that changed from the base of the PR and between e8384d6 and ce508dc.

📒 Files selected for processing (17)
  • src/main/persistence-source-control-ai-migration.test.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/loading-store/store.ts
  • src/main/runtime/rpc/methods/git-params.ts
  • src/main/text-generation/commit-message-text-generation-model-discovery.test.ts
  • src/main/text-generation/commit-message-text-generation.ts
  • src/renderer/src/components/right-sidebar/SourceControlTextGenerationDialog.test.ts
  • src/renderer/src/components/right-sidebar/source-control/ai/text-generation-params.ts
  • src/shared/commit-message-agent-spec.ts
  • src/shared/commit-message-plan-model.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/commit-message-plan.ts
  • src/shared/constants.ts
  • src/shared/global-settings-types.ts
  • src/shared/pi-configured-default-model-state.ts
  • src/shared/source-control-ai-pi-default.test.ts
  • src/shared/source-control-ai.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.

Comment on lines +219 to +223
sanitizedUpdates.piConfiguredDefaultModelState = applyPiConfiguredDefaultSelectionUpdate({
previous: previousSourceControlAi,
next: sanitizedUpdates.sourceControlAi!,
state: operations.state.settings.piConfiguredDefaultModelState
})

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Resolve the nullability of sanitizedUpdates.sourceControlAi at this call site.
set -euo pipefail

# 1) Signature of the function that produces the value assigned just above.
rg -nP -C 12 'function\s+retireLegacyInstructionsForClearedTextActionRecipes' --type=ts

# 2) Writers that pass sourceControlAi into updateSettings / settings RPC.
rg -nP -C 4 '\bsourceControlAi\s*:' --type=ts --type=tsx -g '!**/*.test.*' | rg -n -C 4 'updateSettings|setSettings|settings:update'

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- target file context ---'
sed -n '150,255p' src/main/persistence/applying-settings/settings-update.ts

printf '%s\n' '--- function and symbol locations ---'
rg -n -F 'retireLegacyInstructionsForClearedTextActionRecipes' .
rg -n -F 'applyPiConfiguredDefaultSelectionUpdate' .
rg -n -F 'sourceControlAi' src/main src/renderer src/shared 2>/dev/null || true

printf '%s\n' '--- settings update APIs ---'
rg -n -C 4 'updateSettings|setSettings|settings:update' src/main src/renderer src/shared 2>/dev/null || true

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -u

log=/tmp/coderabbit-shell-logs/shell-output-HOUx4l

printf '%s\n' '--- target-file excerpts from saved output ---'
rg -n -C 25 'settings-update\.ts|retireLegacyInstructionsForClearedTextActionRecipes|applyPiConfiguredDefaultSelectionUpdate' "$log" | head -n 240

printf '%s\n' '--- exact function locations in tracked source ---'
rg -n -F 'retireLegacyInstructionsForClearedTextActionRecipes' --glob '!**/*.test.*' --glob '!**/*.spec.*' .
rg -n -F 'applyPiConfiguredDefaultSelectionUpdate' --glob '!**/*.test.*' --glob '!**/*.spec.*' .

printf '%s\n' '--- sourceControlAi object writers, excluding tests ---'
rg -n -C 3 '\bsourceControlAi\s*:' src --glob '*.{ts,tsx,js,jsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 500

printf '%s\n' '--- sourceControlAi type declarations and normalizers ---'
rg -n -C 5 'type .*SourceControlAi|interface .*SourceControlAi|SourceControlAi|normalizeSourceControlAiSettings|readSourceControlAiSettings' src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 500

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- settings update imports, types, and call site ---'
sed -n '1,245p' src/main/persistence/applying-settings/settings-update.ts

printf '%s\n' '--- legacy retirement helper ---'
cat -n src/main/persistence/applying-settings/source-control-settings.ts

printf '%s\n' '--- selection update implementation ---'
cat -n src/shared/pi-configured-default-model-state.ts | sed -n '1,190p'

printf '%s\n' '--- GlobalSettings declarations ---'
rg -n -C 8 'GlobalSettings\s*=' src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*'
rg -n -C 5 'sourceControlAi\??\s*:' src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*'

printf '%s\n' '--- updateSettings entry points and schemas ---'
rg -n -C 10 'updateSettings\s*\(|update-settings|settings.*update|GlobalSettingsPatch|Partial<GlobalSettings>' src/main src/preload src/shared --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 800

printf '%s\n' '--- global recipe-save result flow ---'
cat -n src/shared/source-control-ai-recipe-save.ts | sed -n '1,235p'

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- GlobalSettings sourceControlAi property ---'
rg -n -C 12 'sourceControlAi' src/shared/global-settings-types.ts

printf '%s\n' '--- settings IPC update handlers ---'
rg -n -C 18 "settings:update|settings:.*update|updateSettings" src/main/ipc/settings.ts src/main --glob '*.ts' --glob '!**/*.test.*' | head -n 500

printf '%s\n' '--- source-control normalization ---'
rg -n -C 25 'function normalizeSourceControlAiSettings|export function normalizeSourceControlAiSettings' src/shared/source-control-ai.ts

printf '%s\n' '--- all global settings sourceControlAi update call sites ---'
rg -n -C 6 "updateSettings\(\s*\{\s*sourceControlAi|updateSettings\(\{ sourceControlAi" src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*'

printf '%s\n' '--- updateSettings callers passing generic update objects ---'
rg -n -C 5 'store\.updateSettings|\.updateSettings\(' src/main src/renderer src/preload --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | rg -v 'updateRepo|updateSettings\s*=' | head -n 800

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- settings IPC handler and sanitizer ---'
sed -n '1,215p' src/main/ipc/settings.ts
rg -n -C 20 'function sanitizeRendererSettingsUpdate|sanitizeRendererSettingsUpdate' src/main src/shared --glob '*.ts' --glob '!**/*.test.*'

printf '%s\n' '--- renderer settings update API ---'
rg -n -C 18 'updateSettings\s*:' src/renderer/src/store src/renderer/src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 400
rg -n -C 12 "settings:set|updateSettings\(" src/renderer/src/store src/preload --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 500

printf '%s\n' '--- declarations involving nullish global sourceControlAi writes ---'
rg -n -C 5 'sourceControlAi\s*:\s*(undefined|null)|sourceControlAi\s*\?\?' src --glob '*.{ts,tsx,js,jsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' || true

printf '%s\n' '--- focused behavioral probe ---'
python3 - <<'PY'
def retire(source):
    # Exact relevant behavior of retireLegacyInstructionsForClearedTextActionRecipes.
    return source if not (source and source.get("actions")) else source

def normalize(value, legacy):
    # Exact nullish fallback shape needed by the call-site question.
    return value if value is not None else legacy

def apply(next_value):
    # Exact first dereference in applyPiConfiguredDefaultSelectionUpdate.
    return next_value["selectedModelByAgentByHost"]

for label, value in [
    ("undefined", None),
    ("null", None),
    ("object", {"selectedModelByAgentByHost": {}}),
]:
    try:
        result = apply(retire(value))
        print(label, "call-site next dereference:", "ok", result)
    except Exception as exc:
        print(label, "call-site next dereference:", type(exc).__name__, str(exc))
PY

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -u

printf '%s\n' '--- renderer persistence path ---'
rg -n -C 18 'function persistSettingsUpdates|const persistSettingsUpdates|persistSettingsUpdates' src/renderer/src/store src/renderer/src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 240

printf '%s\n' '--- settings IPC/preload contract ---'
rg -n -C 10 "'settings:set'|settings:set|setSettings|updateSettings" src/preload src/renderer/src --glob '*.{ts,tsx}' --glob '!**/*.test.*' --glob '!**/*.spec.*' | head -n 300

printf '%s\n' '--- exact nullish call-site probe ---'
python3 - <<'PY'
UNDEFINED = object()

def retire(source):
    # Mirrors `if (!sourceControlAi?.actions) return source`.
    if source is UNDEFINED or source is None or not source.get("actions"):
        return source
    return source

def apply_selection_update(next_value):
    # Mirrors the first property access in applyPiConfiguredDefaultSelectionUpdate.
    return next_value["selectedModelByAgentByHost"]

def normalize(value, previous):
    # Mirrors the nullish fallback used by normalizeSourceControlAiSettings.
    return previous if value is UNDEFINED or value is None else value

previous = {"selectedModelByAgentByHost": {}}
for label, incoming in (
    ("undefined", UNDEFINED),
    ("null", None),
    ("object", {"selectedModelByAgentByHost": {}}),
):
    retired = retire(incoming)
    try:
        apply_selection_update(retired)
        status = "safe"
    except (AttributeError, KeyError, TypeError) as exc:
        status = f"crashes with {type(exc).__name__}"
    fallback = normalize(retired, previous)
    fallback_status = "object" if isinstance(fallback, dict) else type(fallback).__name__
    print(f"{label}: {status}; later normalization yields {fallback_status}")
PY

Repository: stablyai/orca

Length of output: 42614


Guard nullish sourceControlAi updates before applying Pi selection state. The retirement helper preserves undefined, and the IPC writer does not reject null. Pass sanitizedUpdates.sourceControlAi ?? previousSourceControlAi as next before normalization.

Comment on lines +51 to +54
const state: PiConfiguredDefaultModelState =
args.persistedState?.version === 1
? structuredClone(args.persistedState)
: { version: 1, defaultsByHost: {}, commitMessageSeedByHost: {} }

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Validate the cloned persisted state shape, not just version.

Both state builders trust version === 1 and clone the persisted object as-is. The persisted payload is parsed from the on-disk JSON file, so defaultsByHost or commitMessageSeedByHost can be missing (hand-edited profile, or a rollback build that wrote only version). In that case structuredClone returns an object without those maps, and the seeding block below is skipped because args.persistedState is truthy.

Two downstream dereferences then throw:

  • applyPiConfiguredDefaultSelectionUpdate at Line 131 / Line 150 writes state.defaultsByHost[hostKey] = true.
  • selectPersistedModel in src/shared/source-control-ai.ts reads configuredDefaultState?.defaultsByHost[hostKey] and configuredDefaultState?.commitMessageSeedByHost[hostKey], which runs on every commit-message, pull-request, and branch-name resolution.

Normalize the maps when you adopt persisted state. The same fix is needed at Lines 115-118.

🛡️ Proposed fix for both state builders
+function adoptPersistedState(
+  persisted: GlobalSettings['piConfiguredDefaultModelState']
+): PiConfiguredDefaultModelState {
+  const cloned = persisted?.version === 1 ? structuredClone(persisted) : undefined
+  return {
+    version: 1,
+    defaultsByHost: cloned?.defaultsByHost ?? {},
+    commitMessageSeedByHost: cloned?.commitMessageSeedByHost ?? {}
+  }
+}
-  const state: PiConfiguredDefaultModelState =
-    args.persistedState?.version === 1
-      ? structuredClone(args.persistedState)
-      : { version: 1, defaultsByHost: {}, commitMessageSeedByHost: {} }
+  const state = adoptPersistedState(args.persistedState)
-  const state: PiConfiguredDefaultModelState =
-    args.state?.version === 1
-      ? structuredClone(args.state)
-      : { version: 1, defaultsByHost: {}, commitMessageSeedByHost: {} }
+  const state = adoptPersistedState(args.state)

Comment thread src/shared/source-control-ai.ts Outdated
Comment on lines +1018 to +1024
const markedDefault =
configuredDefaultState?.defaultsByHost[hostKey] === true &&
repoModel === undefined &&
operationModel === undefined &&
persisted === PI_RETIRED_COPILOT_DEFAULT_MODEL_ID
const useConfiguredDefaultModel =
agentId === 'pi' && (persisted === PI_DEFAULT_MODEL_ID || markedOperationSeed || markedDefault)

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.

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

An explicit re-selection of github-copilot/gpt-5.4-mini stays treated as the configured default.

markedDefault trusts defaultsByHost[hostKey] whenever the resolved model equals the retired id. Provenance is cleared only by applyPiConfiguredDefaultSelectionUpdate, and that function skips a host when next === previous (Lines 127-129 of src/shared/pi-configured-default-model-state.ts).

Sequence that breaks the stated contract:

  1. Migration seeds defaultsByHost.local = true with the concrete value github-copilot/gpt-5.4-mini.
  2. The user opens the Pi model picker and explicitly selects that same model, which the PR keeps selectable.
  3. The write produces the identical string, so the diff finds no change and defaultsByHost.local stays true.
  4. Resolution reports useConfiguredDefaultModel: true, and --model is omitted.

The user's explicit selection is then ignored on every commit-message, pull-request, and branch-name generation. The PR objectives require that an explicit current selection of github-copilot/gpt-5.4-mini keeps emitting --model.

Fix the root cause in applyPiConfiguredDefaultSelectionUpdate: clear defaultsByHost[hostKey] and commitMessageSeedByHost[hostKey] whenever the incoming update carries a Pi selection for that host, instead of only when the value changes. Presence of the key in the write proves an explicit act; value equality does not.

@nwparker nwparker 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.

Review for the strict verification pass: this PR now changes persisted settings migration and per-host default tracking as well as CLI model selection. I cannot mark it fully verified from the argument-plan tests alone. The remaining acceptance run must use persisted pre-upgrade settings, distinguish implicit defaults from deliberately selected Copilot models, exercise explicit per-operation/per-host overrides, and actually generate branch/commit/PR text with the configured provider.

The Pi recipe also still includes --no-extensions. I separately reproduced #14951 with the actual Pi CLI: an extension-backed provider remains unavailable with that flag. Those users need the provider-loading fix too; do not count their configured-provider flow as verified by omitting --model alone. Leaving #14407 open and this PR unmerged for that complete integration pass.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
.github/workflows/pi-default-runtime.yml (1)

4-7: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extend the paths filter to the modules the smoke test exercises.

The smoke test bundles and asserts against src/shared/commit-message-plan.ts, src/shared/source-control-ai.ts, src/shared/constants.ts, and the Pi configured-default modules. The filter only triggers on src/shared/commit-message-agent-specs-primary.ts and the workflow/test files. A regression in the planner or the source-control resolver would not run this verification.

♻️ Proposed filter extension
     paths:
       - 'src/shared/commit-message-agent-specs-primary.ts'
+      - 'src/shared/commit-message-agent-spec.ts'
+      - 'src/shared/commit-message-plan.ts'
+      - 'src/shared/commit-message-plan-model.ts'
+      - 'src/shared/source-control-ai.ts'
+      - 'src/shared/source-control-ai-model-selection.ts'
+      - 'src/shared/pi-configured-default-model.ts'
+      - 'src/shared/pi-configured-default-model-state.ts'
       - 'tests/tools/pi-default-runtime-smoke.mjs'
       - '.github/workflows/pi-default-runtime.yml'

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 651e822e-c302-4327-9fb7-d135c44e7579

📥 Commits

Reviewing files that changed from the base of the PR and between ce508dc and 26233e1.

📒 Files selected for processing (24)
  • .github/workflows/pi-default-runtime.yml
  • src/main/persistence-source-control-ai-migration.test.ts
  • src/main/persistence/applying-settings/settings-update.ts
  • src/main/persistence/loading-store/normalize-loaded-global-settings.ts
  • src/main/persistence/loading-store/prepare-loaded-terminal-settings.ts
  • src/main/text-generation/commit-message-model-discovery-policy.ts
  • src/main/text-generation/commit-message-text-generation-model-discovery.test.ts
  • src/renderer/src/components/right-sidebar/SourceControlTextGenerationDialog.test.ts
  • src/renderer/src/components/right-sidebar/source-control/ai/text-generation-params.ts
  • src/shared/commit-message-agent-spec.test.ts
  • src/shared/commit-message-agent-spec.ts
  • src/shared/commit-message-agent-specs-primary.ts
  • src/shared/default-global-settings.ts
  • src/shared/global-settings-types.ts
  • src/shared/pi-configured-default-discovery.ts
  • src/shared/pi-configured-default-model-state.ts
  • src/shared/pi-configured-default-model.ts
  • src/shared/rpc-contract/git-params.ts
  • src/shared/source-control-ai-legacy-projection.ts
  • src/shared/source-control-ai-model-selection.ts
  • src/shared/source-control-ai-pi-default.test.ts
  • src/shared/source-control-ai-settings.ts
  • src/shared/source-control-ai.ts
  • tests/tools/pi-default-runtime-smoke.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Comment on lines +230 to +238
const previousSourceControlAi = normalizeSourceControlAiSettings(
operations.state.settings.sourceControlAi,
operations.state.settings.commitMessageAi
)
sanitizedUpdates.piConfiguredDefaultModelState = applyPiConfiguredDefaultSelectionUpdate({
previous: previousSourceControlAi,
next: sanitizedUpdates.sourceControlAi!,
state: operations.state.settings.piConfiguredDefaultModelState
})

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.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
set -euo pipefail
rg -n -B2 -A 40 'function normalizeSettings' src/shared/source-control-ai.ts

Repository: stablyai/orca

Length of output: 151


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- candidate files ---'
fd -t f -i 'source-control-ai|settings-update' src

printf '%s\n' '--- settings-update target ---'
sed -n '1,70p;205,255p' src/main/persistence/applying-settings/settings-update.ts

printf '%s\n' '--- normalization and update definitions ---'
rg -n -B8 -A55 'normalizeSourceControlAiSettings|applyPiConfiguredDefaultSelectionUpdate|function normalizeSettings|normalizeSettings' src

Repository: stablyai/orca

Length of output: 50370


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- settings-update imports and update path ---'
sed -n '1,55p;215,252p' src/main/persistence/applying-settings/settings-update.ts

printf '%s\n' '--- source-control-ai normalization ---'
sed -n '1,180p' src/shared/source-control-ai-settings.ts

printf '%s\n' '--- default-state comparison and model lookup ---'
sed -n '1,130p' src/shared/pi-configured-default-model-state.ts

Repository: stablyai/orca

Length of output: 15617


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- sourceControlAi update contract and callers ---'
rg -n -B6 -A12 'sourceControlAi\??:|sourceControlAi\s*[:=]' src/main src/shared src/renderer --glob '*.ts' --glob '*.tsx' \
  | rg -n -m 120 'sourceControlAi|settings.update|updateSettings|writeSourceControlAiSettings|Partial<GlobalSettings>'

printf '%s\n' '--- updateSettings caller boundary ---'
rg -n -B12 -A18 'updateSettings\(' src/main --glob '*.ts' | head -n 240

printf '%s\n' '--- normalization entry and null handling ---'
rg -n -B8 -A18 'updateSettings\(|sanitizedUpdates\s*=|sourceControlAi.*undefined|sourceControlAi.*null' src/main/persistence/applying-settings/settings-update.ts src/main/persistence --glob '*.ts'

Repository: stablyai/orca

Length of output: 50369


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '%s\n' '--- retirement helper contract ---'
sed -n '1,90p' src/main/persistence/applying-settings/source-control-settings.ts

printf '%s\n' '--- global settings and IPC update boundary ---'
sed -n '450,480p' src/shared/global-settings-types.ts
rg -n -B12 -A20 'updateSettings.*ipc|settings.*update|updateSettings' src/main --glob '*.ts' \
  | rg -n -m 100 'ipc|updateSettings|Partial<GlobalSettings>|sourceControlAi'

printf '%s\n' '--- tests for nullish global sourceControlAi updates ---'
rg -n -B8 -A18 'sourceControlAi:\s*(null|undefined)|sourceControlAi.*null|sourceControlAi.*undefined' src/main --glob '*test.ts'

Repository: stablyai/orca

Length of output: 22782


Guard and normalize sourceControlAi before applying Pi state

normalizeSourceControlAiSettings does not merge legacy model fields into a present sourceControlAi value, so reordering normalization does not fix the claimed comparison mismatch.

If an update contains sourceControlAi: undefined or null, applyPiConfiguredDefaultSelectionUpdate receives that value and can throw when it reads selectedModelByAgentByHost. Use the normalized current value for both next and the persisted update:

const normalizedSourceControlAi = normalizeSourceControlAiSettings(
  sanitizedUpdates.sourceControlAi ?? operations.state.settings.sourceControlAi,
  operations.state.settings.commitMessageAi
)
sanitizedUpdates.piConfiguredDefaultModelState = applyPiConfiguredDefaultSelectionUpdate({
  previous: previousSourceControlAi,
  next: normalizedSourceControlAi,
  state: operations.state.settings.piConfiguredDefaultModelState
})
sanitizedUpdates.sourceControlAi = normalizedSourceControlAi

Comment on lines +53 to +54
marks[hostKey] = true
changed = true

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.

🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Keep the migration idempotent.

When marks[hostKey] is already true, this branch still sets changed = true. Therefore, every startup with the Pi default selected calls markNeedsSave() and rewrites unchanged settings.

Set changed only when this migration adds the mark. Apply the same condition to commitMessageSeedByHost.

Proposed fix
       if (modelForHost(choice, hostKey) === PI_DEFAULT_MODEL_ID) {
-        marks[hostKey] = true
-        changed = true
+        if (marks[hostKey] !== true) {
+          marks[hostKey] = true
+          changed = true
+        }
       }

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0c209310-60f3-446b-b1cb-caf7e4948c35

📥 Commits

Reviewing files that changed from the base of the PR and between 26233e1 and acbc136.

📒 Files selected for processing (10)
  • src/renderer/src/components/settings/CommitMessageAiPane.tsx
  • src/renderer/src/components/settings/PiConfiguredModelReset.tsx
  • src/renderer/src/components/settings/commit-message-ai-search.ts
  • src/renderer/src/i18n/locales/en.json
  • src/shared/commit-message-agent-specs-primary.ts
  • src/shared/commit-message-plan.test.ts
  • src/shared/pi-source-control-model-reset.test.ts
  • src/shared/pi-source-control-model-reset.ts
  • src/shared/source-control-ai-pi-default.test.ts
  • tests/tools/pi-default-runtime-smoke.mjs
💤 Files with no reviewable changes (1)
  • src/shared/commit-message-agent-specs-primary.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/shared/source-control-ai-pi-default.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

config.enabled &&
matchesSettingsSearch(searchQuery, {
title: translate('settings.piConfiguredModelReset.title', 'Saved Pi model choices'),
description: translate('settings.piConfiguredModelReset.action', 'Use Pi’s configured model'),

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use the reset description in both search metadata sites.

Searches for terms in the displayed description, such as “pull requests” or “branch names”, do not match this setting. Both sites use the shorter action label instead.

  • src/renderer/src/components/settings/CommitMessageAiPane.tsx#L229-L229: replace settings.piConfiguredModelReset.action with settings.piConfiguredModelReset.description.
  • src/renderer/src/components/settings/commit-message-ai-search.ts#L8-L8: replace settings.piConfiguredModelReset.action with settings.piConfiguredModelReset.description.
📍 Affects 2 files
  • src/renderer/src/components/settings/CommitMessageAiPane.tsx#L229-L229 (this comment)
  • src/renderer/src/components/settings/commit-message-ai-search.ts#L8-L8

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing as superseded: a merged PR already covers this change. Merged #21693 (b0cbb91, 09-19) made Pi's Source Control AI default 'default' and omits --model (src/shared/commit-message-agent-specs-primary.ts:234,239-247 'lets Pi use its configured provider'). The PR's extra reset UI and legacy migration did not

(Stale-PR cleanup 2026-10-20, approved by Brennan. Reopen if something here is still missing on main.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Pi branch auto-rename hardcodes GitHub Copilot model instead of using Pi's configured provider

2 participants