Truly independent web browser
LibWebView+UI/Qt: Let crash reports wait behind the feedback button
Andreas Klingc0ce922b1837
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cppindex bdfb7acbee3..2535ed91339 100644--- a/Libraries/LibWebView/Application.cpp+++ b/Libraries/LibWebView/Application.cpp@@ -2381,29 +2381,16 @@ void Application::process_did_exit(Process&& process, Optional<int>)if (report_name.is_empty())return;- // The tab's crash screen is this report's one automatic prompt, so it is not offered again. Every other crash is- // hidden from the user, so its report is offered right away.+ // The tab's crash screen already asks about this report. Every other crash is hidden from the user, so its report+ // waits to be reviewed.if (!crash_is_shown_in_tab) {- offer_crash_report(report_name);+ crash_report_saved();} else if (!browser_options().headless_mode.has_value()) {if (auto result = CrashReportStore::the().mark_seen(report_name); result.is_error())warnln("Could not mark crash report as seen: {}", result.error());}}-void Application::offer_newest_pending_crash_report()-{- if (auto names = CrashReportStore::the().pending_report_names(); !names.is_error() && !names.value().is_empty())- offer_crash_report(names.value().first());-}--void Application::offer_crash_report(ByteString const& report_name)-{- if (browser_options().headless_mode.has_value() || browser_options().webdriver_browser_endpoint.has_value())- return;- display_crash_report_notification(report_name);-}-static bool download_path_is_available(LexicalPath const& path){if (FileSystem::exists(path.string()))diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.hindex 9afbd273ce5..0960c091263 100644--- a/Libraries/LibWebView/Application.h+++ b/Libraries/LibWebView/Application.h@@ -338,8 +338,6 @@ public:virtual void open_download(FileDownloader::Download const&) const;virtual void show_download_in_folder(FileDownloader::Download const&) const;- void offer_newest_pending_crash_report();-// FIXME: We should implement UI-agnostic platform APIs to interact with the system clipboard.enum class ClipboardType : u8 {Text,@@ -465,7 +463,7 @@ protected:virtual NonnullRefPtr<Core::Promise<ByteString>> ask_user_for_download_path(ByteString const& file) const;- virtual void display_crash_report_notification([[maybe_unused]] ByteString const& report_name) { }+ virtual void crash_report_saved() { }virtual void update_tabs_display() const { }@@ -493,7 +491,6 @@ private:void handle_compositor_process_death();void recover_compositor_process();void crash_compositor_process();- void offer_crash_report(ByteString const& report_name);ErrorOr<void> launch_request_server();ErrorOr<void> launch_devtools_server();// Returns whether the combined rules changed.diff --git a/Libraries/LibWebView/CrashReportStore.cpp b/Libraries/LibWebView/CrashReportStore.cppindex 81da143c751..5368ce1c64f 100644--- a/Libraries/LibWebView/CrashReportStore.cpp+++ b/Libraries/LibWebView/CrashReportStore.cpp@@ -283,16 +283,6 @@ ErrorOr<void> CrashReportStore::mark_seen(ByteString const& name) constreturn {};}-ErrorOr<void> CrashReportStore::mark_all_seen(UnixDateTime now) const-{- ErrorOr<void> result;- for (auto const& name : TRY(pending_report_names(now))) {- if (auto marked = mark_seen(name); marked.is_error() && !result.is_error())- result = marked.release_error();- }- return result;-}-ErrorOr<void> CrashReportStore::remove_sent_report(ByteString const& name) const{if (!is_saved_report_name(name))@@ -466,7 +456,6 @@ ErrorOr<CrashReportStore::SavedReport> CrashReportStore::saved_report(ByteStringErrorOr<Vector<ByteString>> CrashReportStore::pending_report_names(UnixDateTime) const { return Vector<ByteString> {}; }bool CrashReportStore::has_pending_reports(UnixDateTime) const { return false; }ErrorOr<void> CrashReportStore::mark_seen(ByteString const&) const { return {}; }-ErrorOr<void> CrashReportStore::mark_all_seen(UnixDateTime) const { return {}; }ErrorOr<void> CrashReportStore::remove_sent_report(ByteString const&) const { return {}; }ErrorOr<ByteString> CrashReportStore::store_report(ProcessType, StringView, UnixDateTime) constdiff --git a/Libraries/LibWebView/CrashReportStore.h b/Libraries/LibWebView/CrashReportStore.hindex 0ac994e2d85..e759ee0f0eb 100644--- a/Libraries/LibWebView/CrashReportStore.h+++ b/Libraries/LibWebView/CrashReportStore.h@@ -34,14 +34,13 @@ public:ErrorOr<SavedReport> saved_report(ByteString const& name) const;- // The reports the user has not been asked about yet, newest first. A report of a crash from before the hard cutoff+ // The reports waiting to be reviewed, newest first. A report of a crash from before the hard cutoff// date (October 2, 2026 20:00 UTC) or more than 14 days before `now` stays on disk but is never offered.ErrorOr<Vector<ByteString>> pending_report_names(UnixDateTime now = UnixDateTime::now()) const;bool has_pending_reports(UnixDateTime now = UnixDateTime::now()) const;// Seen reports move into a subdirectory, where the newest of them are kept for reference and never offered again.ErrorOr<void> mark_seen(ByteString const& name) const;- ErrorOr<void> mark_all_seen(UnixDateTime now = UnixDateTime::now()) const;ErrorOr<void> remove_sent_report(ByteString const& name) const;ErrorOr<ByteString> store_report(ProcessType, StringView text, UnixDateTime crashed_at) const;diff --git a/Tests/LibWebView/TestCrashReportStore.cpp b/Tests/LibWebView/TestCrashReportStore.cppindex 6e1fcf39972..d70f91bb577 100644--- a/Tests/LibWebView/TestCrashReportStore.cpp+++ b/Tests/LibWebView/TestCrashReportStore.cpp@@ -154,30 +154,6 @@ TEST_CASE(a_seen_report_is_no_longer_pending)EXPECT(store.has_pending_reports(now));}-TEST_CASE(marking_all_reports_seen_leaves_none_pending)-{- cleanup();- ScopeGuard guard = cleanup;-- auto older = report_name("2026-03-04T05-06-07Z"sv);- auto newer = report_name("2026-03-05T05-06-07Z"sv);- auto stale = report_name("2026-03-03T05-06-07Z"sv);- write_file(older, "Older report\n"sv);- write_file(newer, "Newer report\n"sv);- write_file(stale, "Stale report\n"sv, UnixDateTime::from_unix_time_parts(2026, 10, 1, 0, 0, 0, 0));- auto store = test_store();-- MUST(store.mark_all_seen(now));- EXPECT(!store.has_pending_reports(now));- EXPECT_EQ(directory_entries(), Vector<ByteString> { stale });- EXPECT_EQ(directory_entries("Seen"sv).size(), 2u);- EXPECT_EQ(MUST(store.saved_report(older)).text, "Older report\n"sv);- EXPECT_EQ(MUST(store.saved_report(newer)).text, "Newer report\n"sv);-- MUST(store.mark_all_seen(now));- EXPECT_EQ(directory_entries("Seen"sv).size(), 2u);-}-TEST_CASE(a_report_from_before_the_hard_cutoff_date_is_not_pending){cleanup();diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cppindex 631d8a233cc..547f1658cd5 100644--- a/UI/Qt/Application.cpp+++ b/UI/Qt/Application.cpp@@ -1177,9 +1177,9 @@ void Application::reopen_recently_closed_tab(BrowserWindow* target_window, Optioupdate_reopen_recently_closed_actions();}-void Application::display_crash_report_notification(ByteString const& report_name)+void Application::crash_report_saved(){- m_crash_report_notifier.offer(report_name);+ update_feedback_buttons();}void Application::update_feedback_buttons()diff --git a/UI/Qt/Application.h b/UI/Qt/Application.hindex 65c31d40187..9262f840620 100644--- a/UI/Qt/Application.h+++ b/UI/Qt/Application.h@@ -14,7 +14,6 @@#include <LibWebView/Application.h>#include <LibWebView/BrowsingSession.h>#include <UI/Qt/BrowserWindow.h>-#include <UI/Qt/CrashReportNotifier.h>#include <QApplication>#include <QPointer>@@ -80,7 +79,6 @@ public:bool is_finishing_quit() const { return m_quit_is_finishing; }bool confirm_stop_active_downloads(QWidget* parent = nullptr);- CrashReportNotifier& crash_report_notifier() { return m_crash_report_notifier; }void update_feedback_buttons();void review_crash_report(ByteString const& report_name);@@ -173,7 +171,7 @@ private:virtual void open_download(WebView::FileDownloader::Download const&) const override;virtual void show_download_in_folder(WebView::FileDownloader::Download const&) const override;- virtual void display_crash_report_notification(ByteString const& report_name) override;+ virtual void crash_report_saved() override;virtual bool supports_clipboard_type(ClipboardType) const override;virtual Utf16String clipboard_text(ClipboardType) const override;@@ -218,7 +216,6 @@ private:OwnPtr<QApplication> m_application;BrowserWindow* m_active_window { nullptr };OwnPtr<ProcessManagerWindow> m_process_manager_window;- CrashReportNotifier m_crash_report_notifier;bool m_private_session_restart_in_progress { false };bool m_quit_in_progress { false };diff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cppindex 56a1551f783..faefe7282e9 100644--- a/UI/Qt/BrowserWindow.cpp+++ b/UI/Qt/BrowserWindow.cpp@@ -1560,12 +1560,6 @@ void BrowserWindow::exit_fullscreen()showNormal();m_tabs_container->update_bookmarks_bar_visibility();-- // A crash report that came in while the toolbar was hidden can be offered now, even on a tab other than the one- // that was current back then.- QTimer::singleShot(0, this, [] {- Application::the().crash_report_notifier().show_pending();- });}bool BrowserWindow::event(QEvent* event)@@ -1598,7 +1592,6 @@ bool BrowserWindow::event(QEvent* event)report_activation_to_session_store();QTimer::singleShot(0, this, [this] {refresh_resize_cursor_at_current_position(true);- Application::the().crash_report_notifier().show_pending();});QTimer::singleShot(50, this, [this] {refresh_resize_cursor_at_current_position(true);diff --git a/UI/Qt/CMakeLists.txt b/UI/Qt/CMakeLists.txtindex c48de9c9154..85730fae60b 100644--- a/UI/Qt/CMakeLists.txt+++ b/UI/Qt/CMakeLists.txt@@ -21,7 +21,6 @@ add_library(ladybird_impl STATICBookmarksBar.cppBrowserWindow.cppChromeStyle.cpp- CrashReportNotifier.cppCrashReportReviewWidget.cppDevToolsBanner.cppEventLoopImplementationQt.cppdiff --git a/UI/Qt/CrashReportNotifier.cpp b/UI/Qt/CrashReportNotifier.cppdeleted file mode 100644index 63e6f4237ad..00000000000--- a/UI/Qt/CrashReportNotifier.cpp+++ /dev/null@@ -1,115 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#include <AK/StdLibExtras.h>-#include <LibWebView/CrashReportStore.h>-#include <UI/Qt/Application.h>-#include <UI/Qt/CrashReportNotifier.h>-#include <UI/Qt/LadybirdButton.h>-#include <UI/Qt/Tab.h>--#include <QApplication>-#include <QEvent>-#include <QGuiApplication>--namespace Ladybird {--static constexpr int CRASH_REPORT_POPOVER_WIDTH = 340;--// Only the newest report is offered. One still waiting to be shown is replaced, and stays pending on disk.-void CrashReportNotifier::offer(ByteString report_name)-{- m_pending_report_name = move(report_name);- Application::the().update_feedback_buttons();-- if (!exchange(m_is_listening_for_activation, true)) {- QObject::connect(qApp, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) {- if (state == Qt::ApplicationActive)- show_pending();- });- }- show_pending();-}--// A popup of a window, such as this notifier's own popover, takes activation from the window while it is open.-static bool window_is_active(QWidget& window)-{- if (window.isMinimized())- return false;- if (window.isActiveWindow())- return true;- auto* popup = QApplication::activePopupWidget();- return popup && popup->parentWidget() && popup->parentWidget()->window() == &window;-}--// The report waits until a browser window is active and shows its toolbar, so the popover is shown where the user is.-// It also waits for the application itself to be active. Qt closes a popup on the click that activates an inactive-// application, which would dismiss the popover before its buttons could be used.-void CrashReportNotifier::show_pending()-{- if (!m_pending_report_name.has_value() || QGuiApplication::applicationState() != Qt::ApplicationActive)- return;-- auto* window = Application::the().active_window_if_any();- QWidget* anchor = window ? &window->ladybird_button() : nullptr;- if (!anchor || !anchor->isVisible() || !window_is_active(*anchor->window()))- return;-- // A newer report takes the place of one still on screen, wherever it is, which counts as offered.- if (m_popover) {- m_is_replacing_popover = true;- m_popover->close();- m_is_replacing_popover = false;- }- if (m_anchor)- m_anchor->removeEventFilter(this);- m_anchor = anchor;- m_anchor->installEventFilter(this);-- auto report_name = m_pending_report_name.release_value();- m_popover = new MessagePopover(anchor, CRASH_REPORT_POPOVER_WIDTH, tr("Part of Ladybird stopped unexpectedly"),- tr("You can send us a crash report to help fix it."), tr("Dismiss"),- tr("Review report"));- m_popover->setAttribute(Qt::WA_DeleteOnClose);-- // The review marks the report as seen once it opens it. The popover is the report's one automatic prompt, so- // however else it is left, the report is not offered again. Leaving it also declines the reports still waiting,- // except when a newer report takes its place, which is about to be offered itself.- m_popover->on_accept = [report_name] {- Application::the().review_crash_report(report_name);- Application::the().update_feedback_buttons();- };- m_popover->on_dismiss = [this, report_name] {- auto& store = WebView::CrashReportStore::the();- auto result = m_is_replacing_popover ? store.mark_seen(report_name) : store.mark_all_seen();- if (result.is_error())- warnln("Could not mark crash reports as seen: {}", result.error());- Application::the().update_feedback_buttons();- };-- // The menu button's palette is transparent, so the popover takes its colors from the window instead.- m_popover->update_chrome_style(anchor->window()->palette());- m_popover->adjustSize();- move_popover_below(*m_popover, *anchor, PopoverAlignment::Leading);- m_popover->show();- move_popover_below(*m_popover, *anchor, PopoverAlignment::Leading);- m_popover->raise();-}--// A popup is a window of its own, so it stays on screen when the tab it was shown on goes out of view. It closes with-// it instead, and takes on the colors of the browser around it.-bool CrashReportNotifier::eventFilter(QObject* object, QEvent* event)-{- if (object == m_anchor && m_popover) {- if (event->type() == QEvent::Hide)- m_popover->close();- else if (event->type() == QEvent::PaletteChange)- m_popover->update_chrome_style(m_anchor->window()->palette());- }- return QObject::eventFilter(object, event);-}--}diff --git a/UI/Qt/CrashReportNotifier.h b/UI/Qt/CrashReportNotifier.hdeleted file mode 100644index 37936fdd84e..00000000000--- a/UI/Qt/CrashReportNotifier.h+++ /dev/null@@ -1,38 +0,0 @@-/*- * Copyright (c) 2026-present, the Ladybird developers.- *- * SPDX-License-Identifier: BSD-2-Clause- */--#pragma once--#include <AK/ByteString.h>-#include <AK/Optional.h>-#include <AK/kmalloc.h>-#include <UI/Qt/Popover.h>--#include <QObject>-#include <QPointer>--class QEvent;--namespace Ladybird {--class CrashReportNotifier final : public QObject {-public:- AK_ALLOC_WITH_KMALLOC;-- void offer(ByteString report_name);- void show_pending();--private:- virtual bool eventFilter(QObject*, QEvent*) override;-- bool m_is_listening_for_activation { false };- bool m_is_replacing_popover { false };- Optional<ByteString> m_pending_report_name;- QPointer<MessagePopover> m_popover;- QPointer<QWidget> m_anchor;-};--}diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cppindex 7bfd48cf600..19d8361413b 100644--- a/UI/Qt/WebContentView.cpp+++ b/UI/Qt/WebContentView.cpp@@ -30,7 +30,6 @@#include <LibWebCommon/UIEvents/MouseButton.h>#include <LibWebView/Application.h>#include <LibWebView/CrashReport.h>-#include <LibWebView/CrashReportStore.h>#include <LibWebView/PlatformColors.h>#include <LibWebView/Utilities.h>#include <LibWebView/WebCompatReport.h>@@ -1779,11 +1778,10 @@ void WebContentView::show_crash_report_review(Optional<ByteString> const& hiddenreturn;}m_crash_report_review->on_exit = [this, is_hidden_crash] {- // The tab was opened only for the review, and a report on its way keeps going without it. Closing it also- // declines the reports still waiting, so none of them is offered again.+ // The tab was opened only for the review, and a report on its way keeps going without it. The reports still+ // waiting stay behind the feedback button.if (is_hidden_crash) {- if (auto result = WebView::CrashReportStore::the().mark_all_seen(); result.is_error())- warnln("Could not mark crash reports as seen: {}", result.error());+ Application::the().update_feedback_buttons();if (on_close)on_close();return;diff --git a/UI/Qt/main.cpp b/UI/Qt/main.cppindex 7d39a6fd10c..79111cb68e2 100644--- a/UI/Qt/main.cpp+++ b/UI/Qt/main.cpp@@ -135,8 +135,6 @@ ErrorOr<int> ladybird_main(Main::Arguments arguments)window.setWindowTitle(BROWSER_PRODUCT_NAME);app->offer_to_restore_unexpectedly_closed_tabs(window);}-- app->offer_newest_pending_crash_report();}return app->execute();