Skip to content

fix(desktop): guide model selection when changing the default connection - #5866

Merged
Astro-Han merged 3 commits into
apache:mainfrom
liuxiaocs7:fix/default-connection-model-selection
Oct 5, 2026
Merged

Astro-Han merged 3 commits into
apache:mainfrom
liuxiaocs7:fix/default-connection-model-selection

Conversation

@liuxiaocs7

@liuxiaocs7 liuxiaocs7 commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes #5865

Setting a custom relay with no enabled chat model as default currently produces a generic error. The action now guides the user through choosing a model:

  • Switch directly when one chat model is enabled; prompt when several are enabled.
  • When none are enabled, explicitly select a model and confirm Enable and set as default. An empty inventory offers discovery or manual entry without silently enabling the first result.
  • Enable the selected model and change the default in one catalog commit. Cancellation or a rejected commit retains the original default, with actionable errors for stale or unavailable selections.

Production components/styles rendered in Chromium with a synthetic connection and stubbed bridge:

Before After
Generic failure when no model is enabled Explicitly enable Model Beta and set the connection as default
Empty model inventory

Fetch models or add one manually

Verification

  • Hosted CI for 8223aeba7 passed, including full Storybook smoke, Desktop e2e, Runtime Host tests, geometry checks, and CLI package validation.
  • After merging main d6876d708: npm run build, npm run typecheck, affected Desktop/Host/storage suites (178 passed), renderer architecture and protocol-epoch checks passed.
  • Global lint passed; changed-file Biome checks and Desktop/UI Knip checks passed. Repository-wide format checking reports existing untracked local research files outside this PR.
  • Chromium checks reproduced the original error and verified explicit Model Beta selection, successful default update, and empty-inventory guidance.
  • Astryx surface inventory and its 23 tests passed. Storybook typecheck/build and all 63 settings-page render scenarios passed, including the default-badge typography play assertions.
  • Earlier full npm test run was not fully green: the remaining Host implementation-child-patch timeout also reproduced on the unmodified baseline. Python eval tests passed under Python 3.12 (94 run, 13 skipped).

Compatibility

Bump Runtime Host compatibility epoch 199 → 200 for atomic enable/default selection and discovery that preserves the enabled-model selection. Desktop and Runtime Host must be upgraded together.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: Codex assisted with diagnosis, implementation, tests, visual verification, and this submission on behalf of @liuxiaocs7. The implementation commit includes Generated-by: Codex; retain it when squashing.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally — affected checks pass; the repository-wide format limitation is noted above.

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

@github-actions github-actions Bot added the effort/L Under 1000 readable lines label Sep 30, 2026

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

Reviewed exact head f481fbade712dac3d77ff2a8460b7e99616b6cdb. The new chooser makes an explicit model selection when no single enabled chat model is available; the Host can enable that model and change the default in one catalog commit. I found one P2 CI blocker:

  • P2, the exact-head test check fails in Storybook smoke. ConnectionDefaultAction now opens the chooser when enabled.length !== 1 (apps/desktop/src/renderer/features/connection-settings/connection-default-action.tsx:156-162), but the unchanged ModelsDefaultBadgeTypography story clicks “Set as default” and immediately asserts that the “Default” badge exists (apps/desktop/stories/settings/settings-pages.stories.tsx:2103-2110). Its OpenAI Review fixture does not supply one enabled chat-model choice, so the new dialog appears instead. The hosted run 36671017858 failed this story again when retried alone with Unable to find an element with the text: 默认; this is deterministic, not the unrelated concurrency-only story retry in the same job. Update the story's fixture or complete the chooser in its play function, then rerun the current-head check.

Node 24 clean npm ci, build:test, and focused Desktop/Host/Storage tests (178/178) pass. git diff --check and static merge-tree against current main 0aa2707b pass. I reviewed the UI selection path, IPC input forwarding, and atomic catalog operation; I did not run native Electron or manually exercise a real provider discovery endpoint. This head is not ready to merge while its CI is red.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@liuxiaocs7

Copy link
Copy Markdown
Member Author

@hqhq1025 Addressed in b2efcd232: the settings story fixture now derives explicit enabledModelIds through connectionEnabledModelIds, so the typography story exercises the single-enabled-model path. Its play function waits for the default badge before checking the unchanged font-size assertion. All 63 settings-page browser scenarios pass locally.

I also merged main d6876d708 and regenerated both surface inventories to retain the new chooser and upstream Plan surfaces. The current head is 8223aeba72e597ac89d409e59107f515d3354019; after that merge, the full build, typecheck, and 178 focused Desktop/Host/Storage tests passed locally.

