Route metadata CLI through daemon#320
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (9)
📝 WalkthroughWalkthroughAdds a new daemon route ChangesMetadata command routing
Estimated code review effort: 4 (Complex) | ~55 minutes Sequence Diagram(s)sequenceDiagram
participant CLI as aimux CLI (main.ts / shim)
participant Daemon as Daemon (metadataTextRoute)
participant ProjectService as Project Service
participant Metadata as metadata-server.ts
CLI->>Daemon: POST /core/metadata-text (project, args)
Daemon->>Daemon: parseRuntimeMetadataCliArgs(args)
alt command = endpoint
Daemon->>Daemon: ensure project running, load endpoint
Daemon-->>CLI: 200 text (http://host:port)
else other command
Daemon->>ProjectService: postProjectServiceJson(routePath, body)
ProjectService->>Metadata: update runtime.setContext / setStatus / etc.
Metadata-->>ProjectService: merged metadata (pr merge logic)
ProjectService-->>Daemon: ok / error
Daemon-->>CLI: 200 empty / 400 / 503
end
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Independent review findings resolved in c63d6a8:\n\n- Added /core/metadata-text to LOCAL_CLI_TEXT_ROUTES and covered relay/browser-origin denial for metadata text requests.\n- Bypassed the installed shim metadata fast path for -h/--help so Commander help still renders via the Node launcher instead of daemon parser errors. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/metadata-server.ts (1)
3020-3041: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winMissing optional chaining on
body.context.prregresses handling of a missing/nullcontext.
current.context?.pris optional-chained, butbody.context.pr(both places) is not. Ifbody.contextis everundefined/null— plausible for any direct (non-CLI) caller of this pre-existing public endpoint, since the request type isn't runtime-validated — this throws instead of degrading gracefully like the old spread-based merge did.🐛 Proposed fix
updateSessionMetadata(body.session, (current) => { const pr = - current.context?.pr || body.context.pr + current.context?.pr || body.context?.pr ? { ...(current.context?.pr ?? {}), - ...(body.context.pr ?? {}), + ...(body.context?.pr ?? {}), } : undefined; return { ...current, context: { ...(current.context ?? {}), - ...body.context, + ...(body.context ?? {}), ...(pr ? { pr } : {}), }, }; });🤖 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.ts` around lines 3020 - 3041, The runtime.setContext handler in metadata-server should tolerate a missing or null body.context instead of dereferencing it directly. In the updateSessionMetadata merge logic, update the current.context?.pr/body.context.pr handling so both accesses are optional-chained and the PR merge only runs when body.context.pr exists, preserving the previous graceful behavior for direct callers. Use the setContext request parsing and the updateSessionMetadata callback as the main spots to adjust.
🧹 Nitpick comments (1)
scripts/installed-aimux-shim.sh (1)
198-232: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueVerified:
-X POST --getcombo works as intended.Confirmed via curl semantics that explicit
-X POSToverrides the wire request-line method while--getstill moves--data-urlencodepairs into the query string — this is a known technique, not a bug. The status/cleanup handling mirrorsaimux_post_text_routeexactly.Note the near-duplication with
aimux_post_text_route(lines 129-161): the only real difference is the--get "$@"on the curl invocation. Consider factoring the shared status-handling/cleanup logic into a common helper to avoid drift between the two routes as they evolve.
[optional_refactor_low_effort_low_reward_note]🤖 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 `@scripts/installed-aimux-shim.sh` around lines 198 - 232, The status/cleanup logic in aimux_post_get_query_text_route is duplicated from aimux_post_text_route, so factor the shared curl result handling, body_file cleanup, and trap reset into a common helper and have both route functions call it, keeping only the request-specific curl options in each function.
🤖 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/daemon.ts`:
- Around line 2412-2415: `metadataTextRoute` is currently reachable without the
same CLI-only protection as the other text routes. Update the `Daemon` request
handling around `CORE_API_ROUTES.metadataText` so it is gated by
`LOCAL_CLI_TEXT_ROUTES` or the same loopback/Origin rejection used for the other
CLI text endpoints, preventing remote callers from reaching this metadata
mutation path.
In `@src/main.ts`:
- Around line 3431-3441: The direct CLI handler for metadataCmd.set-progress is
missing the same numeric validation used by parseRuntimeMetadataCliArgs, so
invalid current/total values can become NaN and be persisted as null. Update the
action callback for set-progress to validate Number(current) and Number(total)
with Number.isFinite before calling postRuntimeMetadata, and fail fast with a
clear error if either value is not finite. Keep the fix localized to the
metadataCmd command path so it matches the shim parser behavior.
---
Outside diff comments:
In `@src/metadata-server.ts`:
- Around line 3020-3041: The runtime.setContext handler in metadata-server
should tolerate a missing or null body.context instead of dereferencing it
directly. In the updateSessionMetadata merge logic, update the
current.context?.pr/body.context.pr handling so both accesses are
optional-chained and the PR merge only runs when body.context.pr exists,
preserving the previous graceful behavior for direct callers. Use the setContext
request parsing and the updateSessionMetadata callback as the main spots to
adjust.
---
Nitpick comments:
In `@scripts/installed-aimux-shim.sh`:
- Around line 198-232: The status/cleanup logic in
aimux_post_get_query_text_route is duplicated from aimux_post_text_route, so
factor the shared curl result handling, body_file cleanup, and trap reset into a
common helper and have both route functions call it, keeping only the
request-specific curl options in each function.
🪄 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: 2b835d34-1214-4378-b694-2fb0679fab4b
📒 Files selected for processing (11)
docs/command-ownership-inventory.mdscripts/installed-aimux-shim.shsrc/core-command-contract.tssrc/core-command-ownership.test.tssrc/daemon.test.tssrc/daemon.tssrc/installed-shim.test.tssrc/main.tssrc/metadata-cli-routing.test.tssrc/metadata-cli-routing.tssrc/metadata-server.ts
|
Independent review round 2 resolved in b3ffa73: metadata help subcommands (for example |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
Review fixes landed in e171c68:
@coderabbitai review |
|
✅ Action performedReview finished.
|
Summary
aimux metadata ...commands through daemon/core/metadata-textinstead of spawning one-shot Node on healthy installsVerification
sh -n scripts/installed-aimux-shim.shyarn typecheckyarn lintyarn vitest run src/metadata-cli-routing.test.ts src/daemon.test.ts src/installed-shim.test.ts src/core-command-ownership.test.ts src/metadata-server.test.tsyarn vitest runyarn buildSummary by CodeRabbit
New Features
Bug Fixes