Skip to content

fix: clear Claude auth state when switching bridge modes (#4937)#5780

Open
kodjima33 wants to merge 1 commit intomainfrom
fix/issue-4937
Open

fix: clear Claude auth state when switching bridge modes (#4937)#5780
kodjima33 wants to merge 1 commit intomainfrom
fix/issue-4937

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

Fixes #4937

When switching from user's Claude account mode to Omi AI mode, the isClaudeAuthRequired flag was never cleared. This caused the auth sheet to persist in a loop even after switching to Omi mode, making AI chat completely unusable.

Fix: Clear all Claude auth state (isClaudeAuthRequired, claudeAuthUrl, claudeAuthMethods) when switching bridge modes.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 18, 2026

Greptile Summary

This PR fixes a bug (#4937) in the desktop macOS app where switching from "User's Claude Account" mode to "Omi AI" mode left isClaudeAuthRequired, claudeAuthUrl, and claudeAuthMethods populated with stale values, causing the Claude auth sheet to re-appear in a loop and making AI chat unusable.

Changes:

  • In switchBridgeMode(to:), three lines are added immediately after acpBridge.stop() to reset all Claude auth state (isClaudeAuthRequired = false, claudeAuthUrl = nil, claudeAuthMethods = []) before the new bridge is created.
  • The fix is minimal, targeted, and correct — the class is @MainActor so these updates are safely serialized with all other state mutations.

Issue found:

  • The companion function disconnectClaude() follows the same pattern (stop bridge → switch to Omi mode) but does not include the equivalent auth-state reset. If isClaudeAuthRequired is true at the time of disconnect, the stale auth sheet will persist after disconnection, the same underlying bug.

Confidence Score: 4/5

  • Safe to merge; the fix is correct and targeted, with one closely related omission in disconnectClaude worth addressing.
  • The change is a small, clearly correct three-line fix on a well-understood @MainActor class. The only concern is that the parallel disconnectClaude path has the same auth-state omission that this PR fixes in switchBridgeMode, which could surface as a related bug.
  • desktop/Desktop/Sources/Providers/ChatProvider.swift — specifically the disconnectClaude function around lines 718-723.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/Providers/ChatProvider.swift Adds three state-clearing lines in switchBridgeMode to reset Claude auth state when switching bridge modes; correctly fixes the stale-auth-sheet loop bug. The parallel code path in disconnectClaude has the same omission.

Sequence Diagram

sequenceDiagram
    participant UI as UI / Picker
    participant CP as ChatProvider (@MainActor)
    participant Bridge as ACPBridge

    UI->>CP: switchBridgeMode(to: .omiAI)
    CP->>Bridge: stop()
    Bridge-->>CP: (stopped)
    Note over CP: ✅ NEW: clear isClaudeAuthRequired<br/>clear claudeAuthUrl<br/>clear claudeAuthMethods
    CP->>CP: bridgeMode = "omiAI"
    CP->>Bridge: ACPBridge(passApiKey: true)
    CP->>CP: ensureBridgeStarted()
    Bridge-->>CP: started
    Note over CP: Auth sheet dismissed ✓

    UI->>CP: disconnectClaude()
    CP->>Bridge: stop()
    Bridge-->>CP: (stopped)
    Note over CP: ❌ MISSING: auth state NOT cleared<br/>(isClaudeAuthRequired may still be true)
    CP->>CP: isClaudeConnected = false
    CP->>CP: bridgeMode = "omiAI"
    CP->>Bridge: ACPBridge(passApiKey: true)
    Note over CP: Auth sheet may still show ✗
Loading

Comments Outside Diff (1)

  1. desktop/Desktop/Sources/Providers/ChatProvider.swift, line 718-723 (link)

    P1 Auth state not cleared in disconnectClaude

    disconnectClaude stops the bridge and recreates it (switching back to Omi AI mode) but never resets isClaudeAuthRequired, claudeAuthUrl, or claudeAuthMethods. If the user initiates a disconnect while the auth sheet is still showing (i.e., isClaudeAuthRequired == true), those stale values survive and the auth sheet will continue to be displayed even after the function returns — the same root cause that this PR fixes for switchBridgeMode.

Last reviewed commit: "fix: clear Claude au..."

@beastoin
Copy link
Copy Markdown
Collaborator

Hey @kodjima33 👋 Friendly reminder — this PR has been quiet for a bit. If you don't need further assistance from the CTO, feel free to go ahead and merge it. Let's close the loop and not let it go stale. Thanks!

@pdudas76
Copy link
Copy Markdown

pdudas76 commented Apr 3, 2026

Could this also cause issues switching from Omi to Claude?

The UI notes that a sign in prompt should appear to log into claude after selecting that option in the AI Chat settings. Instead of prompting a login to Claude, I get a message to upgrade to Omi Pro.

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: Latest macOS beta breaks AI chat entirely

3 participants