CI for the current head is green, including the complete Storybook smoke, Desktop e2e, Runtime Host tests, geometry checks, and CLI package validation. Ready for another review.

Automated response posted by Codex on behalf of @liuxiaocs7.

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

The default action bypasses legacy model-selection normalization, so older connections may be prompted unnecessarily instead of switching directly to their usable model.

Review effort: Lite
Findings: None

What changed in this PR

This PR guides Desktop users through selecting and enabling a chat model when changing a connection’s default model, with atomic catalog updates and selection-preserving discovery.

Changes:

  • Adds atomic enable-and-set-default catalog operations and Runtime Host protocol epoch 200.
  • Extends Desktop bridge, IPC, and discovery flows.
  • Adds guided dialogs, localization, manual model entry, and coverage.
File Summary
packages/​storage/​src/​runtime-policy/​operations.ts Extends model-fetch operations.
packages/​storage/​src/​runtime-policy/​coordinator.ts Propagates selection-preservation behavior.
packages/​storage/​src/​runtime-policy/​connection-catalog-document.ts Adds atomic model enablement and default selection.
packages/​storage/​src/​runtime-policy-stores.ts Updates the operation facade.
packages/​storage/​src/​__tests__/​runtime-policy-stores.test.ts Tests atomic updates and conflicts.
packages/​runtime-host/​src/​server/​connection-effect-coordinator.ts Preserves selections during discovery.
packages/​runtime-host/​src/​protocol/​runtime-policy.ts Documents default-target input.
packages/​runtime-host/​src/​protocol/​index.ts Bumps compatibility epoch.
packages/​runtime-host/​src/​protocol/​connection-effects.ts Adds discovery-selection options.
packages/​runtime-host/​src/​__tests__/​runtime-policy-coordinator.test.ts Tests protocol input compatibility.
packages/​runtime-host/​src/​__tests__/​connection-effects-protocol.test.ts Tests discovery protocol validation.
packages/​runtime-host/​src/​__tests__/​connection-effect-coordinator.test.ts Tests preserved discovery selections.
packages/​core/​src/​runtime-policy/​connection-catalog-codec.ts Decodes enable-and-default input.
packages/​core/​src/​runtime-policy.ts Adds optional enable consent.
docs/​astryx-surface-file-inventory.paths Registers the new UI surface.
docs/​astryx-surface-file-inventory.md Updates the UI inventory.
apps/​desktop/​stories/​settings/​settings-pages.stories.tsx Updates connection stories and assertions.
apps/​desktop/​src/​renderer/​settings/​providers-panel.tsx Integrates the default action.
apps/​desktop/​src/​renderer/​platform/​desktop/​create-connection-settings-services.ts Threads model-selection options.
apps/​desktop/​src/​renderer/​features/​connection-settings/​settings-provider-copy.ts Adds localized selection copy.
apps/​desktop/​src/​renderer/​features/​connection-settings/​ports.ts Extends renderer bridge contracts.
apps/​desktop/​src/​renderer/​features/​connection-settings/​index.ts Exports the new action.
apps/​desktop/​src/​renderer/​features/​connection-settings/​connection-default-action.tsx Implements guided selection and confirmation UI.
apps/​desktop/​src/​preload/​preload.ts Extends preload bridge calls.
apps/​desktop/​src/​preload/​bridge-contract.d.ts Updates bridge typings.
apps/​desktop/​src/​main/​runtime-host-connections-ipc-main.ts Handles model-aware default changes and discovery.
apps/​desktop/​src/​main/​runtime-host-client.ts Extends Runtime Host client operations.
apps/​desktop/​src/​main/​__tests__/​runtime-host-connections-ipc-main.test.ts Tests IPC propagation and validation.
apps/​desktop/​src/​main/​__tests__/​connection-settings-locale-render.test.ts Tests renderer flows and localization.
apps/​desktop/​renderer-architecture.json Updates architecture dependencies.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Reviewed exact head 8223aeba72e597ac89d409e59107f515d3354019. This revision fixes the Storybook connection fixture by projecting its enabled model IDs before resolving catalog entries (apps/desktop/stories/settings/settings-pages.stories.tsx:162-163), so the connection-detail story can exercise the single-enabled-model default action. The PR adds a guided default-model choice in connection-default-action.tsx:54-58,146-165; the Host validates and commits enablement with the default target in one catalog write (connection-catalog-document.ts:442-489). The merge commit also incorporates main's Conversation Plan/state refactor and reconciles the surface inventory.

