fix(spa): clear dirty guard before saved navigation #349

Merged
timothy merged 2 commits from codex/344-dirty-guard into main 2026-07-14 08:02:35 +02:00
Owner

Summary

Fixes the navigation regression after saving a remote Jellyfin/Emby connection. Successful saves now clean the dirty guard synchronously before triggering navigation, so the SPA no longer treats completed work as unsaved.

Root cause

RemoteConnectionEditScreen queued its React baseline updates and dispatched synthetic popstate in the same save callback. useDirtyGuard only mirrored dirty into its ref after render/effect, so App observed stale dirty=true and could prompt/veto the successful navigation.

Audit

The only other useDirtyGuard callers—path replacements and remote libraries—remain mounted after saving and do not navigate in the same callback. Both already gate draft mutations while saving.

Change

  • useDirtyGuard returns a stable markClean callback.
  • Connection save calls it only after durable server success and immediately before navigateToPath, while still queuing the real clean baseline.
  • Address/API-key mutations are disabled and guarded while the save owns the current draft, preventing a slow completion from discarding newer edits.
  • SPA conventions document both the narrow event-boundary rule and its request-ownership requirement.
  • A real App-level regression proves the editor unmounts and the source screen mounts without a dirty prompt.

Verification

  • Negative control: the Jellyfin + Emby regression failed before the guard fix.
  • Focused: 118/118 tests passed.
  • Full web: 83 files / 742 tests passed.
  • lint, typecheck, production build, check:api, and git diff --check passed.
  • .NET solution build: succeeded with 0 warnings / 0 errors.
  • Pre-push check:api, lint, typecheck, and production build passed.
  • Cold exact-head re-review: no findings, MERGEABLE @ b9305fdee99d05209c1db6ebc48deb264e19680b.
  • Live browser E2E on a fresh built host: authenticated through the real boot gate; initial Jellyfin connect and subsequent saved-connection edit each returned HTTP 200; each round-tripped through GET /api/v1/media-sources/jellyfin; the source screen mounted and editor unmounted; zero dirty dialogs, console errors, or runtime exceptions. A local Jellyfin-compatible stub supplied only /System/Info and /Library/VirtualFolders.

Fixes #344

## Summary Fixes the navigation regression after saving a remote Jellyfin/Emby connection. Successful saves now clean the dirty guard synchronously before triggering navigation, so the SPA no longer treats completed work as unsaved. ## Root cause `RemoteConnectionEditScreen` queued its React baseline updates and dispatched synthetic `popstate` in the same save callback. `useDirtyGuard` only mirrored `dirty` into its ref after render/effect, so App observed stale `dirty=true` and could prompt/veto the successful navigation. ## Audit The only other `useDirtyGuard` callers—path replacements and remote libraries—remain mounted after saving and do not navigate in the same callback. Both already gate draft mutations while saving. ## Change - `useDirtyGuard` returns a stable `markClean` callback. - Connection save calls it only after durable server success and immediately before `navigateToPath`, while still queuing the real clean baseline. - Address/API-key mutations are disabled and guarded while the save owns the current draft, preventing a slow completion from discarding newer edits. - SPA conventions document both the narrow event-boundary rule and its request-ownership requirement. - A real App-level regression proves the editor unmounts and the source screen mounts without a dirty prompt. ## Verification - Negative control: the Jellyfin + Emby regression failed before the guard fix. - Focused: 118/118 tests passed. - Full web: 83 files / 742 tests passed. - lint, typecheck, production build, check:api, and `git diff --check` passed. - .NET solution build: succeeded with 0 warnings / 0 errors. - Pre-push check:api, lint, typecheck, and production build passed. - Cold exact-head re-review: no findings, `MERGEABLE @ b9305fdee99d05209c1db6ebc48deb264e19680b`. - Live browser E2E on a fresh built host: authenticated through the real boot gate; initial Jellyfin connect and subsequent saved-connection edit each returned HTTP 200; each round-tripped through `GET /api/v1/media-sources/jellyfin`; the source screen mounted and editor unmounted; zero dirty dialogs, console errors, or runtime exceptions. A local Jellyfin-compatible stub supplied only `/System/Info` and `/Library/VirtualFolders`. Fixes #344
timothy added 1 commit 2026-07-13 23:48:44 +02:00
fix(spa): clear dirty guard before saved navigation
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 6s
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 7s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 11s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 11s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m29s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 9m44s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
3481f98bcc
Fixes #344

Co-Authored-By: OpenAI Codex <codex@openai.com>
timothy added 1 commit 2026-07-14 00:06:56 +02:00
fix(spa): preserve remote drafts during save
Build ErsatzTV Image / decisions.md append-only (pull_request) Successful in 10s
Build ErsatzTV Image / Docs update reminder (pull_request) Successful in 11s
Build ErsatzTV Image / Formatting (changed .cs conform to .editorconfig) (pull_request) Successful in 12s
Build ErsatzTV Image / API docs in sync (OpenAPI + endpoint index) (pull_request) Successful in 13s
Build ErsatzTV Image / Build & test (.NET) (pull_request) Successful in 8m32s
Build ErsatzTV Image / EF migration integrity (SQLite + MySql) (pull_request) Successful in 9m50s
Build ErsatzTV Image / Build & push image (amd64) (pull_request) Has been skipped
b9305fdee9
Disable and gate remote connection draft inputs while a save owns the current revision. Exercise the real App-owned route transition after a successful save so the regression proves the editor unmounts without a dirty prompt.

Refs #344

Co-Authored-By: OpenAI Codex <codex@openai.com>
Author
Owner

Review-verdict: MERGEABLE @ b9305fdee9

Cold exact-head re-review found no issues. Both earlier blockers are closed; focused App/remote-connection tests pass 118/118.

Review-verdict: MERGEABLE @ b9305fdee99d05209c1db6ebc48deb264e19680b Cold exact-head re-review found no issues. Both earlier blockers are closed; focused App/remote-connection tests pass 118/118.
timothy merged commit ffb3e6d5e1 into main 2026-07-14 08:02:35 +02:00
timothy deleted branch codex/344-dirty-guard 2026-07-14 08:02:35 +02:00
Sign in to join this conversation.