fix(acms): Updates logic to support PDF uploads from new modal - #423
Merged
Conversation
When a user clicks a document link on the ACMS docket page, ACMS opens a download confirmation modal. The modal does not render the docket entry ID or document name in its HTML, making it impossible to determine which docket entry was clicked from the DOM alone. This commit adds getDocumentDataFromDownloadModal, which injects a script into the page context to access the DownloadConfirmation instance via window.showDocPageInitializer.modalManager.currentComponent and extracts the docketEntryId and docketEntryDocuments. The data is stored in sessionStorage as a bridge between the page context and the extension's content script.
Refactor handleAcmsDownloadPage to support intercepting PDF downloads from the ACMS download confirmation modal and sending them to the RECAP archive. This refactor breaks the code into focused helper methods: - `isDownloadConfirmationModal`: checks if the modal is a billable download page - `resolveDocumentData`: centralizes logic for looking up the docket entry and specific document from sessionStorage - `replaceAcceptChargesButton`: swaps the default button with one that intercepts the download so we can fetch the PDF as a blob for RECAP upload - `startUploadProcess`: fetches the PDF via the merge API and hands the blob to handleDocFormResponse for upload. - `insertRecapBannerIfAvailable`: queries the RECAP archive and displays a centered download banner if a copy exists
ERosendo
force-pushed
the
401-fix-acms-logic-to-upload-pdfs
branch
from
February 8, 2026 20:37
fd64738 to
9f162ec
Compare
ERosendo
marked this pull request as ready for review
February 8, 2026 20:39
albertisfu
requested changes
Feb 11, 2026
albertisfu
left a comment
Contributor
There was a problem hiding this comment.
Thanks @ERosendo this looks good. I only found a potential issue and some code suggestions.
Contributor
Author
|
@albertisfu Thanks for your review! I’ve addressed all your comments, and the PR is ready for another look. |
Fix incorrect key (documentName) in the JSON stored in sessionStorage when showDocPageInitializer fails to load document data.
Refactor document matching to always use Array.find() instead of branching based on result count.
ERosendo
force-pushed
the
401-fix-acms-logic-to-upload-pdfs
branch
from
February 13, 2026 23:59
4344826 to
ebe24d6
Compare
albertisfu
approved these changes
Feb 17, 2026
albertisfu
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the changes @ERosendo this is now ready to be merged.
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.
What does this PR do?
Adds support to intercept PDF downloads from the new ACMS download confirmation modal and upload them to the RECAP Archive.
The new version of ACMS renders a download confirmation modal when a user clicks a document link on the docket page. The modal does not include the docket entry ID or document name in its HTML, so there’s no way to tell which document was clicked using the DOM alone.
On top of that, the modal always displays "Document 1" regardless of which docket entry is actually selected. If the extension relied on parsing this HTML to identify the document, it would incorrectly associate all downloads with docket entry 1, mixing up PDFs from different entries and causing data integrity issues (see freelawproject/recap#401 (comment))
To solve this, this PR introduces a background script function (
getDocumentDataFromDownloadModal) that injects a script into the page context to access theDownloadConfirmationinstance viawindow.showDocPageInitializer.modalManager.currentComponentand extracts thedocketEntryIdanddocketEntryDocuments. The data is stored in sessionStorage as a bridge between the page context and the extension's content script.Changes
getDocumentDataFromDownloadModal()to extract document data from the page context via script injectionhandleAcmsDownloadPageinto focused helper methods:isDownloadConfirmationModal: checks if the modal is a billable download pageresolveDocumentData: consolidates duplicated logic for looking up the docket entry and document from sessionStoragereplaceAcceptChargesButton: swaps the default button with one that intercepts the download for RECAP upload (the original PDF URL is one-time-use)startUploadProcess: fetches the PDF via the merge API and hands the blob tohandleDocFormResponsefor uploadinsertRecapBannerIfAvailable: queries the RECAP archive and displays a centered download banner if a cached copy exists