Skip to content

ref(snapshots): Add shared context for snapshots react code#114390

Closed
NicoHinderling wants to merge 1 commit into04-29-ref_snapshots_add_backend_support_for_individual_image_diffthreshold_value_considerationfrom
04-29-ref_snapshots_add_shared_context_for_snapshots_react_code
Closed

ref(snapshots): Add shared context for snapshots react code#114390
NicoHinderling wants to merge 1 commit into04-29-ref_snapshots_add_backend_support_for_individual_image_diffthreshold_value_considerationfrom
04-29-ref_snapshots_add_shared_context_for_snapshots_react_code

Conversation

@NicoHinderling
Copy link
Copy Markdown
Contributor

@NicoHinderling NicoHinderling commented Apr 29, 2026

Refactors the snapshot viewer React code to reduce prop drilling via a shared context, and improves several UX patterns:

Shared context (SnapshotViewerContext)

  • Extracts viewer state (view mode, diff mode, overlay color, selection, navigation, etc.) into a React context, replacing 20+ props threaded through SnapshotMainContent → child components. Sidebar and main content now consume state via useSnapshotViewer().

URL-driven state

  • Moves viewMode, sortBy, and filter state from localStorage/component state to URL query params with history: 'push', so browser back/forward navigates between views and selections.

Image buffering for smooth navigation

  • Adds useBufferedImageUrl hook that pre-decodes the next image before swapping src, eliminating the white flash when navigating between snapshots in single view.

Sidebar group-based rendering

  • Sidebar now renders collapsed groups (by snapshot name) instead of flat items, with aggregated counts per group. Status filter counts are scoped to the active group when one is selected.

Per-image diff threshold (backend)

  • ImageMetadata now supports an optional diff_threshold field. The comparison task uses per-image threshold when set, falling back to the global snapshot-level threshold.

Header / card polish

  • Compact unified header with project badge and app ID.
  • "Go to Base Build" action in overflow menu.
  • Double-click card to open in single view; tooltips on icon buttons; hoverable metadata tooltip; dark-mode-aware theme toggle fix.
  • Keyboard: Space/Enter both toggle selection; arrow left/right direction corrected for list↔single.

Other

  • PR comment links use selectedTypes query param to match the new URL scheme.
  • Diff views use display: none toggling instead of conditional rendering to preserve zoom/slider state across mode switches.

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fabc76f. Configure here.

listItems,
isSoloView,
onToggleSoloView: handleToggleView,
comparisonType: data?.comparison_type,
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.

Context uses raw API value instead of derived comparisonType

Medium Severity

The context value sets comparisonType: data?.comparison_type (the raw API response), but the old prop-based code passed the locally derived comparisonType variable (line 209), which applies viewOverride logic (viewOverride === 'solo' ? 'solo' : ...) and a 'solo' fallback default. This means the viewOverride URL query parameter is now ignored by all consuming components, and when data?.comparison_type is undefined, the sort dropdown and solo/diff toggle in SnapshotMainContent will behave incorrectly.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit fabc76f. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant