Note
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
Use the checkboxes below for quick actions:
- ▶️ Resume reviews
- 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds a cross-platform subprocess inspector and web-port probing to TerminalManager, surfaces per-terminal running port lists in activity events, and propagates those fields through contracts, server modules, web state, persistence, UI, and tests.
Changes
| Cohort / File(s) | Summary |
|---|---|
Server: TerminalManager core apps/server/src/terminalManager.ts, apps/server/src/terminalManager.test.ts | Replaces boolean subprocessChecker with subprocessInspector returning { hasRunningSubprocess, runningPorts }. Emits activity events with runningPorts, integrates webPortInspector with TTL caching/in-flight dedupe, updates session state and tests (including ignoring HTTP 404 probes). |
Server: subprocess inspection module apps/server/src/terminalProcessInspector/index.ts, apps/server/src/terminalProcessInspector/types.ts, apps/server/src/terminalProcessInspector/utils.ts, apps/server/src/terminalProcessInspector/win32.ts, apps/server/src/terminalProcessInspector/posix.ts | New module implementing default inspectors: collect process families/children, detect listening ports (lsof/ss on POSIX, PowerShell on Win), normalize ports, compare lists, and provide a shim from old checker-to-inspector. Exports types/utilities. |
Server: web-port probing apps/server/src/webPortInspector.ts | New HTTP probe to heuristically detect web servers on localhost (probes 127.0.0.1 and ::1), with timeouts, max body limits, detection heuristics, and exported DEFAULT_WEB_PORT_PROBE_TTL_MS. |
Web: state, normalization, reducers, tests apps/web/src/types.ts, apps/web/src/store.ts, apps/web/src/store.test.ts, apps/web/src/worktreeCleanup.test.ts | Adds runningTerminalPorts: Record<string, number[]> to Thread and runningPorts: number[] to terminal activity events. Adds normalization utilities, integrates per-terminal port set/clear logic in reducer, and updates tests to validate port lifecycle. |
Web: persistence & initialization apps/web/src/persistenceSchema.ts, apps/web/src/persistenceSchema.test.ts, apps/web/src/App.tsx | Hydrates/initializes runningTerminalPorts as {} for persisted/new threads; test fixtures and initial thread payload updated. |
Web: UI — Sidebar apps/web/src/components/Sidebar.tsx | Aggregates per-terminal ports into deduplicated/sorted list, exposes primaryWebPort, updates TerminalStatusIndicator.label to string, renders clickable GlobeIcon for opening primary web port, and adds keyboard handlers. |
Contracts: terminal event schema packages/contracts/src/terminal.ts, packages/contracts/src/terminal.test.ts | Adds runningPorts: number[] to the terminalActivityEventSchema (ints 1–65535, default []); updates tests to include the new field. |
Sequence Diagram
| 1 | sequenceDiagram |
| 2 | participant TM as Server:TerminalManager |
| 3 | participant INS as Inspector (process + web) |
| 4 | participant CONTRACT as Contracts/Validator |
| 5 | participant STORE as Web:Store |
| 6 | participant UI as Sidebar |
| 7 | |
| 8 | TM->>INS: inspectSubprocess(terminalPid) |
| 9 | INS->>INS: collect PIDs (children/family) and check listening ports |
| 10 | INS->>INS: probe HTTP on detected ports (webPortInspector) |
| 11 | INS-->>TM: { hasRunningSubprocess, runningPorts[] } |
| 12 | TM->>CONTRACT: emit TerminalActivityEvent (includes runningPorts) |
| 13 | CONTRACT-->>STORE: validated event |
| 14 | STORE->>STORE: normalizeRunningPorts(runningPorts) and update runningTerminalPorts[terminalId] |
| 15 | STORE-->>UI: state change (thread.runningTerminalPorts) |
| 16 | UI->>UI: compute portsLabel / primaryWebPort and render clickable UI |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 2.94% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main change: tracking terminal listening ports in activity events and thread state. This matches the PR's primary objective of extending activity payloads with running ports and persisting port state. |
| Merge Conflict Detection | ✅ Passed | ✅ No merge conflicts detected when merging into main |
| Description check | ✅ Passed | The PR description comprehensively documents all major changes: cross-platform subprocess/port inspection, activity payload extensions, web-side state persistence, and UI updates. It clearly explains the problem (tracking listening ports) and the solution approach (platform-specific inspectors with caching). However, the description lacks before/after UI screenshots or videos as specified in the template. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
codething/50e6e9da
Comment @coderabbitai help to get the list of available commands and usage tips.