[PR #5542] [MERGED] Sidecar as the agents default connection plus bulk assignment #6807

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5542
Author: @kolacheee
Created: 8/25/2026
Status: ✅ Merged
Merged: 8/25/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/5539-sidecar-agents-default


📝 Commits (2)

  • ad0ce07 feat(agents): sidecar as the agents default connection plus bulk assignment
  • 89244bb style: collapse two wrapped lines Prettier wants on one line

📊 Changes

13 files changed (+264 additions, -12 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+12 -3)
📝 packages/client/src/components/panels/AgentsPanel.tsx (+101 -0)
📝 packages/client/src/components/panels/ConnectionsPanel.tsx (+36 -4)
📝 packages/client/src/hooks/use-agents.ts (+13 -0)
📝 packages/client/src/localization/locales/en.json (+6 -0)
📝 packages/client/src/stores/sidecar.store.ts (+1 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+10 -2)
📝 packages/server/src/routes/sidecar.routes.ts (+1 -0)
📝 packages/server/src/services/generation/agent-resolution.ts (+29 -2)
📝 packages/server/src/services/sidecar/sidecar-model.service.ts (+1 -0)
📝 packages/shared/src/types/sidecar.ts (+5 -0)
📝 scripts/regressions/agent-runtime.regression.ts (+45 -1)

📄 Description

Note

Top of a 3-PR stack: #5540 (base) ← #5541 ← this PR (base branch fix/5537-sidecar-agent-json). Merge bottom-up; GitHub retargets each remaining PR automatically. The diff shown is only this feature once #5541 is merged.

Linked issue

Closes #5539

Why this change

The built-in Local Model could only power agents through a per-agent connection override. Two structural gaps forced the hand-edit-every-agent round trip described in the issue: the sidecar is a client-fabricated pseudo-connection with no stored connection row, so the defaults section's defaultForAgents row flag could not express it; and the only bulk control ("Use local model for all tracker agents") covers tracker-category agents only.

What changed

The agents-default status lives in the sidecar config (useAsAgentsDefault, default false; old saved configs pick it up via the defaults merge on load). Server resolution — both the generation pipeline and the retry route, which duplicates the logic — substitutes the sidecar sentinel for the row default through one exported helper, resolveAgentsDefaultConnectionId.

The helper substitutes only while the sidecar is actually available. That guard is load-bearing: the existing skip-local-sidecar trap only inspects the requested id, so feeding the sentinel into the default slot while the model is missing would flow through untrapped into a misleading "connection was deleted" warning. Degrading to the row default (then chat connection) is also the right semantics — a default is a preference, unlike an explicit per-agent selection, which deliberately skips the agent rather than silently running it on another backend.

The sentinel default also never matches defaultAgentConn.id, so the "agents billing a paid API" warning correctly stays silent for the local model.

Connections panel, defaults section: the Agents picker now offers the Local Model (gated on the model being downloaded, or the flag already being set so a stale default stays visible and clearable; hidden in Lite builds). Selecting it writes the sidecar config and clears any row default; selecting a row or "use chat connection" clears the flag — one source of truth at a time. The other four pairs (Main/Images/Videos/Audio) are unchanged.

Agent editor: the "" option label now shows Agent default (Local Model (sidecar)) when the sidecar default is active, instead of claiming "Use chat connection".

Agents panel, bulk assignment: a connection select plus an Apply-to-all button under the Create/Import/Select row. Options mirror the per-agent picker (saved language connections + the sidecar pseudo-connection + "Agent default connection"). Applies with a confirm dialog, then PATCHes installed package agents by type (/agents/type/:agentType, which creates missing config rows) and custom agents by id — sending only { connectionId }, so agent settings are never clobbered (the wholesale-settings-rewrite hazard from the #5537 investigation). New useUpdateAgentByType hook; new localization keys in en.json only, per the locale fallback convention.

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

Manual verification notes

Automated, from this branch:

  • pnpm lint and pnpm build pass (client tsc runs in the build and is clean).
  • node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-runtime.regression.ts passes, including four new assertions on resolveAgentsDefaultConnectionId: sidecar wins over a row default while available; unavailable degrades to the row default; flag off keeps the row default; nothing set stays null (chat-connection inheritance).
  • pnpm localization:check passes (audit clean, new keys in en.json only).
  • Touched files are Prettier-clean under the repo config (repo-wide format:check fails pre-existing on CRLF Windows checkouts).

Needs a human with the local model downloaded:

  • Connections → defaults → Agents: pick Local Model → agents without an explicit connection run on the sidecar; the Agent editor's blank option reads "Agent default (Local Model (sidecar))".
  • Pick a saved connection afterwards → the sidecar flag clears (re-open the select to confirm) and agents follow the row default.
  • Delete/undownload the model while the sidecar is the default → agents fall back to the row default or chat connection, with no "connection was deleted" warnings.
  • Agents panel: bulk-assign to the sidecar → every agent's editor shows Local Model; bulk-assign to "Agent default connection" → every override clears. Confirm a custom agent kept its settings (prompt, result type) after the bulk PATCH.
  • Retry an agent (rerun from a message) with the sidecar default active → the retry runs on the sidecar too.
  • Mobile viewport: the new bulk row wraps acceptably in the Agents panel.

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)

CHANGELOG entry under [Unreleased] → Added. No docs/ page documents connection defaults today, so no docs-i18n impact from this PR.

Summary by CodeRabbit

  • New Features
    • Local Model can now be selected as the default connection for agents when available.
    • Added bulk reassignment or reset of all visible agents to a selected connection or default.
    • Added confirmation, progress indicators, and success or failure feedback for bulk updates.
  • Bug Fixes
    • Agent generation and retry flows now consistently honor the configured default connection.
    • Unavailable Local Model configurations now correctly fall back to the standard default.

🔄 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/5542 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 8/25/2026 **Status:** ✅ Merged **Merged:** 8/25/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/5539-sidecar-agents-default` --- ### 📝 Commits (2) - [`ad0ce07`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ad0ce071accf6d7249c759b0eda8612540afbd50) feat(agents): sidecar as the agents default connection plus bulk assignment - [`89244bb`](https://github.com/Pasta-Devs/Marinara-Engine/commit/89244bb70341d3577ba79f2f79d82daae4212a91) style: collapse two wrapped lines Prettier wants on one line ### 📊 Changes **13 files changed** (+264 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+12 -3) 📝 `packages/client/src/components/panels/AgentsPanel.tsx` (+101 -0) 📝 `packages/client/src/components/panels/ConnectionsPanel.tsx` (+36 -4) 📝 `packages/client/src/hooks/use-agents.ts` (+13 -0) 📝 `packages/client/src/localization/locales/en.json` (+6 -0) 📝 `packages/client/src/stores/sidecar.store.ts` (+1 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+10 -2) 📝 `packages/server/src/routes/sidecar.routes.ts` (+1 -0) 📝 `packages/server/src/services/generation/agent-resolution.ts` (+29 -2) 📝 `packages/server/src/services/sidecar/sidecar-model.service.ts` (+1 -0) 📝 `packages/shared/src/types/sidecar.ts` (+5 -0) 📝 `scripts/regressions/agent-runtime.regression.ts` (+45 -1) </details> ### 📄 Description > [!NOTE] > **Top of a 3-PR stack**: #5540 (base) ← #5541 ← this PR (base branch `fix/5537-sidecar-agent-json`). Merge bottom-up; GitHub retargets each remaining PR automatically. The diff shown is only this feature once #5541 is merged. ## Linked issue Closes #5539 ## Why this change The built-in Local Model could only power agents through a per-agent connection override. Two structural gaps forced the hand-edit-every-agent round trip described in the issue: the sidecar is a client-fabricated pseudo-connection with **no stored connection row**, so the defaults section's `defaultForAgents` row flag could not express it; and the only bulk control ("Use local model for all tracker agents") covers tracker-category agents only. ## What changed **The agents-default status lives in the sidecar config** (`useAsAgentsDefault`, default `false`; old saved configs pick it up via the defaults merge on load). Server resolution — both the generation pipeline and the retry route, which duplicates the logic — substitutes the sidecar sentinel for the row default through one exported helper, `resolveAgentsDefaultConnectionId`. The helper substitutes **only while the sidecar is actually available**. That guard is load-bearing: the existing `skip-local-sidecar` trap only inspects the *requested* id, so feeding the sentinel into the default slot while the model is missing would flow through untrapped into a misleading "connection was deleted" warning. Degrading to the row default (then chat connection) is also the right semantics — a default is a preference, unlike an explicit per-agent selection, which deliberately *skips* the agent rather than silently running it on another backend. The sentinel default also never matches `defaultAgentConn.id`, so the "agents billing a paid API" warning correctly stays silent for the local model. **Connections panel, defaults section**: the Agents picker now offers the Local Model (gated on the model being downloaded, or the flag already being set so a stale default stays visible and clearable; hidden in Lite builds). Selecting it writes the sidecar config and clears any row default; selecting a row or "use chat connection" clears the flag — one source of truth at a time. The other four pairs (Main/Images/Videos/Audio) are unchanged. **Agent editor**: the "" option label now shows *Agent default (Local Model (sidecar))* when the sidecar default is active, instead of claiming "Use chat connection". **Agents panel, bulk assignment**: a connection select plus an Apply-to-all button under the Create/Import/Select row. Options mirror the per-agent picker (saved language connections + the sidecar pseudo-connection + "Agent default connection"). Applies with a confirm dialog, then PATCHes installed package agents **by type** (`/agents/type/:agentType`, which creates missing config rows) and custom agents **by id** — sending *only* `{ connectionId }`, so agent settings are never clobbered (the wholesale-settings-rewrite hazard from the #5537 investigation). New `useUpdateAgentByType` hook; new localization keys in `en.json` only, per the locale fallback convention. ## Validation <!-- These are human tasks. Never tick a box for a check that was not actually performed. --> - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Automated, from this branch: - `pnpm lint` and `pnpm build` pass (client `tsc` runs in the build and is clean). - `node ./scripts/run-regressions.mjs --filter scripts/regressions/agent-runtime.regression.ts` passes, including four new assertions on `resolveAgentsDefaultConnectionId`: sidecar wins over a row default while available; unavailable degrades to the row default; flag off keeps the row default; nothing set stays null (chat-connection inheritance). - `pnpm localization:check` passes (audit clean, new keys in `en.json` only). - Touched files are Prettier-clean under the repo config (repo-wide `format:check` fails pre-existing on CRLF Windows checkouts). Needs a human with the local model downloaded: - Connections → defaults → Agents: pick **Local Model** → agents without an explicit connection run on the sidecar; the Agent editor's blank option reads "Agent default (Local Model (sidecar))". - Pick a saved connection afterwards → the sidecar flag clears (re-open the select to confirm) and agents follow the row default. - Delete/undownload the model while the sidecar is the default → agents fall back to the row default or chat connection, with no "connection was deleted" warnings. - Agents panel: bulk-assign to the sidecar → every agent's editor shows Local Model; bulk-assign to "Agent default connection" → every override clears. Confirm a custom agent kept its settings (prompt, result type) after the bulk PATCH. - Retry an agent (rerun from a message) with the sidecar default active → the retry runs on the sidecar too. - Mobile viewport: the new bulk row wraps acceptably in the Agents panel. ## Docs and release impact - [ ] No docs changes needed - [x] 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) CHANGELOG entry under `[Unreleased] → Added`. No `docs/` page documents connection defaults today, so no docs-i18n impact from this PR. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Local Model can now be selected as the default connection for agents when available. * Added bulk reassignment or reset of all visible agents to a selected connection or default. * Added confirmation, progress indicators, and success or failure feedback for bulk updates. * **Bug Fixes** * Agent generation and retry flows now consistently honor the configured default connection. * Unavailable Local Model configurations now correctly fall back to the standard default. <!-- 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:13:54 +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#6807
No description provided.