Fix: Slack "Add to Slack" dead-ends on "not signed in" for expired cloud sessions - #660
Open
Nabilhassan12345 wants to merge 1 commit into
Open
Nabilhassan12345 wants to merge 1 commit into
Nabilhassan12345 wants to merge 1 commit into
Conversation
…ssions cloud.status() only checked for an access_token's presence, not its freshness, so the GUI kept showing "signed in" (and the live "Add to Slack" button) after a session had actually expired. Clicking it hit begin_managed_connect's real fresh_access_token check, which correctly rejected it — but the modal just printed the bare error with no way to recover. SlackOneClick now treats a signed_in:false response from connectManaged as a session-expiry signal, switches into the sign-in prompt, and auto-resumes the Slack connect once sign-in completes. Fixes andrewyng#658 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #658
Root cause
Two backend checks disagree about sign-in state:
cloud.status()(cloud.py:213-219), which powers the GUI's polled/v1/cloud/statusandcloud.signed_in, only checksbool(profile.get("access_token"))— presence of a token, not whether it's expired.begin_managed_connect()(cloud.py:345-363), which actually runs on "Add to Slack," callsfresh_access_token(), which checks expiry and tries to refresh — correctly returning{"ok": false, "error": "not signed in", "signed_in": false}when the token is expired with no usable refresh token.So once a stored session expires, the GUI still shows "signed in" and renders the live "Add to Slack" button. Clicking it hits the real check, which rejects it, and the button's error branch just printed the raw "not signed in" string with no recovery path — exactly what's in the issue screenshot.
Fix (frontend only,
surfaces/gui/src)CloudSignIn.tsx:CloudSignInInlinenow accepts an optionalonSignedIncallback, fired once a poll confirms sign-in landed.AddConnectionModal.tsx(SlackOneClick): whenconnectManagedreturnssigned_in: false, the pane now switches into the sign-in prompt instead of dead-ending, passinggoasonSignedInso the Slack connect auto-resumes once sign-in completes — no second click needed. A waiting state takes render priority so this doesn't flash "Sign in" again while the Slack OAuth tab is open.api.ts: typedconnectManaged's response to include thesigned_infield the backend already sends.Deliberately did not change
cloud.status()itself — making it do a live refresh on every 5s poll would add blockinghttpxcalls intoslack_status()/github_status()(called fromasync defroutes withoutasyncio.to_thread), which is a separate, riskier change outside this bug's scope.Tests
AddConnectionModal.slack.test.tsx(5 cases): button shown when signed in; stale-signed-in rejection recovers into sign-in instead of dead-ending; sign-in auto-resumes the Slack connect; a genuine non-auth error still shows as an error; fully-signed-out path also auto-continues.test_cloud.py/test_cloud_server.pypin the contract:cloud.status()can saysigned_in: Truefrom a stale profile whilebegin_managed_connect/connect-managedcorrectly returnsigned_in: False— the frontend depends on that field, not the error string.Test plan
npx tsc --noEmitclean;vitest run— 186/186 passed.pytest tests/test_cloud.py tests/test_cloud_server.py— 40/40 passed. Full suite: 1935 passed, 19 pre-existing failures unrelated to this change (missing optional boto3/slack-bolt deps, sandboxed git worktree) — no production Python code touched.slack-workspaces.spec.tsetc.) — needs a live server + browser install; vitest coverage exercises the same DOM/testids a browser would.refresh_tokenfrom the storedcloud:authprofile, or wait out expiry) → Slack → Connect → One click → Add to Slack.Screenshots
Before — stale-but-"signed in" session: live "Add to Slack" button dead-ends on a bare "not signed in".

After — same stale session: recovers into a real sign-in prompt instead of dead-ending.

After (auto-resumed) — signing back in automatically resumes the Slack connect, no second click.

🤖 Generated with Claude Code