Skip to content

feat(models): surface custom relay setup - #1340

Merged
Astro-Han merged 1 commit into
apache:mainfrom
zly-idleness:feat/1339-custom-relay-provider-entry
Jul 22, 2026
Merged

Astro-Han merged 1 commit into
apache:mainfrom
zly-idleness:feat/1339-custom-relay-provider-entry

Conversation

@zly-idleness

@zly-idleness zly-idleness commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Refs #1339.

  • Surface custom relay setup as first-class provider catalog entries, following the cc-switch profile pattern: endpoint + API key + default model in one setup flow, then automatic model discovery for custom relays.
  • Keep the existing OpenAI Chat Completions-compatible relay explicit as Custom relay (OpenAI Chat) / 自定义中转站(OpenAI Chat).
  • Add separate protocol entries for:
    • openai-responses-compatible → Custom relay (OpenAI Responses) using the OpenAI Responses wire.
    • anthropic-compatible → Custom relay (Anthropic) using the Anthropic Messages wire.
  • Automatically call fetchModels after creating a custom relay connection so providers exposing /v1/models populate the frontend model list. This is gated to custom relays only; named/provider API-key flows keep their previous creation behavior.
  • Require a default model id for custom relays until the connection detail screen has a separate manual model-entry recovery path. Maka still fetches the model catalog after saving, but users do not get stranded in missing_model if discovery fails.
  • Add runtime/test coverage proving:
    • OpenAI Responses relay uses /responses, preserves exact model ids, and preserves tool results across steps.
    • Anthropic-compatible relay uses Anthropic /v1/messages semantics and x-api-key model discovery.
    • The provider catalog, icons, recommended order, endpoint-source contract, first-run recommendations, and copy stay protocol-explicit.

cc-switch reference notes

I checked farion1231/cc-switch and SaladDay/cc-switch-cli before scoping this. The relevant patterns are:

  • provider profiles are the primary UX object;
  • endpoint + key + model/protocol are visible in one setup flow;
  • model fetching is a first-class provider action;
  • protocol/API format matters (anthropic, OpenAI Chat, OpenAI Responses), so Maka now exposes those as separate provider/protocol entries instead of hiding them behind one generic OpenAI-compatible path.

Verification

  • npm run typecheck
  • npm --workspace @maka/core run build && npm --workspace @maka/core run test:dist — 1154/1154 passed
  • npm --workspace @maka/runtime run build && node --test packages/runtime/dist/__tests__/model-fetcher.test.js packages/runtime/dist/__tests__/provider-contract-matrix.test.js packages/runtime/dist/__tests__/provider-conformance.test.js — 161/161 passed
  • npm --workspace @maka/desktop test — 2795/2795 passed
  • npm --workspace @maka/desktop run e2e -- e2e/first-run.spec.ts — 1/1 passed
  • npm --workspace @maka/desktop run e2e — 32/32 passed locally

Note: full npm --workspace @maka/runtime run test:dist still hits the pre-existing local macOS filesystem-worker smoke failure around the operation-scoped Grep sandbox / Homebrew rg dynamic library path; the provider conformance matrix and the new relay coverage pass.

visual

图片 图片 图片 图片

@zly-idleness
zly-idleness force-pushed the feat/1339-custom-relay-provider-entry branch from 33beb23 to 79a87f3 Compare July 22, 2026 11:19

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

Approving with three non-blocking follow-ups.

  1. fetchModels(connection.slug) runs in the generic submit path at apps/desktop/src/renderer/settings/provider-add-form.tsx:87. This affects named providers as well as custom relays, adding a network wait and model-cache side effects to existing creation flows. Gate it behind the custom-relay category.

  2. If the user leaves the default model empty and discovery fails, the error is swallowed and the connection detail screen has no manual model-entry path. This can leave the connection in missing_model with no recovery short of deleting it. Either surface the failure and provide manual entry, or require a model until that recovery path exists.

  3. The latest scope clarification in #1339 leaves OpenAI Responses and Anthropic-compatible relays for follow-ups, while this PR adds both to the public registry and runtime matrix. Keeping the first PR to the existing OpenAI Chat-compatible relay would make the change easier to review and revert. If the expanded scope is intentional, update the issue first.

