Skip to content

fix(components): preserve download dialog for HTML attachments - #342

Open
hasak21 wants to merge 1 commit into
LodyAI:mainfrom
hasak21:fix/html-attachment-download
Open

fix(components): preserve download dialog for HTML attachments#342
hasak21 wants to merge 1 commit into
LodyAI:mainfrom
hasak21:fix/html-attachment-download

Conversation

@hasak21

@hasak21 hasak21 commented Sep 3, 2026

Copy link
Copy Markdown

Related issue

Closes #321

Problem / pressure

Clicking an HTML file attachment uploaded via lody_upload_files with a workspace sourcePath short-circuited handlePreview directly into the live file viewer or browser connection, completely skipping SessionFilePreviewDialog. Because SessionFileCard has no separate download button, users had no way to download the attached HTML file bytes.

Summary

  • Retain SessionFilePreviewDialog for HTML file attachments so that Download and Copy actions remain accessible.
  • Add onOpenLivePreview to SessionFilePreviewPanel and SessionFilePreviewDialog to provide a dedicated action to open the live preview when live provenance is present.
  • Provide canOpenHtmlFile via SessionChatActionContext and SessionTurnList so the live preview action is only displayed when a live preview target is available.
  • Add focused unit tests for SessionFilePreviewPanel and SessionFilePreviewDialog.

Before / after

Before After
Clicking an HTML attachment with a workspace sourcePath directly opened a file viewer tab or prompted to connect to a remote Browser port; the preview dialog with Download was never shown. Clicking an HTML attachment opens SessionFilePreviewDialog with Download and Copy buttons, plus a dedicated "Open live preview" button when a live preview target is available.

Test plan

  • Ran pnpm --filter @lody/components test tests/session-file-preview-dialog.test.tsx tests/session-html-attachment-action.test.ts (all 7 tests passed).
  • Ran pnpm --filter @lody/components typecheck (0 errors).
  • Ran pnpm check:quick (oxlint, lint:i18n, code-collab-imports, platform-boundaries, public-boundary all passed).
  • Ran pnpm format to ensure clean formatting.

Context handoff

Instructions for reviewing agents

  • Review focus: Verify SessionFileGroup.handlePreview in view.tsx and onOpenLivePreview in session-file-preview-dialog.tsx.
  • Decisions to challenge: Confirm that opening SessionFilePreviewDialog with an explicit live preview action is the right model rather than changing SessionFileCard DOM structure.
  • Plausible failures / evidence gaps: Remote browser port connection is only triggered when explicitly requested via the live preview action button rather than automatically on card click.

Authoring context

  • User goal / directives: Restore download functionality for HTML attachments uploaded by agents in conversations while preserving live preview access.
  • Constraints / non-goals: Do not alter the pure button semantics of SessionFileCard or change how non-HTML previewable files render.
  • Risk-bearing decisions: HTML attachments now open the preview dialog first rather than immediately navigating to a file tab, requiring one click to open live preview from the dialog.
  • Destructive or irreversible behavior: None; no persistent data or schema is modified.
  • Deliberately not done or tested: Did not change resolveSessionHtmlAttachmentAction resolution logic, preserving existing local/remote resolution behavior.
  • Unknowns / confidence: High confidence; unit tests verify dialog, download, and live preview callbacks.

…I#321)

Clicking an HTML file attachment uploaded via lody_upload_files with a
workspace sourcePath previously short-circuited handlePreview into the live
file viewer or browser connection, completely skipping
SessionFilePreviewDialog. Because SessionFileCard has no separate download
button, users had no way to download the attached HTML file bytes.

Retain the in-app preview dialog for HTML attachments so that Download
and Copy actions remain accessible. Add onOpenLivePreview to
SessionFilePreviewDialog to provide a dedicated action to open the live
preview when live provenance is present, and wire canOpenHtmlFile so the
action is only shown when available.

Model: gemini-3.8-flash
@Leeeon233

Copy link
Copy Markdown
Contributor

Hi @hasak21, I still can not see the dialog with download, could you check and attach a screenshot?

@Leeeon233 Leeeon233 self-assigned this Sep 3, 2026
@hasak21

hasak21 commented Sep 3, 2026

Copy link
Copy Markdown
Author

Hi @Leeeon233,

Thanks for reviewing! Here are the screenshots and a breakdown clarifying the behavior before and after this change:

1. Before (main) — Bypassed Dialog into File Viewer Tab

Previously, clicking an HTML attachment short-circuited handlePreview directly into the right-hand file viewer tab (SessionFileContentView). Because that surface is designed for inspecting/editing workspace files rather than managing conversation attachments, it did not provide a download button, leaving users unable to save the artifact bytes (as described in #321).

Before: Direct short-circuit to live preview

2. After (PR #342) — Opens SessionFilePreviewDialog with Download

Clicking an HTML attachment now reliably opens the standard SessionFilePreviewDialog modal:

  • Download Action: Located in the top-right toolbar (the download tray icon next to Copy). Clicking it invokes onDownload(file) to save the raw file bytes to disk.
  • Open Live Preview Action: When workspace provenance (sourcePath) is available, a dedicated external-link button is provided right next to Download, allowing users to still jump to the full live rendered viewer if desired.
  • Dialog Body: Shows the syntax-formatted raw HTML source with copy capability.

After: SessionFilePreviewDialog with Download and Live Preview

All unit tests (session-file-preview-dialog.test.tsx and session-html-attachment-action.test.ts) as well as pnpm check:quick and format:check are passing cleanly.

Please let me know if you'd like any further adjustments!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] HTML attachments with a workspace sourcePath skip the download dialog

2 participants