Skip to content

fix(medcat-trainer): open FP, FN, and TP example dialogs - #635

Open
tomolopolis wants to merge 6 commits into
mainfrom
cursor/metrics-fp-fn-dialog-c861
Open

tomolopolis wants to merge 6 commits into
mainfrom
cursor/metrics-fp-fn-dialog-c861

Conversation

@tomolopolis

@tomolopolis tomolopolis commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Clicking a non-zero FP, FN, or TP count on a completed metrics report did not reliably open the example dialog.

The count button looked up the concept with Array.indexOf. The metrics table does not always pass the original row object (it can pass a copy, or its internal { type: 'item', raw } wrapper). That lookup returned -1 and the click threw before the dialog was shown.

Examples from current MedCAT get_stats also use snake_case fields (document_id, source_value). The dialog still expected the older spaced keys (document id, source value), so rows that did open could not show the note or link through to the annotation. Clinical text was interpolated into a Vue template without escaping, so characters such as < or {{ could break that render.

The count colours were also lost. Vuetify sets color: inherit on button and [type=button], and later .btn rules reset --bs-btn-color to the default text colour. Non-zero counts now use the NHS theme variables: true positives var(--success), false negatives var(--warning), and false positives var(--danger). Those variables are set from $theme-colors (green, grey, and red). Zero counts stay disabled.

Changes

  • Resolve FP/FN/TP examples from the clicked row, then by concept, instead of object identity.
  • Accept both the legacy spaced keys and the current snake_case stats payload when rendering and linking examples.
  • Escape clinical text before it is compiled as a template, and fall back to the stored context snippet when the full document is unavailable.
  • Mount the example dialog on document.body and open it after the click, so it is not clipped or closed by the same click.
  • When metrics are calculated, copy both key styles onto each example and look up the annotating user with either key style.
  • Paint non-zero TP, FN, and FP counts from the theme colour variables, including a matching hover background so the number stays readable.

Testing

  • npx vitest run src/tests/components/MetricsConceptSummary.spec.ts (5 tests passed). The count test checks that non-zero buttons stay enabled and that the theme variables are used.
  • In Chrome, with those variables compiled from $theme-colors, a non-zero TP computed to rgb(0, 150, 57), FN to rgb(118, 134, 146), and FP to rgb(218, 41, 28). A zero count stayed the default text colour.
  • Python metrics changes were syntax-checked. The Django suite was not run here because the trainer environment (Django, MedCAT, torch) is not installed.
Open in Web Open in Cursor 

cursoragent and others added 6 commits October 15, 2026 20:33
Clicking a concept count failed when the metrics table did not hand back
the original row, so the example dialog never opened. Current MedCAT stats
examples also use snake_case fields, which left the dialog unable to show
or link those occurrences, and unescaped clinical text could break rendering.

Resolve examples without object identity, accept both key styles, escape
note text, and mount the dialog on document.body.

Co-authored-by: tomolopolis <tomolopolis@users.noreply.github.com>
type=button matched Vuetify's color:inherit rule and overrode the outline
button colors. Keep true positives green, false negatives grey, and false
positives red.

Co-authored-by: tomolopolis <tomolopolis@users.noreply.github.com>
Bootstrap outline colors were still lost once later button rules reset
--bs-btn-color. Set the NHS green, grey, and red on the count buttons
themselves so a non-zero number keeps its colour.

Co-authored-by: tomolopolis <tomolopolis@users.noreply.github.com>
Non-zero TP, FN, and FP counts take --success, --warning, and --danger
from the NHS theme map instead of hardcoded hex values.

Co-authored-by: tomolopolis <tomolopolis@users.noreply.github.com>
… appearing alongside the context to the right of the mention
@tomolopolis
tomolopolis marked this pull request as ready for review October 18, 2026 16:40
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.

2 participants