Skip to content

fix(onboard): respect messaging channel toggle in sandbox creation#1508

Merged
ericksoa merged 3 commits intomainfrom
fix/1505-v2
Apr 5, 2026
Merged

fix(onboard): respect messaging channel toggle in sandbox creation#1508
ericksoa merged 3 commits intomainfrom
fix/1505-v2

Conversation

@ericksoa
Copy link
Copy Markdown
Contributor

@ericksoa ericksoa commented Apr 5, 2026

Summary

  • setupMessagingChannels() now returns the selected channel names
  • createSandbox() accepts enabledChannels param and filters messagingTokenDefs to only include user-selected channels
  • When enabledChannels is null (backward compat / direct calls), all channels with tokens are included

Closes #1505

Test plan

  • Run onboarding with a Slack token saved from a prior session
  • Deselect Slack in the toggle picker
  • Verify no slack-bridge provider is created during sandbox setup
  • Verify non-interactive mode still auto-enables all detected channels

Summary by CodeRabbit

  • New Features

    • Users can select specific messaging channels to enable during sandbox onboarding.
  • Improvements

    • Sandbox setup now includes only the messaging channels selected by the user.
    • Non-interactive onboarding now reports detected configured channels (and returns an empty list when none are configured).
  • Tests

    • Added automated tests covering channel filtering and non-interactive channel detection.

setupMessagingChannels() now returns the selected channel names so
createSandbox() can filter messagingTokenDefs to only include channels
the user actually enabled. Previously, any channel with a saved token
was configured regardless of the toggle picker state.

Closes #1505

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 802d4196-bdef-43be-a6cf-7a80974bb37d

📥 Commits

Reviewing files that changed from the base of the PR and between 0010afa and 1e46058.

📒 Files selected for processing (1)
  • bin/lib/onboard.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • bin/lib/onboard.js

📝 Walkthrough

Walkthrough

createSandbox now accepts an optional enabledChannels parameter; setupMessagingChannels returns the user-selected channel names and is exported. The onboarding flow awaits channel selection and passes enabledChannels into createSandbox, which filters messaging token definitions so only selected channels are configured. (50 words)

Changes

Cohort / File(s) Summary
Sandbox Onboarding Implementation
bin/lib/onboard.js
Added enabledChannels = null parameter to createSandbox(...); setupMessagingChannels() now returns selected channel names and is exported. Onboarding awaits the selection and passes enabledChannels into createSandbox(). messagingTokenDefs and allowed-ID extraction are filtered by the enabled token env keys so only selected channels produce providers.
Tests — Onboarding
test/onboard.test.js
Updated assertions to expect the extra enabledChannels arg in createSandbox() calls. Added tests verifying provider creation and sandbox --provider flags are filtered when enabledChannels is ["telegram"] or []. Added non-interactive tests for setupMessagingChannels() detecting configured channels or returning empty when none.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant OnboardScript as Onboard
    participant CredStore as CredentialStore
    participant SandboxManager as Sandbox/Providers

    User->>Onboard: run onboarding
    Onboard->>Onboard: setupMessagingChannels() (interactive or non-interactive)
    Onboard-->>User: present channel toggles / detect env tokens
    User-->>Onboard: selectedChannels (array) 
    Onboard->>Onboard: build enabledTokenEnvKeys from selectedChannels
    Onboard->>CredStore: query credential store for messaging tokens (filtered by enabledTokenEnvKeys)
    CredStore-->>Onboard: available tokens (only enabled channels)
    Onboard->>SandboxManager: createSandbox(..., enabledChannels) with filtered providers
    SandboxManager-->>Onboard: provider creation results
    Onboard-->>User: onboarding completes
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nudged the toggles, quiet and bright,

Only chosen voices join the night.
Old tokens sleeping, called on demand,
The sandbox builds just what I planned.
🥕🌙

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix(onboard): respect messaging channel toggle in sandbox creation' accurately describes the main change: propagating user-selected messaging channels to sandbox creation.
Linked Issues check ✅ Passed The code changes fully address issue #1505 by propagating selected channels from setupMessagingChannels() to createSandbox() and filtering messagingTokenDefs accordingly.
Out of Scope Changes check ✅ Passed All changes are scoped to the fix: enabledChannels parameter addition, setupMessagingChannels return value, filtering logic, and exports, with corresponding test coverage.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1505-v2

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
test/onboard.test.js (1)

1264-1273: Add a behavior-level regression test for channel deselection.

