Title: fix(mship): return the chat connect flow to the tab that started it by j15z · Pull Request #6403 · simstudioai/sim · GitHub
Open Graph Title: fix(mship): return the chat connect flow to the tab that started it by j15z · Pull Request #6403 · simstudioai/sim
X Title: fix(mship): return the chat connect flow to the tab that started it by j15z · Pull Request #6403 · simstudioai/sim
Description: Summary Chat credential connects now run in a popup that returns through a new self-closing /oauth/chat-complete page, so the chat tab updates in place instead of the flow landing on a duplicate copy of the app in a new tab The connect verdict now comes from the server routing the flow to its success callback, not from diffing the workspace credential list — that diff reported failure whenever you re-authorized an account you had already linked, since that path updates the account row and creates no new credential The row's connected lock is stricter than its label: a swallowed credential-draft failure leaves the row retryable instead of latching it shut with nothing behind it The popup is named per attempt, so sibling credential rows can't renavigate each other's window A cross-origin connect URL stays on the anchor (keeping rel="noopener") instead of taking the popup path The focus verifier reads the attempt after its refetch, so a verdict published mid-flight isn't overwritten, and it treats a popup parked on /oauth-error or the workspace error exit as finished rather than waiting on it Desktop Unaffected — the desktop app never reaches the popup path. Desktop can't run OAuth in an embedded window: Better Auth binds the flow's state to the initiating browser's cookies, the Sim browser panel's partition isn't signed in to Sim, and Google/Microsoft reject embedded user agents outright. So the chip hands the whole flow to the system browser through the desktop bridge (beginOAuthConnect), which opens /desktop/connect, runs the authorize route there, and bounces /desktop/connect/complete to the app's 127.0.0.1 loopback. The app refocuses itself and refreshes credentials off that push. Why this PR can't touch it: onConnectClick takes the bridge branch and returns before buildOAuthChatCompleteAuthorizeUrl or window.open is ever called, so popupRef is never set on desktop. Every guard added here keys off that ref — isPopupStillOpen(null) exits on its first line — which makes the terminal-path check and the per-attempt popup naming unreachable. Completion still arrives through useDesktopOAuthConnectListener in use-oauth-return.ts, untouched by this PR, and desktop keeps its own attempt correlation via setActiveDesktopOAuthChatAttempt / resolveDesktopOAuthChatAttempt. Type of Change Bug fix Testing Tested manually. bun run lint, check:audits (22 audits), check:api-validation, and type-check all pass. 173 test files / 1800 tests green, including new coverage for the close-refused redirect and its cross-origin returnTo rejection, the per-attempt popup name, the terminal-page settle, and the retryable-lock behavior. Not verified in a real browser: whether COOP: same-origin on /oauth/chat-complete ever refuses window.close(). It closed fine in manual testing; the 400ms redirect is the fallback if it doesn't. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary Chat credential connects now run in a popup that returns through a new self-closing /oauth/chat-complete page, so the chat tab updates in place instead of the flow landing on a duplicate c...
X Description: Summary Chat credential connects now run in a popup that returns through a new self-closing /oauth/chat-complete page, so the chat tab updates in place instead of the flow landing on a duplicate c...
Opengraph URL: https://github.com/simstudioai/sim/pull/6403
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:48329d67-dc7f-f995-8802-ec4cf6964c55 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E460:7D93E:971040:CF4FC8:6AFB4C03 |
| html-safe-nonce | 09d8a201c96dd8a79a514a1d056db61405eec20f3041153b42816d447aad952c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNDYwOjdEOTNFOjk3MTA0MDpDRjRGQzg6NkFGQjRDMDMiLCJ2aXNpdG9yX2lkIjoiNDc1NTM0OTUxNTE3NzUxMTkzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0d2fa2eca7a5dd2e9255170bd8b3101dd8e99e6b6ff58e49d509c5c3eb5137c7 |
| hovercard-subject-tag | pull_request:4233134711 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6403/files |
| twitter:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/96924014?s=400&v=4 |
| og:image:alt | Summary Chat credential connects now run in a popup that returns through a new self-closing /oauth/chat-complete page, so the chat tab updates in place instead of the flow landing on a duplicate c... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | acf7616d06cc051644705b379878c9bb13dc5e70ecf4ffd9b34140f8ac01d7e1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 26504db649b58525278f77a52b80ba5f10d5f4de |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width