Skip to content

feat(ports): name the dev server behind each workspace port - #11258

Open
Docker-Hunterpedia wants to merge 3 commits into
stablyai:mainfrom
Docker-Hunterpedia:feat/dev-server-port-labels
Open

Docker-Hunterpedia wants to merge 3 commits into
stablyai:mainfrom
Docker-Hunterpedia:feat/dev-server-port-labels

Conversation

@Docker-Hunterpedia

@Docker-Hunterpedia Docker-Hunterpedia commented Jul 29, 2026 •

Copy link
Copy Markdown

Summary

The ports UI showed the raw OS process name, so every JS dev server rendered as node:

:5173  node          →   :5173  Vite
:3000  node          →   :3000  Next.js
:6006  node          →   :6006  Storybook

You could see that something was listening and where, but not what. This names it.

The scanner already collected each listener's command line to attribute it to a worktree (local-workspace-port-scanner.ts), then threw it away at enrichPort. This classifies it instead and carries a bounded label on the port.

Unrecognized processes are unchanged — they keep showing the process name exactly as today. Where a label does replace it, the raw process name moves to the tooltip so it stays available for debugging.

Recognized: Vite, electron-vite, Next.js, Nuxt, Astro, Remix, SvelteKit, Gatsby, Docusaurus, Angular, CRA, Storybook, Expo, Metro, webpack, Parcel, Rails, Django, Uvicorn, Gunicorn, Flask, Laravel, Phoenix, Air, Hugo, Jekyll, json-server, http-server — plus a pnpm dev style fallback when the framework isn't visible in argv.

Updated display sites: Ports panel (right sidebar), status-bar popover, worktree card, port details dialog, and the Cmd+J palette.

Screenshots

Captured from the running dev build (pnpm dev) against real listening processes — no mocked state.

Ports popover showing dev server labels

The same frame shows both halves of the change:

  • :5173 → electron-vite and :5180 → Vite are the labels. Before this PR both read node, because that is their OS process name.
  • :6769, :9453, :55278 → Electron are the untouched fallback. Unrecognized processes still show their process name exactly as they do today.

Worktree card hover, showing the same labels in the sidebar surface:

Worktree card live ports

Images live on a separate branch of the fork, so no binaries land in this PR's diff.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test (ports/palette scope — see below)
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

pnpm lint passes end to end, including the repo's custom gates: reliability-gate manifest (52 gates), max-lines ratchet — "no new bypasses", bundled skill guides, skill-bundle manifest, localization catalog (parity across all 5 locales), and localization coverage. pnpm typecheck passes across all three projects. pnpm run check:code-quality:changed and check:react-doctor:changed both report 0 new findings across 14 changed files. oxfmt --check is clean on every file this branch touches.

pnpm build was not run — it packages the app and is not needed to validate this change.

Tests: 156 passing across the ports and palette scope (src/main/ports/, the four workspace-port-* lib modules, worktree-palette-search, and components/ports/). The full suite was not run locally; CI shards it.

46 test cases were added across 3 files:

  • dev-server-signature.test.ts — command lines shaped the way each platform actually reports them: Linux /proc/<pid>/cmdline (NUL-joined), macOS ps -o command=, Windows Win32_Process.CommandLine (quoted, backslashes). Includes the negative cases that matter: a bare node server.js stays unlabelled, and a directory named vite-playground is not mistaken for Vite. Two cases are real command lines captured verbatim from live processes.
  • workspace-port-process-label.test.ts — label/fallback precedence.
  • workspace-port-scan-client.test.ts — rejection of malformed devServer payloads.
  • Extended local-workspace-port-scanner.test.ts with end-to-end wiring.

End-to-end verification in the running app. Beyond unit tests, I queried the live scan through the app's own IPC (window.api.workspacePorts.scan) in the dev build:

:5173  → { id: 'electron-vite', label: 'electron-vite' }   owner: orca
:5180  → { id: 'vite',          label: 'Vite' }            owner: orca
:6769  → no devServer (Electron)
:9453  → no devServer (Electron)
:55278 → no devServer (Electron)
external ports → no devServer

AI Review Report

