Skip to content

FIX guard unsaved configuration changes - #2631

Open
Ching Wei Kang (WilliamK112) wants to merge 9 commits into
microsoft:mainfrom
WilliamK112:codex/guard-unsaved-config-2594
Open

Ching Wei Kang (WilliamK112) wants to merge 9 commits into
microsoft:mainfrom
WilliamK112:codex/guard-unsaved-config-2594

Conversation

@WilliamK112

@WilliamK112 Ching Wei Kang (WilliamK112) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

  • warn before discarding unsaved PyRIT Configuration or Environment & Secrets edits
  • use React Router navigation blocking for Configuration tab changes, application navigation, and browser Back/Forward
  • use a beforeunload guard for refresh, close, and hard navigation
  • guard both Configuration and Environment reload actions with the same confirmation dialog
  • track dirty content across all loaded environment files, while preserving drafts when switching between files
  • reset discarded content before continuing the requested navigation or reload

This builds on the URL-backed Configuration tabs merged in #2606 and is updated onto the current main branch.

Closes #2594.

Tests and Documentation

  • npm test -- --runInBand src/components/Configuration/Configuration.test.tsx src/components/Configuration/EnvironmentFiles.test.tsx — 20 passed
  • npm run type-check — passed
  • npm run lint — passed
  • npm run build — passed
  • full frontend suite — 1,430 passed; one unrelated LabelsBar click-away test failed both in the full run and in isolation (that component is outside this PR diff)

No documentation changes are needed for this data-loss prevention fix. JupyText was not run because the change is frontend-only.

AI assistance

I used OpenAI Codex to help implement the navigation guards, update tests, merge current main, and run validation. I reviewed the final diff and test results.

Signed-off-by: Ching-Wei Kang <ckang53@wisc.edu>
Comment thread frontend/src/components/Configuration/Configuration.tsx Outdated
Comment thread frontend/src/main.tsx Outdated

@romanlutz Roman Lutz (romanlutz) 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.

Re-reviewed a292338 from scratch. Both previous findings are addressed, and I resolved both threads:

  • Failed environment-file reloads now preserve unsaved-change protection for retained drafts, including after further editing.
  • The router now initializes after authentication restores the requested URL, so the rendered route matches the deep link.

I found no new confirmed production defects.

One caveat remains: some confirmation-dialog tests fail intermittently in JSDOM. In the diagnostic runs, the guard stayed active and the dialog was mounted, but it was marked aria-hidden. I reproduced the same failure with the unchanged shared dialog and tab controls, without this PR's guard or router code. I am therefore not treating it as a new blocking finding against this PR, but the test-reliability issue remains unresolved.

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.

Configuration silently discards unsaved changes during navigation

2 participants