Skip to content

fix(toast): draw the toast as widgets so the message can be selected - #1262

Merged
echelon merged 2 commits into
storytold:mainfrom
switch87:fix/selectable-toast
Oct 13, 2026
Merged

echelon merged 2 commits into
storytold:mainfrom
switch87:fix/selectable-toast

Conversation

@switch87

Copy link
Copy Markdown
Contributor

The problem

The toast at the bottom centre of the canvas was drawn straight onto its layer:

let galley = painter.layout(text, t.font(14.0), foreground, wrap);
painter.rect_filled(r, 6.0, background.gamma_multiply(fade));
painter.galley(r.center() - galley.size() / 2.0, galley, foreground);

Painted text is never hit-tested, so nothing in a toast could be selected or copied. That is a real loss for exactly the messages this surface exists for — they are paths and commands:

  • toast_error carries DownloadOutcome::Failed(e) and The SAM 3 download failed: {e}
  • toast_for exists for "messages that say where to look or what to do next"
  • Event::Toast / s.toast(…) reach here as text like Exported frame to /path/to/frame.png

egui's Label is selectable by default (style.interaction.selectable_labels), and LightCraft never turns that off — but it only helps widgets. The other craft apps already render their toasts as labels; this one was the odd one out.

The change

Same toast, drawn as an Area + Frame + wrapping Label. Everything visual is carried over unchanged: the centring on canvas.bottom() - 60, the 6 px radius, the 40/22 px of padding (now Margin::symmetric(20, 11)), the wrap width of canvas.width() - 80 clamped to 200–720, and the 0.25 s fade, which now tints the frame and the text instead of the galley.

Tests

crates/ui-egui/src/tests_toast.rs:

  • the_toast_is_a_widget_the_pointer_reaches — the toast has an area_rect of its own, and moving the pointer onto it makes egui offer the text cursor. Painted text is never hit-tested, so this fails against the old code.
  • the_toast_still_wraps_a_long_message_inside_the_canvas — a long message still wraps inside the canvas.

Both fail on the pre-change code (the toast is laid out as a widget, not paint) and pass after.

About the local cargo xtask ci

I could not get a fully green cargo xtask ci here, and neither of the two blockers is in this change — both reproduce on a pristine main with everything stashed:

  • clippy stops at crates/pipeline/src/spots.rs:250 with clippy::chunks_exact_to_as_chunks, a lint that only exists from Rust 1.98. With that one lint allowed, -p lightcraft-ui-egui --all-targets -- -D warnings is clean.
  • test has 7 failures in tests_model_setup, all invalid parameters for 'denoise.models.install': this build cannot run denoise models — the denoise models are unavailable in this environment.

The gates that do run are green: fmt, parity (every cited id and path exists), layers (31 crates, no violations) and assets (42 files, all attributed).

The toast was painted straight onto the layer with painter.galley(), and
painted text is never hit-tested: nothing in it could be selected or
copied. A toast often carries the path or the command the user needs
elsewhere ("Exported frame to /path"), and egui's selectable labels —
on by default — only work on real widgets.

Draw it as an Area with a Frame and a wrapping Label instead, keeping the
same centring, 6 px radius, 20/11 padding and the 0.25 s fade-out.

The new tests assert the toast has an area of its own, that the pointer
reaches the text (egui offers the text cursor over it), and that a long
message still wraps within the canvas. All three fail when the toast is
painted, which is what they are for.
@echelon

echelon commented Oct 13, 2026

Copy link
Copy Markdown
Member

Landed on main in #1426 — thank you, @switch87, for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

ArekatlaNishanthchowdary pushed a commit to ArekatlaNishanthchowdary/lightcraft that referenced this pull request Oct 13, 2026
ArekatlaNishanthchowdary pushed a commit to ArekatlaNishanthchowdary/lightcraft that referenced this pull request Oct 13, 2026
ArekatlaNishanthchowdary pushed a commit to ArekatlaNishanthchowdary/lightcraft that referenced this pull request Oct 13, 2026
…cks meant for what is under it (a dialog's button)
@bflatastic

Copy link
Copy Markdown
Member

A follow-up on this one, @switch87: it landed in batch 32a (#1426), and #1431 had to take it out again.

Drawn as an egui Area, the toast takes the clicks meant for whatever is under it. ai_masks_without_the_model_offer_the_download fails with the workspace's features (cargo test --workspace --lib ai_masks_without_the_model_offer): the model dialog's folder button sits under the toast and never gets its click. The Area also fades in by default, which changed the toast's first frames.

Selectable toast text is still wanted. Ways that would keep clicks going through: make only the text interactive while the pointer is over it, add a small copy button, or keep the last messages in a place they can be copied from. A new PR along one of those lines is welcome.


Generated by Claude Code

@echelon

echelon commented Oct 13, 2026

Copy link
Copy Markdown
Member

Follow-up: this was taken back out of main in #1431 ("the toast as a widget takes the clicks meant for what is under it (a dialog's button)"). If you'd like to rework it so the toast doesn't intercept clicks, a new PR is very welcome — thanks again!

bogusyogi pushed a commit to Orthic-Labs/ember that referenced this pull request Oct 14, 2026
…rea doesn't fade in (storytold#1262), storytold#1282's test runs on Windows

Ember: the toast hunk (an egui Area) is left out; Ember keeps its painted toast.

(cherry picked from commit 2e877ad)
@switch87
switch87 deleted the fix/selectable-toast branch October 15, 2026 03:48
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.

3 participants