I audited my own first pass rather than assuming it was complete. It was not — three real gaps surfaced, all fixed in this PR:

  1. Missing validation at the remote trust boundary. workspace-port-scan-client.ts validates every field of an incoming scan (pid, processName, advertisedUrl) because remote scan results arrive from another host over RPC. The new field crossed that same boundary unvalidated, and its label renders straight into a row — a version-mismatched or hostile runtime sending devServer: { label: {…} } would have thrown inside React. Added isOptionalDevServerIdentity plus rejection tests.
  2. A converter silently dropping the field. workspacePortAsExternal rebuilds the port object field-by-field; ports from other repos pass through it to render as "External". The same server would have read Vite in its own repo and node from another — the exact inconsistency this PR exists to remove.
  3. A fourth display site. worktree-palette-search.ts builds its own "5173 · node" label for Cmd+J. Now shows the dev server. Search semantics deliberately untouched — port matching there is numeric-only, and making names searchable would be a behavior change beyond this PR.

Checked and found genuinely clean: preload and RPC are pass-through (result: unknown, no schema strips the field); no RUNTIME_PROTOCOL_VERSION bump needed, per the contract at shared/protocol-version.ts:12-15; the max-lines ratchet tracks only files with disables and none were added; the reliability-gate manifest is unaffected; mobile, CLI, and e2e have no port display surface.

Cross-platform was explicitly reviewed. The classifier is fed by all three platform paths and is tested against each one's real command-line format, including Windows quoted paths with spaces ("C:\Program Files\nodejs\node.exe"), backslash separators, and .exe/.cmd casing. No keyboard shortcuts, shortcut labels, or filesystem path construction are touched — matching splits on both separators rather than using path, since these are foreign-platform strings, not local paths. No Electron platform-specific APIs involved.

Security Audit

Command lines are not exposed to the renderer — deliberately. argv routinely carries secrets (--api-key=…, --token=…). Classification runs in the main process and only a bounded label crosses the IPC/RPC boundary, so raw command lines never reach renderer, web, or mobile clients. The package-manager fallback reconstructs its label from two allowlists (manager, script name), so even that path cannot emit attacker-influenced text.

Untrusted input is validated. Scan results from a remote runtime are validated before rendering — see gap 1 above. Field-shape validation only, consistent with the sibling checks in that file; no length bounds, matching existing behavior for processName.

No new command execution, no new IPC surface, no new dependencies, no auth or filesystem paths touched. The classifier is a pure function over strings the scanner already had in memory. Matching is basename-scoped, which is a correctness safeguard as well as a security one — the worktree path is present in argv for attribution, so naive substring matching would false-positive on any project whose directory happens to be named after a framework.

No follow-up security work identified.

Notes

  • SSH is out of scope and unchanged. SSH ports use a separate type (EnrichedDetectedPort, shared/ssh-types.ts) scanned by the relay, which carries processName but no command line. Those rows degrade to exactly today's behavior. Extending coverage means adding argv to the relay's scan payload — a wire-format change to a component that deploys to remote hosts independently, so it belongs in its own PR.
  • Folder workspaces are unaffected: attribution happens upstream and already handles them; classification is orthogonal.
  • No new localization keys. Dev server names are proper nouns and are deliberately not translated. The details dialog reuses the existing Process row rather than adding a Dev server row, specifically to avoid inventing translations across all five locales.
  • CI has not run the gates on this PR. Fork PRs need a maintainer to approve workflows, so only track-community-pr has executed so far. The lint/typecheck/test results above are from local runs; please approve the workflow run to confirm them independently.
  • electron-vite was added to the signature table only after running the feature against the live app and seeing this repo's own dev server fall through to node — a good argument for driving the real UI rather than trusting fixtures.

🤖 Generated with Claude Code

https://claude.ai/code/session_017d6N1M478gPZCZES38tCxG

Docker-Hunterpedia and others added 2 commits July 29, 2026 04:37
The ports UI showed the raw OS process name, so every JS dev server
rendered as `node` — :5173 node, :3000 node, :4200 node — and you could
not tell Vite from Next.js from Storybook.

The scanner already collected each listener's command line to attribute
it to a worktree, then discarded it. Classify it instead and carry a
bounded label on the port.

Classification runs in main rather than the renderer because argv
routinely carries secrets (`--api-key=…`); only the label crosses the
IPC/RPC boundary, so raw command lines never reach renderer, web, or
mobile clients. Matching is scoped to argument basenames so a worktree
at ~/code/vite-playground is not mistaken for Vite — the worktree path
is in argv for attribution, so substring matching would false-positive.

