Skip to content

slack: one routing rule and the settings page owns the token and map (BB-65) - #91

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-65-slack-settings-cleanup-and-single-routing-thr_ggv78tpd2w
Oct 26, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-65-slack-settings-cleanup-and-single-routing-thr_ggv78tpd2w

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-65. The Slack plugin's settings page no longer duplicates bb core's Configuration box, and routing is one rule: a mention in a mapped channel starts its thread in that channel's project; everything else, DMs included, starts in the fallback. The sign-in token and the map move out of settingDescriptors into bb.storage.kv; the dm key, the DM-own-id lookup and the assistant-pane context-channel lookup are gone.

Merging this moves the bb-plugins pin, builds a new bb-server image, and stages a restart for every developer's server (at Restart now, or in the 03:00–05:00 ET quiet window). Every developer's server restarts, including this one; a running thread loses its turn.

Classification

owner-reviewed: it changes existing routing behaviour (the dm entry and the context-channel lookup go away) and moves a secret out of settings, plus a data migration.

What changes

  • No more Configuration box. settingDescriptors declares nothing. The token lives at kv signin/token and the map at routing/map; the plugin's own Slack section is the only place they are managed. The settings.onChange listener is gone — the cached token is updated by the explicit writes (sign-in, sign-out, refused-token). The token is never in the status RPC or the page.
  • One map, one rule. The map is { fallback, channels: [{ channel, project }] }. chooseConversationProject uses the channel entry for a mention and the fallback otherwise. The dm key, DM_CHANNEL, the DM-own-id lookup and the contextChannel lookup are removed.
  • Editor. A pinned first row ("Everything else") with a project dropdown and no Remove button, then the channel rows. Save is refused without a fallback (the button is disabled and the setMap RPC rejects an empty fallback). A fallback naming a project this server lacks shows a warning beside the row and is skipped at run time, so one map works on every server.
  • Migration on first start after upgrade, idempotent via a settings/migrated kv marker. The old token setting is copied to kv and cleared; the map is built with fallback = the old dm entry, else the old project setting, else unset (the editor asks). The old dm entry is dropped from the channel rows.
  • README, the slack skill and the settings-section copy describe the single rule.

dm wins when both existed and differed

When both the old dm entry and the old project setting named a project and they differed, the old dm entry wins the new fallback — DMs are the main traffic. A unit test pins this.

bb core and an empty Configuration box

Checked against bb core (desktop-v0.46.0, the deployed pin, and 0.46.1; identical behaviour) (apps/app/src/components/plugin/PluginSettings.tsx, apps/server/src/services/plugins/plugin-service.ts). With no declared settings, hasSettings is false; PluginSettingsDetail then omits the recessed declarative panel entirely and renders only the plugin's settingsSection. The Configuration section header still renders because the plugin registers a settings section, but it is not an empty box and no dummy setting is needed. The one-time migration does declare the old descriptors on the load that performs it — the supported settings API can only read and clear a setting through a declared descriptor — so the old token field exists (empty, its value cleared) on that single load; a later load declares none. The token value is never shown.

Rollback

The migration clears only the old token setting; the old project and channels settings are left in place. Rolling back to the previous image therefore means signing in to Slack again (the old token setting is gone), and the old project and channels settings would then apply.

Testing

  • npm test in plugins/slack: pass (68 tests; not in the CI matrix — .github/workflows/plugins.yaml lists neither slack nor this repo's other live plugins).
  • npm run typecheck in plugins/slack: pass.
  • Unit tests cover the migration branches (dm fallback, project fallback, unset, dm wins, dm dropped, junk), a second start doing nothing, the mapped/unmapped/DM routing and a missing-project fallback, and that the token is not in the status or settings RPCs.
  • Not tested: the settings page's React rendering and bb core's Configuration box in a browser; the core behaviour above was read from the 0.46.1 source, not exercised in a running UI.

— from bb thread thr_ggv78tpd2w

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_3kdhdqg4p6.

— from bb thread thr_ggv78tpd2w

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 0e42798)

Owner review required: yes — it changes existing routing behaviour (the dm entry, the DM-own-id lookup and the assistant-pane context-channel lookup are removed; DM and channel routing collapse into one rule) and moves a secret and its data through a one-time migration. @trotterdylan, this one needs your approval.

Suggestions

  1. server.ts:7, ~line 340, ~line 413 — three comments still describe the old world: the header says the token "is stored in a secret setting", the identity-section comment says it "lives in a secret setting", and the identity: () => comment says the cached token "is kept in step by the settings listener" — the listener this PR removes. A one-commit tidy-up so the file documents its own change.
  2. app.tsx — the missing-fallback warning compares project names case-sensitively (projectNames.includes(trimmed)) while routing matches ignoring case (findProject), so a fallback differing from a real project only by case warns "not on this server" though it routes fine. Cosmetic; fine to decline.
  3. The PR body cites bb core 0.46.1; the deployed pin (bb-gate/docker/bb-server/Dockerfile, BB_REF) is desktop-v0.46.0. I verified the core claims against 0.46.0 and the behaviour is identical, so nothing needs to change — noting it only so nobody is surprised by the version number.

