From fd7ebbec7c1aad4974b36de2b10297a4f06f6b3a Mon Sep 17 00:00:00 2001 From: Eslam Ahmad Date: Sun, 2 Aug 2026 19:46:11 +0800 Subject: [PATCH] fix(web): handle the new-from-template file-menu choice (#196) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `FileMenuChoice::NewFromTemplate` was added with the scene-template work and wired into the native host, but the web host's `match` was left at the original eight variants. Rust requires exhaustive matches, so op-host-web stopped compiling under its own feature: error[E0004]: non-exhaustive patterns: `FileMenuChoice::NewFromTemplate` not covered --> crates/op-host-web/src/widget_host/chrome_menu_press.rs:32:78 That breaks `cargo test -p op-host-web --features canvaskit`, which rust-check.yml runs, and `cargo build --features canvaskit` for the wasm bundle. The other wasm gates use `--features web`, so nothing else catches it. The arm yields `None` rather than a `FileAction`: templates are desktop-only so far, `FileAction` has no template variant, and the panel is not wired on web. Returning early instead — as the native host's equivalent match does — would skip the lines below that close the menu and clear hover, leaving the menu stuck open on click. `None` dispatches nothing while still closing the menu, so the row is inert rather than broken. --- .../src/widget_host/chrome_menu_press.rs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/op-host-web/src/widget_host/chrome_menu_press.rs b/crates/op-host-web/src/widget_host/chrome_menu_press.rs index 504b11927..77accf47d 100644 --- a/crates/op-host-web/src/widget_host/chrome_menu_press.rs +++ b/crates/op-host-web/src/widget_host/chrome_menu_press.rs @@ -29,16 +29,17 @@ impl WidgetHost { let Some(choice) = menu.choice_for_row(row) else { return; }; - self.editor_state.editor_ui.pending_file_action = Some(match choice { - FileMenuChoice::NewFile => FileAction::New, - FileMenuChoice::OpenFile => FileAction::Open, - FileMenuChoice::Save => FileAction::Save, - FileMenuChoice::SaveAs => FileAction::SaveAs, - FileMenuChoice::ExportImage => FileAction::ExportImage, - FileMenuChoice::ExportAllFrames => FileAction::ExportAllFrames, - FileMenuChoice::OpenRecent(i) => FileAction::OpenRecent(i), - FileMenuChoice::ClearRecent => FileAction::ClearRecent, - }); + self.editor_state.editor_ui.pending_file_action = match choice { + FileMenuChoice::NewFile => Some(FileAction::New), + FileMenuChoice::OpenFile => Some(FileAction::Open), + FileMenuChoice::Save => Some(FileAction::Save), + FileMenuChoice::SaveAs => Some(FileAction::SaveAs), + FileMenuChoice::ExportImage => Some(FileAction::ExportImage), + FileMenuChoice::ExportAllFrames => Some(FileAction::ExportAllFrames), + FileMenuChoice::OpenRecent(i) => Some(FileAction::OpenRecent(i)), + FileMenuChoice::ClearRecent => Some(FileAction::ClearRecent), + FileMenuChoice::NewFromTemplate => None, // templates are desktop-only + }; self.editor_state.editor_ui.file_menu_open = false; self.editor_state.editor_ui.file_menu.hover = None; self.mark_dirty();