← Back to PRs

#14689: onboard: set per-channel DM scope by default for multi-channel setups

by constansino open 2026-02-12 13:55 View on GitHub →
commands stale size: S
## What This PR makes channel onboarding safer for shared inbox scenarios by setting a DM-isolated session scope during setup. ### Change In `setupChannels` (`src/commands/onboard-channels.ts`): - If `session.dmScope` is **unset** - and user selected **2+ DM-capable channels** - onboarding now sets `session.dmScope = "per-channel-peer"` - interactive mode: asks for confirmation (default: yes) - non-interactive/skip-confirm mode: applies automatically ## Why Many first-time multi-channel setups leave `dmScope` unset and later run into DM context bleed/cross-channel continuity surprises. The core behavior (`dmScope=main` when unset) is documented, but onboarding currently only warns; it does not apply a safe default. This PR keeps backward compatibility for existing configs and only affects onboarding-generated config when `dmScope` is not explicitly set. ## Scope and compatibility - ✅ No change for users who already set `session.dmScope` - ✅ No change for single-channel DM onboarding - ✅ No core routing behavior change - ✅ Existing deployments remain untouched ## Validation - Ran targeted test suite: - `corepack pnpm -s vitest src/commands/onboard-channels.test.ts` ## Related - Closes #14688 - Related context: #10172, #7861, #14117 <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This change introduces a new onboarding step in `setupChannels` that, when `session.dmScope` is unset and the user selects 2+ DM-capable channels, prompts (or auto-applies in `skipConfirm` mode) setting `session.dmScope` to `"per-channel-peer"` to isolate DM session history per channel+sender. The logic is implemented as `maybeConfigureDmScopeIsolation()` and is invoked at the end of channel selection, after optional DM policy configuration. This keeps core routing behavior unchanged and only affects onboarding-generated config defaults. <h3>Confidence Score: 3/5</h3> - This PR is mostly safe, but it may apply an incorrect dmScope default for multi-account channels during onboarding. - The change is localized and preserves existing behavior when dmScope is already set, but the onboarding default is hard-coded to per-channel-peer despite the codebase recommending per-account-channel-peer for multi-account channels, which can lead to account-level DM context mixing. - src/commands/onboard-channels.ts <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs