Repository navigation
fix(onboard): forward enabled messaging channels into policy preset suggestions - #2069
Conversation
…uggestions The Balanced tier omits messaging presets by default, so a user who enabled telegram, slack, or discord in the messaging step would still see the matching preset unchecked at the policy step. Extract the seed-suggestions logic from setupPoliciesWithSelection into a pure helper and forward enabledChannels alongside the existing brave and local-inference additions. Closes #2014 Co-Authored-By: Claude <[email protected]> Signed-off-by: Tinson Lai <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughUpdated onboarding to persist selected Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI as Onboard CLI
participant Onboard as onboard.ts
participant SessionStore as Session (persist)
participant Presets as computeSetupPresetSuggestions
User->>CLI: select messaging channels
CLI->>Onboard: record selection
Onboard->>SessionStore: save messagingChannels (string[] | null)
User->>CLI: resume onboarding -> choose tier
CLI->>SessionStore: load session
SessionStore->>Onboard: return messagingChannels
CLI->>Onboard: provide tierName + enabledChannels
Onboard->>Presets: computeSetupPresetSuggestions(tierName, { enabledChannels, webSearchConfig, provider, knownPresetNames })
Presets->>Onboard: return ordered preset suggestions
Onboard->>CLI: present suggested presets
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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 docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/onboard.ts`:
- Around line 5264-5269: computeSetupPresetSuggestions is being called with
enabledChannels that can be an empty array during a resumed flow, which loses
previously recorded channel configuration and omits messaging presets. Update
the argument passed to computeSetupPresetSuggestions so enabledChannels is
derived from the saved session state when present (e.g., use
sessionState.recordedChannels or session.channels if non-empty) instead of
blindly using the local enabledChannels; keep the other params (tierName,
webSearchConfig, provider, knownPresetNames) unchanged and ensure the fallback
remains the original enabledChannels when no recorded channels exist.
In `@test/onboard.test.ts`:
- Line 57: Replace the CommonJS require for computeSetupPresetSuggestions and
getSuggestedPolicyPresets with an ESM named import: remove the require statement
and add these two symbols to the existing ESM import block at the top of the
test file (import { computeSetupPresetSuggestions, getSuggestedPolicyPresets }
from "../dist/lib/onboard.js"); ensure you don’t create duplicate imports if
either symbol is already imported and run the tests to confirm the ESM import
works in the test environment.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c18cc642-03c7-4b5d-9c41-f9dc250c1a38
📒 Files selected for processing (2)
src/lib/onboard.tstest/onboard.test.ts
…ard-messaging-channels-to-presets
…orts in tests Address CodeRabbit review on #2069: 1. On resume, setupMessagingChannels() is skipped when the sandbox step is already complete, so selectedMessagingChannels defaults to []. The downstream computeSetupPresetSuggestions() then had nothing to forward, leaving messaging presets unchecked again. Add messagingChannels to the Session schema, normalizeSession, createSession defaults, SessionUpdates, and filterSafeUpdates — mirroring the existing policyPresets shape — so the value written at onboard.ts:6167 actually persists to disk. The policy step now reads latestSession.messagingChannels as a fallback when the live selection is empty. 2. Replace the createRequire shim in test/onboard.test.ts with a plain ESM import — the named exports resolve through the existing import block. Co-Authored-By: Claude <[email protected]> Signed-off-by: Tinson Lai <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/onboard.ts (1)
6165-6169:⚠️ Potential issue | 🟠 MajorPersist configured channels, not raw toggle selections.
setupMessagingChannels()can return channels the user toggled on but never finished configuring. Those names are now written to session state and later fed back intocomputeSetupPresetSuggestions(), so the policy step can auto-suggest/select a preset for a channel that was never actually configured.Possible fix
startRecordedStep("sandbox", { sandboxName, provider, model }); - selectedMessagingChannels = await setupMessagingChannels(); + selectedMessagingChannels = (await setupMessagingChannels()).filter((name) => { + const channel = MESSAGING_CHANNELS.find((c) => c.name === name); + return Boolean( + channel && + (getCredential(channel.envKey) || + normalizeCredentialValue(process.env[channel.envKey])), + ); + }); onboardSession.updateSession((current) => { current.messagingChannels = selectedMessagingChannels; return current; }); @@ enabledChannels: selectedMessagingChannels.length > 0 ? selectedMessagingChannels : recordedMessagingChannels,Also applies to: 6264-6267
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/onboard.ts` around lines 6165 - 6169, The session is being updated with raw toggle selections from setupMessagingChannels() which can include channels the user never finished configuring; change the update to persist only fully configured channels (e.g., filter selectedMessagingChannels for channels with completed config/required fields) before calling onboardSession.updateSession so computeSetupPresetSuggestions() only sees actual configured channels. Update the logic where selectedMessagingChannels is set (from setupMessagingChannels()) to either have setupMessagingChannels return only configured channels or apply a filter/validation step prior to writing to onboardSession.messagingChannels; apply the same change to the other occurrence referenced (the block around lines 6264-6267).
🧹 Nitpick comments (1)
src/lib/onboard.ts (1)
5376-5391: Move this helper to typed CLI code to keep session/preset logic undertsconfig.cli.json.This helper adds decision logic to a file under
@ts-nocheck, contrary to the guideline thatsrc/lib/should use TypeScript with type-checking. The helper depends only ontiers.resolveTierPresets()and theLOCAL_INFERENCE_PROVIDERSconstant—both readily available in typed context. Moving it to a typed helper module (e.g.,onboard-session.tsor a new utility file) would bring this logic under type safety while keeping the plumbing cohesive.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/onboard.ts` around lines 5376 - 5391, Move the computeSetupPresetSuggestions helper out of the `@ts-nocheck` file into a typed CLI module (e.g., onboard-session.ts or a new utils file compiled under tsconfig.cli.json), reimplementing it with proper TypeScript types for parameters (tierName: string, options: { enabledChannels?: string[]; webSearchConfig?: any; provider?: string; knownPresetNames?: string[] }) and exporting it; update callers to import the new function; ensure the implementation uses tiers.resolveTierPresets(...) and the LOCAL_INFERENCE_PROVIDERS constant from the typed modules and preserves the same add/suggestions logic for enabledChannels, webSearchConfig ("brave") and provider ("local-inference").
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/lib/onboard-session.ts`:
- Around line 208-210: The normalization for overrides.messagingChannels
currently filters non-string entries and returns [] for malformed non-empty
arrays, which conflates corrupt input with an intentional empty selection;
update the logic in filterSafeUpdates (and the other similar places handling
overrides.messagingChannels) to only accept the array if every element is a
string (e.g., Array.isArray(overrides.messagingChannels) &&
overrides.messagingChannels.every(v => typeof v === "string")), otherwise set
messagingChannels to null so malformed input does not erase previously saved
selections; apply the same validation pattern to the other occurrences
referenced (the other messagingChannels normalization sites).
---
Outside diff comments:
In `@src/lib/onboard.ts`:
- Around line 6165-6169: The session is being updated with raw toggle selections
from setupMessagingChannels() which can include channels the user never finished
configuring; change the update to persist only fully configured channels (e.g.,
filter selectedMessagingChannels for channels with completed config/required
fields) before calling onboardSession.updateSession so
computeSetupPresetSuggestions() only sees actual configured channels. Update the
logic where selectedMessagingChannels is set (from setupMessagingChannels()) to
either have setupMessagingChannels return only configured channels or apply a
filter/validation step prior to writing to onboardSession.messagingChannels;
apply the same change to the other occurrence referenced (the block around lines
6264-6267).
---
Nitpick comments:
In `@src/lib/onboard.ts`:
- Around line 5376-5391: Move the computeSetupPresetSuggestions helper out of
the `@ts-nocheck` file into a typed CLI module (e.g., onboard-session.ts or a new
utils file compiled under tsconfig.cli.json), reimplementing it with proper
TypeScript types for parameters (tierName: string, options: { enabledChannels?:
string[]; webSearchConfig?: any; provider?: string; knownPresetNames?: string[]
}) and exporting it; update callers to import the new function; ensure the
implementation uses tiers.resolveTierPresets(...) and the
LOCAL_INFERENCE_PROVIDERS constant from the typed modules and preserves the same
add/suggestions logic for enabledChannels, webSearchConfig ("brave") and
provider ("local-inference").
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a094aaa4-81d6-450a-8bf0-2c2c569e8e7c
📒 Files selected for processing (4)
src/lib/onboard-session.test.tssrc/lib/onboard-session.tssrc/lib/onboard.tstest/onboard.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- test/onboard.test.ts
…Channels return A channel toggled on but left without a bot token still landed in the returned array because the no-token branch continue'd without removing the name from the `enabled` Set. The bogus selection then flowed into the Docker build args, the session record, and the policy-preset picker — all claiming the channel was configured when no credential had been saved. Delete the name from `enabled` in the no-token branch and derive the return value from the Set so only channels with credentials survive. Co-Authored-By: Claude <[email protected]> Signed-off-by: Tinson Lai <[email protected]>
ericksoa
left a comment
There was a problem hiding this comment.
Looks good — clean refactor of preset suggestion logic, correct channel forwarding with credential gating, solid test coverage. Minor nits (recordedMessagingChannels defaults to [] vs null for consistency, no unit test for the resume fallback path) are non-blocking.
The Balanced tier omits messaging presets by default, so a user who enabled telegram, slack, or discord in the messaging step would still see the matching preset unchecked at the policy step. Extract the seed-suggestions logic from setupPoliciesWithSelection into a pure helper and forward enabledChannels alongside the existing brave and local-inference additions.
Closes #2014
Summary
Related Issue
Changes
Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)AI Disclosure
Signed-off-by: Tinson Lai [email protected]
Summary by CodeRabbit
New Features
Bug Fixes
Tests