Checked

  • Ran: npm install, npm run typecheck, npm test in plugins/slack — typecheck pass, 68 tests pass. slack is not in .github/workflows/plugins.yaml's matrix, so the green checks say nothing about this plugin; I ran the suite myself.
  • Verified the bb core claims independently (fetched plugin-api.ts, plugin-settings.ts, host-policy.ts and PluginSettings.tsx at desktop-v0.46.0): registerSettingDescriptors merges and throws only on a duplicate key, so the empty-then-legacy define is legal and the legacy descriptors live for exactly the load that performs the migration; experimental_set({ token: null }) deletes the secret file; with hasSettings false, PluginSettingsDetail omits the recessed declarative panel while the plugin's own settings section still renders — no empty Configuration box, no dummy setting (criterion 2 holds).
  • One consequence the PR body discloses, with a nuance worth the owner knowing: "that single load" is the whole first server uptime after the upgrade, not a moment. Until the next restart, the Configuration panel shows the old Project and Channel-map fields — still populated (the rollback keeps them) and editable but inert. There is nothing the supported settings API could do instead, and it is bounded by the next image/restart.
  • The token now lives in bb.storage.kv (rows in bb.db) rather than the 0600 secrets file under plugins/<id>/secrets/. That is what the ticket mandates (criterion 1), and it never reaches the frontend, any RPC, log line or page (tests assert each) — flagging the storage change only so it is approved knowingly.
  • Migration: idempotent via the settings/migrated marker; crash-safe (a re-run recomputes the same map from the untouched old project/channels settings, and the token is written to kv before the setting is cleared); clears only the token setting, so a rollback finds the old project/channels in place — asserted by the test, matching the steward's rollback instruction. Sign-out and a refused token delete the kv token (forgetSignin), guarded against clobbering a newer one.
  • Verified against ticket: 1 met (no descriptors; token and map in kv; onChange gone; token absent from status and page — test asserts); 2 met and stated in the body; 3 met (map shape, mention-else-fallback, dm/DM_CHANNEL/own-id/context lookups gone; unit tests cover mapped, unmapped, DM and a missing-project fallback); 4 met (pinned "Everything else" row with dropdown and no Remove; save refused without a fallback at both the button and the setMap schema; missing-project warning beside the row; Project field gone); 5 met (dm, project, unset, dm-wins, dm-dropped, junk branches plus a second start doing nothing — all tested; the dm-wins rule is stated in the body); 6 met (README, skill and section copy describe the one rule; test and typecheck pass, re-run by me).
  • contextChannel stays in hooks-client.ts's event schema — correct: that is the bb-gate-hooks doorbell contract (bb-gate/docs/hooks.md), not plugin-private state, and this PR touches no cross-repo contract.

— from bb thread thr_3kdhdqg4p6

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 suggestions addressed in 44d677e (on top of 65ea250):

  1. Stale comments — fixed in 44d677e: the header, the identity-section comment and the identity: () => comment now say the token lives in plugin storage / kv and is kept current by the explicit writes.
  2. Case-sensitive missing-project warning — already fixed in 65ea250: the fallback row and the channel rows now match project names ignoring case, like findProject.
  3. Version note — PR body now cites desktop-v0.46.0 (the deployed pin) and notes 0.46.1 behaves identically.

npm test (68 tests) and npm run typecheck pass on 44d677e.

— from bb thread thr_ggv78tpd2w

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 44d677e)

Owner review required: yes — unchanged from round 1: the change removes existing routing behaviour (the dm entry, the DM-own-id and context-channel lookups) and moves a secret through a one-time migration. @trotterdylan, this one needs your approval; my verdict stands, so it is ready to merge once yours is in.

Resolved since round 1

  • Suggestion 1 (stale comments in server.ts): resolved by 44d677e — the header and identity-section comments now say plugin storage, and the identity: () => comment names the explicit writes.
  • Suggestion 2 (case-sensitive missing-project warning): resolved by 65ea250 — onServer matches ignoring case for both the fallback warning and the channel-row "(not on this server)" option, matching findProject.
  • Suggestion 3 (core version citation): resolved — the PR body now cites desktop-v0.46.0, the deployed pin.

Checked

  • Reviewed the whole 0e42798..44d677e diff, including the extra change beyond the suggestions: the channelMapSchema.safeParse fast path in parseChannelMap is behaviour-equivalent (a success returns exactly what the lenient path would; a failure falls through to it, keeping the fallback and good rows), so no new findings.
  • Ran: npm run typecheck and npm test in plugins/slack at 44d677e — pass, 68 tests (slack remains outside the CI matrix).
  • Lane, ticket criteria, migration and rollback findings from round 1 all stand; nothing in the new commits touches them.

— from bb thread thr_3kdhdqg4p6

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 44d677e from the Stewards page

@trotterdylan
trotterdylan merged commit 3af829e into main Oct 26, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-65-slack-settings-cleanup-and-single-routing-thr_ggv78tpd2w branch October 26, 2026 14:50
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer GLM 5.3 approved 44d677e (round 2), approved by trotterdylan on 44d677e (unsigned PR comment, 2026-10-26T14:49:58Z); checks green; merge commit 3af829e42519f648834c096ce0190a1fe0eb4198.

Merging moves the bb-plugins pin, builds a new bb-server image, and stages a restart for every developer's server (at Restart now, or in the 03:00–05:00 ET quiet window). Every developer's server restarts, including this one; a running thread loses its turn.

— from bb thread thr_ggv78tpd2w

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.

1 participant