[PR #8764] [MERGED] feat(connections): live address and key checks, one structure for the account modals #8789

Closed
opened 2026-11-07 17:39:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8764
Author: @Gunterlie
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @Gunterlie

Base: staging ← Head: feat/connection-live-checks


📝 Commits (5)

  • 24986bd feat(connections): live address and key checks in the account modals
  • 85dcadf fix(connections): live check says when the server refuses an address, and stops waiting after 10 s
  • c613290 fix(i18n): sort the new check key
  • 1fd87b4 fix(connections): live check review fixes (stale debounce, busy provider, custom key, timeout scope, log level)
  • d359d2e fix(connections): trust a model list as a key check only at the provider's default address

📊 Changes

9 files changed (+781 additions, -290 deletions)

View changed files

➕ packages/client/src/components/connections/AccessCheck.tsx (+117 -0)
📝 packages/client/src/components/connections/ConnectionAccountEditor.tsx (+204 -111)
📝 packages/client/src/components/connections/ConnectionBalance.tsx (+39 -32)
📝 packages/client/src/components/modals/create-connection/AccessStep.tsx (+125 -90)
📝 packages/client/src/components/modals/create-connection/CreateConnectionModalContent.tsx (+64 -32)
📝 packages/client/src/components/ui/Modal.tsx (+4 -1)
📝 packages/client/src/hooks/use-connections.ts (+58 -0)
📝 packages/client/src/localization/locales/en.json (+18 -0)
📝 packages/server/src/routes/connections.routes.ts (+152 -24)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.

Linked issue

None. This is planned Connections work agreed with a maintainer from a mockup, so no issue was opened.

Why this change

When you add or edit an account today, you get no feedback until you press Connect or Test. A wrong address or a key with one missing character shows up only after a save or as a big error box. In Edit, Test stays off until the account has a model, and Save sits below the fold.

The two modals also had different structures. The key, address and name were in a different order in each, and the Add modal had two header bars.

What changed

  • Live checks. The address and key fields check themselves while you type (600 ms pause) and when you paste. Each field shows a spinner, a green check, a warning or an error, with one status line and "Check again" on failure. A new POST /api/connections/check route runs model discovery without saving anything. For OpenRouter and NanoGPT, whose model lists are public, it also calls their key endpoint. Unsupported providers (media, subscription sign-in) keep the old manual Test row.
  • Key safety. Edit checks the saved key (sent as accountId, never to the client) only against the saved or default address. A changed address is checked without the key, so a half-typed address never receives it. The route has the Test rate limit and the same SSRF policy as Test.
  • Clear results. A network failure is now marked as "no answer" (unreachable in the discovery error body), so the check no longer says "The server answered 502" when nothing answered. Only 401 or 403 from a key endpoint counts as a rejected key.
  • One structure for both modals.
    • One header bar. Add has back, provider icon and the name field. Edit has picture, name and the "Use this account" switch. Modal gets an optional titleSlot.
    • Access comes first. Cloud providers show the key first, and their address moves into More options, which opens when the address check warns. A local server shows the address first.
    • Edit order is Access, Models, Usage and balance (meter switch now inside its card), More options. Section headings use the small capitals of the Connections panel.
    • The Edit footer is pinned, with Delete on the left and Cancel and Save on the right.
  • New English strings are in en.json.

Validation

  • pnpm check passed locally.
  • Client and server tsc --noEmit, ESLint on the changed client files and pnpm localization:check passed.
  • The new route was called by hand with a dead address, a bad OpenAI key, a bad OpenRouter key, a key-less OpenRouter check, an unsupported provider and an unknown account.
  • Screenshots were taken in a local dev build at 390, 768 and 1440 px: Add (NanoGPT with a bad key) and Edit (saved bad key, More options open with a dead address).
  • Reviewed by the Marinara reviewer and by local CodeRabbit. Fixed findings: the saved key going to a changed address, "no answer" shown for HTML replies, 429/5xx counted as a bad key, status lines inside the field label, no fallback when the check itself fails, and the Add check skipping the http:// that Save adds.
  • Second CodeRabbit run, fixed: an address that the server policy refuses now says so instead of "No answer"; the check now stops waiting after 10 s; the provider name check uses Object.hasOwn. These three fixes are type-checked; they were not run against a live server.
  • Second CodeRabbit run, not fixed: it asked for the accent colour instead of --warning/--destructive and emerald-500. Red and green carry the meaning of the check here, and about 36 client files already use emerald-500 for success. It also noted that model discovery builds its key headers inline; that code is unchanged from staging.
  • Dottore Review, fixed: the check waits until the typed key and address settle, so a key typed for one service never goes to the next one; after Replace the empty key field shows no verdict; a key shows "Key works" only when the model list came from the provider's default address (a custom server or proxy may not check keys), otherwise "Server answers"; the 10 s limit now applies only to the live check, not to the catalog refresh; a provider that answers 429 or 5xx gets a neutral "busy" line instead of "Check the address"; a failed live check logs at debug instead of a warning for connection "undefined". Type-checked and linted; not run against a live server.
  • Not fixed: when no key or address field exists, focus goes to the visually hidden heading in the Add header. Screen readers handle this, and every account form with a field focuses that field first.

Manual verification

  • Manually verify in the browser that Add > NanoGPT with a wrong key shows a red field, "Key not accepted (401)" and "Check again", and that the button reads "Continue anyway".
  • Manually verify that Add > NanoGPT with a working key shows a green check and the model count.
  • Manually verify that Add > a local OpenAI-compatible server shows the address first, and that localhost:1234/v1 without http:// passes the check.
  • Manually verify that the Add header name field saves the typed name, and that an empty name falls back to the provider name.
  • Manually verify that Edit with a wrong saved key shows the error without retyping the key, and that changing the address in More options does not send the saved key there.
  • Manually verify that More options opens by itself when the address check warns, in both Add and Edit.
  • Manually verify that the header switch in Edit turns the account on and off.
  • Manually verify the Edit footer stays pinned and Save stays in view at 390 px.
  • Manually verify that image, video and voice providers still show the manual Test row.
  • Manually verify the layout in light and dark themes.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) 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)