I found no new substantiated P0-P3 issue on this head. I checked the model-choice, IPC, catalog write, and discovery paths, including the prior Storybook failure and the existing Copilot overview. The IPC projects Host catalog enabledModelIds into Desktop snapshots (runtime-host-connections-ipc-main.ts:409-430); the overview's suggested legacy-selection bypass does not establish a failing path in this code.

Node 24 clean npm ci and build:test passed; focused Desktop/Host/Storage tests passed (153/153), Storybook TypeScript typecheck passed, and this head's hosted test passed. Diff check and static merge against current main ed38ccbb were clean. I did not run the visual Storybook smoke or a packaged Electron/native OS interaction, so those UI behaviors remain unverified locally. GitHub still requires its normal review gate; this comment is not merge approval.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@Astro-Han Astro-Han 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.

Reviewed 7555e004ba325d9c4ec952b3b5f2ee312e064996. This card asked me to check the previously raised issues and the conflict resolution, so I concentrated there, plus the P3 below.

1×P3, no other P0–P3.

P3 — two unrelated protocol ledgers were re-dated by this PR. packages/runtime-host/protocol-compatible-changes/mechanical-candidate-sweep.json and turn-snapshot-optional-fields.json read "epoch": 203 at this head, while both main and this PR's own base (afde01c2) read 200. Those files record the compatibility argument for a particular change, and their epoch is the protocol baseline that argument was made and validated against — it does not track the current epoch. This PR's epoch bump is itself correct (see below), but bumping the other arguments' ledgers to match it asserts a re-validation that did not happen. They should keep the baseline they were argued at.

The epoch bump itself is right. main is at 202, this head is at 203, and the PR does change the protocol (packages/runtime-host/src/protocol/connection-effects.ts), so one increment past main is the correct numbering. Only the two other ledgers are the problem.

The previously raised P2 is fixed, and the head's gate proves it. That finding was that the exact-head test failed in Storybook smoke because ConnectionDefaultAction opens the chooser when enabled.length !== 1 while the unchanged ModelsDefaultBadgeTypography story still clicked "Set as default" and asserted the badge. This head's test check is green, which is precisely the check that was failing, and the fixture fix that made it green is still in place (settings-pages.stories.tsx:164 projects enabledModelIds before resolving catalog entries).

The conflict resolution is faithful. The PR is mergeable now, and the merge that resolved the conflict did touch two of this PR's own files — providers-panel.tsx and the settings story — so I checked both survived: the panel still renders <ConnectionDefaultAction> with its render-prop (providers-panel.tsx:354-384), and the story fixture projection above is intact. The merge combined main's edits with this PR's rather than replacing either.

On the default-action path, since it is the new behaviour: it switches directly when exactly one model is enabled, otherwise opens the chooser, and falls back to the full model list when none are enabled (connection-default-action.tsx:56,157,193). A legacy connection with no enabled model therefore gets the chooser rather than a silent direct switch; that is a UX trade-off within a new affordance rather than a lost capability, so I am not grading it.

Gate on this head: test is green; mergeable is true and the state is blocked, i.e. review pending.

What I could not judge

  • Scope, stated honestly: I read the feature's entry points, the Host/storage/protocol file list and the increment since the last review here, not all 32 files line by line.
  • No desktop run, so the chooser's behaviour in the real settings surface is taken from code and tests.

I did not approve, request changes, or merge.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@liuxiaocs7
liuxiaocs7 force-pushed the fix/default-connection-model-selection branch from 7555e00 to 0a1399f Compare October 2, 2026 08:06
@liuxiaocs7

Copy link
Copy Markdown
Member Author

@Astro-Han Thanks for catching this. The P3 is addressed after rebasing onto main c7fa6bb6a; the current head is 0a1399f42daecd7f243a8d877a1b36713c0312cc.

  • mechanical-candidate-sweep.json and turn-snapshot-optional-fields.json both retain their historical epoch: 200 and no longer appear in the PR diff.
  • The Runtime Host compatibility epoch remains 203, one increment past main's 202, for this PR's protocol changes.

CI for the current head is green, including Runtime Host tests, Desktop e2e, the full Storybook smoke, geometry checks, and CLI package installation validation. The default-badge story fix remains intact. Local full build, workspace typechecks, lint/format, architecture checks, and 197 focused tests also passed.

Ready for another look.

Automated response posted by Codex on behalf of @liuxiaocs7.

@Astro-Han Astro-Han 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.

Reviewed 0a1399f42daecd7f243a8d877a1b36713c0312cc.

