Skip to content

Commit c2aa028

Browse files
authored
Merge branch 'develop' into feat/mcp-safe-abort
2 parents 6613c46 + 9cefe89 commit c2aa028

13 files changed

+69
-55
lines changed

packages/insomnia/src/main/mcp/transport-streamable-http.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ const wrappedFetch = async (
256256
fetchFn: authFetchFn,
257257
});
258258
}
259-
// Close the oauth authorization modal after authorization is complete
260-
BrowserWindow.getAllWindows().forEach(window => {
261-
window.webContents.send('hide-oauth-authorization-modal');
262-
});
263259
if (authResult !== 'AUTHORIZED') {
264260
throw new UnauthorizedError();
265261
}
@@ -268,6 +264,10 @@ const wrappedFetch = async (
268264
// Wrap and throw MCPAuthError for better identification, some of the errors thrown by sdk are generic Error which is hard to identify
269265
throw new MCPAuthError(e.message || 'Authentication failed', { cause: e });
270266
} finally {
267+
// Close the oauth authorization modal after authorization is complete
268+
BrowserWindow.getAllWindows().forEach(window => {
269+
window.webContents.send('hide-oauth-authorization-modal');
270+
});
271271
unsubscribe();
272272
}
273273
return await wrappedFetch(url, init, context, authProvider, true);

packages/insomnia/src/network/network.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ export const tryToExecutePreRequestScript = async (
384384
originalRequestGroups,
385385
});
386386

