Skip to content

fix(server): agent browsers' DevTools ports no longer show as servers - #38060

Closed
kacigaya wants to merge 1 commit into
pingdotgg:mainfrom
kacigaya:fix/preview-ignore-devtools-port
Closed

kacigaya wants to merge 1 commit into
pingdotgg:mainfrom
kacigaya:fix/preview-ignore-devtools-port

Conversation

@kacigaya

@kacigaya kacigaya commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Problem

When an agent's tool launched a browser for automation (for example, a headless Chrome), the thread's Servers list showed that browser's DevTools port, such as localhost:34613, as if it were a dev server. The browser inherits T3CODE_THREAD_ID from the agent's shell, so the port scanner treated its --remote-debugging-port listener as an agent server. The DevTools port does not serve a page, so it should not appear in the list.

Change

In readAgentThreads, a process started with --remote-debugging-port= is no longer counted as an agent's process.

  • Linux: the scanner reads /proc/<pid>/cmdline only for pids that already have an agent thread, so untagged listeners cost nothing extra.
  • macOS: the scanner checks the same argument in the ps -E line it already reads.

The agent's real servers still appear in the list.

Scope

This is a small fix for an obvious bug, so I did not open an issue first: an agent's automation browser showed up as a preview server.

Verification

  • vp test run src/preview/PortScanner.test.ts: 33/33 pass. The new test fails without the fix.
  • vp lint, vp fmt --check, and the server typecheck pass.
  • Live check with vp run dev and a Replay thread. Two listeners, both started with that thread's T3CODE_THREAD_ID:
    • a normal HTTP server on :5173
    • headless Chrome with --remote-debugging-port=9333
Before After
Before: Servers lists localhost:5173 and localhost:9333 (chrome) After: Chrome DevTools answers on localhost:9333, and Servers lists only localhost:5173
Full window Full window · DevTools tab

Before, the list showed both ports. After, the agent's Chrome is still running: http://localhost:9333/json/version returns HeadlessChrome/156. At the same moment, the list shows only localhost:5173. I tested on Linux only. Unit tests cover the macOS ps -E path, but I did not run it on a Mac.

Made with Claude Opus 5.5 in Claude Code, running in T3 Code.

A browser an agent tool launches inherits T3CODE_THREAD_ID, so its
--remote-debugging-port listener was listed as the thread's server.
Skip processes started with that flag on Linux and macOS.
@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 17, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 57a8b51

Macroscope's review found this PR approvable — Agent browser DevTools listeners are excluded from agent-owned preview discovery on macOS and Linux. The change is limited to discovery attribution, preserves terminal ownership, and does not modify running processes or stored data.

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

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

PortScanner now checks process command lines for the DevTools remote-debugging argument before assigning agent thread ownership. Linux and macOS tests cover filtering an agent-launched Chrome process from discovered servers.

Changes: Browser process attribution

Layer / File(s) Summary
Detect and exclude browser processes
apps/server/src/preview/PortScanner.ts, apps/server/src/preview/PortScanner.test.ts
PortScanner checks for --remote-debugging-port= when determining agent thread ownership on macOS and Linux. Tests verify that the agent-owned Node server is returned and the Chrome listener is omitted.

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

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#22542: Added thread attribution for listening servers, which this change adjusts for agent-launched browser processes.

Suggested reviewers: t3dotgg, juliusmarminge

Merge Risk: Minimal · up to 57a8b

Agent-launched browser DevTools ports are now hidden from the Servers list. A rare macOS case, where an environment variable contains the DevTools flag, could hide a regular server, but the impact is small and nothing blocks merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: agent-launched browsers' DevTools ports no longer appear as servers. It follows the conventional commit form and matches the raw summary and PR objectives, which descr…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description covers the problem, the change, scope, and verification in enough detail to review. It explains that agent-launched browsers inherit T3CODE_THREAD_ID, so their --remote-debugging-port …
Full details: Title check

Explanation

The title names the main change: agent-launched browsers' DevTools ports no longer appear as servers. It follows the conventional commit form and matches the raw summary and PR objectives, which describe excluding processes with --remote-debugging-port= from agent-owned server detection.

Full details: Description check

Explanation

The description covers the problem, the change, scope, and verification in enough detail to review. It explains that agent-launched browsers inherit T3CODE_THREAD_ID, so their --remote-debugging-port listeners were shown as agent servers. It describes the Linux /proc/<pid>/cmdline check and the macOS ps -E check. Scope explains why no issue was opened. Verification lists the focused test run (33/33, new test fails without the fix), lint and typecheck results, and a live Linux check with before/after screenshots. It also states what was not checked: macOS was not run on a Mac. The author also names the model and harness used, as the template asks. The template's Scope section asks for a linked issue or a justification for none. The author gave a justification, which meets the template. The only gap is that the screenshot evidence is hosted on an external gist. That is acceptable under the template.

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 215bd59 and 57a8b51.

Files selected for processing: 2

  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant