feat: remove restriction for AI-generated mock server type in workspace modal#9825
feat: remove restriction for AI-generated mock server type in workspace modal#9825
Conversation
There was a problem hiding this comment.
Pull request overview
Removes the UI restriction that prevented selecting Cloud Mock hosting when creating a mock server via Auto Generate (AI), and includes a small update to mock route → HAR serialization / error extraction used when registering routes with the remote mock service.
Changes:
- Allow Cloud Mock selection regardless of
mockServerCreationType === 'ai'in the new workspace modal. - Simplify Cloud Mock help text (remove the “Not available when creating with Auto Generate” messaging).
- Adjust
mockRouteToHarheader mapping and return more specific error text when the remote mock service responds with an error object.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/insomnia/src/ui/components/modals/new-workspace-modal.tsx | Removes the AI-specific Cloud Mock disablement and related message, enabling AI + Cloud hosting selection. |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.mock-route.$mockRouteId.tsx | Tweaks HAR response generation for mock routes and improves remote error message extraction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .filter(({ name }) => !!name) | ||
| .map(h => ({ | ||
| id: h.id || '', | ||
| name: h.name, | ||
| value: h.value, | ||
| description: h.description || '', | ||
| disabled: h.disabled ?? false, |
There was a problem hiding this comment.
mockRouteToHar is documented as producing a HAR response, but validHeaders currently includes non-HAR fields (id, description, disabled) and also includes headers marked disabled. This can cause disabled mock headers (including Set-Cookie) to still be sent to the remote mock service and produces a non-spec HAR payload. Consider filtering out disabled headers here and mapping to the HAR shape { name, value } (see packages/insomnia/src/common/har.ts:405-411 for how HAR headers are built elsewhere).
| .filter(({ name }) => !!name) | |
| .map(h => ({ | |
| id: h.id || '', | |
| name: h.name, | |
| value: h.value, | |
| description: h.description || '', | |
| disabled: h.disabled ?? false, | |
| .filter(({ name, disabled }) => !!name && !disabled) | |
| .map(h => ({ | |
| name: h.name, | |
| value: h.value, |
| const validHeaders = headersArray | ||
| .filter(({ name }) => !!name) | ||
| .map(h => ({ | ||
| id: h.id || '', | ||
| name: h.name, | ||
| value: h.value, | ||
| description: h.description || '', | ||
| disabled: h.disabled ?? false, | ||
| })); |
There was a problem hiding this comment.
The PR title indicates changes limited to the workspace modal restriction for AI-generated mock servers, but this file also changes HAR serialization and remote error parsing for mock routes. If these changes are unrelated to the modal feature, consider splitting them into a separate PR (or updating the PR description/title to reflect the additional behavior changes).
✅ Circular References ReportGenerated at: 2026-04-21T09:17:38.133Z Summary
Click to view all circular references in PR (20)Click to view all circular references in base branch (20)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
|
With the mockbin changes we can also get rid of the guards preventing the same path with different method types during create and update for cloud mocks: https://github.com/Kong/insomnia/blob/develop/packages/insomnia/src/routes/organization.%24organizationId.project.%24projectId.workspace.%24workspaceId.mock-server.mock-route.new.tsx#L25-L41 |
…er can not have same path
…ction-for-ai-gen-mock
|
@shelby-moore To avoid introducing potential bugs, we will hold off on lifting these restrictions until 12.7. For version 12.6, our primary focus is ensuring a stable rollout of the dynamic mock feature. |
Uh oh!
There was an error while loading. Please reload this page.