Skip to content

Refactor: UI restructure, notifications, save dialog, and categorical LUT fix#32

Merged
luca-heltai merged 8 commits into
mainfrom
refactor/ui
May 26, 2026
Merged

Refactor: UI restructure, notifications, save dialog, and categorical LUT fix#32
luca-heltai merged 8 commits into
mainfrom
refactor/ui

Conversation

@pcolt

@pcolt pcolt commented May 20, 2026

Copy link
Copy Markdown
Collaborator

Overview

  1. Edit panel restructure — field assignment controls moved from the left pipeline drawer into the right inspector Edit tab; UI helpers extracted; Edit Tools controls reordered; docs/ui_structure.md added with full component tree.

  2. Centralize notifications — 9 scattered alert state pairs replaced with a single VSnackbar driven by notify() in notifications.py; auto-dismisses after 5 s.

  3. Save dialog, toolbar polish, categorical LUT fix — inline filename field replaced with an explicit save dialog (pre-filled, routes save_dialog_action = "save" | "commit"); toolbar buttons use icon + small text; categorical LUT annotations re-applied on array/range/preset changes so the color bar keeps reflecting data values without toggling.

Summary

  • Move _build_edit_assign_panel() and _build_selection_tools_panel() into the right Edit tab; reorder Edit Tools controls
  • Add docs/ui_structure.md with component tree and planned module split
  • Replace 9 alert state pairs with notification_message / notification_type / notification_show + VSnackbar; add notifications.py with notify() helper
  • Remove _apply_pending_save_filename / _save_active_data helpers; pv_save_active_data opens a dialog (save_dialog_action = "save")
  • Add pv_confirm_save_dialog(filename) and pv_cancel_save_dialog(); pv_commit_edit_session opens same dialog with save_dialog_action = "commit"
  • save_paraview_output / resolve_paraview_output_path take explicit filename kwarg; overwrite retry uses save_overwrite_target
  • Add save_dialog / save_dialog_action to state_setup.py
  • Categorical LUT: re-call _configure_categorical_lookup_table after array/range/preset changes when LUT is already categorical; remove hasattr guards in _disable_scalar_coloring
  • Add test_data/square_mat_12.vtk and square_mat_345.vtk for categorical coloring coverage
  • Update unit tests and e2e test for dialog-based save flow

Test plan

  • Unit tests: conda run -n coral-paraview pytest -q tests/ --ignore-glob=tests/test_e2e*.py (165 pass)
  • Edit tab: enter edit mode → right inspector Edit tab shows Field Assignment and Edit Tools panels in correct order
  • Notifications: upload, save, edit assign, errors surface as a snackbar; auto-dismisses after 5 s
  • Save dialog: load a file → Save Result → dialog pre-filled → enter name → Save → file appears in file list
  • Commit dialog: edit mode → Save And Add To Pipeline → dialog → confirm → session closed, result loaded into pipeline
  • Overwrite: save to existing name → overwrite dialog → confirm rewrites
  • Categorical coloring: enable categorical on a MaterialID mesh → open different file with different categorical ids → color bar updates with right category labels
  • E2E: conda run -n coral-paraview pytest -q tests/test_e2e_edit_selection_playwright.py

pcolt added 4 commits May 19, 2026 15:02
…UI helpers

- Move Edit Mode (field selection, expression, assign) from left pipeline
  drawer into a new _build_edit_assign_panel() in the right Edit tab
- Extract _build_selection_tools_panel() from inline code in the Edit tab
- Move Geometry mode selector from Field Assignment into Edit Tools panel,
  above Selection mode — it controls picking, not assignment
- Reorder Edit Tools: Pick/Rotate, Select All/Clear, selection count,
  Geometry mode, Selection mode, Selection behavior, Grow/angle, status
- Add docs/ui_structure.md with full component tree and planned module split
- Link ui_structure.md from README Architecture section
- Update e2e tests: wait_for_selector anchored to "Edit Tools" label
…kbar

Replaces 9 scattered alert state pairs (error_message, upload_status,
edit_status, save_status, state_status, edit_apply_status,
edit_selection_status, color_controls_status, pv_runtime_message display)
with a single VSnackbar driven by notification_message/type/show.