Unrecognized processes keep showing the process name exactly as before,
and the raw name moves to the tooltip wherever a label replaces it.

SSH ports are unchanged: they use a separate type scanned by the relay
that carries no command line, so they degrade to today's behavior.

No RUNTIME_PROTOCOL_VERSION bump — adding an optional field is excluded
per the contract in shared/protocol-version.ts.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017d6N1M478gPZCZES38tCxG
Running the feature against the live app surfaced electron-vite — the dev
server this repo itself uses — falling through to `node`. Added its
signature and covered both it and the real macOS vite command line with
cases captured verbatim from `ps -o command=`.

Formatting is oxfmt over the files this branch touches.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017d6N1M478gPZCZES38tCxG
@Docker-Hunterpedia
Docker-Hunterpedia marked this pull request as ready for review July 29, 2026 02:31
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 476453d6-c055-4978-83c2-2ffdb1a6c4a5

📥 Commits

Reviewing files that changed from the base of the PR and between 41f0c2a and 5bf06b3.

📒 Files selected for processing (3)
  • src/main/ports/dev-server-signature.test.ts
  • src/main/ports/dev-server-signature.ts
  • src/renderer/src/lib/workspace-port-process-label.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/lib/workspace-port-process-label.ts

📝 Walkthrough

Walkthrough

Adds framework and package-script detection for listening development-server processes, attaches recognized identities to scanned workspace ports, and validates the new metadata in scan responses. Introduces shared process-label and tooltip helpers, then applies them across port panels, worktree cards, status popovers, and palette search. Tests cover classifier signatures, scan enrichment, response validation, label formatting, and renderer fallback behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: labeling workspace ports by dev server.
Description check ✅ Passed The description follows the required template and includes summary, screenshots, testing, AI review, security audit, and notes.
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.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/renderer/src/lib/workspace-port-process-label.ts (1)

3-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Trim redundant type documentation.

Keep one short type-level description; the field names and types convey the rest. As per coding guidelines, comments must be concise, limited to non-obvious information, and preferably one line.

Proposed cleanup
-/**
- * What a port row shows for the process behind the listener.
- *
- * A recognized dev server takes the primary slot, because "Vite" answers the
- * question a row of `node` never could. The raw process name is not discarded:
- * it moves to `detail` so it stays reachable for debugging.
- */
+/** Display label and optional raw process name for a workspace port. */
 export type WorkspacePortProcessLabel = {
-  /** Primary text: the dev server when recognized, otherwise the process. */
   label: string
-  /** Raw process name, set only when a dev server label displaced it. */
   detail?: string
 }

Source: Coding guidelines


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 59a202c6-d786-47ad-9572-9534faaac288

📥 Commits

Reviewing files that changed from the base of the PR and between c8dba6d and 41f0c2a.

📒 Files selected for processing (14)
  • src/main/ports/dev-server-signature.test.ts
  • src/main/ports/dev-server-signature.ts
  • src/main/ports/local-workspace-port-scanner.test.ts
  • src/main/ports/local-workspace-port-scanner.ts
  • src/renderer/src/components/right-sidebar/PortsPanel.tsx
  • src/renderer/src/components/sidebar/WorktreeCardPorts.tsx
  • src/renderer/src/components/status-bar/ports-status-popover-rows.tsx
  • src/renderer/src/lib/workspace-port-process-label.test.ts
  • src/renderer/src/lib/workspace-port-process-label.ts
  • src/renderer/src/lib/workspace-port-scan-client.test.ts
  • src/renderer/src/lib/workspace-port-scan-client.ts
  • src/renderer/src/lib/worktree-palette-search.test.ts
  • src/renderer/src/lib/worktree-palette-search.ts
  • src/shared/workspace-ports.ts

Comment thread src/main/ports/dev-server-signature.ts Resolved
Comment thread src/main/ports/dev-server-signature.ts Resolved
@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR replaces the raw OS process name shown in every port display surface with a friendly dev server label (e.g. node → Vite, Next.js, Storybook). Classification runs entirely in the main process so raw argv — which can carry secrets — never crosses the IPC/RPC boundary; only a bounded { id, label } pair is transmitted.

  • New classifier (dev-server-signature.ts): quote-aware, basename-scoped tokenizer matched against a 28-entry signature table plus a package-manager-script fallback; identifyPackageScript correctly uses only command-line tokens (not processName) to prevent cross-field false positives.
  • Trust-boundary validation (workspace-port-scan-client.ts): isOptionalDevServerIdentity guards the new field on incoming remote scan results, consistent with all existing field validators in that file.
  • Five display sites updated (Ports panel, status-bar popover, worktree card, details dialog, Cmd+J palette) with the raw process name demoted to tooltip detail, and workspacePortAsExternal now carries the field so external listeners receive consistent labels.

Confidence Score: 5/5

Safe to merge — the change is additive, the classifier is a pure function over data the scanner already held, and all display paths degrade gracefully to the prior behavior when no signature matches.

The classifier is well-isolated: it runs in main, only a bounded label crosses IPC, and the trust boundary is validated before any label reaches the renderer. The package-manager fallback is restricted to commandLine tokens so processName cannot contribute spurious matches. The devServer field is correctly carried through workspacePortAsExternal, closing the external-ports inconsistency the PR set out to fix. 46 new tests cover platform-specific command-line formats, negative cases, and remote payload validation. No regressions identified.

Files Needing Attention: No files require special attention.

Important Files Changed

Filename Overview
src/main/ports/dev-server-signature.ts New classifier: tokenizes command lines via basename-scoped, quote-aware splitting and matches against a signature table; package-manager fallback correctly restricted to commandLine tokens only to prevent cross-field false positives.
src/shared/workspace-ports.ts Adds DevServerIdentity type (plain string id, not a union, to survive forward-compat mismatches) and optional devServer field to WorkspacePortBase.
src/renderer/src/lib/workspace-port-scan-client.ts Adds isOptionalDevServerIdentity validation for the new field at the remote-trust boundary; null is correctly rejected.
src/main/ports/local-workspace-port-scanner.ts Wires identifyDevServer into enrichPort; result conditionally spread so the field is absent when unrecognized.
src/renderer/src/lib/workspace-port-process-label.ts New display helper; equality guard correctly suppresses redundant tooltip detail when processName already matches the dev server label.
src/renderer/src/components/right-sidebar/PortsPanel.tsx Uses new label helpers across LocalPortRow and LocalPortDetailsDialog; correctly carries devServer through workspacePortAsExternal.
src/renderer/src/lib/worktree-palette-search.ts Palette search now prefers devServer.label over processName for display; port matching intentionally left numeric-only.
src/renderer/src/components/sidebar/WorktreeCardPorts.tsx Switches WorktreePortRow to new label helpers; both inline label and tooltip updated consistently.
src/renderer/src/components/status-bar/ports-status-popover-rows.tsx PortRow updated consistently with the other display sites.

Sequence Diagram

sequenceDiagram
    participant Scanner as local-workspace-port-scanner
    participant Sig as dev-server-signature
    participant IPC as Electron IPC / RPC
    participant Client as workspace-port-scan-client
    participant Label as workspace-port-process-label
    participant UI as Renderer Components

    Scanner->>Sig: "identifyDevServer({ processName, commandLine })"
    Note over Sig: tokenize argv only for package-script fallback
    Sig-->>Scanner: DevServerIdentity or undefined
    Scanner->>IPC: WorkspacePort with devServer field
    Note over IPC: Raw argv never crosses boundary
    IPC->>Client: raw payload unknown
    Client->>Client: isOptionalDevServerIdentity validation
    Client-->>Label: WorkspacePort validated
    Label->>Label: getWorkspacePortProcessLabel
    Label-->>UI: label and optional detail
    UI-->>UI: formatWorkspacePortProcessTooltip
Loading

Reviews (2): Last reviewed commit: "fix(ports): report Puma as itself and st..." | Re-trigger Greptile

…cess name

Two review findings on the dev-server classifier:

- A bare `puma` token labelled every Rack app "Rails". Sinatra, Hanami, Roda
  and `bundle exec puma` are indistinguishable at that point, so the label is
  now Puma. Rails still wins when `rails server` is visible in argv.
- The package-script fallback searched a token pool merged from argv and the
  process name, so a process named `npm` beside an unrelated `dev.js` read as
  "npm dev". Signature matching still reads both fields, since a rewritten
  title is sometimes the only evidence; the fallback now reads argv alone.

Also trims the label type's doc comment to one line per AGENTS.md.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_017d6N1M478gPZCZES38tCxG

This branch has not been deployed

No deployments
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