Skip to content

Bug/connection mode fixes#5998

Open
EthanHealy01 wants to merge 14 commits intomainfrom
bug/connectionModeFixes
Open

Bug/connection mode fixes#5998
EthanHealy01 wants to merge 14 commits intomainfrom
bug/connectionModeFixes

Conversation

@EthanHealy01
Copy link
Copy Markdown
Contributor

@EthanHealy01 EthanHealy01 commented Mar 25, 2026

connection.rs

Added a guard at the top of set_connection_mode: if lock_connection_mode is already true in the store, the command returns early without touching connection_mode, server_config, or the lock flag. It still writes setup_completed: true so the onboarding doesn't repeat on every restart. Previously there was no Rust-side protection, so any JS call could silently overwrite an admin config.


connectionModeService.ts

Four changes:

  • loadConfig() now checks LOCAL_MODE_STORAGE_KEY regardless of the stored mode ('saas' or 'selfhosted'). Previously it only checked when mode === 'saas', so locked deployments (which keep 'selfhosted' in the store) would ignore the flag and auto-login after sign-out.

  • switchToLocal() now preserves server_config in the in-memory config when the deployment is locked, so the sign-in form can still show the correct URL after the user goes offline. Also removes the old stirling-provisioned-server-url localStorage workaround that was patching over this gap.

  • switchToSaaS() and switchToSelfHosted() both now clear JWT_EXPIRED_PROMPTED_KEY on successful sign-in, enabling the one-shot modal to fire again next time the JWT expires.

  • switchToSelfHosted() now calls selfHostedServerMonitor.start() directly — consolidated from three separate call sites in SetupWizard into this single call.


AppProviders.tsx

  • Previously, on every launch with an expired JWT, it set pendingSignIn and the modal appeared unconditionally. Now it checks JWT_EXPIRED_PROMPTED_KEY in localStorage first — sets the flag and shows the modal only if the flag isn't already set. switchToSaaS/switchToSelfHosted clear the flag on sign-in so the next expiry shows it again.

  • Previously, locked deployments (lock_connection_mode: true) would set pendingSignIn = { locked: true } which opened the modal in a non-dismissible locked state. Now locked deployments silently stay in their configured mode — the user signs in via Settings when ready.

  • Previously all first launches called switchToLocal(). Now it reads the config first — if locked with a server URL, it starts the backend and sets selfhosted mode without touching the store (which would wipe server_config). Normal first launches still go through switchToLocal().

  • Previously the monitor effect only started it (when connectionMode === 'selfhosted'). Now it also calls selfHostedServerMonitor.stop() on the cleanup path whenever the mode is anything other than selfhosted, so the status dot resets correctly on sign-out.


DesktopOnboardingModal.tsx

Removed the isLocked state and the effect that suppressed the modal for locked deployments. Previously, locked deployments skipped the onboarding entirely and relied on a non-dismissible SignInModal — but that modal no longer auto-fires. Now all deployments see the onboarding. dismissFinal now calls switchToLocal() so dismissing without signing in leaves the app in a usable local mode rather than stranded.


SetupWizard/index.tsx

Three changes:

  • loadLockedConfig() drops the localStorage.getItem('stirling-provisioned-server-url') fallback — now unnecessary since switchToLocal() preserves server_config in memory.

  • "Connect to a different server" is now always rendered on the unreachable screen. When locked it shows as a custom disabled element with a hover tooltip ("Your organisation has restricted this app to a specific server").

  • Use local tools instead" on the self-hosted login screen is now always visible — previously it was only shown on unlocked deployments and hidden on locked ones, which was the opposite of what was needed


licenseService.ts

Added suppressErrorToast: true to the getLicenseInfo request. The LicenseContext already handles failures gracefully via error state — the global handleHttpError interceptor was showing a noisy "Server error" toast for the 500 response when opening Settings in local mode.


setup-env.ts / .env.desktop.example

Added getOptionalKeys() which reads # optional inline comments from example env files. Keys marked optional are excluded from the missing-key check in ensureEnvFile. Used to mark VITE_DEV_SIMULATE_EXPIRED_JWT as optional so it doesn't block dev builds that haven't set it.

@EthanHealy01 EthanHealy01 marked this pull request as ready for review March 25, 2026 21:58
@dosubot dosubot bot added the size:S This PR changes 10-29 lines ignoring generated files. label Mar 25, 2026
@stirlingbot stirlingbot bot added the Front End Issues or pull requests related to front-end development label Mar 25, 2026
@dosubot dosubot bot added the Bugfix Pull requests that fix bugs label Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

📦 Tauri Desktop Builds Ready!

The desktop applications have been built and are ready for testing.