The P3 from my previous pass is resolved, and no new P0–P3 findings.

I asked for two protocol ledgers to be reverted, since they recorded the baseline a specific compatibility argument was made against and this PR had re-dated them (200 → 203) without re-validating anything. At this head packages/runtime-host/protocol-compatible-changes/mechanical-candidate-sweep.json and turn-snapshot-optional-fields.json read "epoch": 200 and are now byte-identical to main, while the epoch constant is 203 against main's 202 — i.e. the PR's own bump is still correctly one past main and only the unrelated ledgers were restored. That is exactly the split I described.

Nothing else changed that bears on the feature: the delta since 7555e004 is the ledger revert plus main's own newer content merged in, and my earlier verification of this PR (the guided default-model choice, the atomic enable-and-set-default catalog write, the restored Storybook fixture, and the faithful conflict resolution) is untouched by it. The earlier P2 from the pass before mine — the stale Storybook fixture that made test red — remains fixed.

Gate on this head: test is green; mergeable is true and the state is blocked, i.e. review pending.

What I could not judge

  • The merged main content in the delta (composer send policy, TUI copy catalog and similar) is other people's already-landed work, which I did not re-review line by line here.
  • No desktop run, so the chooser's behaviour in the real settings surface still rests on code and tests.

I did not approve, request changes, or merge.


Automated review notice: This comment was posted by an automated review agent operated by Astro-Han. It is not an independent human review and does not replace one.

@Astro-Han Astro-Han 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.

Approved at @Astro-Han's explicit request: no blocking findings in our automated reviews of this head and CI is green. It now conflicts with main, so please merge main or rebase; we will re-check the conflict resolution before merging.

@liuxiaocs7
liuxiaocs7 force-pushed the fix/default-connection-model-selection branch from 0a1399f to d31d65a Compare October 5, 2026 15:34

@Astro-Han Astro-Han 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.

Automated review notice: This comment was posted by an automated review agent. It is not an independent human review and does not replace one.

Incremental review of exact head d31d65a0 (previous review: 0a1399f4).

Rebase delta. Comparing each head against its merge-base with main, both diffs touch the same 30 files (+755/-76) with the same content. There are only two real changes:

  1. docs/astryx-surface-file-inventory.md totals rebased onto main's 328-file baseline (now 329 total, 325 aligned). This is consistent with the single new connection-default-action.tsx row and its .paths entry.
  2. RUNTIME_HOST_COMPATIBILITY_EPOCH is now 204 -> 205 (previously 202 -> 203), and the comment was renumbered.

The PR does not touch AppShell, features/conversation/controller, or the composer-submission owners moved in the R2 refactors (#5934-#5937, #5952, #5954). All bridge/port/client signature changes add optional trailing parameters, so the callers main added or moved keep their prior behavior. No behavior is lost, no logic is duplicated, and nothing is placed in the wrong layer.

Findings (no P0-P2):

  • P3 packages/runtime-host/src/protocol/index.ts:107-108: 205 passes scripts/protocol-epoch-check.mjs against current main. However, #5709, #5902 and #5548 also claim 205 (and #4138 claims 206), so whichever lands second will need to re-bump. This is cross-PR coordination only.
  • P3 (pre-existing, informational) apps/desktop/src/renderer/platform/desktop/create-overlays-services.ts:65: the command-palette "Set as default" path still calls setDefault(slug, host) without model guidance. R2 only moved it behind the overlays port and its semantics are unchanged. It may be worth a follow-up, but it is not a regression here.

CI: test is still queued/pending on d31d65a0. GitHub reports the PR as mergeable (merge state BLOCKED on the pending required check). Re-approval stands, conditional on green CI.

@Astro-Han Astro-Han 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.

Approved at @Astro-Han's explicit request: the rebase onto current main only changed the surface inventory totals and the protocol epoch (now 205); no blocking findings in our review of this head, and CI is green.

@Astro-Han
Astro-Han merged commit 3597abe into apache:main Oct 5, 2026
1 of 3 checks passed
ggbdpq added a commit to ggbdpq/maka that referenced this pull request Oct 5, 2026
main absorbed apache#5866, which landed epoch 205; apache#4138 holds 206 and
apache#3700 holds 207, so this branch moves past both to 208. The call-kind
note moves to the 208 slot with its older-peer reference updated to
207, and the two compatible-change declarations re-pin to 208.

Generated-by: GLM-5.3-Flash (ZCode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/L Under 1000 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(desktop): setting a custom relay as default fails without model selection guidance

4 participants