No files under docs/ changed.


🔄 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/8764 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 11/3/2026 **Status:** ✅ Merged **Merged:** 11/3/2026 **Merged by:** [@Gunterlie](https://github.com/Gunterlie) **Base:** `staging` ← **Head:** `feat/connection-live-checks` --- ### 📝 Commits (5) - [`24986bd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/24986bd72934f4cf1d23edc53258333cb3489acd) feat(connections): live address and key checks in the account modals - [`85dcadf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/85dcadfe0e1a92665d957c039de13c612bff59f5) fix(connections): live check says when the server refuses an address, and stops waiting after 10 s - [`c613290`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c61329099241959f4e0431c17d6519b1ed73a35f) fix(i18n): sort the new check key - [`1fd87b4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1fd87b48d51df2bb36d47c8e369b5745333cdacb) fix(connections): live check review fixes (stale debounce, busy provider, custom key, timeout scope, log level) - [`d359d2e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d359d2e8399dd61fb8b3d8857f7f88df0569c4d7) fix(connections): trust a model list as a key check only at the provider's default address ### 📊 Changes **9 files changed** (+781 additions, -290 deletions) <details> <summary>View changed files</summary> ➕ `packages/client/src/components/connections/AccessCheck.tsx` (+117 -0) 📝 `packages/client/src/components/connections/ConnectionAccountEditor.tsx` (+204 -111) 📝 `packages/client/src/components/connections/ConnectionBalance.tsx` (+39 -32) 📝 `packages/client/src/components/modals/create-connection/AccessStep.tsx` (+125 -90) 📝 `packages/client/src/components/modals/create-connection/CreateConnectionModalContent.tsx` (+64 -32) 📝 `packages/client/src/components/ui/Modal.tsx` (+4 -1) 📝 `packages/client/src/hooks/use-connections.ts` (+58 -0) 📝 `packages/client/src/localization/locales/en.json` (+18 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+152 -24) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. ## Linked issue None. This is planned Connections work agreed with a maintainer from a mockup, so no issue was opened. ## Why this change When you add or edit an account today, you get no feedback until you press Connect or Test. A wrong address or a key with one missing character shows up only after a save or as a big error box. In Edit, Test stays off until the account has a model, and Save sits below the fold. The two modals also had different structures. The key, address and name were in a different order in each, and the Add modal had two header bars. ## What changed - **Live checks.** The address and key fields check themselves while you type (600 ms pause) and when you paste. Each field shows a spinner, a green check, a warning or an error, with one status line and "Check again" on failure. A new `POST /api/connections/check` route runs model discovery without saving anything. For OpenRouter and NanoGPT, whose model lists are public, it also calls their key endpoint. Unsupported providers (media, subscription sign-in) keep the old manual Test row. - **Key safety.** Edit checks the saved key (sent as `accountId`, never to the client) only against the saved or default address. A changed address is checked without the key, so a half-typed address never receives it. The route has the Test rate limit and the same SSRF policy as Test. - **Clear results.** A network failure is now marked as "no answer" (`unreachable` in the discovery error body), so the check no longer says "The server answered 502" when nothing answered. Only 401 or 403 from a key endpoint counts as a rejected key. - **One structure for both modals.** - One header bar. Add has back, provider icon and the name field. Edit has picture, name and the "Use this account" switch. `Modal` gets an optional `titleSlot`. - Access comes first. Cloud providers show the key first, and their address moves into More options, which opens when the address check warns. A local server shows the address first. - Edit order is Access, Models, Usage and balance (meter switch now inside its card), More options. Section headings use the small capitals of the Connections panel. - The Edit footer is pinned, with Delete on the left and Cancel and Save on the right. - New English strings are in `en.json`. ## Validation - `pnpm check` passed locally. - Client and server `tsc --noEmit`, ESLint on the changed client files and `pnpm localization:check` passed. - The new route was called by hand with a dead address, a bad OpenAI key, a bad OpenRouter key, a key-less OpenRouter check, an unsupported provider and an unknown account. - Screenshots were taken in a local dev build at 390, 768 and 1440 px: Add (NanoGPT with a bad key) and Edit (saved bad key, More options open with a dead address). - Reviewed by the Marinara reviewer and by local CodeRabbit. Fixed findings: the saved key going to a changed address, "no answer" shown for HTML replies, 429/5xx counted as a bad key, status lines inside the field label, no fallback when the check itself fails, and the Add check skipping the `http://` that Save adds. - Second CodeRabbit run, fixed: an address that the server policy refuses now says so instead of "No answer"; the check now stops waiting after 10 s; the provider name check uses `Object.hasOwn`. These three fixes are type-checked; they were not run against a live server. - Second CodeRabbit run, not fixed: it asked for the accent colour instead of `--warning`/`--destructive` and `emerald-500`. Red and green carry the meaning of the check here, and about 36 client files already use `emerald-500` for success. It also noted that model discovery builds its key headers inline; that code is unchanged from `staging`. - Dottore Review, fixed: the check waits until the typed key and address settle, so a key typed for one service never goes to the next one; after Replace the empty key field shows no verdict; a key shows "Key works" only when the model list came from the provider's default address (a custom server or proxy may not check keys), otherwise "Server answers"; the 10 s limit now applies only to the live check, not to the catalog refresh; a provider that answers 429 or 5xx gets a neutral "busy" line instead of "Check the address"; a failed live check logs at debug instead of a warning for connection "undefined". Type-checked and linted; not run against a live server. - Not fixed: when no key or address field exists, focus goes to the visually hidden heading in the Add header. Screen readers handle this, and every account form with a field focuses that field first. ### Manual verification - [ ] Manually verify in the browser that Add > NanoGPT with a wrong key shows a red field, "Key not accepted (401)" and "Check again", and that the button reads "Continue anyway". - [ ] Manually verify that Add > NanoGPT with a working key shows a green check and the model count. - [ ] Manually verify that Add > a local OpenAI-compatible server shows the address first, and that `localhost:1234/v1` without `http://` passes the check. - [ ] Manually verify that the Add header name field saves the typed name, and that an empty name falls back to the provider name. - [ ] Manually verify that Edit with a wrong saved key shows the error without retyping the key, and that changing the address in More options does not send the saved key there. - [ ] Manually verify that More options opens by itself when the address check warns, in both Add and Edit. - [ ] Manually verify that the header switch in Edit turns the account on and off. - [ ] Manually verify the Edit footer stays pinned and Save stays in view at 390 px. - [ ] Manually verify that image, video and voice providers still show the manual Test row. - [ ] Manually verify the layout in light and dark themes. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) 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) No files under `docs/` changed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:39:43 +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#8789
No description provided.