Skip to content

fix(bots): a paired bot on this desktop's Orca account joins its Slack workspace without a token - #45514

Open
LDH1103 wants to merge 3 commits into
stablyai:mainfrom
LDH1103:fix/bot-slack-same-account-workspace
Open

LDH1103 wants to merge 3 commits into
stablyai:mainfrom
LDH1103:fix/bot-slack-same-account-workspace

Conversation

@LDH1103

@LDH1103 LDH1103 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

ELI5

If your other computer is signed in to the same Orca account, its bots can join the Slack workspace your bots are already in without pasting the Slack token again.

What Changed

Before: Add to Slack on a bot that lives on a paired computer, with none of that computer's bots in Slack yet, always opened the configuration refresh token form. That happened even when the paired computer was signed in to this desktop's own Orca account, which already holds a grant for the workspace this desktop's bots are in. The hand-off line did not help, because it is offered only when the two accounts differ.

After: when the bot's host has no known workspace and is signed in to this desktop's Orca account, the setup uses the workspace this desktop's bots are in (most recent first) and goes straight to Approve in Slack.

Mechanism:

  • slack-setup-teams.ts: new knownAccountSlackTeam(bot) keeps knownSlackTeam(hostBots(bot)) first, then falls back to this desktop's bots when the host runs as this desktop's account.
  • bot-host-orca-account.ts: readBotHostOnOwnAccount(hostId) reads the host's sign-in fresh, so the one-time setup decision does not race the first account read. It shares the predicate with useBotHostOnOwnAccount.
  • use-bot-slack-setup.ts: the not_created step uses knownAccountSlackTeam.

Why

Slack config grants belong to the Orca account (grant_expired: "the account has none for that workspace"), not to one computer, but a bot's setup only looked at its own host's bots for a workspace. The cloud has no endpoint that lists an account's grants, so the client can only learn the workspace from bots it can see. This desktop's bots are the ones it can always see, and when the host shares the account their workspace is one the account holds a grant for.

Alternatives considered:

  • Offer the hand-off line for the same account too: the hand-off mints a one-time code so another account can create the app, and the cloud answers same_account for this case. Creating the app on the host directly is the existing path.
  • A cloud endpoint listing grants: larger, crosses the contract, and not needed for this case.

The workspace picker for a bot already in Slack (otherSlackTeams) is unchanged, since its names come from the host's own bots.

Linked Issue

Fixes #45513

Visual Proof

N/A: no screen changes. The dialog now starts on its existing Approve in Slack step instead of its existing token form for this case. The updated paired dialog test covers it.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Every added test fails without this change and avoids the test anti-patterns

  • Updated BotSlackSetupDialog.paired.test.tsx: the same-account case used to assert the token form, and now asserts setUpApp on the server with this desktop's workspace and no token form. With the fix reverted, this test fails.

  • pnpm check:changed (base upstream/main): 32 checks passed on Windows. pnpm build is left to CI.

Risk

The riskiest part: a paired server signed in to this desktop's account now gets an app made in this desktop's most recent Slack workspace without asking. A second bot on one computer already does the same. If the account's grant for that workspace has lapsed, the cloud answers grant_expired and the dialog shows its existing reconnect token form. The change adds one orcaAccount.status read to the paired host, only when that host has no Slack bot yet. No saved data or contracts change, and older paired servers answer the same calls as before. Back it out with a plain revert.

Level: Low

AI Disclosure

Written with Claude Code (Claude Opus 5.5): diagnosis, code and test changes. The author asked for the fix and approved opening this PR.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Renderer-only logic: no platform, path or shortcut code. Mobile has no Slack setup flow.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • I stated the risk: what could break, for whom, and how to back it out
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…k workspace without a token

Slack config grants belong to the Orca account, but a new bot's setup only
looked at bots on its own host for a known workspace. A server signed in to
this desktop's account, with none of its bots in Slack yet, asked for a config
token the account already holds, and the hand-off line is offered only for a
different account. Fall back to this desktop's bots' workspace when the bot's
host runs as this desktop's own account.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Slack setup now checks for a known workspace on the bot’s host. If the bot is on a remote host that shares this desktop’s Orca account, setup also checks bots on this desktop’s local execution host. When Slack reports that the app is not created, setup uses the supplied team ID or falls back to the known account’s Slack team. Host account checks can request a fresh status read.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 0e52c