This regex check confirms parameter wiring, but it won’t catch regressions where createSandbox ignores enabledChannels. Please add one integration assertion that a stored token for a deselected channel (e.g., Slack) does not produce a provider create ... slack-bridge command.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/onboard.test.js` around lines 1264 - 1273, The test currently checks
parameter wiring with a regex but doesn't assert behavior when channels are
deselected; add an integration assertion that verifies createSandbox actually
respects enabledChannels by storing a token for a deselected channel (e.g.,
Slack) and asserting that the resulting command output or recorded provider
actions does NOT include a "provider create ... slack-bridge" invocation. Update
the test around the createSandbox/startRecordedStep checks (look for
createSandbox and enabledChannels usage) to simulate a deselected channel token
and assert absence of any provider create slack-bridge call in the produced
commands or logs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/onboard.test.js`:
- Around line 1264-1273: The test currently checks parameter wiring with a regex
but doesn't assert behavior when channels are deselected; add an integration
assertion that verifies createSandbox actually respects enabledChannels by
storing a token for a deselected channel (e.g., Slack) and asserting that the
resulting command output or recorded provider actions does NOT include a
"provider create ... slack-bridge" invocation. Update the test around the
createSandbox/startRecordedStep checks (look for createSandbox and
enabledChannels usage) to simulate a deselected channel token and assert absence
of any provider create slack-bridge call in the produced commands or logs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd911baa-674a-4375-a6f8-d906fbe37146

📥 Commits

Reviewing files that changed from the base of the PR and between 39b0761 and 02682cc.

📒 Files selected for processing (2)
  • bin/lib/onboard.js
  • test/onboard.test.js

…eractive return

Verify that createSandbox respects the enabledChannels parameter:
- only selected channels get providers created
- empty enabledChannels creates no messaging providers
- setupMessagingChannels returns correct channel list in non-interactive mode
- setupMessagingChannels returns empty array when no tokens are set

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
bin/lib/onboard.js (1)

2531-2556: ⚠️ Potential issue | 🟠 Major

Apply enabledChannels to all downstream messaging state, not just provider tokens.

This filter only trims messagingTokenDefs. messagingAllowedIds and setupPoliciesWithSelection() still infer channels from saved env/credentials, and a ready sandbox can be reused without knowing it was built with a broader channel set. A user who deselects Slack/Telegram can therefore still carry that channel’s config forward. Please persist the selected set and use it for downstream config and recreate decisions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bin/lib/onboard.js` around lines 2531 - 2556, The current code only applies
enabledChannels via enabledEnvKeys to messagingTokenDefs, but
messagingAllowedIds and setupPoliciesWithSelection still derive channels from
existing env/credentials; update the flow so the selected channel set is
persisted and used everywhere: compute enabledEnvKeys from enabledChannels (as
already done) and then apply that same Set to filter messagingAllowedIds and to
short-circuit or parameterize setupPoliciesWithSelection (use the enabledEnvKeys
or enabledChannels as an explicit argument) so recreate decisions and downstream
config only consider the persisted selection; also store the selected channels
on the sandbox metadata/state so future runs read that persisted selection
instead of inferring from saved credentials (references: enabledChannels,
enabledEnvKeys, MESSAGING_CHANNELS, messagingTokenDefs, messagingAllowedIds,
setupPoliciesWithSelection).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@bin/lib/onboard.js`:
- Around line 2531-2556: The current code only applies enabledChannels via
enabledEnvKeys to messagingTokenDefs, but messagingAllowedIds and
setupPoliciesWithSelection still derive channels from existing env/credentials;
update the flow so the selected channel set is persisted and used everywhere:
compute enabledEnvKeys from enabledChannels (as already done) and then apply
that same Set to filter messagingAllowedIds and to short-circuit or parameterize
setupPoliciesWithSelection (use the enabledEnvKeys or enabledChannels as an
explicit argument) so recreate decisions and downstream config only consider the
persisted selection; also store the selected channels on the sandbox
metadata/state so future runs read that persisted selection instead of inferring
from saved credentials (references: enabledChannels, enabledEnvKeys,
MESSAGING_CHANNELS, messagingTokenDefs, messagingAllowedIds,
setupPoliciesWithSelection).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4a931019-3c48-4ce4-b11e-ef87bc7ee521

📥 Commits

Reviewing files that changed from the base of the PR and between 02682cc and 0010afa.

📒 Files selected for processing (2)
  • bin/lib/onboard.js
  • test/onboard.test.js

Gate messagingAllowedIds on the filtered messagingTokenDefs so user IDs
for deselected channels are not written into the sandbox Dockerfile.

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@ericksoa ericksoa self-assigned this Apr 5, 2026
@ericksoa ericksoa merged commit 9f17941 into main Apr 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(onboard): deselected messaging channels still configured if token exists in credential store

2 participants