upstream/2026-04-26 PR4: remote ports 大物 (port-scanner 切り出し + v2 サイドバー統合)#438
upstream/2026-04-26 PR4: remote ports 大物 (port-scanner 切り出し + v2 サイドバー統合)#438
Conversation
…et-sh#3676) * feat(ports): extract port scanner to shared package for v2 remote hosts Move port detection and PortManager into @superset/port-scanner so the host-service can surface remote workspace ports over tRPC subscriptions without duplicating scan logic. Desktop and host-service each wire their own kill strategy via a constructor-injected killFn. Also fixes two blockers found during extraction: - PortManager.scanAbort was nulled on stop() and never re-allocated, leaving subsequent scans without an AbortSignal. - The desktop ports router hit SQLite on every enrichment; now cached per workspace and invalidatable. * feat(ports): merge remote host-service ports into the sidebar list usePortsData now polls ports.getAll on every online remote v2 host every 5s (via tanstack useQueries) and merges the results with the local Electron port stream. Each EnrichedPort carries a hostUrl so useKillPort can route kills to the owning host-service instead of always hitting Electron. Polling rather than SSE-subscribing keeps the existing httpBatchLink client intact — the host-service already debounces scans behind hints, so ports.getAll is a cheap in-memory read. * feat(ports): resolve ports.json labels on remote host-services Host-service's ports.getAll now returns EnrichedPort[] by reading each workspace's .superset/ports.json and attaching a per-port label. The lookup is memoized per workspaceId so the 5s renderer poll doesn't retrigger fs+sqlite reads. Parse errors are silent here (unlike desktop's loader, which surfaces them): this endpoint is a best-effort hint feeding a sidebar list, not a config validator. * fix(ports): drop label cache entries when workspaces are deleted Previously the label cache held a workspaceId → labels map for the life of the process. After a workspace was deleted, the next lookup would still return cached labels (or the cached "null" sentinel), both of which are stale. Desktop: split the cache out of the ports router so workspace-delete paths can invalidate without creating a ports ↔ workspaces import cycle, then call it from `deleteWorkspace` and the project-cascade delete. Host-service: call `invalidateLabelCache` from `workspace.delete` and `workspace-cleanup` after the sqlite row is removed. Rollback-on-create paths are intentionally skipped — the workspace never had a cache entry to begin with. * perf(port-scanner): read /proc directly on Linux instead of spawning lsof On Linux we now resolve listening sockets by reading /proc/net/tcp, /proc/net/tcp6, and /proc/<pid>/fd/* in process. This is the same approach VS Code uses for its remote tunnel port detection (see src/vs/workbench/contrib/remoteTunnel). macOS keeps the lsof path; Windows keeps netstat. The switch matters for remote v2 host-services running on Linux: the old lsof fork happened on every scan tick (2.5s periodic + hint-driven bursts) and dominated cost on hosts with many terminal daemons. Two file reads + one directory walk is roughly 10× cheaper and avoids child-process lifecycle (timeouts, aborts, partial stdout). Parsers are pure and exported so we test them on canned /proc lines rather than requiring a real /proc mount in CI. * fix(ports): wire v2 sidebar port list * fix(ports): address review cleanups * Fix v2 port sidebar interactions * Add host port events for v2 sidebar * Patch v2 port cache from host events * Fix port sidebar event and kill contracts * Refactor dashboard port data transforms
…traction - Re-export getProcessCommand/getProcessName from @superset/port-scanner index (used by fork-only browser-automation router and browser-mcp-bridge). - Update browser-automation/index.ts and pane-resolver.ts imports from the removed main/lib/terminal/port-scanner to @superset/port-scanner. - Biome formatter polish on shared/types/ports.ts and browser-automation imports after the rename.
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 25 minutes and 40 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (79)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
PR1〜PR5 (#435 #436 #437 #438 #440) で 13 commits 全件 cherry-pick + 手動 conflict 解消で取り込み済み。 本コミットは git 履歴上 behind=0 とするための ours マージ記録。 取り込み済み 13 commits: - 1f55c62 Fix host service restart adoption (superset-sh#3732) - 0fe65d2 test(desktop): remove host-service-coordinator test (superset-sh#3734) - 3012b5a Add optimistic Electric collection updates (superset-sh#3722) - c272a51 fix(desktop): drop branch row from v2 sidebar workspace item (superset-sh#3733) - c2f3fdc feat(desktop): add fade-edge mask utilities (superset-sh#3735) - 682d07c fix v2 terminal osc links (superset-sh#3736) - 7c0d22b feat(ports): surface remote host-service ports in the sidebar (superset-sh#3676) - 6a3be2d [codex] Stabilize v2 terminal resize (superset-sh#3739) - 8928ac6 [codex] Improve v2 pane header responsiveness (superset-sh#3737) - 5fe3d22 refactor(desktop): tidy v2 terminal session dropdown (superset-sh#3743) - 66c23d6 Fix automation timezone scheduling (superset-sh#3738) - 16e270c [codex] Add terminal session titles (superset-sh#3740) - 583fa5d fix(desktop): refit v2 terminal after font settle (superset-sh#3742)
Summary
upstream (superset-sh/superset) からの 9 commits 取り込みバッチの PR4(最後・最大)。
7c0d22b77(superset-sh#3676) は 78 files / +4234 -1088 の大物で、新規packages/port-scanner/パッケージを切り出し、host-service の v2 リモートポートをサイドバーに統合する。9 件の conflict を fork の v1 PortsList 機能(detected/static 二段表示、isPending loader、navigation)を保持しつつ統合。取り込み内容
7c0d22b77packages/port-scanner/新規パッケージ抽出(PortManager + scanner + procfs + static-ports)。host-service のports.getAllで workspace ごとのports.jsonラベルを解決。renderer のusePortsDataが remote v2 host を 5 秒間隔で polling して merge。EnrichedPort.hostUrlを導入し、kill を hostUrl-based でルーティング。加えて
19af7282cで fork 固有依存(browser-automation / browser-mcp-bridge)を新パッケージへ移行。Fork 側のコンフリクト解決(9 ファイル)
shared/types/ports.tsEnrichedPort拡張(detected,pid,processName,terminalId,detectedAt,address)を保持しつつ、upstream のhostUrl: string | null(local Electron port なら null、remote host-service URL でルーティング)を統合。paneIdをterminalIdにリネーム(upstream の port-scanner はDetectedPort.terminalIdを使うため、もはや paneId と呼ぶ意味がない)。apps/desktop/src/lib/trpc/routers/ports/ports.tsbuildLabelCache/getLabelsForPath(detected + static port を返す 2 段アプローチ) を保持。getAllで各EnrichedPortにterminalId(was paneId) とhostUrl: nullを補完。getLabelsForWorkspace(label-cache.ts) は fork のキャッシュ構造と被るので使わず、invalidatePortLabelCachere-export だけ残す(projects.ts / db-helpers.ts が消費)。packages/host-service/src/trpc/router/workspace/workspace.tscreateSimpleGitWithEnvと upstream のinvalidateLabelCacheを併存。apps/desktop/src/main/lib/host-service-coordinator.tsv2 worktree 関連
TerminalPane.tsx: ターミナル OSC リンク open をopenUrlInV2Workspace({store, target: "current-tab", url})ヘルパー経由に統一(upstream 方針)。openUrlInV2Workspace.ts: fork のBrowserPaneData.modeが必須なのでdata: { url, mode: "generic" } satisfies BrowserPaneDataで補完(FORK NOTE)。v2-workspace/$workspaceId/page.tsx: fork のuseCollections/rightSidebarOpenViewWidth/setShowPresetsBar系と upstream のuseConsumeOpenUrlRequestを両方併記。v1 PortsList 関連
useKillPort.ts: paneId → terminalId にリネーム +workspaceIdを kill mutation に追加(新スキーマ{workspaceId, terminalId, port}対応)。upstream のusePortKillActionsヘルパーは v2 用なので使わず、v1 のインラインtoast.error実装を保持(FORK NOTE)。MergedPortBadge.tsx(4 ブロック):isDetected分岐(fork 仕様: detected = primary 色、!detected = muted 色 + "Not detected" 表示、static label 列挙用)を保持。isPendingベースLuLoaderCirclespinning loader を採用。port.terminalIdbaseline でcanJumpToTerminal判定。WorkspacePortGroup.tsx:handleCloseAllをif (isPending) return; void killPorts(detectedPorts)に統合(fork の "detected ports のみ kill" + upstream の pending ガード)。19af7282c統合 fixpackages/port-scanner/src/index.ts:getProcessCommand,getProcessNameを 追加 re-export(fork 専用browser-automationルーターとbrowser-mcp-bridge/pane-resolverが消費)。apps/desktop/src/lib/trpc/routers/browser-automation/index.ts,apps/desktop/src/main/lib/browser-mcp-bridge/pane-resolver.ts:main/lib/terminal/port-scanner→@superset/port-scannerへの import path 移行。Fork 固有機能ヘルスチェック
DashboardSidebarPortsList(新 v2 用) が追加され、v1 PortsList と併存検証
bun install: ✅ (5757 packages, 46s)bun run typecheck: ✅ (28/28 successful, fork 統合 fix 後)bun run lint: ✅ (Biome: 4368 files, no fixes applied; format fix は cherry-pick 直後に取り込み済み)bun run --filter @superset/desktop compile:app: ✅ (electron-vite build, 3m 48s, exit 0)上流バッチ取り込み完了
このマージで
behind upstream/main = 0に到達(PR1〜PR4 で 9 commits 全件取り込み)。Test plan
LuLoaderCircleが回り、kill が成功すると消えるdetectedPortsのみ kill される (static label は残る)DashboardSidebarPortsListで local + remote ports が混在表示@superset/port-scanner経由で getProcessTree/getProcessName/getProcessCommand を呼べる