Repository navigation
Fix agent command connection handling - #81
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds WebSocket keepalive (ping/pong) with deadlines and separate reader/pinger goroutines, applies write deadlines to outbound sends, exposes a Postgres pool error reporter wired to the control-plane logger, adds CI/test scripts and Playwright smoke tests, includes schema and auth unit tests, and refreshes project status metadata. ChangesWebSocket Keepalive Enhancement
Postgres Pool Error Reporting
Project Status Metadata Refresh
CI and Package Scripts
Playwright and Smoke Tests
Schema and Control-Plane Unit Tests
sequenceDiagram
participant Client
participant Dialer
participant Conn
participant Reader
participant Pinger
Client->>Dialer: dial connection
Dialer-->>Conn: connection established
Client->>Conn: set read deadline and pong handler
Client->>Reader: start reader(conn)
Client->>Pinger: start pinger(conn)
loop every pingPeriod
Pinger->>Conn: set write deadline and send ping
Conn-->>Pinger: pong or error
end
Reader->>Conn: read messages and reset read deadline
alt read error or ping/write fail
Reader->>Client: trigger reconnect
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
services/control-plane/src/db/index.ts (1)
33-47: 💤 Low valuePool error wiring looks correct; consider isolating reporter throws.
The registration order (listener at module load, setter to swap implementation later) is sound, and the fallback to
console.errorcovers the startup window beforesetPoolErrorReporteris invoked.One small hardening: if a future reporter throws synchronously, the throw escapes the
pool.on('error')listener as an uncaught exception. Wrapping the call defends against that without changing current behavior.♻️ Optional defensive wrap
pool.on('error', (error) => { if (poolErrorReporter) { - poolErrorReporter(error); - return; + try { + poolErrorReporter(error); + } catch (reporterError) { + console.error('[db] Pool error reporter threw:', reporterError, 'original:', error); + } + return; } console.error('[db] Unexpected idle Postgres client error:', error); });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/control-plane/src/db/index.ts` around lines 33 - 47, The pool 'error' handler currently calls poolErrorReporter(error) directly which can let exceptions thrown by the reporter escape; wrap the reporter invocation inside a try/catch in the pool.on('error') callback (still call console.error fallback on errors) so any synchronous throw from poolErrorReporter is caught and logged instead of crashing the process; update the handler around the pool.on('error') listener and keep setPoolErrorReporter and poolErrorReporter semantics unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@services/control-plane/src/db/index.ts`:
- Around line 33-47: The pool 'error' handler currently calls
poolErrorReporter(error) directly which can let exceptions thrown by the
reporter escape; wrap the reporter invocation inside a try/catch in the
pool.on('error') callback (still call console.error fallback on errors) so any
synchronous throw from poolErrorReporter is caught and logged instead of
crashing the process; update the handler around the pool.on('error') listener
and keep setPoolErrorReporter and poolErrorReporter semantics unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 77bb7012-de91-4705-bee0-167ea27a6544
📒 Files selected for processing (4)
agents/agentd/internal/ws/client.goproject_status.mdservices/control-plane/src/db/index.tsservices/control-plane/src/index.ts
There was a problem hiding this comment.
🧹 Nitpick comments (1)
services/control-plane/package.json (1)
13-13: ⚡ Quick winDeclare
vitestin package devDependencies to avoid implicit workspace coupling.
"test": "vitest run"currently depends on root-level tooling resolution. Addvitestto@agent-command/control-planedevDependencies so the package remains self-contained and CI behavior is stable across pnpm/turbo modes.Proposed diff
"devDependencies": { "`@types/bcryptjs`": "^3.0.0", "`@types/node`": "^20.10.0", "`@types/pg`": "^8.11.0", "tsx": "^4.19.0", - "typescript": "^5.3.0" + "typescript": "^5.3.0", + "vitest": "^4.1.6" }The same issue exists in
packages/ac-schema/package.json—add"vitest": "^4.1.6"there as well.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@services/control-plane/package.json` at line 13, The package's test script ("test": "vitest run") relies on a workspace root tool; add vitest to the package devDependencies so the package is self-contained: in services/control-plane/package.json add a devDependency entry "vitest": "^4.1.6" and do the same in packages/ac-schema/package.json (ensure version "^4.1.6"), then run a local install/check to verify the test script resolves vitest from the package's own devDependencies.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@services/control-plane/package.json`:
- Line 13: The package's test script ("test": "vitest run") relies on a
workspace root tool; add vitest to the package devDependencies so the package is
self-contained: in services/control-plane/package.json add a devDependency entry
"vitest": "^4.1.6" and do the same in packages/ac-schema/package.json (ensure
version "^4.1.6"), then run a local install/check to verify the test script
resolves vitest from the package's own devDependencies.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 23fc6da8-975f-4df8-85bf-dae844171d1e
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (8)
.github/workflows/ci.ymlpackage.jsonpackages/ac-schema/package.jsonpackages/ac-schema/tests/core-workflows.test.tsplaywright.dashboard.config.tsservices/control-plane/package.jsonservices/control-plane/tests/auth.test.tstests/smoke/dashboard.spec.ts
✅ Files skipped from review due to trivial changes (1)
- packages/ac-schema/package.json
Summary\n- add websocket ping/pong deadlines for agentd\n- report idle Postgres pool errors through the control-plane logger\n- include project status update already present locally\n\n## Verification\n- go test ./... (agents/agentd)\n- pnpm --filter @agent-command/control-plane typecheck\n- pnpm --filter @agent-command/control-plane build
Summary by CodeRabbit
New Features
Bug Fixes
Tests & CI
Documentation