Skip to content

fix(server): Servers panel no longer lists the Claude CLI's own port - #36176

Closed
sulcer wants to merge 5 commits into
pingdotgg:mainfrom
sulcer:fix/servers-panel-agent-port
Closed

sulcer wants to merge 5 commits into
pingdotgg:mainfrom
sulcer:fix/servers-panel-agent-port

Conversation

@sulcer

@sulcer sulcer commented Nov 13, 2026

Copy link
Copy Markdown

Problem

Every Claude thread lists the Claude CLI itself under Servers (localhost:<port> · Agent · 2.1.323), and the page returns 404. Claude Code holds a loopback port once a plugin registers a tool with $.tool.register. The CLI carries T3CODE_THREAD_ID, so the scanner reads that port as a server the thread started. Details and repro: #36173.

Change

 ClaudeAdapterV2 spawnClaudeCodeProcess
-  portDiscovery.trackAgent()
+  portDiscovery.trackAgent(child.pid)

 PortScanner withAgentOwners
-  owners.set(pid, agent)            // every pid with the thread
+  if (!agentCliPids.has(pid)) owners.set(pid, agent)

Only the CLI's own pid is skipped. Servers it starts keep their attribution. Codex and ACP calls are unchanged: the Codex CLI does not carry the thread, and ACP adapters do not call trackAgent.

Door: two-way. Blast Radius: narrow. A wrong pid would hide one row in the Servers panel.

Scope

Fixes #36173.

Verification

  • New case in PortScanner.test.ts (Linux and macOS): fails on main with the CLI's listener listed, passes here. vp run check:changed passes.
  • vp run dev with a real Claude thread and a mod that registers a tool. The CLI holds a port in both runs.
main this branch this branch, agent ran python3 -m http.server
Servers lists localhost:62403, Agent · 2.1.323 No Servers section Servers lists localhost:8765, Agent · Python

I did not run it on Linux or Windows. Windows does not attribute agent listeners at all.

Created with Claude Opus 5.5 in Claude Code.

The Claude CLI runs with its thread id in its environment, so port
discovery attributed a port the CLI holds itself to the thread and
listed it as a server. Claude Code holds one whenever a plugin
registers a tool with $.tool.register. The adapter now passes the
CLI's pid to trackAgent, and the scanner skips that pid's listeners.
Servers the CLI starts are still listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 13, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 868d00a

Macroscope's review found this PR approvable — The Servers panel excludes the Claude CLI’s own listener while retaining servers it starts. The change is confined to discovery attribution, with no persistent-data or process-control changes.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6e16b77 and d954f87.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Port discovery now tracks active agent CLI PIDs and excludes those processes from agent server ownership. The Claude adapter passes the spawned child PID to port discovery. A test checks that the CLI listener is excluded while a child server listener remains discoverable.

Changes: Agent Port Discovery

Layer / File(s) Summary
Track agent CLI PIDs
apps/server/src/preview/PortScanner.ts
trackAgent accepts an optional CLI PID. Port discovery records that PID while tracking is active and removes it when tracking is released.
Exclude CLI listeners
apps/server/src/preview/PortScanner.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/preview/PortScanner.test.ts
Port discovery does not assign agent ownership to active CLI PIDs. The Claude adapter supplies the child PID, and a test checks that scanning excludes the CLI listener but reports the child server listener.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: juliusmarminge, t3dotgg

Merge Risk: Minimal · previous review 6e16b

The Servers panel stops listing the Claude CLI's own port while still showing servers the agent starts. The change is narrow and cosmetic in scope. No concrete defect was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the Servers panel no longer lists the Claude CLI's own port. It matches the diff, which skips the CLI pid in agent-owner resolution and passes the pid through trackAge…
Description check Passed The description follows the template. It covers Problem, Change, Scope, and Verification. The Problem section gives the symptom, the trigger, and a link to the issue. The Change section shows the diff…
Linked Issues check Passed Issue #36173 requires the Servers section to list only servers started by the thread's agent or terminals. It must not list the Claude CLI's own loopback port. At the reviewed head, PortScanner.ts a…
Out of Scope Changes check Passed The whole-PR changes are limited to the Claude adapter PID handoff, the PortScanner.ts CLI-PID set and owner-attribution skip, and a new test case. The cliPid parameter is optional, so Codex and A…
Full details: Title check

