Skip to content

refactor(preview): share media UI - #1764

Merged
l0gicgate merged 6 commits into
lgse:mainfrom
adamcbrewer:refactor/1659-shared-preview-components
Oct 20, 2026
Merged

l0gicgate merged 6 commits into
lgse:mainfrom
adamcbrewer:refactor/1659-shared-preview-components

Conversation

@adamcbrewer

@adamcbrewer adamcbrewer commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Audio, video and model previews repeat their headers, navigation buttons and badge construction. I've pulled those common pieces into shared components so we can change them in one place and keep the previews consistent.

The shared UI now lives in two files under src/ui/preview:

  • components.rs contains the details header, previous/next button builder, navigation row, badge row and badge label builders. It also holds the common spacing and minimum panel width values.
  • player_layout.rs contains the video/model layout, moved out of video/layout.rs. Each preview supplies its content, details and controls, with optional badges and timeline sections. The model badges now have their own named area instead of occupying a slot called timeline.

Their common appearance is defined in src/style.css, using neutral classes such as preview-details-title and preview-details-badge.

Audio uses the shared header and navigation, while keeping its larger title, artwork, spectrum and responsive layout. Video and models also use the shared badges and player layout. Each preview supplies its centre widget: a playback button for audio/video, or the camera indicator for models.

The waveform and volume controls were already shared. Playback, seeking, metadata loading and camera animation stay in their existing preview implementations. The loaded previews keep their existing appearance, with one implementation to edit when we change a common header, navigation button or badge.

Mesh previews now also show their filename, listing position and file format during the first load, with the triangle count appearing as soon as parsing provides it. Camera controls become active once the first image is ready. When changing angles, the current mesh dims and the spinner in the preview header shows progress until the next view is ready. Failed angle changes keep the previous image and allow a retry. Next rotates the camera clockwise around the model; Previous rotates it anticlockwise. The dot follows the rendered view.

Starts from upstream main at e0f73973, after #1644 was confirmed merged.

Visual evidence

N/A. The loaded previews retain their existing typography, theme styling and narrow, wide and tall arrangements. Mesh loading shows the available file details with the loading spinner in the preview header.

How to test

  1. Preview audio, video and STL/3MF files. Resize the window through narrow, wide and tall shapes, including audio's side-by-side arrangement.
  2. Open an uncached STL/3MF mesh. During the first render, check that the filename and format are visible, the triangle count appears when available, and the camera buttons remain inactive until the image is ready.
  3. Cycle model camera views. Next should move the camera dot clockwise and Previous anticlockwise, matching the rendered view. Check that the header spinner appears while the retained image is dimmed. Check keyboard focus, loading/retry feedback, thumbnail preference, live themes and reduced motion. Step between tracks and videos and exercise playback, seeking and volume too.

Expected result: Loaded previews keep their existing appearance and behaviour. Mesh previews show useful details from the start and the header spinner while generating an image or changing angle.

Related issue

Closes #1659

@adamcbrewer adamcbrewer changed the title refactor(preview): share media preview UI components refactor(preview): share media UI and show mesh loading feedback Oct 19, 2026
@adamcbrewer adamcbrewer changed the title refactor(preview): share media UI and show mesh loading feedback refactor(preview): share media UI Oct 19, 2026
@l0gicgate

Copy link
Copy Markdown
Contributor

Review

Merged main (4804a312) with no conflicts. Reviewed the full diff against the updated main. No blocking issues found.

Checked

  • Shared components: DetailsHeader, navigation_button, navigation_row and the badge builders replace the duplicated audio, video and model code. PlayerLayout now tracks its parts by explicit areas instead of child order, and the model badges have their own area.
  • CSS renames keep the existing look. .preview-details-title.preview-audio-title still beats the base title rule, and the HDR badge still overrides the base badge. Dropping preview-video-play from the camera indicator changes nothing, because preview-model-camera already resets its padding and the 64 px drawing area exceeds the 44 px minimum. docs/themes.md already says class names are not a stable API for user stylesheets.
  • Camera direction: ModelView::step(1) now goes front-left, back-left, back-right, front-right. In the indicator's y-down drawing that is clockwise, and CameraMotion turns the dot the same way.
  • Model loading lifecycle: the loading screen made by show_model_loading is reused when a mesh arrives. It is reset when an embedded-image result arrives, when the file changes, or when the first load fails (the paintable().is_some() guard sends first-load failures to the normal error message). While no image exists, view changes are ignored and the camera buttons stay inactive.
  • Tests: the new and changed tests check behaviour: initial metadata and progress, retained image and progress while changing views, the clockwise turn, and failure retry. They contain no layout assertions.
  • Comments: one doc comment was added. It is now worded more tightly: `tooltip` names `binding`, when given, with `%{keys}`.

Non-blocking notes

  • The model loading card now appears immediately instead of after PREVIEW_SPINNER_DELAY, so a fast cached render may flash it briefly.
  • 3MF files with an embedded image and FreeCAD files show the mesh-style details and inactive camera controls while loading, then switch to the plain image layout. The updated docs describe this.

Review commit: 4eadee4c docs(preview): clarify the navigation button tooltip contract

Local verification (tests limited to the affected preview code; CI runs the full suites)

  • ./scripts/test-headless.py -- ui::preview:: keyboard_dispatch::audio_tracks keyboard_dispatch::video_clips services::model_preview sandbox::model: 71 passed
  • ./scripts/e2e.sh on test_quick_preview.py, test_preview_media_controls.py, test_preview_media_layout.py and test_preview_video.py: 75 passed
  • cargo fmt --all --check and cargo clippy --all-targets --all-features -- -D warnings: clean

CI: Metadata policy passes. The main CI run for this fork PR is waiting for maintainer approval and has not started.

@l0gicgate

Copy link
Copy Markdown
Contributor

@adamcbrewer I am removing the loading cards on the models. They flash in/out too quickly for small models and it's not necessary imo. The loading spinner in the header is sufficient.

@adamcbrewer

Copy link
Copy Markdown
Contributor Author

I debated this myself. No worries

Remove the centred progress card over the mesh image. The header spinner
beside the open button is again the only loading indicator for the first
load and for view changes, with the stage carried by its accessible label.
Drop the orphaned "Waiting for preview…" catalog string.
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.

refactor(preview): share preview UI components after #1644 merges

2 participants