Skip to content

Feature/auth and quality hub api#118

Merged
mrdailey99 merged 4 commits intodevelopfrom
feature/auth-and-quality-hub-api
Apr 15, 2026
Merged

Feature/auth and quality hub api#118
mrdailey99 merged 4 commits intodevelopfrom
feature/auth-and-quality-hub-api

Conversation

@mrdailey99
Copy link
Copy Markdown
Collaborator

No description provided.

mrdailey99 and others added 3 commits April 13, 2026 17:07
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 15, 2026 04:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the auth login flow to better support “fire-and-forget” browser launching and faster shutdown of the localhost OAuth callback server, and bumps the CLI beta version with small docs tweaks.

Changes:

  • Replace execFile with detached spawn(...).unref() for opening the system browser.
  • Force-close HTTP connections after OAuth callback responses (via Connection: close + closeAllConnections?.()).
  • Bump package version to 1.5.0-beta.5 and update installation notes in docs/README.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/services/auth/loginFlow.ts Updates browser launch strategy and callback server connection handling.
package.json Version bump for the beta release.
docs/mcp.md Clarifies that @beta install is required for MCP support.
README.md Same @beta install clarification in quick setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 82 to 84
const spawnOpts = { detached: true, stdio: 'ignore' as const };
let child;
switch (process.platform) {
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let child; creates an implicit any under the repo’s strict TS config, which will fail compilation. Please give this a concrete type (e.g., ChildProcess) or restructure to assign a typed const child = ... from a helper so the switch still works without any.

Copilot uses AI. Check for mistakes.
execFile('xdg-open', [url]);
child = spawn('xdg-open', [url], spawnOpts);
break;
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spawned child process can emit an error event (e.g., xdg-open/open/powershell.exe not found). With no error listener, Node will treat it as an unhandled EventEmitter error and crash the CLI. Add a no-op/error-logging handler (or handle ENOENT explicitly) before calling unref().

Suggested change
}
}
child.on('error', (error) => {
console.error(`Failed to open browser automatically: ${error.message}`);
});

Copilot uses AI. Check for mistakes.
Comment on lines 79 to 98
export function openBrowser(url: string): void {
// detached:true + stdio:'ignore' + unref() is the standard Node.js pattern for
// fire-and-forget child processes — the event loop will not wait for them to exit.
const spawnOpts = { detached: true, stdio: 'ignore' as const };
let child;
switch (process.platform) {
case 'darwin':
execFile('open', [url]);
child = spawn('open', [url], spawnOpts);
break;
case 'win32':
// Pass the URL via $args[0] so it is never interpolated into the -Command
// string — avoids quote-breaking and injection risk from special characters.
execFile('powershell.exe', ['-NoProfile', '-Command', 'Start-Process $args[0]', '-args', url]);
child = spawn('powershell.exe', ['-NoProfile', '-Command', 'Start-Process $args[0]', '-args', url], spawnOpts);
break;
default:
execFile('xdg-open', [url]);
child = spawn('xdg-open', [url], spawnOpts);
break;
}
child.unref();
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openBrowser behavior changed (detached + stdio ignore + unref + platform-specific spawn args), but there are currently unit tests for other loginFlow functions and none covering this. Consider adding a unit test that asserts the correct command/args/options are selected per platform (which may require routing process spawning through a stub-friendly indirection similar to loginFlowClient).

Copilot uses AI. Check for mistakes.
- Add explicit ChildProcess type to suppress implicit-any lint warning
- Add no-op error handler to prevent unhandled EventEmitter crash on ENOENT
- Extract getBrowserCommand() pure function for testability
- Add unit tests covering all platforms and URL passthrough

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mrdailey99 mrdailey99 merged commit fc43ff8 into develop Apr 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants