Fix Copilot login prompt appearing after integrator sign-in#2139
Conversation
📝 WalkthroughWalkthroughCentralizes SSO completion into Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AI_Machine as AI Machine
participant Platform
participant Copilot
participant CredStore as Credential Store
Client->>AI_Machine: openLogin / subscribe event
AI_Machine->>Platform: request STS
Platform-->>AI_Machine: return STS
AI_Machine->>Copilot: exchange STS for Copilot token
Copilot-->>AI_Machine: return Copilot token
AI_Machine->>CredStore: store credentials as `BI_INTEL`
CredStore-->>AI_Machine: confirm store
AI_Machine-->>Client: emit COMPLETE_AUTH (or LOGIN/CANCEL_LOGIN/LOGOUT per state)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@workspaces/ballerina/ballerina-extension/src/views/ai-panel/aiMachine.ts`:
- Around line 408-416: bridgePlatformLogin currently always sends
AIMachineEventType.COMPLETE_AUTH which is only handled in
Authenticating.ssoFlow, so when called from the inUnauthenticated path the
machine stays in Unauthenticated; update bridgePlatformLogin to detect the
caller/state and emit a transition handled by Unauthenticated (or add a new
event) instead of unconditionally sending COMPLETE_AUTH — e.g., add a
conditional around aiStateService.send to dispatch an event handled by the
Unauthenticated flow (or create and dispatch a new AIMachineEventType like
COMPLETE_AUTH_EXTERNAL and wire that into the inUnauthenticated transition), and
update the state machine handlers (Authenticating.ssoFlow or the
inUnauthenticated transition) accordingly so storing BI_INTEL credentials leads
to a real state transition.
- Around line 570-574: The catch block that currently only logs
bridgePlatformLogin errors must also notify the state machine so the UI can
recover from Authentication.ssoFlow; replace or augment the console.error in the
catch with a send(...) call that dispatches a cancel/failure event (e.g. send({
type: "CANCEL_LOGIN", error }) or send({ type: "BRIDGE_LOGIN_FAILED", error }))
so the machine receives a terminal/failure event after openLogin() resolves;
locate the try/catch around bridgePlatformLogin() in aiMachine.ts and add the
send(...) call referencing the existing state machine sender (send) and include
the caught error as payload.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ad509207-6f05-4dcc-8f0e-8e6368d30f18
📒 Files selected for processing (1)
workspaces/ballerina/ballerina-extension/src/views/ai-panel/aiMachine.ts
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
Fixes wso2/product-integrator#1319
Summary by CodeRabbit
Bug Fixes
Style