[PR #7102] [MERGED] feat(connections): pick, pin and type models from the Connections menu (#7098) #7477

Closed
opened 2026-10-23 04:20:12 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7102
Author: @SpicyMarinara
Created: 10/5/2026
Status: ✅ Merged
Merged: 10/5/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/connection-model-switcher-7098


📝 Commits (10+)

  • 4482d3c feat(connections): save fetched model lists and pinned models on connections
  • 306cd3d feat(chat): pick, pin and type a connection's model from the Connections menu
  • ac5e8f0 fix(chat): keep the pin toggle's name and give phone controls 44px targets
  • bb79878 test(e2e): cover the Connections menu model picker on desktop and phones
  • b9ca362 docs: describe picking and pinning models from the Connections menu
  • 130d74b Merge remote-tracking branch 'origin/staging' into feat/connection-model-switcher-7098
  • 5060074 test(e2e): match Fetch Models' refresh query in the editor accent test
  • 6a5bf17 fix(connections): answer 409 when a model list goes stale while loading
  • 7e55694 fix(chat): safer Enter, IME keys, dialog role and focus in the model picker
  • d869347 Merge remote-tracking branch 'origin/staging' into feat/connection-model-switcher-7098

📊 Changes

23 files changed (+1924 additions, -202 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/chats/chat-settings.md (+2 -0)
📝 docs/connections/connecting-to-a-provider.md (+3 -1)
📝 docs/connections/organizing-connections.md (+14 -5)
➕ e2e/connection-model-switcher.e2e.ts (+369 -0)
📝 e2e/core-flows.e2e.ts (+2 -1)
📝 e2e/ux-feedback-sweep.e2e.ts (+5 -4)
📝 packages/client/src/components/chat/QuickConnectionSwitcher.tsx (+184 -95)
📝 packages/client/src/components/chat/QuickSwitcherMobile.tsx (+95 -15)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+17 -36)
➕ packages/client/src/components/connections/ConnectionModelPicker.tsx (+405 -0)
📝 packages/client/src/features/chat-settings/sections/ConnectionSection.tsx (+66 -1)
📝 packages/client/src/hooks/use-connections.ts (+92 -28)
➕ packages/client/src/lib/connection-model-selection.ts (+90 -0)
📝 packages/client/src/lib/connection-transfer.ts (+6 -0)
📝 packages/client/src/localization/locales/en.json (+28 -0)
📝 packages/server/src/db/schema/connections.ts (+8 -0)
📝 packages/server/src/routes/backup.routes.ts (+5 -1)
📝 packages/server/src/routes/connections.routes.ts (+58 -12)
📝 packages/server/src/services/storage/connections.storage.ts (+118 -2)

...and 3 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7098

Why this change

  • Changing a model meant opening the connection panel, picking the connection, fetching its models and choosing one, every time. Some users made one connection per model instead (the reporter had 18 OpenRouter connections).
  • The maintainer's mockup adds a Models column to the Connections menu by the chat input, with search, typed IDs, pins and refresh, plus a model field in Chat Settings → Connection.

What changed

  • Connections menu (desktop): a non-modal dialog showing the chosen connection's models beside the connection list. Search or type a model ID. Enter picks the model whose ID or name was typed, or the only match, and uses the typed text as an ID only when nothing matches. Refresh the list, and star models into a Pinned section. Picking a model saves it to the connection, selects the connection for the chat if needed, closes the menu and returns focus to its button. Random keeps its pool-only menu.
  • Phones: tapping a connection opens its models as a second step in the same sheet, with a back arrow. Tap targets are at least 44px, there is no horizontal scroll, and the Chat Settings model list scrolls into view when opened.
  • Chat Settings → Connection: a Model field with the same picker.
  • One shared picker: desktop, phones and Chat Settings use the same component. A pick goes through connectionFieldsForModelPick, which the connection editor now shares, so context size and output limit follow the model exactly as in the editor and other model fields (vision, image, embedding) are untouched.
  • Saved model lists: each chat connection keeps its fetched list with the fetch time (savedModels). Reopening or reloading doesn't ask the provider again; Refresh and the editor's Fetch Models replace the list. A new API key, base URL or provider clears it, and a fetch that finishes after such a change isn't saved. Only id, name and limit fields are stored, so no credentials. Built-in lists (Claude Subscription, the Codex fallback) and media connections are answered live.
  • Pins: stored on the connection (pinnedModels, POST /connections/:id/pinned-models, updated in a transaction so quick clicks can't overwrite each other). They travel in connection exports and profile backups; saved lists don't, matching how the API key and derived data are handled. Old rows load with empty values.
  • A list that went stale while loading (the key, base URL or provider changed) is answered with 409 and refetched, not cached.
  • Custom endpoints never fall back to the built-in OpenAI and Z.AI catalog; a failed or empty list shows a plain message and still accepts a typed ID.
  • Enter and Escape are ignored while an input method (Japanese, Chinese and so on) is composing.
  • Docs and changelog: quick switcher, Chat Settings and provider setup guides updated; changelog entry added.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks (not a substitute for the boxes above):

  • pnpm check and pnpm localization:check pass; pnpm regression:node is 510/510.
  • New scripts/regressions/connection-model-list.regression.ts uses a stub provider. It covers the saved list with its fetch time, no provider call on reuse, refresh replacing it, a failed refresh keeping it, pins and their limits (100 pins, 512-character IDs), old rows loading, no secrets in the saved list, clearing on a key, URL or provider change, the stale-fetch race through the route (409), and profile and connection export and import. It fails on the base commit.
  • New e2e/connection-model-switcher.e2e.ts passes 6/6 on desktop-chromium, mobile-chromium and mobile-webkit. It counts calls to a stub provider and also covers the Enter rules, the input-method guard, focus return, pick scope (only model, context size and output limit change) and a custom endpoint's error state. It fails on the base commit.
  • An independent adversarial review found seven problems (partial-search Enter, IME keys, menu role, focus, stale refresh caching, custom-endpoint fallback, an e2e route glob); all are fixed with proof.
  • Local CodeRabbit raised two points, both declined: pinning on an imported connection still under review (quarantine guards credential use through getWithKey; pinning stores IDs only and never reads the key), and clearing the saved list when the key is cleared implicitly (that only happens for Decision connections, which never save a list).
  • Related existing e2es pass, apart from three tests that fail identically on unmodified staging: two in chat-settings-window (tips dismissal, reset-dialog copy) and the ux-feedback-sweep Background icon check, which now fails at line 685 after the Connections dialog step passes.

Manual verification notes

  • Manually verify the desktop menu with a real OpenRouter or NanoGPT connection: models load once, pins survive a reload, and picking a model updates the connection editor's Model and Context Size.
  • Manually verify a provider with no models endpoint shows the plain error and still accepts a typed model ID.
  • Manually verify Claude (Subscription) and OpenAI (ChatGPT) connections list and switch models.
  • Manually verify an agent using the same connection runs with the newly picked model.
  • Manually verify the phone sheet on a real iPhone and Android: two-step flow, back arrow, keyboard not covering the list.
  • Manually verify Chat Settings → Connection → Model in Roleplay, Conversation and Game.
  • Manually verify a custom theme and Accent Pulse: star and selection accents follow the theme.
  • Manually verify a connection exported and imported keeps its pins and loads its model list fresh.
  • Local servers (LM Studio, KoboldCpp): after loading a different model there, press Refresh to see it.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Docs changed: docs/connections/organizing-connections.md, docs/chats/chat-settings.md, docs/connections/connecting-to-a-provider.md, CHANGELOG.md. Translations follow in a docs-i18n PR.

UI evidence (if applicable)

The e2e attaches the desktop menu (dark and light) and the phone models step (mobile-chromium and mobile-webkit, dark and light).

Summary by CodeRabbit

  • New Features
    • Choose a model for a connection from the chat switcher or Chat Settings. Search provider models, enter a model ID, pin models, and refresh the model list.
    • On mobile, choose a connection and model from the Connections tab.
    • Model selections apply across chats, agents, and helpers using that connection. Context and output limits update when available.
    • Model lists are saved for reuse. Pinned models are included in connection exports and profile backups; saved model lists are not.
  • Documentation
    • Updated connection and chat settings guides with model selection, caching, and export details.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7102 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/5/2026 **Status:** ✅ Merged **Merged:** 10/5/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/connection-model-switcher-7098` --- ### 📝 Commits (10+) - [`4482d3c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4482d3c011c0477b1dc9ddf78db4ebcbe62af1ca) feat(connections): save fetched model lists and pinned models on connections - [`306cd3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/306cd3d38397ea28768df45d39ff1567a8b20a8e) feat(chat): pick, pin and type a connection's model from the Connections menu - [`ac5e8f0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ac5e8f077f9708fde391af02266fe2ef5854e532) fix(chat): keep the pin toggle's name and give phone controls 44px targets - [`bb79878`](https://github.com/Pasta-Devs/Marinara-Engine/commit/bb798786d6e02e1adc847164534e62f7e48717a7) test(e2e): cover the Connections menu model picker on desktop and phones - [`b9ca362`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b9ca3622aeea257e787d799a203f55116d35f5c0) docs: describe picking and pinning models from the Connections menu - [`130d74b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/130d74b383cbcdad6df12518865d0bf4f1a833c4) Merge remote-tracking branch 'origin/staging' into feat/connection-model-switcher-7098 - [`5060074`](https://github.com/Pasta-Devs/Marinara-Engine/commit/506007408f12595ab80d8fbb499ae8c1af2378ab) test(e2e): match Fetch Models' refresh query in the editor accent test - [`6a5bf17`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a5bf17c58963880a88b63095490be708ce337c1) fix(connections): answer 409 when a model list goes stale while loading - [`7e55694`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7e556947b4f3275e888752897af967dfb5d588d7) fix(chat): safer Enter, IME keys, dialog role and focus in the model picker - [`d869347`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d8693478cd2c7b4ab0cfee6b0c89715fa370e198) Merge remote-tracking branch 'origin/staging' into feat/connection-model-switcher-7098 ### 📊 Changes **23 files changed** (+1924 additions, -202 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/chats/chat-settings.md` (+2 -0) 📝 `docs/connections/connecting-to-a-provider.md` (+3 -1) 📝 `docs/connections/organizing-connections.md` (+14 -5) ➕ `e2e/connection-model-switcher.e2e.ts` (+369 -0) 📝 `e2e/core-flows.e2e.ts` (+2 -1) 📝 `e2e/ux-feedback-sweep.e2e.ts` (+5 -4) 📝 `packages/client/src/components/chat/QuickConnectionSwitcher.tsx` (+184 -95) 📝 `packages/client/src/components/chat/QuickSwitcherMobile.tsx` (+95 -15) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+17 -36) ➕ `packages/client/src/components/connections/ConnectionModelPicker.tsx` (+405 -0) 📝 `packages/client/src/features/chat-settings/sections/ConnectionSection.tsx` (+66 -1) 📝 `packages/client/src/hooks/use-connections.ts` (+92 -28) ➕ `packages/client/src/lib/connection-model-selection.ts` (+90 -0) 📝 `packages/client/src/lib/connection-transfer.ts` (+6 -0) 📝 `packages/client/src/localization/locales/en.json` (+28 -0) 📝 `packages/server/src/db/schema/connections.ts` (+8 -0) 📝 `packages/server/src/routes/backup.routes.ts` (+5 -1) 📝 `packages/server/src/routes/connections.routes.ts` (+58 -12) 📝 `packages/server/src/services/storage/connections.storage.ts` (+118 -2) _...and 3 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #7098 ## Why this change - Changing a model meant opening the connection panel, picking the connection, fetching its models and choosing one, every time. Some users made one connection per model instead (the reporter had 18 OpenRouter connections). - The maintainer's mockup adds a Models column to the Connections menu by the chat input, with search, typed IDs, pins and refresh, plus a model field in Chat Settings → Connection. ## What changed - **Connections menu (desktop):** a non-modal dialog showing the chosen connection's models beside the connection list. Search or type a model ID. Enter picks the model whose ID or name was typed, or the only match, and uses the typed text as an ID only when nothing matches. Refresh the list, and star models into a Pinned section. Picking a model saves it to the connection, selects the connection for the chat if needed, closes the menu and returns focus to its button. Random keeps its pool-only menu. - **Phones:** tapping a connection opens its models as a second step in the same sheet, with a back arrow. Tap targets are at least 44px, there is no horizontal scroll, and the Chat Settings model list scrolls into view when opened. - **Chat Settings → Connection:** a Model field with the same picker. - **One shared picker:** desktop, phones and Chat Settings use the same component. A pick goes through `connectionFieldsForModelPick`, which the connection editor now shares, so context size and output limit follow the model exactly as in the editor and other model fields (vision, image, embedding) are untouched. - **Saved model lists:** each chat connection keeps its fetched list with the fetch time (`savedModels`). Reopening or reloading doesn't ask the provider again; Refresh and the editor's Fetch Models replace the list. A new API key, base URL or provider clears it, and a fetch that finishes after such a change isn't saved. Only id, name and limit fields are stored, so no credentials. Built-in lists (Claude Subscription, the Codex fallback) and media connections are answered live. - **Pins:** stored on the connection (`pinnedModels`, `POST /connections/:id/pinned-models`, updated in a transaction so quick clicks can't overwrite each other). They travel in connection exports and profile backups; saved lists don't, matching how the API key and derived data are handled. Old rows load with empty values. - A list that went stale while loading (the key, base URL or provider changed) is answered with 409 and refetched, not cached. - Custom endpoints never fall back to the built-in OpenAI and Z.AI catalog; a failed or empty list shows a plain message and still accepts a typed ID. - Enter and Escape are ignored while an input method (Japanese, Chinese and so on) is composing. - **Docs and changelog:** quick switcher, Chat Settings and provider setup guides updated; changelog entry added. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks (not a substitute for the boxes above): - `pnpm check` and `pnpm localization:check` pass; `pnpm regression:node` is 510/510. - New `scripts/regressions/connection-model-list.regression.ts` uses a stub provider. It covers the saved list with its fetch time, no provider call on reuse, refresh replacing it, a failed refresh keeping it, pins and their limits (100 pins, 512-character IDs), old rows loading, no secrets in the saved list, clearing on a key, URL or provider change, the stale-fetch race through the route (409), and profile and connection export and import. It fails on the base commit. - New `e2e/connection-model-switcher.e2e.ts` passes 6/6 on desktop-chromium, mobile-chromium and mobile-webkit. It counts calls to a stub provider and also covers the Enter rules, the input-method guard, focus return, pick scope (only model, context size and output limit change) and a custom endpoint's error state. It fails on the base commit. - An independent adversarial review found seven problems (partial-search Enter, IME keys, menu role, focus, stale refresh caching, custom-endpoint fallback, an e2e route glob); all are fixed with proof. - Local CodeRabbit raised two points, both declined: pinning on an imported connection still under review (quarantine guards credential use through `getWithKey`; pinning stores IDs only and never reads the key), and clearing the saved list when the key is cleared implicitly (that only happens for Decision connections, which never save a list). - Related existing e2es pass, apart from three tests that fail identically on unmodified staging: two in chat-settings-window (tips dismissal, reset-dialog copy) and the ux-feedback-sweep Background icon check, which now fails at line 685 after the Connections dialog step passes. ### Manual verification notes - [ ] Manually verify the desktop menu with a real OpenRouter or NanoGPT connection: models load once, pins survive a reload, and picking a model updates the connection editor's Model and Context Size. - [ ] Manually verify a provider with no models endpoint shows the plain error and still accepts a typed model ID. - [ ] Manually verify Claude (Subscription) and OpenAI (ChatGPT) connections list and switch models. - [ ] Manually verify an agent using the same connection runs with the newly picked model. - [ ] Manually verify the phone sheet on a real iPhone and Android: two-step flow, back arrow, keyboard not covering the list. - [ ] Manually verify Chat Settings → Connection → Model in Roleplay, Conversation and Game. - [ ] Manually verify a custom theme and Accent Pulse: star and selection accents follow the theme. - [ ] Manually verify a connection exported and imported keeps its pins and loads its model list fresh. - [ ] Local servers (LM Studio, KoboldCpp): after loading a different model there, press Refresh to see it. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Docs changed: `docs/connections/organizing-connections.md`, `docs/chats/chat-settings.md`, `docs/connections/connecting-to-a-provider.md`, `CHANGELOG.md`. Translations follow in a `docs-i18n` PR. ## UI evidence (if applicable) The e2e attaches the desktop menu (dark and light) and the phone models step (mobile-chromium and mobile-webkit, dark and light). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Choose a model for a connection from the chat switcher or Chat Settings. Search provider models, enter a model ID, pin models, and refresh the model list. * On mobile, choose a connection and model from the Connections tab. * Model selections apply across chats, agents, and helpers using that connection. Context and output limits update when available. * Model lists are saved for reuse. Pinned models are included in connection exports and profile backups; saved model lists are not. * **Documentation** * Updated connection and chat settings guides with model selection, caching, and export details. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:20:12 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7477
No description provided.