Skip to content

refactor: extract app overlay logic into dedicated module#59

Merged
timcogan merged 2 commits intomasterfrom
refactor/overlay-module
Mar 27, 2026
Merged

refactor: extract app overlay logic into dedicated module#59
timcogan merged 2 commits intomasterfrom
refactor/overlay-module

Conversation

@timcogan
Copy link
Copy Markdown
Owner

@timcogan timcogan commented Mar 26, 2026

Summary by CodeRabbit

  • Refactor

    • Internal overlay management reorganized for improved maintainability; overlay behavior preserved and more modular.
  • New Features

    • Improved overlay navigation and “jump to next” across viewports and frames.
    • More reliable attach/detach and visibility toggling for streamed and parametric overlays, including better handling across grouped views.
  • Documentation

    • Verification checklist updated to require paired benchmark runs and median-delta reporting for key load/render metrics.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Overlay management (GSPS, SR, Parametric Map) was extracted from src/app.rs into a new module src/app/overlay.rs. Overlay merge/attach/pending/authoritative workflows, visibility/navigation, and history sync logic moved into the new module; DESIGN.md was updated accordingly.

Changes

Cohort / File(s) Summary
Documentation
DESIGN.md
Reattributed overlay verification scope from src/app.rs to src/app/overlay.rs and added benchmark checklist requiring paired baseline-vs-refactor make benchmark runs and median delta reporting for total, startup, dicom_load, render_ui.
Module Extraction
src/app.rs
Removed ~790 lines of overlay-related private methods and the OverlayNavigationTarget definition; added mod overlay; declaration.
New Overlay Module
src/app/overlay.rs
Added ~805 lines implementing overlay management: merge/insert/attach for GSPS/SR/Parametric Map, pending overlay staging/merge, set-authoritative workflows (with detach from current study + history sync), overlay-target frame computation, navigation (next/jump), toggle/visibility, and texture refresh/repain scheduling.

Sequence Diagram(s)

sequenceDiagram
  participant UI as "egui UI"
  participant App as "DicomViewerApp"
  participant Overlay as "overlay module"
  participant History as "History/Cache"
  participant Image as "DicomImage"

  UI->>App: user toggles overlays / requests next overlay
  App->>Overlay: next_overlay_navigation_target()
  Overlay-->>App: OverlayNavigationTarget (viewport,frame)
  App->>Image: update active frame / viewport
  App->>Overlay: ensure overlays visible / attach pending
  Overlay->>History: sync authoritative/pending changes
  Overlay-->>App: overlay attach results
  App->>UI: refresh_active_textures(ctx) / schedule repaint
  UI-->>Image: render with overlays
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I dug a neat little burrow for overlays,
GSPS, SR, PM hopped in to play—
Merged, attached, and marching through frames,
History kept tidy, UI paints the day,
Hooray for tidy code and hops all the way! 🎨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: extracting overlay-related code from src/app.rs into a new dedicated src/app/overlay.rs module.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/overlay-module

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
DESIGN.md (1)

77-83: Add the benchmark step for this refactor path.

The new verification bucket covers app/overlay.rs, but it still omits the baseline-vs-refactor benchmark run. Since this PR moves a fairly hot chunk of viewer logic, I'd keep that perf gate in this checklist too so regressions are caught alongside the functional checks.

Based on learnings: After large refactors, run make benchmark on the baseline and refactor versions with the same BENCH_* settings, and report median deltas for total, startup, dicom_load, and render_ui.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DESIGN.md` around lines 77 - 83, Add a benchmark step to the verification
checklist: when validating changes touching app/overlay.rs (and related
app/load.rs and app/history.rs) run baseline vs refactor benchmark runs via the
tools/benchmark path (invoke the Makefile target `make benchmark` with identical
BENCH_* environment settings) and report median deltas for the named metrics
`total`, `startup`, `dicom_load`, and `render_ui`; update the checklist entry
(the tooling/benchmark item) to require these paired runs and a short summary of
median regressions before approving the PR.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@DESIGN.md`:
- Around line 77-83: Add a benchmark step to the verification checklist: when
validating changes touching app/overlay.rs (and related app/load.rs and
app/history.rs) run baseline vs refactor benchmark runs via the tools/benchmark
path (invoke the Makefile target `make benchmark` with identical BENCH_*
environment settings) and report median deltas for the named metrics `total`,
`startup`, `dicom_load`, and `render_ui`; update the checklist entry (the
tooling/benchmark item) to require these paired runs and a short summary of
median regressions before approving the PR.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ea47e9cf-d44e-4f8a-8007-ce2ae8d8d890

📥 Commits

Reviewing files that changed from the base of the PR and between 207d788 and f70a66a.

📒 Files selected for processing (3)
  • DESIGN.md
  • src/app.rs
  • src/app/overlay.rs

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
DESIGN.md (1)

90-90: LGTM! Benchmark requirements consistently applied.

The benchmark verification requirements are appropriately included in the tooling/benchmark changes section, maintaining consistency with the streaming/overlay/history verification scope.

Optional style improvement: Three consecutive sentences begin with "Run" (lines 88-90). Consider rewording for variety, such as:

  • "Additionally, run paired baseline vs refactor benchmark runs..."
  • "Finally, run paired baseline vs refactor benchmark runs..."

However, this is a minor stylistic point and the current wording is clear and functional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@DESIGN.md` at line 90, The wording in the DESIGN.md snippet repeats the verb
"Run" at the start of three consecutive sentences; please rephrase the sentence
that currently reads "Run paired baseline vs refactor benchmark runs via `make
benchmark` with identical `BENCH_*` environment settings, and include a short
summary of median deltas/regressions for `total`, `startup`, `dicom_load`, and
`render_ui`." to avoid repetition (e.g., start with "Additionally," or
"Finally,") while keeping the same meaning and requirements so the benchmark
instruction remains intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@DESIGN.md`:
- Line 90: The wording in the DESIGN.md snippet repeats the verb "Run" at the
start of three consecutive sentences; please rephrase the sentence that
currently reads "Run paired baseline vs refactor benchmark runs via `make
benchmark` with identical `BENCH_*` environment settings, and include a short
summary of median deltas/regressions for `total`, `startup`, `dicom_load`, and
`render_ui`." to avoid repetition (e.g., start with "Additionally," or
"Finally,") while keeping the same meaning and requirements so the benchmark
instruction remains intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8997bbe4-e4a3-485f-9c7b-0cf5cf454145

📥 Commits

Reviewing files that changed from the base of the PR and between f70a66a and bc46c0f.

📒 Files selected for processing (1)
  • DESIGN.md

@timcogan timcogan merged commit 5856401 into master Mar 27, 2026
7 checks passed
@timcogan timcogan deleted the refactor/overlay-module branch March 27, 2026 11:19
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.

1 participant