fix: attach local overlay config routing#120
Conversation
|
Warning Review limit reached
More reviews will be available in 32 minutes and 21 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 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthrough
ChangesAttach config path forwarding and Code Mode local routing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 |
|
| Filename | Overview |
|---|---|
| packages/core/src/attach/options.ts | Adds configPath and projectConfigPath to AttachServeOptions, resolved from CAPLETS_CONFIG/CAPLETS_PROJECT_CONFIG env vars with correct fallbacks to resolveConfigPath/resolveProjectConfigPath. |
| packages/core/src/attach/server.ts | Threads the new configPath and projectConfigPath fields through to createNativeCapletsService, completing the fix for local overlay config routing. |
| packages/core/src/native/service.ts | Two targeted fixes: execute() now uses serviceHasCaplet for local (correctly handles codeModeCaplets), and serviceHasCaplet now checks sourceCaplet so remote direct tools shadow same-ID local Code Mode handles. |
| packages/core/test/attach-cli.test.ts | Adds two well-scoped tests: one verifying env-var config paths flow through attach options, another verifying --project-root determines the default projectConfigPath. |
| packages/core/test/native-remote.test.ts | Adds two integration tests covering the new routing: local Code Mode handles execute locally, and remote direct tools correctly prevent local Code Mode handles from being routed locally. |
Sequence Diagram
sequenceDiagram
participant CLI as caplets attach (CLI)
participant Opts as resolveAttachServeOptions
participant Server as attachResolvedCaplets
participant Composite as CompositeNativeCapletsService
participant Local as LocalOverlayService
participant Remote as RemoteNativeCapletsService
CLI->>Opts: "env{ CAPLETS_CONFIG, CAPLETS_PROJECT_CONFIG }"
Opts->>Opts: resolveConfigPath(env.CAPLETS_CONFIG)
Opts->>Opts: resolveProjectConfigPath(projectRoot)
Opts-->>Server: "AttachServeOptions{ configPath, projectConfigPath }"
Server->>Composite: "createNativeCapletsService({ configPath, projectConfigPath })"
Composite->>Local: createLocalOverlayService (uses configPath/projectConfigPath)
Composite->>Remote: createRemoteService
Note over Composite: execute(code_mode, code)
Composite->>Composite: executeCodeModeRunNative(this, request)
Composite->>Composite: runCodeMode calls execute(local-code, ...)
Composite->>Local: serviceHasCaplet - codeModeCaplets includes local-code? YES
Composite->>Remote: serviceHasCaplet - has local-code? NO
Composite->>Local: local.execute(local-code, request)
Local-->>Composite: result
Note over Composite: Remote direct tool shadows local Code Mode
Composite->>Remote: "serviceHasCaplet(shared) - sourceCaplet === shared? YES"
Composite->>Remote: remote.execute(shared, request)
Reviews (2): Last reviewed commit: "fix(core): tighten attach overlay routin..." | Re-trigger Greptile
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e8eccaf06e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary
CAPLETS_CONFIGandCAPLETS_PROJECT_CONFIGpaths when runningcaplets attach.@caplets/coreandcaplets.Root Cause
caplets attachresolved the remote target correctly, but the attach serve path did not forward the local overlay config paths intocreateNativeCapletsService. That made attached clients load local overlay Caplets from the default user config root, which could expose unrelated handles such asast-grep,context7,linear,lsp,osv, orsourcegraph.Validation
PNPM_HOME=/opt/homebrew/bin pnpm --filter @caplets/core test -- test/attach-cli.test.tsPNPM_HOME=/opt/homebrew/bin pnpm --filter @caplets/core test -- test/native-remote.test.tsPNPM_HOME=/opt/homebrew/bin pnpm format:checkPNPM_HOME=/opt/homebrew/bin pnpm typecheckpnpm verifycompleted successfully:format:check,lint,code-mode:check-api,typecheck,schema:check,test,benchmark:check, andbuild.Summary by CodeRabbit
Bug Fixes
New Features
caplets attachnow preserves the caller's configuration paths for proper local overlay handling with intended configurations.