Skip to content

feat(channels): add bailian_anthropic and moonshot_coding channel types with UI checkbox support#1455

Merged
looplj merged 3 commits into
looplj:unstablefrom
banlanzs:unstable
Apr 23, 2026
Merged

feat(channels): add bailian_anthropic and moonshot_coding channel types with UI checkbox support#1455
looplj merged 3 commits into
looplj:unstablefrom
banlanzs:unstable

Conversation

@banlanzs

Copy link
Copy Markdown
Contributor

No description provided.

…es with UI checkbox support

- Add bailian_anthropic (Anthropic format) at https://dashscope.aliyuncs.com/apps/anthropic
- Add moonshot_coding (Kimi Coding endpoint) at https://api.kimi.com/coding
- Both use anthropic/messages format with anthropic.PlatformDirect transformer
- Implement checkbox UI pattern (like Gemini Vertex/Anthropic AWS) for Kimi Coding selection
- Fix handleKimiCodingChange to properly update form.type and form.baseURL on toggle
- Add English/Chinese i18n keys for new channel types and Kimi Coding checkbox
- Update Ent schema, channel configs, provider mappings, and generated code

Follows dual/triple-channel pattern used by Minimax, Moonshot, Doubao providers.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces support for new channel types, specifically bailian_anthropic and moonshot_coding, across the frontend configuration, backend schema, and server logic. The changes include updating the channel action dialog to handle the new Kimi Coding option, adding configuration data for the new providers, and implementing the corresponding outbound transformers in the backend. A review comment suggests refactoring the backend logic to group the new channel types with existing ones that share identical transformer configurations to reduce code duplication.

Comment thread internal/server/biz/channel_llm.go Outdated
@greptile-apps

greptile-apps Bot commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds two new channel types — bailian_anthropic (Alibaba Cloud Bailian via Anthropic Messages API) and moonshot_coding (Kimi Coding endpoint via Anthropic Messages API) — across the full stack: Ent schema, GraphQL, backend transformer routing, frontend Zod schema, channel/provider configs, and i18n strings.

  • bailian_anthropic is exposed via the existing API-format dropdown when the Bailian provider is selected (anthropic/messagesbailian_anthropic via getChannelTypeForApiFormat). No special checkbox is needed.
  • moonshot_coding requires a new "Kimi Coding" checkbox (useKimiCoding) because it shares the anthropic/messages format with the existing moonshot_anthropic type. The === true guard on onCheckedChange is correctly applied (the concern from the previous thread is addressed).
  • Backend routes both new types through anthropic.PlatformDirect in buildChannelWithTransformer, grouped in a single case block alongside the other Anthropic-compatible platforms.
  • All new enum values are registered in the Ent TypeValidator and the generated migrate/schema.go, so database validation is consistent with the application layer.
  • One minor defensive opportunity: derivedChannelType could guard if (useKimiCoding && selectedProvider === 'moonshot') to mirror the implicit invariant that the provider-change handler already maintains — see the inline comment.

Confidence Score: 5/5

Safe to merge — all layers are consistently updated and the previous thread's type-safety concern is resolved

The change is a well-scoped addition following established patterns. Backend enum validation, Ent schema, GraphQL, frontend Zod schema, provider/channel configs, and locales are all updated in lock-step. The === true guard on the new checkbox (the prior review concern) is correctly applied. The only note is a defensive provider-guard in derivedChannelType which is a style/robustness suggestion, not a functional bug.

frontend/src/features/channels/components/channels-action-dialog.tsx — the derivedChannelType memo could add an explicit selectedProvider === 'moonshot' guard for useKimiCoding

Important Files Changed

Filename Overview
frontend/src/features/channels/components/channels-action-dialog.tsx Adds useKimiCoding state and handleKimiCodingChange handler for moonshot_coding checkbox; wires the === true guard correctly; derivedChannelType and all reset paths look sound
frontend/src/features/channels/data/config_channels.ts Adds bailian_anthropic and moonshot_coding channel configs with correct apiFormat, default models, icon, and colour; CHANNEL_TYPE_TO_PROVIDER mapping is also correct
frontend/src/features/channels/data/config_providers.ts Adds bailian_anthropic to the bailian provider and moonshot_coding to the moonshot provider; ordering puts Anthropic-format types first, consistent with other providers
frontend/src/features/channels/data/schema.ts Correctly adds bailian_anthropic and moonshot_coding to the Zod channelTypeSchema enum
internal/server/biz/channel_llm.go Groups TypeBailianAnthropic and TypeMoonshotCoding under a shared anthropic.PlatformDirect transformer case; both new types require an API key (handled by the default guard), which is correct
internal/ent/channel/channel.go Generated file adds TypeBailianAnthropic and TypeMoonshotCoding constants and registers them in TypeValidator; no issues
internal/ent/schema/channel.go Schema source correctly adds bailian_anthropic and moonshot_coding to the type enum
internal/server/gql/ent.graphql GraphQL schema correctly includes the two new channel type enum values
frontend/src/locales/en/channels.json Adds channels.types.bailian_anthropic, channels.types.moonshot_coding, and channels.dialogs.fields.apiFormat.kimiCoding.label — all keys consumed by the UI are present
frontend/src/locales/zh-CN/channels.json Chinese locale parity with the English file; all three new translation keys are present

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects Provider] --> B{Provider?}
    B -->|bailian| C[API Format Dropdown]
    C -->|anthropic/messages| D[derivedChannelType = bailian_anthropic]
    C -->|openai/chat_completions| E[derivedChannelType = bailian]

    B -->|moonshot| F[API Format Dropdown]
    F -->|anthropic/messages| G{useKimiCoding checkbox}
    G -->|checked| H[derivedChannelType = moonshot_coding]
    G -->|unchecked| I[derivedChannelType = moonshot_anthropic]
    F -->|openai/chat_completions| J[derivedChannelType = moonshot]

    D --> K[Backend: anthropic.PlatformDirect transformer]
    H --> K
    E --> L[Backend: bailian custom transformer]
    I --> M[Backend: anthropic.PlatformMoonshot transformer]
    J --> N[Backend: moonshot custom transformer]
Loading

Reviews (4): Last reviewed commit: "fix(channels): add type guard to Kimi Co..." | Re-trigger Greptile

- Reset useKimiCoding on provider change, initialRow change, and dialog open/close
- Merge TypeBailianAnthropic and TypeMoonshotCoding switch cases

@banlanzs banlanzs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue review

@banlanzs banlanzs marked this pull request as draft April 23, 2026 09:09
@banlanzs banlanzs marked this pull request as ready for review April 23, 2026 09:10
Comment thread frontend/src/features/channels/components/channels-action-dialog.tsx Outdated
@banlanzs banlanzs marked this pull request as draft April 23, 2026 09:33
@banlanzs banlanzs marked this pull request as ready for review April 23, 2026 09:33
@looplj looplj merged commit 0de87e3 into looplj:unstable Apr 23, 2026
4 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