Skip to content

Commit 5c71b26

Browse files
committed
Added a 2 second delay before closing the browser
1 parent b910595 commit 5c71b26

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/lib/utils.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ export async function connectToRemoteServer(
130130
const sseTransport = transportStrategy === 'sse-only' || transportStrategy === 'sse-first'
131131
const transport = sseTransport
132132
? new SSEClientTransport(url, {
133-
authProvider,
134-
requestInit: { headers },
135-
eventSourceInit,
136-
})
133+
authProvider,
134+
requestInit: { headers },
135+
eventSourceInit,
136+
})
137137
: new StreamableHTTPClientTransport(url, {
138-
authProvider,
139-
requestInit: { headers },
140-
})
138+
authProvider,
139+
requestInit: { headers },
140+
})
141141

142142
try {
143143
if (client) {
@@ -300,8 +300,16 @@ export function setupOAuthCallbackServerWithLongPoll(options: OAuthCallbackServe
300300
log('Auth code received, resolving promise')
301301
authCompletedResolve(code)
302302

303-
res.send('Authorization successful! You may close this window and return to the CLI.' +
304-
'<script>window.close();</script>')
303+
res.send(`
304+
Authorization successful!
305+
You may close this window and return to the CLI.
306+
<script>
307+
// If this is a non-interactive session (no manual approval step was required) then
308+
// this should automatically close the window. If not, this will have no effect and
309+
// the user will see the message above.
310+
window.close();
311+
</script>
312+
`)
305313

306314
// Notify main flow that auth code is available
307315
options.events.emit('auth-code-received', code)
@@ -377,7 +385,7 @@ export async function findAvailablePort(preferredPort?: number): Promise<number>
377385
export async function parseCommandLineArgs(args: string[], defaultPort: number, usage: string) {
378386
// Process headers
379387
const headers: Record<string, string> = {}
380-
let i = 0;
388+
let i = 0
381389
while (i < args.length) {
382390
if (args[i] === '--header' && i < args.length - 1) {
383391
const value = args[i + 1]

0 commit comments

Comments
 (0)