Skip to content

STUDYU-57 fix(flutter_common): isolate debug storage by environment - #886

Draft
johannesvedder wants to merge 5 commits into
devfrom
fix/supabase-session-storage
Draft

johannesvedder wants to merge 5 commits into
devfrom
fix/supabase-session-storage

Conversation

@johannesvedder

Copy link
Copy Markdown
Contributor

Description

Switching STUDYU_ENV while reusing fixed localhost ports caused Flutter web to restore Supabase sessions and participant-local data from the previous environment. The stale credentials produced invalid JWT and refresh-token failures until browser storage was cleared manually.

This change namespaces all SecureStorage keys by STUDYU_ENV in debug builds. .env.dev and .env.local therefore keep separate sessions, participant credentials, selected subjects, caches, and onboarding state. Debug .env and all profile/release builds retain the existing unscoped keys, so deployed participants and Designer users keep their current storage behavior. Supabase fallback URLs within one environment continue sharing the same namespace.

The storage namespace is selected before environment loading, and each operation resolves its key before waiting for the storage lock.

Testing Steps

  1. Run the app on port 8080 with --dart-define=STUDYU_ENV=.env.dev and create or restore participant state.
  2. Restart it on the same port with .env.local; verify it does not restore the .env.dev session or participant data.
  3. Switch back to .env.dev; verify its previous debug state is restored.
  4. Repeat the environment switch for Designer on port 8081 and verify no stale refresh-token errors occur.
  5. Run cd flutter_common && rtk fvm flutter test.
  6. Run scripts/pre-commit-check from the repository root.

PR Checklist

  • Formatting passes via scripts/pre-commit-check
  • Dart and Flutter analyzers pass via scripts/pre-commit-check
  • No visual changes
  • Manual app and Designer environment-switch flow verified

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit fbdcaad):

(expires Tue, 21 Jul 2026 09:55:25 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 2149dad49ed83535217e50d5c18c0c8c90da629b

@johannesvedder
johannesvedder force-pushed the fix/supabase-session-storage branch from a7a25b3 to fbdcaad Compare July 14, 2026 09:49
@johannesvedder johannesvedder linked an issue Jul 16, 2026 that may be closed by this pull request
@ibrahimozkn ibrahimozkn changed the title fix(flutter_common): isolate debug storage by environment STUDYU-57 fix(flutter_common): isolate debug storage by environment Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem connecting to the HPI database in App.

1 participant