feat: auto-reload monitors for user switch and config changes#404
Open
4eh5xitv6787h645ebv wants to merge 1 commit inton00bcodr:mainfrom
Open
feat: auto-reload monitors for user switch and config changes#4044eh5xitv6787h645ebv wants to merge 1 commit inton00bcodr:mainfrom
4eh5xitv6787h645ebv wants to merge 1 commit inton00bcodr:mainfrom
Conversation
Adds two monitors that run after plugin initialization: 1. User change monitor — polls ApiClient.getCurrentUserId() every 1s and reloads the page when a different user logs in via SPA navigation. Clears all JE_ sessionStorage keys (e.g. JE_IsAdmin) before reload to prevent stale admin state leaking to non-admin users. Fixes n00bcodr#402 2. Config change monitor — snapshots public-config and private-config on entering the JE admin config page, compares against current server config on exit, and reloads only if settings actually changed. Both monitors use location polling as the primary detection mechanism because Jellyfin's SPA router uses history.pushState() which does not fire hashchange or popstate events. hashchange/popstate listeners are kept as supplementary fast-path detectors. Safety features: - 5s reload cooldown (sessionStorage) prevents infinite reload loops - Baseline userId adoption handles late plugin init (null initial user) - Monotonic snapshot token discards stale async responses on rapid nav - In-flight snapshot await (1.5s) prevents missed changes on fast exit - Graceful sessionStorage fallback for private browsing mode - Config page detection parses name= query param (not substring match) - decodeURIComponent guarded against malformed % sequences This PR was developed with AI assistance (Claude). All changes have been reviewed, tested manually, and verified with E2E tests against a live Jellyfin 10.11 dev instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
JE_sessionStorage keys (e.g.JE_IsAdmin) to prevent admin UI leaking to non-admin usershistory.pushState()which does not firehashchange/popstateeventsFixes #402
Mitigates #270 — config changes now auto-reload when leaving the config page
Mitigates #277 — stale session state is cleared on user switch
Implementation Notes
This PR was developed with AI assistance (Claude). All changes have been reviewed, tested manually, and verified with E2E tests against a live Jellyfin 10.11 dev instance.
Safety features:
name=query param (not substring match)decodeURIComponentguarded against malformed%sequencesTesting