Skip to content

fix(desktop): keep the live controller when a model switch fails#3003

Merged
esengine merged 1 commit into
main-v2from
fix/2768-harden-model-switch
Jun 4, 2026
Merged

fix(desktop): keep the live controller when a model switch fails#3003
esengine merged 1 commit into
main-v2from
fix/2768-harden-model-switch

Conversation

@esengine
Copy link
Copy Markdown
Owner

@esengine esengine commented Jun 4, 2026

Re-implementation of #2768 by @paradoxSCH (Closes #2644) against current main-v2 — the original couldn't be rebased because #2928's multi-tab refactor moved every field it touched (a.ctrltab.Ctrl etc.), so I re-applied the load-bearing fixes against the new WorkspaceTab model.

The bug (still live on main-v2)

SetModel (desktop/app.go) and rebuild (desktop/settings_app.go) both did tab.Ctrl.Close() before boot.Build. A failed build — e.g. switching to an unknown/misconfigured model — returned the error but left the tab pointing at a closed controller, killing the conversation. The frontend then swallowed the error (SetModel(...).catch(() => {})), so the user saw nothing.

Fix

  • Build → swap → close on success only. On a failed boot.Build, the existing controller is left untouched and still usable. (both SetModel and rebuild)
  • Surface the failure in useController.ts via local_notice instead of dropping it.
  • Quiet boot diagnostics on the desktop — pass Stderr: io.Discard to the three desktop boot.Build sites (SetModel, rebuild, initial tab build) so bash-sandbox warnings stop leaking to the Windows desktop console during rebuilds.

Scoped to the correctness fixes; left out the original PR's unrelated bits (dist placeholder, a JSX→ReactElement type tweak) which aren't bugs.

Verification

  • gofmt clean; go build ./... (desktop) + full go test ./... (desktop module) green
  • pnpm run typecheck (frontend) clean
  • Added TestSetModelFailureLeavesTabStateIntact (failed switch returns an error and leaves tab controller/model unmutated)

Closes #2768
Closes #2644

SetModel and rebuild closed the active tab's controller before building
the replacement, so a failed boot.Build (e.g. an unknown model) left the
tab with a closed controller and the conversation dead — and the frontend
swallowed the error. Build first, swap, then close the old controller
only on success; on failure the existing controller stays live. Surface
the failure in the UI via local_notice instead of dropping it, and pass
io.Discard for boot diagnostics so sandbox warnings stop leaking to the
desktop console on rebuilds.
@github-actions github-actions Bot added the v2 Go rewrite (1.x) — main-v2 branch, active development label Jun 4, 2026
@esengine esengine merged commit faa1d20 into main-v2 Jun 4, 2026
9 checks passed
@esengine esengine deleted the fix/2768-harden-model-switch branch June 4, 2026 03:08
esengine added a commit that referenced this pull request Jun 4, 2026
…3011)

* fix(desktop): remove accidental project tabs rollout

* fix(desktop): preserve settings session on rebuild errors

* fix(desktop): preserve model-switch + macOS chrome fixes in tabs revert

The tabs revert reintroduced regressions for fixes that landed on top of
#2928:
- SetModel closed the controller before boot.Build, so a failed switch
  left a dead controller (regressed #3003); restore build→swap→close and
  io.Discard for boot diagnostics, and surface the failure in the UI.
- The macOS window chrome (#2997) was stripped from the frontend; restore
  Platform() wiring (bridge.ts), the data-platform/chrome layer (App.tsx),
  and the darwin-only CSS (minus the removed workspace-tabs-bar rule).

---------

Co-authored-by: Sivan <liuxw96@foxmail.com>
Co-authored-by: reasonix <reasonix@deepseek.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: bash sandbox requested but unavailable on this platform; running bash unconfined

1 participant