Skip to content

fix(composer): address image-editor follow-up nits on #1491#1565

Merged
tellaho merged 3 commits into
mainfrom
tho/spoiler-followup-nits
Jul 7, 2026
Merged

fix(composer): address image-editor follow-up nits on #1491#1565
tellaho merged 3 commits into
mainfrom
tho/spoiler-followup-nits

Conversation

@tellaho

@tellaho tellaho commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Category: improvement
User Impact: Image annotation opens faster for large uploads and behaves more consistently if a save is already in progress.
Problem: Follow-up review on #1491 called out a few sharp edges in composer image editing: fetched image bytes were serialized as JSON arrays, Escape could look like cancel while a save still completed, and the revert affordance’s draft behavior needed an explicit scope decision.
Solution: Return fetched image bytes over Tauri IPC as a raw buffer, gate Escape while the editor is saving, and document the in-memory-only revert behavior as the intended follow-up boundary.

File changes

desktop/src-tauri/src/commands/media_download.rs
Returns image-editor media bytes as tauri::ipc::Response so large images cross IPC as raw bytes instead of JSON number arrays while preserving existing validation and size caps.

desktop/src/features/messages/lib/useMediaUpload.ts
Documents the revert-originals map as intentionally in-memory-only, recording draft round-trip persistence as outside this follow-up’s scope.

desktop/src/features/messages/ui/ComposerAttachments.tsx
Tracks the image editor’s save state in the lightbox and prevents Escape from leaving edit mode while a save upload is in flight.

desktop/src/features/messages/ui/ComposerImageEditor.tsx
Reports save-in-flight state to the parent and clears that signal on unmount so the lightbox Escape guard stays accurate.

desktop/src/shared/api/tauriMedia.ts
Reads fetch_media_bytes responses as an ArrayBuffer and wraps them in a Uint8Array for the editor.

desktop/src/testing/e2eBridge.ts
Updates the E2E mock for fetch_media_bytes to return the same raw ArrayBuffer shape as the Tauri command.

Reproduction Steps

  1. Open the desktop composer and attach an image.
  2. Open the attachment lightbox, enter draw mode, add a stroke, and save.
  3. Confirm the edited attachment replaces the original and can still be reverted while the composer remains active.
  4. Start another edit and press Escape before saving; the editor should leave draw mode normally.
  5. While a save is in progress, Escape should no longer make the UI look canceled while the attachment swap still lands.

Validation

  • GitHub CI: previously green after rerunning one unrelated smoke failure; latest run for 770c71ef is in progress with no failures observed yet.
  • Marge final gate: approved in-thread for focused scope/correctness; follow-up spoiler active-state re-check passed on 770c71ef with independent screenshot verification.
  • Local checks from final gate: biome check ., file-sizes, px-text, tsc, pnpm test 1885/1885, desktop-tauri fmt-check, and cargo check passed; local clippy findings were pre-existing outside this PR.

Screenshots / Mocks

Editor lightbox idle Editor lightbox active annotation
Editor lightbox idle Editor lightbox with freehand annotation and brush cursor visible
Spoiler inactive Spoiler active
Spoiler toggle inactive Spoiler toggle active with rounded shared-button ring

Coordination

buzz://message?channel=99a4d0c9-e02b-49e3-aa81-e637c4fd0292&thread=790c65884f4b236b88f23b9c7a82dd904d4113a8822bc1c8df3c4f7896896ff8

Follow-ups from the #1491 review:

- fetch_media_bytes now replies with tauri::ipc::Response so image bytes
  cross IPC as a raw buffer instead of a JSON number array (~3x smaller
  to serialize at the 50 MiB cap). TS wrapper reads an ArrayBuffer and
  the e2e mock returns the same shape.
- Escape no longer exits canvas edit mode while a save upload is in
  flight: the editor reports its saving state up, and the lightbox's
  Escape handler ignores the key mid-save so a dismissal can't look like
  a cancel while the attachment swap still lands.
- Documented the in-memory-only revert map as an explicit non-goal for
  draft round-trips, per the review's recorded-decision ask.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
@tellaho tellaho marked this pull request as draft July 7, 2026 00:15
@tellaho tellaho changed the title fix composer image-editor follow-up nits fix(composer): address image-editor follow-up nits Jul 7, 2026
@tellaho tellaho marked this pull request as ready for review July 7, 2026 00:47
@tellaho tellaho changed the title fix(composer): address image-editor follow-up nits fix(composer): address image-editor follow-up nits on #1491 Jul 7, 2026
npub1223z34hd7vtwc6qj4s7flsxkj644nlre2nthu7lrrmkumhu3xddsrx9r6w and others added 2 commits July 6, 2026 18:05
When an attachment is spoilered, the lightbox toggle now swaps its
circular pill for the shared button rounded-lg shape with a 2px
white ring, so the active/selected state is obvious at a glance.
Idle look and toggle behavior are unchanged.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
The previous data-[state=on] classes never applied in the real build:
the TooltipTrigger wrapping the Toggle clobbers Radix's data-state
attribute. Gate the active classes on isSpoilered instead, and
strengthen the treatment (solid white ring-2 + white/25 fill on the
shared rounded-lg shape) so the selected state is obvious against the
dark lightbox backdrop.

Co-authored-by: Taylor Ho <taylorkmho@gmail.com>
Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
@tellaho tellaho enabled auto-merge (squash) July 7, 2026 01:44
@tellaho tellaho merged commit 49391d8 into main Jul 7, 2026
25 checks passed
@tellaho tellaho deleted the tho/spoiler-followup-nits branch July 7, 2026 15:38
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