Skip to content

fix(ui): Make event Context tab attachment previews expandable - #1358

Open
antonis wants to merge 2 commits into
mainfrom
fix/attachment-preview-expand-collapse
Open

antonis wants to merge 2 commits into
mainfrom
fix/attachment-preview-expand-collapse

Conversation

@antonis

@antonis antonis commented Oct 1, 2026 •

Copy link
Copy Markdown

Description

While testing getsentry/sentry-react-native#6818 I noticed that the Attachment component takes expanded only as a prop, with no way to toggle it.

This makes the component manage its own expanded state (seeded from the expanded prop) and turns the hint into a button that toggles the preview open and closed. Previews stay lazily rendered — collapsed by default, nothing decoded until requested — so the perf intent of lazy rendering is preserved. EnvelopeDetails, which passes expanded, is unaffected.

How tested

  • Unit tests updated (Attachment.test.tsx): added a case that expands on click (content renders, download URL built on demand) and collapses again. 15/15 pass (vitest run).
  • Verified manually against a running dev build: an error event carrying an image/png screenshot attachment now expands to render the image on the Context → Attachments section, and collapses back.
collapsed expanded
Screenshot 2026-10-01 at 15 06 36 Screenshot 2026-10-01 at 15 06 27

The `Attachment` component took `expanded` only as a prop with no way to
toggle it. On the event Context tab it is rendered without that prop, so
the preview stayed collapsed forever and the download link (whose URL is
only built when expanded) was inert too — the "Expand to preview
attachment." hint did nothing.

Let the component manage its own expanded state, seeded from the prop, and
make the hint a button that toggles the preview open and closed. Previews
stay lazily rendered (collapsed by default), so nothing is decoded until
requested. `EnvelopeDetails`, which passes `expanded`, is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
spotlightjs Skipped Skipped Oct 16, 2026 10:46am UTC

Request Review

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ Patch coverage is 100.00% (4 of 4 changed executable lines covered; target 80%).
Project statement coverage is 51.90%.

Changed files with executable lines (1)
File Patch coverage Changed executable lines
packages/spotlight/src/ui/telemetry/components/insights/envelopes/Attachment.tsx 100.00% 4/4 covered

Generated by Coverage Action

@antonis
antonis marked this pull request as ready for review October 1, 2026 13:12
@antonis
antonis requested review from BYK and MathurAditya724 and a balanced review from Copilot October 16, 2026 10:39

Copilot AI left a comment

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.

🟡 Changes recommended

The toggle replaces the focused button, causing keyboard focus loss.

1 open finding
What changed in this PR

Makes attachment previews expandable and collapsible in the event Context tab while preserving lazy rendering.

Changes:

  • Adds local expansion state initialized from the expanded prop.
  • Adds preview toggle buttons and a test covering expansion, download URL creation, and collapse.
File Description
packages/​spotlight/​src/​ui/​telemetry/​components/​insights/​envelopes/​Attachment.tsx Adds expansion state and preview controls.
packages/​spotlight/​src/​ui/​telemetry/​components/​insights/​envelopes/​Attachment.test.tsx Tests toggling and lazy download URL creation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/spotlight/src/ui/telemetry/components/insights/envelopes/Attachment.tsx Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 95711390 Deployed Oct 16, 2026 by antonis via Build #2421
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