Explanation

The title names the main change: the Servers panel no longer lists the Claude CLI's own port. It matches the diff, which skips the CLI pid in agent-owner resolution and passes the pid through trackAgent. The title follows the conventional commit form the repository template asks for.

Full details: Description check

Explanation

The description follows the template. It covers Problem, Change, Scope, and Verification. The Problem section gives the symptom, the trigger, and a link to the issue. The Change section shows the diff and says what is unchanged for Codex and ACP. Scope links #36173. Verification lists a focused test on Linux and macOS, a manual run with screenshots, and states what was not checked (Linux and Windows runs). The model and harness line is present. The Verification section does not state the exact test command result for Linux and macOS separately, and the 'Created with Claude Opus 5.5' line is an unverified model claim, but these do not leave the description largely incomplete.

Full details: Linked Issues check

Explanation

Issue #36173 requires the Servers section to list only servers started by the thread's agent or terminals. It must not list the Claude CLI's own loopback port. At the reviewed head, PortScanner.ts adds an optional cliPid to trackAgent and stores it in agentCliPids. withAgentOwners now skips any PID in that set, so the CLI listener is not attributed to the thread. Other PIDs that carry T3CODE_THREAD_ID keep their attribution, so servers the agent starts stay listed. trackAgent's release function deletes the PID, so a reused PID is not skipped later. The whole-PR diff from the merge base confirms this logic. Per the summary, ClaudeAdapterV2.ts passes child.pid to trackAgent. The summary also reports a Linux/macOS test in PortScanner.test.ts. I did not inspect that test file or the adapter hunk directly in this review. Remaining uncertainty: the fix assumes the listening socket belongs to the process whose PID is child.pid. If Claude Code binds the port in a helper process, that listener stays attributed. The PR reports that the CLI holds the port directly. Manual macOS verification is non-coding and does not affect this result.

Full details: Out of Scope Changes check

Explanation

The whole-PR changes are limited to the Claude adapter PID handoff, the PortScanner.ts CLI-PID set and owner-attribution skip, and a new test case. The cliPid parameter is optional, so Codex and ACP callers that omit it keep prior behavior. The trackAgent doc comment and signature change directly support the new parameter. No unrelated hunks appear in the inspected PortScanner.ts diff. The adapter and test hunks rely on the PR summary, which describes them as directly tied to the same fix.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bd9909f and 6e16b77.

Files selected for processing: 3

  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
  • apps/server/src/preview/PortScanner.test.ts
  • apps/server/src/preview/PortScanner.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 13, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

The automated pipeline stopped on this pull request and will not merge it:

the fix is written and reviewed, but proving it needs something no worker has:

  • Permanent blocker: The supplied reproduction requires macOS with Claude Code 2.1.323 and a plugin whose session.start hook registers a ping tool through $.tool.register. This VM is Linux, and access to another macOS host outside the device pool is prohibited. Replay scenarios cannot reproduce provider-specific behavior.
  • The CLI listener disappearing and an agent-started Python HTTP server remaining visible with agent attribution were not verified on either commit.

It stays open for a person to finish or close.

@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body takeover:in-progress A takeover lead is working on this PR and removed takeover:in-progress A takeover lead is working on this PR takeover:blocked Takeover blocked; reason in the PR body labels Nov 13, 2026
…nt-port

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge juliusmarminge added takeover:blocked Takeover blocked; reason in the PR body and removed takeover:in-progress A takeover lead is working on this PR labels Nov 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 15, 2026
@github-actions github-actions Bot removed the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR conflicts with main. Rebase it or merge main into it. If it still conflicts after 7 days with no activity, it will be closed automatically.

See the conflict window.

@github-actions github-actions Bot added the needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. label Nov 19, 2026
@shivamhwp

Copy link
Copy Markdown
Collaborator

Thanks for the PR, @sulcer! #38916 already fixes this on main, so we're closing this PR. If you think the problem still exists, let us know and we can reopen it.

@shivamhwp shivamhwp closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Conflicts with its base branch. Closes after 7 days with no activity. size:S 10-29 changed lines (additions + deletions). takeover:blocked Takeover blocked; reason in the PR body vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Servers panel lists the Claude CLI's own port when a mod registers a tool

3 participants