Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: clear all Slack client cache on token update and disconnect#143

Merged
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/slack-workspace-switchingbreaking-brake/cc-wf-studio:fix/slack-workspace-switchingCopy head branch name to clipboard
Nov 24, 2025
Merged

fix: clear all Slack client cache on token update and disconnect#143
breaking-brake merged 1 commit intomainbreaking-brake/cc-wf-studio:mainfrom
fix/slack-workspace-switchingbreaking-brake/cc-wf-studio:fix/slack-workspace-switchingCopy head branch name to clipboard

Conversation

@breaking-brake
Copy link
Copy Markdown
Owner

Problem

When updating Slack workspace token directly (without deleting the old token first), the workspace did not switch properly.

Current Behavior

  1. Connect with Workspace A token
  2. Update directly to Workspace B token (without deletion)
  3. ❌ Stays on Workspace A (does not switch)

Expected Behavior

  1. Connect with Workspace A token
  2. Update directly to Workspace B token (without deletion)
  3. ✅ Switches to Workspace B

Workaround (Before Fix)

  1. Connect with Workspace A token
  2. Delete token
  3. Connect with Workspace B token
  4. ✅ Switches to Workspace B (works correctly)

Solution

Since the delete → create flow was working correctly, we made token update flow use exactly the same implementation as the delete → create flow.

Root Cause

SlackTokenManager.storeManualConnection() only adds a new token without deleting old ones. This caused:

  • Both Workspace A and Workspace B tokens remain in Secret Storage
  • Workspace A's WebClient remains cached in SlackApiService
  • Result: System continues to use Workspace A

Changes

File 1: src/extension/commands/slack-connect-manual.ts

Changes:

  • Call tokenManager.clearConnection() before storing new token to delete all existing tokens
  • Changed invalidateClient(workspaceId) to invalidateClient() to clear all WebClient cache
// Step 3: Clear existing connections before storing new one (same as delete → create flow)
await tokenManager.clearConnection();

// Step 4: Store connection in VSCode Secret Storage
await tokenManager.storeManualConnection(
  workspaceId,
  workspaceName,
  workspaceId,
  accessToken,
  ''
);

// Invalidate SlackApiService client cache to force re-initialization
slackApiService.invalidateClient();  // Changed from invalidateClient(workspaceId)

File 2: src/extension/commands/open-editor.ts

Changes:

  • Added slackApiService.invalidateClient() call in SLACK_DISCONNECT message handler
case 'SLACK_DISCONNECT':
  try {
    await slackTokenManager.clearConnection();
    slackApiService.invalidateClient();  // ← Added
    vscode.window.showInformationMessage('Slack Bot Token deleted successfully');
    // ...
  }

Impact

  • ✅ Direct token update (Workspace A → B) now works correctly
  • ✅ Delete → create flow behavior unchanged (maintains existing behavior)
  • ✅ Multiple workspace management not supported (single workspace only)
  • ✅ Secret Storage and cache are reliably synchronized

Testing

  • Manual E2E testing completed
    • Connect with Workspace A token
    • Update directly to Workspace B token (no deletion)
    • Workspace B is displayed correctly
    • Sharing to Workspace B succeeds
  • Code quality checks passed (format, lint, check)
  • Build successful

Notes

This fix makes the token update flow use the exact same implementation as the delete → create flow. This prevents future bugs and ensures consistent behavior.

- Added tokenManager.clearConnection() before storeManualConnection() to match delete → create flow
- Changed invalidateClient(workspaceId) to invalidateClient() to clear all cached clients
- Added invalidateClient() call in SLACK_DISCONNECT handler
- Ensures workspace switching works correctly when updating tokens directly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@breaking-brake breaking-brake merged commit 4ab26dd into main Nov 24, 2025
3 checks passed
@breaking-brake breaking-brake mentioned this pull request Nov 24, 2025
github-actions Bot added a commit that referenced this pull request Nov 24, 2025
## [2.12.2](v2.12.1...v2.12.2) (2025-11-24)

### Bug Fixes

* clear all Slack client cache on token update and disconnect ([#143](#143)) ([4ab26dd](4ab26dd))

### Documentation

* add Slack sharing demo GIFs and reorganize Key Features ([#142](#142)) ([9ef4d05](9ef4d05))
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.12.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@breaking-brake breaking-brake deleted the fix/slack-workspace-switching branch November 24, 2025 09:19
@breaking-brake breaking-brake mentioned this pull request Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.