Skip to content

agentHost: support --host and print resolved server urls#306219

Merged
rebornix merged 1 commit intomainfrom
rebornix/associated-ermine
Mar 30, 2026
Merged

agentHost: support --host and print resolved server urls#306219
rebornix merged 1 commit intomainfrom
rebornix/associated-ermine

Conversation

@rebornix
Copy link
Copy Markdown
Member

  • added --host support to scripts/code-agent-host.js
  • print Local and Network addresses instead of echoing the raw bind address

Copilot AI review requested due to automatic review settings March 30, 2026 04:59
@rebornix rebornix self-assigned this Mar 30, 2026
@vs-code-engineering vs-code-engineering bot added this to the Backlog milestone Mar 30, 2026
@rebornix rebornix requested a review from connor4312 March 30, 2026 05:02
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

Adds CLI/runtime support for selecting the bind host for the standalone Agent Host server and improves startup logging by printing resolved “Local” and “Network” WebSocket URLs.

Changes:

  • Add --host support to scripts/code-agent-host.js and agentHostServerMain.ts.
  • Introduce resolveServerUrls/formatWebSocketUrl helper to compute display URLs (including IPv6 bracket formatting).
  • Add unit tests for URL resolution/formatting behavior.

Reviewed changes

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

File Description
src/vs/platform/agentHost/test/node/serverUrls.test.ts Adds tests for URL formatting and local/network URL resolution.
src/vs/platform/agentHost/node/serverUrls.ts New helper to format WebSocket URLs and resolve local/network addresses for logging.
src/vs/platform/agentHost/node/agentHostServerMain.ts Parses --host, passes it to the WebSocket server, and prints resolved Local/Network URLs on ready.
scripts/code-agent-host.js Adds --host CLI support and changes startup behavior to rely on server-printed resolved URLs.
Comments suppressed due to low confidence (2)

src/vs/platform/agentHost/node/serverUrls.ts:47

  • formatWebSocketUrl unconditionally brackets any host containing :. If the caller passes an already-bracketed IPv6 host (e.g. "[::1]"), this produces an invalid URL like ws://[[::1]]:8081. Consider normalizing by stripping a single surrounding [/] pair before applying the IPv6 bracketing logic.
export function formatWebSocketUrl(host: string, port: number): string {
	const normalizedHost = host.includes(':') ? `[${host}]` : host;
	return `ws://${normalizedHost}:${port}`;

scripts/code-agent-host.js:100

  • startServer now returns a Promise that never rejects and there’s no handler for the child process error event. If spawning the server fails (missing build output, permission issues, etc.), the script can either crash due to an unhandled error event or hang without a clear error path. Consider listening for proc.on('error', ...) and rejecting (or exiting with a non-zero code) when startup fails or the process exits before printing READY:.
function startServer(programArgs) {
	return new Promise((resolve) => {
		const env = { ...process.env };
		const entryPoint = path.join(
			__dirname,
			'..',
			'out',
			'vs',
			'platform',
			'agentHost',
			'node',
			'agentHostServerMain.js',
		);

		console.log(
			`Starting agent host server: ${entryPoint} ${programArgs.join(' ')}`,
		);
		const proc = cp.spawn(process.execPath, [entryPoint, ...programArgs], {
			env,
			stdio: [process.stdin, null, process.stderr],
		});
		proc.stdout.on('data', (data) => {
			const text = data.toString();
			process.stdout.write(text);
			const m = text.match(/READY:(\d+)/);
			if (m) {
				resolve();
			}
		});

		proc.on('exit', (code) => process.exit(code));

@rebornix rebornix modified the milestones: Backlog, 1.115.0 Mar 30, 2026
@rebornix rebornix marked this pull request as ready for review March 30, 2026 21:23
@rebornix rebornix merged commit a4855ab into main Mar 30, 2026
22 checks passed
@rebornix rebornix deleted the rebornix/associated-ermine branch March 30, 2026 21:23
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.

3 participants