notify() helper in notifications.py is the sole write path; snackbar
auto-dismisses after 5 s. Success toasts removed from self-evident
toggle operations (color bar, orientation axes, categorical) to avoid
covering the viewport during E2E screenshot assertions.
Save dialog refactor:
- Remove inline Output filename field from toolbar
- Replace direct save button actions with a two-step flow: button
  opens a named save dialog (save_dialog_action = "save"|"commit"),
  pv_confirm_save_dialog routes to save_paraview_output or
  _commit_edit_session with the filename passed explicitly
- Add pv_confirm_save_dialog / pv_cancel_save_dialog controllers
- Add save_dialog / save_dialog_action to state_setup
- Pass filename kwarg through file_operations.save_paraview_output
  and resolve_paraview_output_path instead of reading state as side
  effect; overwrite retry uses save_overwrite_target (the conflicting
  path) not save_filename
- Update unit and e2e tests for the dialog-based flow

Toolbar buttons:
- Buttons use small VBtn with icon + small text label
- docs/ui_structure.md: add Toolbar button flows diagram

Categorical LUT fix:
- Re-apply categorical LUT annotations whenever the active LUT is
  already marked categorical after an array/range/preset change, so
  the color bar keeps reflecting current data values without requiring
  a UI toggle
- Remove legacy hasattr guards in _disable_scalar_coloring; access
  display.LookupTable / ColorArrayName directly
- Add square_mat_12.vtk and square_mat_345.vtk test meshes with
  MaterialID fields for categorical coloring coverage
@pcolt
pcolt marked this pull request as draft May 20, 2026 11:32
@pcolt
pcolt requested a review from luca-heltai May 20, 2026 11:33
@pcolt

pcolt commented May 20, 2026

Copy link
Copy Markdown
Collaborator Author

@luca-heltai this is marked as draft because I may add some other refactors or fixes but I could also split in different PRs. What is ready is PR #31 which needs to merge or get reviewed first

@pcolt
pcolt changed the base branch from fix/surface-selection-geometry-filter to main May 20, 2026 12:40
pcolt added 2 commits May 20, 2026 16:18
The test was intermittently failing on CI after the new categorical test
added resource pressure, causing the 1s sleep to be insufficient for the
ParaView render to complete. _wait_for_foreground polls every 250ms up to
8s, so the assertion fires as soon as content appears rather than at a
fixed deadline.
Two timing-sensitive failures on CI:

- categorical_toggle: assert _switch_checked immediately after
  wait_for_selector fired before the Trame state update arrived in the
  browser; replaced with _wait_for_switch_checked (polls up to 8s).

- show_faces: _wait_for_foreground returned the previous full-mesh render
  immediately because the viewport already had content; added narrower_than
  so the poll waits until the bbox shrinks to a fraction of the full width
  before accepting the faces-only render.
@pcolt
pcolt removed the request for review from luca-heltai May 20, 2026 14:45
pcolt added 2 commits May 22, 2026 10:48
Extend the categorical LUT staleness fix to cover active-node changes:
set_active_node now calls _refresh_categorical_annotations so the color
bar reflects the new source's values when the user clicks between pipeline
nodes, without requiring a manual toggle.

Extract the repeated 3-line conditional into _refresh_categorical_annotations
so both apply_coloring and set_active_node share a single call site.

Extend test_paraview_categorical_annotations_updated_on_file_switch with
pipeline-switch steps: after the file-load regression check, click file A
then file B in the pipeline browser and verify the render is stable before
and after a categorical toggle. Add _wait_for_stable_viewport helper that
polls until two consecutive screenshots show no significant change, avoiding
the race between the Trame state push and the ParaView render push.
@luca-heltai

Copy link
Copy Markdown
Contributor

I like this. I think we have a bug in two dimensions. For a refined two dimensional grid, surface selection does not seem to work. But it's the same in the main branch.

@luca-heltai
luca-heltai merged commit 7fbe1c2 into main May 26, 2026
1 check passed
@pcolt

pcolt commented May 27, 2026

Copy link
Copy Markdown
Collaborator Author

Could you confirm the bug or make a video perhaps? Because I am not able to reproduce it

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