When a paired computer shares this desktop's Orca account, Slack setup now goes to "Approve in Slack" for a workspace already known on this desktop. If the account's grant has lapsed, the existing reconnect-token form still appears. The earlier concern about a stale status read right after sign-in is fixed and has a regression test. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a paired bot on this desktop's Orca account joins its Slack workspace without a token. It matches the raw summary and objectives, which describe skipping the configura…
Description check Passed The description follows the repository template. It includes ELI5, What Changed (before and after, plus mechanism), Why (with alternatives considered), a linked issue (Fixes #45513), Visual Proof mark…
Linked Issues check Passed Issue #45513 requires that, for a paired bot host with no known Slack workspace that runs as this desktop's Orca account, Add to Slack reuses this desktop's workspace and skips the configuration refre…
Out of Scope Changes check Passed The changed areas support the objective in #45513: slack-setup-teams.ts (new knownAccountSlackTeam, and hostBots widened to accept Pick<Bot, 'hostId'> for reuse), bot-host-orca-account.ts (`…
Full details: Title check

Explanation

The title names the main change: a paired bot on this desktop's Orca account joins its Slack workspace without a token. It matches the raw summary and objectives, which describe skipping the configuration refresh-token form when the paired host shares the desktop's account. The title is specific and uses the fix(bots) convention. It is somewhat long at 96 characters, but it stays on topic.

Full details: Description check

Explanation

The description follows the repository template. It includes ELI5, What Changed (before and after, plus mechanism), Why (with alternatives considered), a linked issue (Fixes #45513), Visual Proof marked N/A with a reason, Testing with checkboxes and the test that fails without the change, Risk with level and revert plan, AI Disclosure, the upstream boundary checkbox, Notes, and the checklist. The Review heading is empty, and the manual testing box is unchecked, but the author reports automated test results and the description explains why. Overall it is mostly complete.

Full details: Linked Issues check

Explanation

Issue #45513 requires that, for a paired bot host with no known Slack workspace that runs as this desktop's Orca account, Add to Slack reuses this desktop's workspace and skips the configuration refresh-token form. At head, knownAccountSlackTeam in slack-setup-teams.ts checks the host's own bots first, then this desktop's bots only when readBotHostOnOwnAccount returns true. readBotHostOnOwnAccount in bot-host-orca-account.ts returns true for the local host, and otherwise awaits refreshBotHostOrcaAccount(hostId, { fresh: true }) and compares the host's signed-in email with the desktop's cloud email. The fresh-read change since the previous review addresses the race: when a read is in flight, a fresh request waits for it to settle and then starts a new read. The code clears entry.reading before the awaited promise resolves, so the follow-up read is not blocked. use-bot-slack-setup.ts uses knownAccountSlackTeam in the not_created step. If no team is found, the token form still appears, as before. The paired dialog test covers the same-account case. I did not execute the tests, and the diff tool could not return the incremental diff, so the changed hunks were checked from the head file only. The different-account path is unchanged, as the issue requires.

Full details: Out of Scope Changes check

Explanation

The changed areas support the objective in #45513: slack-setup-teams.ts (new knownAccountSlackTeam, and hostBots widened to accept Pick&lt;Bot, 'hostId'&gt; for reuse), bot-host-orca-account.ts (runsAsOwnAccount shared by useBotHostOnOwnAccount and readBotHostOnOwnAccount, and the fresh option on refreshBotHostOrcaAccount, which also refreshes account status after sign-in), use-bot-slack-setup.ts (the not_created step), and the paired dialog and account tests. The otherSlackTeams picker path is unchanged, as the PR states. The fresh option is needed for the one-time setup decision to avoid the race. I found no unrelated changes. The incremental diff could not be retrieved, so the test-file changes were judged from the raw summary only.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b3649305-f93f-4c01-b681-654f3a1dae48
Commits

Reviewing files that changed from the base of the PR and between db35e7e and 0e52c2b.

Files selected for processing: 4

  • src/renderer/src/components/bots/slack/BotSlackSetupDialog.paired.test.tsx
  • src/renderer/src/components/bots/slack/use-bot-slack-setup.ts
  • src/renderer/src/lib/bot-host-orca-account.test.ts
  • src/renderer/src/lib/bot-host-orca-account.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 05400fd1-c81e-4663-8c56-14c3ce9476c0
Commits

Reviewing files that changed from the base of the PR and between 5897d88 and db35e7e.

Files selected for processing: 4

  • src/renderer/src/components/bots/slack/BotSlackSetupDialog.paired.test.tsx
  • src/renderer/src/components/bots/slack/slack-setup-teams.ts
  • src/renderer/src/components/bots/slack/use-bot-slack-setup.ts
  • src/renderer/src/lib/bot-host-orca-account.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

[Bug]: A paired Orca server on the same account asks for a Slack config token again

1 participant