387+
const preTestResults: RequestTestResult[] = (mutatedContext.requestTestResults || []).map(result => ({
388+
...result,
389+
category: 'pre-request',
390+
}));
387391
return {
388392
request: mutatedContext.request,
389393
environment: mutatedContext.environment,
@@ -393,7 +397,7 @@ export const tryToExecutePreRequestScript = async (
393397
globals: mutatedContext.globals,
394398
baseGlobals: mutatedContext.baseGlobals,
395399
cookieJar: mutatedContext.cookieJar,
396-
requestTestResults: mutatedContext.requestTestResults,
400+
requestTestResults: preTestResults,
397401
userUploadEnvironment: mutatedContext.userUploadEnvironment,
398402
execution: mutatedContext.execution,
399403
transientVariables: mutatedContext.transientVariables,
@@ -483,7 +487,7 @@ export async function savePatchesMadeByScript(patches: {
483487
});
484488
}
485489

486-
export const tryToExecuteScript = async (context: RequestAndContextAndOptionalResponse) => {
490+
const tryToExecuteScript = async (context: RequestAndContextAndOptionalResponse) => {
487491
const {
488492
script,
489493
request,
@@ -757,7 +761,12 @@ export async function tryToExecuteAfterResponseScript(context: RequestAndContext
757761
});
758762
}
759763

760-
return postMutatedContext;
764+
const postTestResults: RequestTestResult[] = (postMutatedContext?.requestTestResults || []).map(result => ({
765+
...result,
766+
category: 'after-response',
767+
}));
768+
769+
return { ...postMutatedContext, requestTestResults: postTestResults };
761770
}
762771

763772
export const tryToInterpolateRequest = async ({

packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.$requestId.send.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,8 @@ export const sendActionImplementation = async (options: {
281281

282282
window.main.completeExecutionStep({ requestId });
283283

284-
const preTestResults = (mutatedContext.requestTestResults || []).map(
285-
(result: RequestTestResult): RequestTestResult => ({ ...result, category: 'pre-request' }),
286-
);
287-
const postTestResults =
288-
(postMutatedContext?.requestTestResults || []).map(
289-
(result: RequestTestResult): RequestTestResult => ({ ...result, category: 'after-response' }),
290-
) || [];
284+
const preTestResults = mutatedContext.requestTestResults || [];
285+
const postTestResults = postMutatedContext?.requestTestResults || [];
291286
if (testResultCollector) {
292287
testResultCollector.results = [...testResultCollector.results, ...preTestResults, ...postTestResults];
293288
const timingSteps = await window.main.getExecution({ requestId });

packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.runner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ export const Runner: FC = () => {
620620
<TooltipTrigger key={`parent-folder-${id}=${name}`}>
621621
<Tooltip message={name}>
622622
<i className="fa fa-folder fa-1x mr-0.3 h-4 text-[--color-font]" />
623-
<i className="fa fa-caret-right fa-1x mr-0.3 text-[--color-font]-50 h-4 opacity-50" />
623+
<i className="fa fa-caret-right fa-1x mr-0.3 h-4 opacity-50" />
624624
</Tooltip>
625625
</TooltipTrigger>
626626
);

packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.mock-route.$mockRouteId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ export const MockRouteRoute = () => {
262262
>
263263
Mock Headers{' '}
264264
{headersCount > 0 && (
265-
<span className="color-inherit shadow-small flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
265+
<span className="color-inherit flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
266266
{headersCount}
267267
</span>
268268
)}

packages/insomnia/src/ui/components/modals/cloud-credential-modal/cloud-credential-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export const CloudCredentialModal = (props: CloudCredentialModalProps) => {
187187
onChange={e => setManualInputUrl(e.target.value)}
188188
/>{' '}
189189
<button
190-
className="btn btn--super-compact btn--outlined gap-[--padding-xs flex items-center"
190+
className="btn btn--super-compact btn--outlined gap-[--padding-xs] flex items-center"
191191
type="submit"
192192
disabled={isAuthenticating}
193193
onClick={exchangeAzureCode}

packages/insomnia/src/ui/components/modals/invite-modal/invite-modal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ const MemberListItem: FC<{
438438
<div className="flex min-w-[88px] items-center justify-center">
439439
<Button
440440
aria-label="Manage collaborators"
441-
className="pressed:bg-opacity-40 flex min-w-[70px] cursor-pointer items-center justify-center gap-2 rounded-sm bg-[rgba(var(--color-surprise-rgb),var(--tw-bg-opacity))] bg-opacity-100 bg-clip-padding p-1 text-sm text-[--color-font-surprise] outline-none transition-all hover:bg-opacity-80 focus-visible:ring-2 focus-visible:ring-white/75"
441+
className="flex min-w-[70px] cursor-pointer items-center justify-center gap-2 rounded-sm bg-[rgba(var(--color-surprise-rgb),var(--tw-bg-opacity))] bg-opacity-100 bg-clip-padding p-1 text-sm text-[--color-font-surprise] outline-none transition-all hover:bg-opacity-80 focus-visible:ring-2 focus-visible:ring-white/75 data-[pressed]:bg-opacity-40"
442442
onPress={() => {
443443
if (!permissionRef.current['own:organization']) {
444444
showModal(AlertModal, {

packages/insomnia/src/ui/components/modals/oauth-authorization-status-modal.tsx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const OAuthAuthorizationStatusModal: FC = () => {
1515
const [authCodeUrlStr, setAuthCodeUrlStr] = useState<string | undefined>();
1616
const [submitting, setSubmitting] = useState<boolean>(false);
1717
const { submit: redirectToDefaultBrowserSubmit } = useDefaultBrowserRedirectActionFetcher();
18+
const [error, setError] = useState<string | null>(null);
1819

1920
useEffect(() => {
2021
const unsubscribe = window.main.on('show-oauth-authorization-modal', (_, authCodeUrlStr: string) => {
@@ -65,6 +66,7 @@ export const OAuthAuthorizationStatusModal: FC = () => {
6566
} else if (status === 'getting_code') {
6667
modalRef.current?.show();
6768
setSubmitting(false);
69+
setError(null);
6870
}
6971
}, [status]);
7072

@@ -84,7 +86,7 @@ export const OAuthAuthorizationStatusModal: FC = () => {
8486
{status === 'getting_code' && (
8587
<>
8688
<p className="text-[rgba(var(--color-font-rgb),0.8))] text-start">
87-
See your browser to finish authorization, if the browser didnt open automatically, copy and paste this
89+
See your browser to finish authorization, if the browser didn't open automatically, copy and paste this
8890
URL into your browser to authorize.
8991
</p>
9092
<div className="form-control form-control--outlined no-pad-top flex">
@@ -110,29 +112,36 @@ export const OAuthAuthorizationStatusModal: FC = () => {
110112
</p>
111113
<form
112114
onSubmit={e => {
113-
e.preventDefault();
114-
const form = e.currentTarget;
115-
const data = new FormData(form);
115+
try {
116+
e.preventDefault();
117+
const form = e.currentTarget;
118+
const data = new FormData(form);
116119

117-
const url = data.get('url');
118-
invariant(typeof url === 'string', 'Expected code to be a string');
119-
if (url.length === 0) {
120-
return;
121-
}
122-
setSubmitting(true);
123-
const parsedUrl = new URL(url);
124-
const params = Object.fromEntries(parsedUrl.searchParams);
125-
const { encryptedUrl: encryptedRedirectUrl, encryptedKey, iv } = params;
126-
if (encryptedRedirectUrl && encryptedKey && iv) {
120+
const url = data.get('url');
121+
invariant(typeof url === 'string', 'Expected code to be a string');
122+
if (url.length === 0) {
123+
return;
124+
}
125+
setError(null);
126+
setSubmitting(true);
127+
const parsedUrl = new URL(url);
128+
const params = Object.fromEntries(parsedUrl.searchParams);
129+
const { encryptedUrl: encryptedRedirectUrl, encryptedKey, iv } = params;
130+
if (encryptedRedirectUrl && encryptedKey && iv) {
131+
return redirectToDefaultBrowserSubmit({
132+
encryptedRedirectUrl,
133+
encryptedKey,
134+
iv,
135+
});
136+
}
127137
return redirectToDefaultBrowserSubmit({
128-
encryptedRedirectUrl,
129-
encryptedKey,
130-
iv,
138+
redirectUrl: url,
131139
});
140+
} catch (error) {
141+
setError(error instanceof Error ? error.message : String(error));
142+
setSubmitting(false);
143+
return;
132144
}
133-
return redirectToDefaultBrowserSubmit({
134-
redirectUrl: url,
135-
});
136145
}}
137146
>
138147
<div className="form-control form-control--outlined no-pad-top" style={{ display: 'flex' }}>
@@ -151,6 +160,7 @@ export const OAuthAuthorizationStatusModal: FC = () => {
151160
Proceed
152161
</button>
153162
</div>
163+
{error && <p className="text-danger">Error: {error}</p>}
154164
</form>
155165
</>
156166
)}

packages/insomnia/src/ui/components/panes/request-pane.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export const RequestPane: FC<Props> = ({ environmentId, settings, onPaste }) =>
202202
<Button
203203
isDisabled={!urlHasQueryParameters}
204204
onPress={handleImportQueryFromUrl}
205-
className="asma-pressed:bg-[--hl-sm] flex h-full w-[14ch] flex-shrink-0 items-center justify-start gap-2 rounded-sm px-2 py-1 text-sm text-[--color-font] ring-1 ring-transparent transition-colors hover:bg-[--hl-xs] focus:bg-[--hl-sm] focus:ring-inset focus:ring-[--hl-md] aria-selected:bg-[--hl-xs] aria-selected:hover:bg-[--hl-sm] aria-selected:focus:bg-[--hl-sm]"
205+
className="flex h-full w-[14ch] flex-shrink-0 items-center justify-start gap-2 rounded-sm px-2 py-1 text-sm text-[--color-font] ring-1 ring-transparent transition-colors hover:bg-[--hl-xs] focus:bg-[--hl-sm] focus:ring-inset focus:ring-[--hl-md] aria-selected:bg-[--hl-xs] aria-selected:hover:bg-[--hl-sm] aria-selected:focus:bg-[--hl-sm] data-[pressed]:bg-[--hl-sm]"
206206
>
207207
Import from URL
208208
</Button>

packages/insomnia/src/ui/components/panes/response-pane.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export const ResponsePane: FC<Props> = ({ activeRequestId }) => {
186186
>
187187
Headers
188188
{activeResponse.headers.length > 0 && (
189-
<span className="shadow-small flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
189+
<span className="flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
190190
{activeResponse.headers.length}
191191
</span>
192192
)}
@@ -197,7 +197,7 @@ export const ResponsePane: FC<Props> = ({ activeRequestId }) => {
197197
>
198198
Cookies
199199
{cookieHeaders.length > 0 && (
200-
<span className="shadow-small flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
200+
<span className="flex aspect-square items-center justify-between overflow-hidden rounded-lg border border-solid border-[--hl-md] p-2 text-xs">
201201
{cookieHeaders.length}
202202
</span>
203203
)}

0 commit comments

Comments
 (0)