Cache and centralize UT Direct login-state detection - #179
Merged
spotta85 merged 2 commits intoJul 18, 2026
Conversation
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.
Problem
We dont know if the user is logged in. We can check but thats slow
#178
Solution
Explicity manage this stuff and cache for performance :)
flowchart LR subgraph login-state.ts [login-state.ts — single owner] cache[(local:utdLoggedIn<br/>true / false / null)] probe[isLoggedIn probe fetch] end CS[Content script<br/>recordLoginStateFromPage] -->|DOM: login form?| cache CK[Cookie watcher<br/>sessionid-degree-audits-production] -->|removed → false<br/>set → verify| cache BG[Background runNewAudit] -->|refreshLoginState guard| probe POP[Popup] -->|getCachedLoginState → instant paint| cache POP -->|refreshLoginState → verify| probe cache -->|watchLoginState → live updates| POP probe --> cacheThe interface (everything else — probe URL, cookie name, storage key, redirect semantics — is private):
getCachedLoginState()refreshLoginState()watchLoginState(cb)recordLoginStateFromPage(doc)registerSessionCookieWatcher()openLoginTab()Behavior
You can basically tell with certainty if user is not logged in or what.
Use the formatting described in teh code -> first check, then do the refresh with the auxillary functions
If the session expires adn coookie not deleted, we kinda fried but tahts why you ahve to check first before doing any action that requires auth.