feat: add MiniMax M2.7 as configurable backend for Ask about Code#53
feat: add MiniMax M2.7 as configurable backend for Ask about Code#53octo-patch wants to merge 2 commits intojohannesjo:mainfrom
Conversation
The "Ask about Code" inline Q&A feature now supports MiniMax as an
alternative to the Claude Code CLI. Users can switch providers in
Settings and supply a MINIMAX_API_KEY to use MiniMax M2.7 (204K
context) without needing claude installed.
- electron/ipc/ask-code-minimax.ts: streaming MiniMax backend via
OpenAI-compatible API, with abort-signal handling and SSE parsing
- electron/ipc/ask-code.ts: route to MiniMax or Claude based on
provider arg passed through IPC
- electron/ipc/register.ts: forward provider/minimaxApiKey from IPC args
- src/store/{types,core,ui,store,persistence}.ts: persist askCodeProvider
and minimaxApiKey settings
- src/components/SettingsDialog.tsx: provider selector + API key input
- src/components/AskCodeCard.tsx: pass provider/apiKey through IPC
- README.md: mention MiniMax as supported Ask-about-Code provider
- electron/ipc/ask-code-minimax.test.ts: 12 unit tests
There was a problem hiding this comment.
Pull request overview
Adds MiniMax M2.7 as an alternate backend for the app’s Ask about Code feature, allowing users to switch providers in Settings and stream responses via MiniMax’s OpenAI-compatible API.
Changes:
- Added a new Electron MiniMax streaming backend with SSE parsing, cancellation, and basic request limits.
- Routed ask-about-code IPC calls to either Claude CLI or MiniMax based on a new persisted
askCodeProvidersetting. - Added Settings UI for provider selection and MiniMax API key entry, and threaded these values through the IPC call chain.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
electron/ipc/ask-code-minimax.ts |
Implements MiniMax streaming backend (fetch + SSE parsing + abort/timeout). |
electron/ipc/ask-code-minimax.test.ts |
Adds unit tests for MiniMax streaming, headers, errors, and cancellation. |
electron/ipc/ask-code.ts |
Routes requests to MiniMax when selected; keeps Claude CLI path as default. |
electron/ipc/register.ts |
Extends IPC handler to accept/validate provider and minimaxApiKey. |
src/store/core.ts |
Adds default store fields for askCodeProvider and minimaxApiKey. |
src/store/types.ts |
Extends persisted/in-memory state typings for new provider + key fields. |
src/store/ui.ts |
Adds setters for provider and API key. |
src/store/store.ts |
Re-exports new UI setters from the store module. |
src/store/persistence.ts |
Persists/loads provider selection and MiniMax API key. |
src/components/SettingsDialog.tsx |
Adds provider dropdown and conditional MiniMax API key input. |
src/components/AskCodeCard.tsx |
Passes provider + API key into the IPC AskAboutCode call. |
README.md |
Documents MiniMax as a supported Ask-about-Code provider. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/store/persistence.ts
Outdated
| editorCommand: store.editorCommand || undefined, | ||
| dockerImage: store.dockerImage !== 'parallel-code-agent:latest' ? store.dockerImage : undefined, | ||
| askCodeProvider: store.askCodeProvider !== 'claude' ? store.askCodeProvider : undefined, | ||
| minimaxApiKey: store.minimaxApiKey || undefined, |
There was a problem hiding this comment.
minimaxApiKey is being persisted into state.json (and therefore also into the .bak backup) in plaintext. This is a high-risk secret-storage pattern for an API key; consider storing it via an OS credential store / Electron secure storage (e.g., safeStorage + platform keychain) or avoid persisting it by default (or only persist when provider === 'minimax' and add an explicit “forget key” action).
| minimaxApiKey: store.minimaxApiKey || undefined, | |
| // Do not persist API keys in plaintext application state files. |
| const { win, messages } = makeMockWin(); | ||
|
|
||
| // Simulate a slow response that never closes | ||
| let rejectReader!: (err: unknown) => void; |
There was a problem hiding this comment.
rejectReader is declared but never used, which will fail the repo’s @typescript-eslint/no-unused-vars lint rule. Remove it (or use it) to keep npm run lint / npm run check passing.
| let rejectReader!: (err: unknown) => void; |
| inactiveColumnOpacity?: number; | ||
| editorCommand?: string; | ||
| dockerImage?: string; | ||
| askCodeProvider?: string; | ||
| minimaxApiKey?: string; | ||
| customAgents?: AgentDef[]; |
There was a problem hiding this comment.
PersistedState.askCodeProvider is typed as string, but the in-memory store restricts this to 'claude' | 'minimax'. Narrowing the persisted type to the same union (and validating to that) will make the persistence layer safer and prevent accidental misuse elsewhere.
Review findings (new issues not covered by Copilot)1. API key flows through IPC and lives in renderer store (medium severity)In minimaxApiKey: store.minimaxApiKey,This means:
Copilot's comment covered plaintext persistence to 2. User-initiated cancel sends
|
|
Thank you very much! <3 |
johannesjo
left a comment
There was a problem hiding this comment.
Three issues to address before merge:
- API key exposure — the MiniMax API key is held in plaintext renderer memory and transmitted in the IPC payload on every query. Consider keeping it in the main process only, reading it there from persisted state.
- No
max_tokenscap — without a limit, a single query can produce an unbounded response, leading to unexpected latency and cost. - Cancel exit code — user-initiated cancellation emits
exitCode: 1(treated as an error); it should emit a neutral/cancelled signal instead.
Additionally, cancelAskAboutCode calls the MiniMax canceller regardless of which provider is active — it should be guarded by a provider check. Details in the review comment.
- Move API key to main process only: add SetMinimaxApiKey IPC channel, store key in main-process memory, remove from renderer store and per-request IPC payload, stop persisting to state.json - Add max_tokens: 2048 cap to MiniMax request body - Fix cancel exit code: emit exitCode 0 with cancelled flag instead of exitCode 1 for user-initiated cancellation - Guard cancelAskAboutCode by provider: track active provider per request, only call cancelAskAboutCodeMinimax when provider is minimax - Narrow PersistedState.askCodeProvider type to 'claude' | 'minimax' - Remove unused rejectReader variable in ask-code-minimax.test.ts Co-Authored-By: Octopus <liyuan851277048@icloud.com>
|
Thanks for the detailed review! All four issues plus the Copilot feedback have been addressed in commit dfb2e00: 1. API key exposure (medium):
2. No max_tokens cap (medium):
3. Cancel exit code (low):
4. cancelAskAboutCode provider guard:
Copilot feedback:
All 12 unit tests pass. TypeScript typecheck passes with no errors. |
Summary
claudeCLI requiredChanges
electron/ipc/ask-code-minimax.tselectron/ipc/ask-code-minimax.test.tselectron/ipc/ask-code.tsproviderargelectron/ipc/register.tsprovider/minimaxApiKeyfrom IPC call argssrc/store/{types,core,ui,store,persistence}.tsaskCodeProvider+minimaxApiKeystore fields, persisted to state.jsonsrc/components/SettingsDialog.tsxsrc/components/AskCodeCard.tsxREADME.mdTest plan
npm test— 12 new passing tests, all existing tests still passCtrl+,) → see new "Ask about Code" section with provider dropdownMINIMAX_API_KEY, select code in a task, ask a question — response streams in