Skip to content

Explain automatically detected filing values - #216

Merged
nonprofittechy merged 3 commits into
mainfrom
fix/extraction-marker-help
Sep 3, 2026
Merged

Explain automatically detected filing values#216
nonprofittechy merged 3 commits into
mainfrom
fix/extraction-marker-help

Conversation

@nonprofittechy

@nonprofittechy nonprofittechy commented Sep 3, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace extraction-based Recommended labels with * markers in cascading choices.
  • Add an accessible help icon and modal explaining automatic detection and its possible mistakes.
  • Show the same marker and explanation on the final review page for extracted case, document, and party values.

Matching accuracy (added after review)

Marking a value as "detected from your document" is a claim, so this PR also tightens the matching that decides which option gets the marker. This slightly broadens the original scope, but the old heuristics would have made the new marker say things that were not true.

  • Courts are matched on whole words, not substrings. The extracted court guess was compared to court codes with an unanchored in, so a short county name inside a longer one won: a document reading "McHenry County" put Henry County at the top of the list and pre-selected it. Williamson matched Will, Whiteside matched White, Crawford matched Ford. Court codes drop the spaces inside a county name (stclair, rockisland), so the comparison is now against runs of whole words. That also lets a real caption match — "Circuit Court of Cook County, Illinois" now finds the Cook courts, where before it matched none.
  • An ambiguous guess is prioritized but not chosen. When the guess names only the county, every division of that county matches and none of them is what the document said, so they sit at the top of the list unselected instead of the case being filed in whichever division sorts first. A guess that names the division still selects it.
  • Levenshtein distance is gone from the other dropdowns. At a threshold loose enough to forgive a typo it also pairs unrelated options — "Motion" and "Notice" are three edits apart — and the marker turned that into a claim about the filer's document. Substring matching still covers the near misses that mattered ("Eviction" finds "Evictions"). efile/utils/str_dist.py had no other callers and is removed.
  • The case lookup help text waits for a marker to exist. It was gated on there being a court guess, not on that guess matching a court, so it could promise an asterisk that appeared nowhere on the page. (Copilot's finding.)
  • A docket number must match exactly to be marked. A filer who corrects 2026-CV-1234 to 2026-CV-123 has not left our guess in place, and the substring rule was still calling it automatically detected.
  • The modal wording now reflects that several options in a list can carry the marker.
  • The review page fetches its parties once instead of three times. (Copilot's finding.)

Validation

  • Repository pre-commit hooks passed: Ruff, djLint, Stylelint, ESLint, type checking, Bandit, and migration checks.
  • uv run pytest -q — 664 passed.
  • npm run test:unit — 43 passed.
  • Local Playwright browser smoke test passed against the Django server with LocalStack and the extraction worker running.

Screenshots

Screenshots are stored outside the repository in this public gist:

https://gist.github.com/nonprofittechy/68589d297e9072f1b27a9205b417de8d

Final review with extraction markers

Extraction marker explanation modal

🤖 Generated with Claude Code

https://claude.ai/code/session_01JCsBkAUTE8jxP4BrbPexAm

Copilot AI 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.

🟡 Changes recommended

Court prioritization currently conflates extraction guesses with location matching, which can incorrectly apply “(Recommended)” labeling to extraction-derived suggestions instead of the intended * marker.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the e-filing workflow UI to represent automatically detected (document-extracted) values with a compact * marker and provides an accessible, reusable help affordance (icon + modal) explaining what the marker means and that extraction can be wrong.

Changes:

  • Replace extraction “(Recommended)” labeling with * markers in dropdown prioritization and downstream saved display strings.
  • Add a shared help button and Bootstrap modal explaining the extraction marker, and surface it across relevant workflow pages.
  • Mark extracted values on the final review page (case fields, parties, documents) and add test coverage for the new marker behavior.
File summaries
File Description
efile_app/efile/views/review.py Computes extracted_markers to flag extracted values for the final review page.
efile_app/efile/views/case_lookup.py Adjusts guessed court source to use extraction guesses only.
efile_app/efile/api/dropdown_views.py Switches extraction matches to * marker; refines court prioritization logic for extraction vs location.
efile_app/efile/tests/test_review_submit_flow.py Adds an integration-style assertion that extracted markers and modal copy appear on final review.
efile_app/efile/tests/test_filing_types_amount_in_controversy.py Adds a unit test verifying dropdown option text uses * instead of “Recommended”.
efile_app/efile/templates/efile/workflow_base.html Includes the extraction marker modal globally in the workflow layout.
efile_app/efile/templates/efile/review.html Displays * markers next to extracted case/doc/party values and shows page-level help when relevant.
efile_app/efile/templates/efile/organize_documents.html Shows extraction marker help when a guessed filing type is present.
efile_app/efile/templates/efile/extraction_review.html Adds extraction marker help icon in the extracted document section header.
efile_app/efile/templates/efile/components/extraction_marker_modal.html New reusable modal explaining the asterisk marker.
efile_app/efile/templates/efile/components/extraction_marker_help.html New reusable help-icon button that opens the modal.
efile_app/efile/templates/efile/case_lookup.html Adds page-level help text/icon when an extracted court suggestion exists.
efile_app/efile/static/js/organize-documents.js Normalizes saved option text by stripping “(Recommended)” and * suffixes.
efile_app/efile/static/js/extraction-review.js Normalizes saved/displayed option text while still rendering the * marker when applicable.
efile_app/efile/static/js/case-lookup.js Normalizes saved court name to avoid persisting UI markers into stored text.
efile_app/efile/static/css/reorganized-flow.css Styles the page help row, help icon button, and extraction section header layout.
Review details
  • Files reviewed: 16/16 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread efile_app/efile/api/dropdown_views.py Outdated
Comment thread efile_app/efile/static/js/extraction-review.js Outdated

Copilot AI 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.

🟡 Changes recommended

There are a couple of user-facing/behavioral issues identified in the changed hunks (including a misleading help message condition and a small inefficiency in the review view) that should be addressed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

efile_app/efile/views/review.py:70

  • all_parties = list(parties) forces an immediate queryset evaluation but the list is only used once to build party_ids. You can iterate the existing parties queryset directly here and drop the extra list allocation.
  • Files reviewed: 18/18 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread efile_app/efile/templates/efile/case_lookup.html
The court guess extracted from a document was compared to court codes with
an unanchored substring test, so a short county name inside a longer one
won: a document reading "McHenry County" put Henry County at the top of the
list and pre-selected it, with an asterisk claiming the document said so.
Williamson matched Will, Whiteside matched White, Crawford matched Ford.

Compare runs of whole words instead. Court codes drop the spaces inside a
county name ("stclair", "rockisland"), so a run of words is the smallest
unit worth comparing, and it also lets a real caption match: "Circuit Court
of Cook County, Illinois" now finds the Cook courts, where before it found
none and the case lookup page still promised an asterisk that was not there.

Where the guess names only the county, every division of that county
matches and none of them is what the document said, so leave them at the
top of the list unselected rather than filing the case in whichever one
sorts first. A guess that names the division still selects it.

Drop the Levenshtein fallback for the other dropdowns. At a threshold loose
enough to forgive a typo it also pairs unrelated options - "Motion" and
"Notice" are three edits apart - and the new marker turns that into a claim
about the filer's document. Substring matching still covers the near
misses that mattered ("Eviction" finds "Evictions").

Also:
- Reveal the case lookup asterisk help only once a court in the list
  carries the marker.
- Require an exact match before marking a docket number as extracted: a
  filer correcting 2026-CV-1234 to 2026-CV-123 has not left our guess in
  place.
- Reword the modal now that several options can carry the marker.
- Fetch the review page's parties once instead of three times.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JCsBkAUTE8jxP4BrbPexAm

Copilot AI 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.

🔵 Needs a closer look

The final-review document marker logic can incorrectly mark supporting documents as “detected from your document” even though extraction data is only sourced from the current lead document.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

efile_app/efile/views/review.py:83

  • draft.extracted_guesses is only sourced from the current lead document’s extraction, but this logic marks every document whose filing_type_name matches the extracted filing type. If multiple documents share the same filing type, the review page will show * on supporting documents even though they were not the basis for the extraction, which can mislead filers.
  • Files reviewed: 19/19 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@nonprofittechy
nonprofittechy merged commit e73ea4f into main Sep 3, 2026
8 checks passed
@nonprofittechy
nonprofittechy deleted the fix/extraction-marker-help branch September 3, 2026 18:42
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.

Use a star treatment for LITEFile-recommended filing choices

2 participants