Build integrations-update from @agent-relay/integration-prompts + suppress idle integrations#380
Conversation
|
Warning Review limit reached
More reviews will be available in 42 minutes and 11 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: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe PR refactors system message snippet generation in ChangesDescriptor-driven integration snippet builder
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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.
Code Review
This pull request refactors the generation of integration system message snippets by delegating the narrative construction to a shared builder from @agent-relay/integration-prompts. It also introduces filtering to omit idle integrations (those without historical downloads, active event subscriptions, or narrow writeback command roots) to prevent noisy or empty messages. The review feedback identifies a bug in buildActiveIntegrationDescriptors where checking subscribedProviders.has(integration.provider) incorrectly marks all integrations of a provider as active if at least one has an active subscription, and provides a code suggestion to check each integration's subscribeAgent status directly.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| const subscriptionSummaries = integrationSubscriptionSummaries(integrations) | ||
| const subscribedProviders = new Set(subscriptionSummaries.map((summary) => summary.provider)) | ||
|
|
||
| const descriptors: IntegrationDescriptor[] = [] | ||
| for (const integration of integrations) { | ||
| const historyEnabled = integration.downloadHistoricalData === true | ||
| const eventScopePaths = this.canonicalMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
| const writebackCommandPaths = writebackCommandMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
|
|
||
| if (integrations.length === 0) { | ||
| lines.push('- none') | ||
| } else { | ||
| for (const integration of integrations) { | ||
| const scopeLabels = collectScopeLabels(integration.scope) | ||
| const scopeSummary = scopeLabels.length > 0 ? scopeLabels.join(', ') : 'all configured scope' | ||
| const mountPaths = this.canonicalMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
| const discoveryPath = projectIntegrationPathForRelayfilePath(discoveryMountPathForProvider(integration.provider)) | ||
| const writebackCommandPaths = writebackCommandMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
| const liveContextPaths = integration.downloadHistoricalData === true | ||
| ? [] | ||
| : slackThreadContextMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
| const historyEnabled = integration.downloadHistoricalData === true | ||
| const writebackPaths = historyEnabled | ||
| ? mountPaths.join(', ') || 'the configured provider paths' | ||
| : writebackCommandPaths.join(', ') | ||
| const writebackInstruction = writebackPaths | ||
| ? `create writeback files under ${writebackPaths}, not under discovery` | ||
| : 'select narrower resources before creating local writeback files; discovery is schema-only' | ||
| const skippedHistoryPaths = skippedHistoricalMountPathsForIntegration(integration) | ||
| .map(projectIntegrationPathForRelayfilePath) | ||
| const skippedCappedPaths = skippedCappedLocalSyncMountPathsForIntegration(integration) | ||
| const isActive = historyEnabled | ||
| || writebackCommandPaths.length > 0 | ||
| || subscribedProviders.has(integration.provider) | ||
| if (!isActive) continue |
There was a problem hiding this comment.
When a project has multiple integrations of the same provider (e.g., multiple Slack workspaces), checking subscribedProviders.has(integration.provider) will incorrectly mark all integrations of that provider as active if at least one of them has an active subscription. This defeats the purpose of suppressing idle integrations. Instead, we should check the subscribeAgent status of the specific integration directly.
const subscriptionSummaries = integrationSubscriptionSummaries(integrations)
const descriptors: IntegrationDescriptor[] = []
for (const integration of integrations) {
const historyEnabled = integration.downloadHistoricalData === true
const eventScopePaths = this.canonicalMountPathsForIntegration(integration)
.map(projectIntegrationPathForRelayfilePath)
const writebackCommandPaths = writebackCommandMountPathsForIntegration(integration)
.map(projectIntegrationPathForRelayfilePath)
const isListening = integration.subscribeAgent === true && (
eventScopePaths.length > 0 ||
(toRelayfileProvider(integration.provider) === 'slack' && slackListenDms(integration))
)
const isActive = historyEnabled
|| writebackCommandPaths.length > 0
|| isListening
if (!isActive) continue241c24c to
ad13f63
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/main/integrations.test.ts`:
- Around line 1173-1175: The makeIntegration helper function currently returns a
hardcoded empty scope object, but the type system now expects integrations with
provider-specific scope shapes (like scope with channels for Slack). Update the
makeIntegration function to accept an optional scope parameter as a second
argument, and set provider-appropriate default values: for the 'slack' provider,
default to scope with an empty channels array if no scope is provided, and for
other providers use an empty scope. Then update the calls to makeIntegration at
lines 1175, 1207, 1313, and 1355 to pass the required scope data (such as the
channels array ['C123']) as the second argument where needed.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 79ae12cf-39e0-4161-b765-b1af203790e2
📒 Files selected for processing (2)
src/main/integrations.test.tssrc/main/integrations.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 241c24ce31
ℹ️ 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".
| // entirely — a visible-but-idle integration adds only noise at spawn. | ||
| private buildSystemMessageSnippet(integrations: ConnectedIntegration[]): string { | ||
| const descriptors = this.buildActiveIntegrationDescriptors(integrations) | ||
| if (descriptors.length === 0) return '' |
There was a problem hiding this comment.
Send a clearing update when integrations become inactive
When the last active integration is removed or disabled, callers such as disconnect() still invoke syncAgentState(..., true), but this early return turns the broadcast into a no-op. Existing agents that previously received an integrations update never get the old clearing/- none message, so they can keep attempting stale writebacks or waiting on subscriptions after the integration is gone; suppressing idle context should only apply to spawn/no-op cases, not state transitions that clear prior state.
Useful? React with 👍 / 👎.
| const integrations = this.visibleIntegrationsForProject(projectId) | ||
| const subscriptionsReady = await this.syncEventSubscriptions(projectId) | ||
| this.lastSubscriptionsReady.set(projectId, subscriptionsReady) | ||
| await this.syncEventSubscriptions(projectId) |
There was a problem hiding this comment.
Preserve failed subscription registration in the prompt
When syncEventSubscriptions returns false for Relayfile/account auth failures or reconcile errors, this result is now discarded and the later descriptor builder still renders subscriptions from config as active. That regresses the previous warning path for “requested but not registered yet,” so agents can be told to wait for integration events that were not actually registered, and the prompt text no longer changes when registration later recovers.
Useful? React with 👍 / 👎.
…+ gate idle integrations The <integrations-update> spawn narrative was a ~75-line hand-maintained copy of @agent-relay/integration-prompts' fullInjectInstructions. Map ConnectedIntegration -> the package's IntegrationDescriptor and call the shared builder instead, deleting the duplicate. Also stop emitting the message for integrations that aren't doing anything. buildActiveIntegrationDescriptors keeps only integrations that are syncing (downloadHistoricalData), listening (event subscription), or actionable (narrow writeback roots mounted). When none qualify the whole message is suppressed at both spawn (initialSpawnInstructions) and on state-change broadcasts, instead of injecting an empty "- none" snippet. Drops the unused subscriptionsReady plumbing; listening is derived from integration config directly (matching the package, which has no readiness concept). Test fixtures that used idle/empty integrations as stable broadcast/dedup baselines now use active fixtures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
ad13f63 to
4474091
Compare
- Fix per-provider listening collision (gemini): derive "listening" per
integration via integrationSubscriptionSummaries([integration]) instead
of a provider-keyed set, so one subscribed Slack workspace no longer
marks every Slack integration active. Also de-duplicates the rendered
subscription list across same-provider descriptors.
- Fix CI typecheck failure (coderabbit / GitHub checks): revert the
default test fixture scope to {} (it activates via its narrow channel
mountPath, not scope) so the mock store's inferred element type stops
rejecting the {} / { listenDms } fixtures elsewhere. tsconfig.node.json
includes tests; tsconfig.json does not, which is why it was missed.
- Send one clearing update on active->none transitions (codex P2): when
the last active integration is disconnected, already-notified agents now
get a "- none" update instead of silence, so they stop relying on stale
context. Idle suppression still applies to spawn/no-op.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Addressed review feedback in e7f72f2: ✅ Gemini (HIGH) — per-provider listening collision ( ✅ CodeRabbit / GitHub checks — typecheck failure: real failure I missed locally — ✅ Codex (P2) — clearing update on disconnect: good catch. Added a one-time clearing broadcast on active→none transitions: a project that previously broadcast/spawned a non-empty update now sends a ↩️ Codex (P2) — preserve failed subscription-registration warning: declining intentionally. Dropping the New test coverage: per-integration listening path + active→none clearing. Suite 58/58, ipc-handlers 25/25, |
Why
Two issues with the
<integrations-update>context injected on agent spawn:@agent-relay/integration-promptsfor adapter-doc parsing only. The verbose spawn narrative was still produced by a ~75-line hand-maintained copy of the package'sfullInjectInstructionsinsrc/main/integrations.ts.What
Use the package.
buildSystemMessageSnippetnow maps eachConnectedIntegrationinto the package'sIntegrationDescriptorand callsfullInjectInstructions, deleting the local duplicate. The opencodeprescriptiveSpawnInstructionstable is unchanged (it's more capable than the package's generic builder).Gate idle integrations. New
buildActiveIntegrationDescriptorskeeps only integrations that are:downloadHistoricalDataon, orsubscribeAgent+ event globs), orWhen none qualify, the message is suppressed entirely — at spawn (
initialSpawnInstructionsreturnsundefined) and on state-change broadcasts — instead of injecting an empty- nonesnippet.Removes the now-unused
subscriptionsReadyplumbing; "listening" is derived from integration config directly (the package has no readiness concept). This also drops the old "subscriptions requested but not registered yet" warning.Notes / tradeoffs
[]in tests, so fixtures activate via narrow paths / history).Test plan
vitest run src/main/integrations.test.ts— 56/56vitest run src/main/ipc-handlers.test.ts— 25/25tsc --noEmitclean,eslintclean🤖 Generated with Claude Code