These are non-blocking for this PR. Proceed.

@Astro-Han

Copy link
Copy Markdown
Contributor

E2E failed, I think it is related to the onboarding page setting up providers. Could you check on the test, happy path and potential corner cases?

@zly-idleness
zly-idleness force-pushed the feat/1339-custom-relay-provider-entry branch from 79a87f3 to c87deb6 Compare July 22, 2026 16:03
@zly-idleness

Copy link
Copy Markdown
Contributor Author

Thanks — fixed the failing E2E and incorporated the review feedback in c87deb6.

What changed:

  1. The CI failure was e2e/first-run.spec.ts: it compared recommended rows against PROVIDER_REGISTRY[type].label, but the first-run UI renders localized providerDisplay copy. The new custom relay rows are Chinese in the zh first-run fixture, so the test was wrong after adding localized relay copy. I updated the test to assert the zh display copy that the UI actually renders.

  2. fetchModels(connection.slug) is now gated to custom relays only (defaults.category === 'custom'). Named provider/API-key creation flows no longer pay the extra network wait or model-cache side effect.

  3. Custom relays now require a default model id during creation. Maka still fetches /v1/models after saving, but a failed discovery no longer strands the user in missing_model with no manual recovery path.

  4. The expanded scope is intentional for feat(models): make custom relay providers first-class and easy to configure #1339: OpenAI Chat-compatible, OpenAI Responses, and Anthropic-compatible are now three separate provider/protocol entries instead of one overloaded OpenAI-compatible path. I also updated the PR body with this scope and the fresh verification.

Fresh local verification after the fix:

  • npm run typecheck ✅
  • npm --workspace @maka/core run build && npm --workspace @maka/core run test:dist ✅ 1154/1154
  • npm --workspace @maka/runtime run build && node --test packages/runtime/dist/__tests__/model-fetcher.test.js packages/runtime/dist/__tests__/provider-contract-matrix.test.js packages/runtime/dist/__tests__/provider-conformance.test.js ✅ 161/161
  • npm --workspace @maka/desktop test ✅ 2795/2795
  • npm --workspace @maka/desktop run e2e -- e2e/first-run.spec.ts ✅ 1/1
  • npm --workspace @maka/desktop run e2e ✅ 32/32 locally

@Astro-Han

Copy link
Copy Markdown
Contributor

One small follow-up for visual review: since this PR adds three first-class custom relay entries and changes the full provider setup form, could you add a live-app screenshot to the PR description?

Ideally, the capture would show the relay entries in Settings → Models and one opened relay form with the endpoint, API key, and required default model fields visible. Please use fake values and make sure no real credential appears in the screenshot.

This is not a merge blocker, and it does not replace the representative creation-flow E2E. It would simply make the copy, layout, and discoverability changes easier to review.

@zly-idleness

Copy link
Copy Markdown
Contributor Author

One small follow-up for visual review: since this PR adds three first-class custom relay entries and changes the full provider setup form, could you add a live-app screenshot to the PR description?

Ideally, the capture would show the relay entries in Settings → Models and one opened relay form with the endpoint, API key, and required default model fields visible. Please use fake values and make sure no real credential appears in the screenshot.

This is not a merge blocker, and it does not replace the representative creation-flow E2E. It would simply make the copy, layout, and discoverability changes easier to review.

One small follow-up for visual review: since this PR adds three first-class custom relay entries and changes the full provider setup form, could you add a live-app screenshot to the PR description?

Ideally, the capture would show the relay entries in Settings → Models and one opened relay form with the endpoint, API key, and required default model fields visible. Please use fake values and make sure no real credential appears in the screenshot.

This is not a merge blocker, and it does not replace the representative creation-flow E2E. It would simply make the copy, layout, and discoverability changes easier to review.

Sure

@Astro-Han

Copy link
Copy Markdown
Contributor

LGTM, thanks for the visual screenshot. Merging!

@Astro-Han
Astro-Han merged commit 47d18b7 into apache:main Jul 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants