[codex] fix ai-remover edit routing - #5
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
WalkthroughDetects AI-remover models, routes their edit requests to the base model path (no Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant Resolver as ModelResolver
participant Infer as TypeInference
participant Router as SubmitRouter
participant Builder as PayloadBuilder
participant API as API
Client->>Resolver: resolveModel(modelRef)
Resolver->>Infer: inferApiModelType(modelName)
Infer-->>Resolver: "ai-remover" / undefined
Resolver-->>Client: ResolvedModel {apiModelType, modelName,...}
Client->>Router: buildSubmitTarget(model,"edit")
Router->>Infer: isAiRemoverModel(model)
Infer-->>Router: true / false
alt ai-remover
Router-->>Client: /api/v3/{modelName} (base)
else standard
Router-->>Client: /api/v3/{modelName}/edit
end
Client->>Builder: buildEditPayload(params)
Builder->>Infer: isAiRemoverModel(model)
Infer-->>Builder: true / false
alt ai-remover
Builder-->>Client: { image, enable_base64_output, enable_sync_mode, prompt? }
else standard
Builder-->>Client: { images, prompt, size, enable_base64_output, enable_sync_mode }
end
Client->>API: POST request
API-->>Client: Task / result
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea41fbab85
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/config/models.ts`:
- Around line 59-88: findCachedModelType and resolveApiModelType must strip any
CANONICAL_MODEL_SUFFIXES from refs/ids before looking up the cache or inferring
submit mode so canonical edit suffixes (e.g., provider/model/edit) map to the
cached provider/model and correctly classify ai-remover models; update
findCachedModelType to normalize each ref by removing CANONICAL_MODEL_SUFFIXES
before calling apiCache?.models.find, and update resolveApiModelType (and any
code paths that call inferSubmitMode for configured/direct ids) to strip those
suffixes from id and modelName prior to calling findCachedModelType or
inferApiModelType so remover models get the authoritative cached type and
correct submit mode.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b550f948-d18e-4584-b271-22b9c7d13ccf
📒 Files selected for processing (9)
src/api/client.tssrc/config/models.tssrc/config/types.tssrc/core/operations.tssrc/utils/model-routing.tstests/api/client.test.tstests/commands/cli.test.tstests/config/models.test.tstests/core/operations.test.ts
|
🎉 This PR is included in version 1.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
Fixes #4.
This change makes
editwork correctly for Wavespeedai-removermodels such aswavespeed-ai/image-background-removerandbria/remove-background.Before this change, users hitting remover models through the CLI or MCP
edittool could get400responses because the request was routed like a normal image-edit model and sent the wrong payload shape.Root Cause
The runtime treated all image edit models the same:
/editfor non-canonical aliasesimagesas an array plus generic edit fieldsThat breaks remover models because those endpoints use the base model path and expect a singular
imagefield instead ofimages.A second issue was that model resolution discarded the Wavespeed catalog
type, so the command layer could not reliably distinguish remover models from normal edit models when resolving aliases.What Changed
The fix preserves and infers API model type during model resolution, then uses that metadata to apply remover-specific edit behavior.
In practice this PR:
typemetadata on resolved modelsai-removerfor known remover model IDs when cache metadata is unavailableeditrequests for remover models to the base model path instead of appending/editimagefieldimage-eraser)Additional Test Fix
While validating the change, the CLI integration tests were failing in this environment because they spawned
bunby name and assumed it was onPATH.This PR updates the CLI test harness to spawn the current Bun executable via
process.execPath, which makes the existing tests pass consistently without changing product behavior.Validation
I ran:
/Users/allan/.bun/bin/bun test/Users/allan/.bun/bin/bun run lint/Users/allan/.bun/bin/bun run buildResults:
bun test: 86 passing, 4 skipped, 0 failingbun run lint: passedbun run build: passedSummary by CodeRabbit
New Features
Tests
Chores