feat(tui): source project and topology from service - #180
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
More reviews will be available in 51 minutes and 49 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughTwo new project-level diagnostic endpoints ( ChangesAsync project observability & topology endpoints
Sequence Diagram(s)sequenceDiagram
rect rgba(70, 130, 180, 0.5)
Note over MultiplexerProject,MetadataServer: Project Observability Refresh
MultiplexerProject->>MetadataServer: getFromProjectService("/project-observability")
MetadataServer->>DesktopState: getState()
DesktopState-->>MetadataServer: sessions/services/worktrees/tasks/notifications
MetadataServer-->>MultiplexerProject: ProjectObservabilityResponse (or error)
alt payload valid
MultiplexerProject->>MultiplexerProject: applyProjectObservability(host, project)
MultiplexerProject-->>Screen: re-render if still on "project" screen
else invalid/error
MultiplexerProject->>MultiplexerProject: emptyProjectObservability → host.projectObservability
end
end
rect rgba(80, 160, 100, 0.5)
Note over MultiplexerTopology,MetadataServer: Topology Refresh
MultiplexerTopology->>MetadataServer: getFromProjectService("/topology")
MetadataServer->>DesktopState: getState()
DesktopState-->>MetadataServer: worktrees/sessions/teammates
MetadataServer-->>MultiplexerTopology: ProjectTopologyResponse (or error)
alt isProjectTopology valid
MultiplexerTopology->>MultiplexerTopology: applyTopology(host, topology)
MultiplexerTopology-->>Screen: re-render if still on "topology" screen
else invalid/error
MultiplexerTopology->>MultiplexerTopology: emptyTopology() → host.topology
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 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)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (3)
src/metadata-server.test.ts (1)
623-656: ⚡ Quick winAdd teammate coverage to the observability summary test.
This case only populates
sessions, so it won’t catch regressions where teammate agents are excluded from summary counts.🤖 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 `@src/metadata-server.test.ts` around lines 623 - 656, The test "serves project observability from desktop state, tasks, and notifications" only populates sessions, services, and worktrees in the mock desktop state returned by the getState() method, which means it won't detect regressions if teammate agents are excluded from summary counts. Add a teammates array to the desktop state object in the getState() method to include sample teammate data, and update the expected unreadNotifications count in the toMatchObject assertion if needed to ensure the test validates that teammate agents are properly included in the observability summary.src/multiplexer/project.test.ts (1)
39-49: ⚡ Quick winAdd one test for malformed nested payloads that still satisfy top-level shape.
Current failure coverage mostly exercises missing
story. Add a case like{ summary: {}, progress: {}, story: [] }and assertrefreshProjectObservabilityreturnsfalseplus empty fallback. That protects contract validation from regressing.🤖 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 `@src/multiplexer/project.test.ts` around lines 39 - 49, Add a new test case alongside the existing test in the test file that validates contract validation for malformed nested payloads. Create a test where the mocked getFromProjectService returns a response with all top-level shape properties present (summary, progress, story) but with malformed or invalid nested content, then assert that refreshProjectObservability still returns false and the projectObservability fallback remains empty. This ensures the contract validation properly handles cases where the top-level structure is correct but inner data is corrupted or invalid.src/multiplexer/topology.test.ts (1)
32-42: ⚡ Quick winAdd a validation-focused negative test for missing
health/ non-numericcounts.Given the
ProjectTopologycontract, include one explicit malformed payload test (with top-level keys present) and assertrefreshTopologyreturnsfalsewith empty fallback. This guards the runtime validator against silent weakening.🤖 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 `@src/multiplexer/topology.test.ts` around lines 32 - 42, Add a new test case in the topology.test.ts file that validates malformed ProjectTopology payloads are properly rejected. Create a test where the getFromProjectService returns a response with a malformed topology object that has missing or invalid fields (such as missing health field or non-numeric counts values) while keeping other top-level keys present. Assert that refreshTopology returns false and that the topology falls back to an empty state with zero counts (worktrees: 0, agents: 0, services: 0). This ensures the runtime validator properly enforces the ProjectTopology contract and prevents silently accepting incomplete or invalid payloads.
🤖 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.
Inline comments:
In `@src/metadata-server.ts`:
- Around line 1365-1373: The buildProjectObservability function is called with
only sessions, services, and worktrees from the state object, but it should also
include the teammates data to ensure agent summary counts (agentsRunning,
agentsWaiting, agentsOffline) are accurate. Add the teammates property to the
object passed to buildProjectObservability by including teammates:
state.teammates ?? [] alongside the existing state.sessions, state.services, and
state.worktrees properties.
In `@src/multiplexer/project.ts`:
- Around line 14-16: The projectIndex clamping logic in the conditional block
starting at line 14 only guards against the upper bound (when projectIndex >=
storyLength) but does not protect against negative values. Add an additional
check to clamp the lower bound by ensuring projectIndex cannot be negative, such
as using Math.max(0, host.projectIndex) or adding a separate condition to
validate that projectIndex is greater than or equal to zero after the existing
bounds checks.
- Around line 18-25: The isProjectObservability type guard function is
performing only shallow type checks that allow invalid objects to pass through.
Harden the validation by checking that the nested objects (summary and progress)
contain the required fields expected by the ProjectObservability contract, and
that the story array contains properly structured elements. Replace the
surface-level type checks with deeper validation that ensures each property
matches the actual ProjectObservability shape, so invalid payloads are rejected
and the refresh can fall back safely.
In `@src/multiplexer/topology.ts`:
- Around line 14-16: The bounds checking for host.topologyIndex in the topology
application logic only validates the upper bound but ignores negative values,
which can result in invalid selection. After the existing check that bounds
topologyIndex to be less than len, add an additional condition to clamp negative
topologyIndex values to 0, ensuring the index is always within the valid range
of [0, len-1]. This should be done before the closing brace on line 16.
- Around line 18-26: The isProjectTopology function is validating the
ProjectTopology type too loosely. It needs to be stricter in its type checking
to prevent malformed payloads from passing through. Currently it only checks
that projectName is a string, counts is an object, and worktrees and rows are
arrays, but it should also validate that the counts object contains the expected
numeric properties and that the required health property exists. Update the
isProjectTopology function to perform deeper validation of the counts object
structure to ensure all required fields have the correct types (for example,
validating that numeric count fields are actually numbers), and add a check for
the health property to match the full ProjectTopology contract.
---
Nitpick comments:
In `@src/metadata-server.test.ts`:
- Around line 623-656: The test "serves project observability from desktop
state, tasks, and notifications" only populates sessions, services, and
worktrees in the mock desktop state returned by the getState() method, which
means it won't detect regressions if teammate agents are excluded from summary
counts. Add a teammates array to the desktop state object in the getState()
method to include sample teammate data, and update the expected
unreadNotifications count in the toMatchObject assertion if needed to ensure the
test validates that teammate agents are properly included in the observability
summary.
In `@src/multiplexer/project.test.ts`:
- Around line 39-49: Add a new test case alongside the existing test in the test
file that validates contract validation for malformed nested payloads. Create a
test where the mocked getFromProjectService returns a response with all
top-level shape properties present (summary, progress, story) but with malformed
or invalid nested content, then assert that refreshProjectObservability still
returns false and the projectObservability fallback remains empty. This ensures
the contract validation properly handles cases where the top-level structure is
correct but inner data is corrupted or invalid.
In `@src/multiplexer/topology.test.ts`:
- Around line 32-42: Add a new test case in the topology.test.ts file that
validates malformed ProjectTopology payloads are properly rejected. Create a
test where the getFromProjectService returns a response with a malformed
topology object that has missing or invalid fields (such as missing health field
or non-numeric counts values) while keeping other top-level keys present. Assert
that refreshTopology returns false and that the topology falls back to an empty
state with zero counts (worktrees: 0, agents: 0, services: 0). This ensures the
runtime validator properly enforces the ProjectTopology contract and prevents
silently accepting incomplete or invalid payloads.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f2fad601-1b05-4f5b-8960-53858e44dbd5
📒 Files selected for processing (7)
app/lib/api.tssrc/metadata-server.test.tssrc/metadata-server.tssrc/multiplexer/project.test.tssrc/multiplexer/project.tssrc/multiplexer/topology.test.tssrc/multiplexer/topology.ts
|
Resolved the CodeRabbit project/topology review items in 164b948: teammate counts, negative index clamps, stricter payload validators, and validation-focused tests. Latest CodeRabbit check is green and the independent review returned no findings. |
Summary
/project-observabilityand/topologyproject-service endpoints.Verification
PATH="$HOME/.nvm/versions/node/v24.16.0/bin:$PATH" yarn typecheckPATH="$HOME/.nvm/versions/node/v24.16.0/bin:$PATH" yarn lintPATH="$HOME/.nvm/versions/node/v24.16.0/bin:$PATH" yarn vitest run src/metadata-server.test.ts src/multiplexer/project.test.ts src/multiplexer/topology.test.ts src/project-observability.test.ts src/project-topology.test.tsPATH="$HOME/.nvm/versions/node/v24.16.0/bin:$PATH" yarn vitest runPATH="$HOME/.nvm/versions/node/v24.16.0/bin:$PATH" yarn buildSummary by CodeRabbit
New Features
Tests