Skip to content

TT-7484 fix going offline and back online#389

Merged
gtryus merged 6 commits into
developfrom
fix-401-token
Jul 2, 2026
Merged

TT-7484 fix going offline and back online#389
gtryus merged 6 commits into
developfrom
fix-401-token

Conversation

@gtryus

@gtryus gtryus commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-closed from 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.

Comment thread src/main/loginState.ts Outdated
// `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 thread tests/e2e/helpers.ts Outdated
Comment on lines +143 to +148
handleUnauthorized(
tokenCtx,
coordinator,
fingerprint,
setOrbitRetries
);
@gtryus gtryus merged commit 48353ad into develop Jul 2, 2026
1 check passed
@gtryus gtryus deleted the fix-401-token branch July 2, 2026 23:25
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.
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.

2 participants