TT-7484 fix going offline and back online#389
Merged
Merged
Conversation
added 5 commits
July 2, 2026 15:53
- I get a blank electron app when I use this commit
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves offline/online transition reliability in the Electron app by hardening 401/unauthorized recovery paths, preventing the main process from quitting during login window handoffs, and adding Playwright e2e coverage for the “Go Offline” restart flow.
Changes:
- Add shared 401 recovery (
handleUnauthorized) usage to avoid getting stuck on the loading screen and centralize session invalidation behavior. - Fix Electron “Go Offline” to relaunch the app (instead of quitting) and prevent
window-all-closedfrom quitting the app during login/auth window transitions. - Expand e2e helpers/specs to cover login, team/project creation + save, and the “Go Offline” restart regression.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/e2e/helpers.ts | Adds robust e2e helpers for login, Orbit-queue polling, and cleanup when “Go Offline” relaunches into an untracked process. |
| tests/e2e/electron.spec.ts | Refactors login flow and adds an end-to-end regression test covering save + “Go Offline” restart behavior. |
| src/renderer/src/store/orbit/actions.tsx | On 401 during initial orbit load, triggers the same unauthorized recovery used by Orbit strategies instead of hanging. |
| src/renderer/src/store/importexport/electronExport.tsx | Prevents a crash by guarding against op.attributes being undefined. |
| src/renderer/src/Sources.tsx | Exposes and reuses a shared unauthorized handler; fixes requestQueue.retry call to actually execute. |
| src/renderer/src/routes/Loading.tsx | Avoids misrouting offline users to profile creation; prevents duplicate force-login behavior. |
| src/renderer/src/crud/orbitReset.ts | Logs orbit reset retry failures instead of silently swallowing them. |
| src/renderer/src/context/TokenProvider.tsx | Centralizes “invalidate session + force login” behavior in one canonical place. |
| src/renderer/src/components/ProfileDialog.tsx | Simplifies the dialog title rendering logic. |
| src/renderer/src/components/App/HeadStatus.tsx | Handles and logs offlineAvailToggle failures to avoid unhandled promise rejections. |
| src/renderer/src/components/App/AppHead.tsx | Fixes offline logout loop and relaunches the app when going offline instead of quitting. |
| src/main/loginState.ts | Introduces shared “login in progress” state to coordinate main/auth processes around window handoffs. |
| src/main/ipcMethods.ts | Ensures relaunch actually exits, and guards window-all-closed from quitting during login handoff. |
| src/main/index.ts | Removes the unconditional duplicate window-all-closed handler so the guarded one in ipcMethods.ts is authoritative. |
| src/main/auth-process.ts | Uses shared login-state guard to prevent app quit during Auth0 window → main window transitions. |
| // `window-all-closed` (registered in ipcMethods.ts) must not quit the app | ||
| // while that replacement is in flight — even though the window count can | ||
| // legitimately hit zero for an instant during the handoff. | ||
| let isLogingIn = false; |
Comment on lines
+143
to
+148
| handleUnauthorized( | ||
| tokenCtx, | ||
| coordinator, | ||
| fingerprint, | ||
| setOrbitRetries | ||
| ); |
… in fetchOrbitData (copilot)
gtryus
added a commit
that referenced
this pull request
Jul 2, 2026
Fixes a "Go Offline" crash caused by multiple interacting bugs: - window-all-closed race: Two separate handlers existed — one in index.ts (unconditional app.quit()) and one in ipcMethods.ts (guarded by isLogingIn). The index.ts handler fired first, killing the app mid-window-handoff. - exitApp vs relaunchApp: "Go Offline" called exitApp() (just quits), leaving the user staring at nothing. Needed relaunchApp() to restart into the offline session. - app.relaunch() doesn't exit: Without an explicit app.exit(), the old process stayed alive. - Infinite logout loop offline: expiresAt === -1 triggered logout unconditionally, even when legitimately offline. - Profile completeness bounce: Offline users were incorrectly sent to /createProfile because local-only data lacked profile fields. - 401 black hole: fetchOrbitData silently returned on 401, leaving the loading screen stuck forever. Additionally: isLogingIn is extracted to a shared module, forceLogin() is consolidated into invalidateOnlineSession(), previously-swallowed errors are now logged, and a comprehensive E2E test covers team creation through "Go Offline" relaunch.
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.
Enhance the handling of 401 errors by streamlining the recovery process and improving error logging. Implement functionality for transitioning between online and offline states, ensuring a smoother user experience when going offline or back online. Address issues related to app behavior during these transitions.