Download Artifacts:

🐧 Linux x64: Download Stirling-PDF-linux-x86_64 (.deb, .AppImage) - 215.3 MB
🍎 macOS Intel: Download Stirling-PDF-macos-x86_64 (.dmg) - 210.5 MB
🪟 Windows x64: Download Stirling-PDF-windows-x86_64 (.exe, .msi) - 229.0 MB
🍎 macOS ARM64: Download Stirling-PDF-macos-aarch64 (.dmg) - 208.8 MB


Built from commit 9a8e5dd
Artifacts expire in 7 days

@ConnorYoh ConnorYoh requested a review from Ludy87 as a code owner March 26, 2026 12:07
@stirlingbot stirlingbot bot added Test Testing-related issues or pull requests Gradle Pull requests that update Gradle code Tauri Pull requests that update Tauri code and removed Bugfix Pull requests that fix bugs labels Mar 26, 2026
@stirlingbot
Copy link
Copy Markdown
Contributor

stirlingbot bot commented Mar 26, 2026

🌐 TOML Translation Verification Summary

🔄 Reference Branch: pr-branch

📃 File Check: en-GB/translation.toml

  1. Test Status:Passed
  2. Test Status:Passed
  3. Test Status:Passed

✅ Overall Check Status: Success

Thanks @EthanHealy01 for your help in keeping the translations up to date.

Copy link
Copy Markdown
Contributor

@ConnorYoh ConnorYoh left a comment

Choose a reason for hiding this comment

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

Wait

  - Rust guard preserves server_config/lock when set_connection_mode is
    called on a locked deployment; still writes setup_completed so
    onboarding doesn't repeat on every restart
  - switchToLocal() preserves server_config on locked deployments;
    loadConfig() respects LOCAL_MODE_STORAGE_KEY regardless of stored mode,
    fixing auto re-login after sign-out on locked deployments
  - selfHostedServerMonitor.start() consolidated into switchToSelfHosted()
    as the single calling point
  - Removed automatic sign-in modal on every launch with expired JWT;
    replaced with a one-shot prompt per expiry cycle using a localStorage
    flag cleared on next successful sign-in
  - selfHostedServerMonitor.stop() called immediately on leaving selfhosted
    mode so the status dot resets correctly
  - First-launch locked deployments skip switchToLocal() to avoid clearing
    server_config from the store
  - Suppress error toast on license-info 500s (LicenseContext handles silently)
@dosubot dosubot bot added size:L This PR changes 100-499 lines ignoring generated files. and removed size:S This PR changes 10-29 lines ignoring generated files. labels Mar 29, 2026
@stirlingbot
Copy link
Copy Markdown
Contributor

stirlingbot bot commented Mar 30, 2026

✅ Backend License Check Passed

All backend dependencies have valid and allowed licenses.

The backend license report has been updated successfully.

{children}
</div>
{hovered && (
<div className="absolute left-1/2 -translate-x-1/2 bottom-[calc(100%+8px)] text-white whitespace-nowrap pointer-events-none z-[1000] shadow-lg rounded-[var(--mantine-radius-sm)] text-[.8rem] bg-[var(--mantine-color-dark-7)] px-[10px] py-[6px]">
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.

inline z index used here. These really long class names are hard to read. Should we be using theme based css for this. Are they all actually needed. Should each one even be a component that we can reuse?

if (!authChecked || !pendingSignIn) return;
window.dispatchEvent(new CustomEvent(OPEN_SIGN_IN_EVENT, { detail: pendingSignIn }));
setPendingSignIn(null);
window.dispatchEvent(new CustomEvent(OPEN_SIGN_IN_EVENT, { detail: { locked: false } }));
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.

Why are we no longer conditional on locked?

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.

Double check the version bump is needed in this PR and is still correct

EthanHealy01 and others added 2 commits April 1, 2026 00:17
@stirlingbot stirlingbot bot removed Test Testing-related issues or pull requests Gradle Pull requests that update Gradle code labels Mar 31, 2026
@stirlingbot
Copy link
Copy Markdown
Contributor

stirlingbot bot commented Mar 31, 2026

🚀 V2 Auto-Deployment Complete!

Your V2 PR with embedded architecture has been deployed!

🔗 Direct Test URL (non-SSL) http://54.175.155.236:5998

🔐 Secure HTTPS URL: https://5998.ssl.stirlingpdf.cloud

This deployment will be automatically cleaned up when the PR is closed.

🔄 Auto-deployed for approved V2 contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Front End Issues or pull requests related to front-end development size:L This PR changes 100-499 lines ignoring generated files. Tauri Pull requests that update Tauri code Translation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants