Repository navigation
feat(ports): name the dev server behind each workspace port - #11258
Docker-Hunterpedia wants to merge 3 commits into
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds 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)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/lib/workspace-port-process-label.ts (1)
3-15: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueTrim 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
📒 Files selected for processing (14)
src/main/ports/dev-server-signature.test.tssrc/main/ports/dev-server-signature.tssrc/main/ports/local-workspace-port-scanner.test.tssrc/main/ports/local-workspace-port-scanner.tssrc/renderer/src/components/right-sidebar/PortsPanel.tsxsrc/renderer/src/components/sidebar/WorktreeCardPorts.tsxsrc/renderer/src/components/status-bar/ports-status-popover-rows.tsxsrc/renderer/src/lib/workspace-port-process-label.test.tssrc/renderer/src/lib/workspace-port-process-label.tssrc/renderer/src/lib/workspace-port-scan-client.test.tssrc/renderer/src/lib/workspace-port-scan-client.tssrc/renderer/src/lib/worktree-palette-search.test.tssrc/renderer/src/lib/worktree-palette-search.tssrc/shared/workspace-ports.ts
Greptile SummaryThis PR replaces the raw OS process name shown in every port display surface with a friendly dev server label (e.g.
Confidence Score: 5/5Safe 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.
|
| 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
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
Summary
The ports UI showed the raw OS process name, so every JS dev server rendered as
node: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 atenrichPort. 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 devstyle 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.The same frame shows both halves of the change:
:5173→ electron-vite and:5180→ Vite are the labels. Before this PR both readnode, 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:
Images live on a separate branch of the fork, so no binaries land in this PR's diff.
Testing
pnpm lintpnpm typecheckpnpm test(ports/palette scope — see below)pnpm buildpnpm lintpasses 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 typecheckpasses across all three projects.pnpm run check:code-quality:changedandcheck:react-doctor:changedboth report 0 new findings across 14 changed files.oxfmt --checkis clean on every file this branch touches.pnpm buildwas 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 fourworkspace-port-*lib modules,worktree-palette-search, andcomponents/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), macOSps -o command=, WindowsWin32_Process.CommandLine(quoted, backslashes). Includes the negative cases that matter: a barenode server.jsstays unlabelled, and a directory namedvite-playgroundis 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 malformeddevServerpayloads.local-workspace-port-scanner.test.tswith 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: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:
workspace-port-scan-client.tsvalidates 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 itslabelrenders straight into a row — a version-mismatched or hostile runtime sendingdevServer: { label: {…} }would have thrown inside React. AddedisOptionalDevServerIdentityplus rejection tests.workspacePortAsExternalrebuilds the port object field-by-field; ports from other repos pass through it to render as "External". The same server would have readVitein its own repo andnodefrom another — the exact inconsistency this PR exists to remove.worktree-palette-search.tsbuilds 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); noRUNTIME_PROTOCOL_VERSIONbump needed, per the contract atshared/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/.cmdcasing. No keyboard shortcuts, shortcut labels, or filesystem path construction are touched — matching splits on both separators rather than usingpath, 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
EnrichedDetectedPort,shared/ssh-types.ts) scanned by the relay, which carriesprocessNamebut 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.Processrow rather than adding aDev serverrow, specifically to avoid inventing translations across all five locales.track-community-prhas executed so far. The lint/typecheck/test results above are from local runs; please approve the workflow run to confirm them independently.electron-vitewas added to the signature table only after running the feature against the live app and seeing this repo's own dev server fall through tonode— a good argument for driving the real UI rather than trusting fixtures.🤖 Generated with Claude Code
https://claude.ai/code/session_017d6N1M478gPZCZES38tCxG