Skip to content

Truly independent web browser

LibWebView+UI/Qt: Add an outbox for sending crash reports

Andreas Klingdf7ac54b0ad0
diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cpp
index 2535ed91339..1401762ecc0 100644
--- a/Libraries/LibWebView/Application.cpp
+++ b/Libraries/LibWebView/Application.cpp
@@ -52,6 +52,7 @@
#include <LibWebView/CompositorClient.h>
#include <LibWebView/CompositorPresentationClient.h>
#include <LibWebView/CookieJar.h>
+#include <LibWebView/CrashReportOutbox.h>
#include <LibWebView/CrashReportStore.h>
#include <LibWebView/FaviconStore.h>
#include <LibWebView/FontService.h>
@@ -2384,7 +2385,7 @@ void Application::process_did_exit(Process&& process, Optional<int>)
// 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) {
- crash_report_saved();
+ CrashReportOutbox::the().reports_changed();
} 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());
diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.h
index 0960c091263..5500e8f72f9 100644
--- a/Libraries/LibWebView/Application.h
+++ b/Libraries/LibWebView/Application.h
@@ -463,8 +463,6 @@ protected:
virtual NonnullRefPtr<Core::Promise<ByteString>> ask_user_for_download_path(ByteString const& file) const;
- virtual void crash_report_saved() { }
-
virtual void update_tabs_display() const { }
virtual void rebuild_bookmarks_menu() const { }
diff --git a/Libraries/LibWebView/CMakeLists.txt b/Libraries/LibWebView/CMakeLists.txt
index 65784c2caa2..3faecf02a8b 100644
--- a/Libraries/LibWebView/CMakeLists.txt
+++ b/Libraries/LibWebView/CMakeLists.txt
@@ -25,6 +25,7 @@ set(SOURCES
CookieJar.cpp
CrashReport.cpp
CrashReportDiagnostics.cpp
+ CrashReportOutbox.cpp
CrashReportReview.cpp
CrashReportStore.cpp
CrashReportSubmission.cpp
diff --git a/Libraries/LibWebView/CrashReportDiagnostics.cpp b/Libraries/LibWebView/CrashReportDiagnostics.cpp
index bd9d4ca027c..65d8988b684 100644
--- a/Libraries/LibWebView/CrashReportDiagnostics.cpp
+++ b/Libraries/LibWebView/CrashReportDiagnostics.cpp
@@ -91,6 +91,16 @@ CrashReportDiagnostics CrashReportDiagnostics::parse(StringView text)
return diagnostics;
}
+ByteString CrashReportDiagnostics::signature() const
+{
+ StringBuilder builder;
+ builder.appendff("{}\n", header("Process"sv));
+ for (auto name : failure_headers)
+ builder.appendff("{}\n", header(name));
+ builder.appendff("{}\n{}", signal.name, stack);
+ return builder.to_byte_string();
+}
+
ByteString CrashReportDiagnostics::header(StringView name) const
{
for (auto const& entry : headers) {
diff --git a/Libraries/LibWebView/CrashReportDiagnostics.h b/Libraries/LibWebView/CrashReportDiagnostics.h
index 0f93aa8a1b6..d0f2e3352ed 100644
--- a/Libraries/LibWebView/CrashReportDiagnostics.h
+++ b/Libraries/LibWebView/CrashReportDiagnostics.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/Array.h>
#include <AK/ByteString.h>
#include <AK/Optional.h>
#include <AK/Time.h>
@@ -26,11 +27,16 @@ struct WEBVIEW_API CrashReportDiagnostics {
Optional<u64> number;
};
+ static constexpr auto failure_headers = Array { "Verification failed"sv, "Assertion failed"sv, "Rust panic"sv, "Exit code"sv };
+
static CrashReportDiagnostics parse(StringView text);
// The first value under this name, or an empty string when the report has no such line.
ByteString header(StringView name) const;
+ // What the crash has in common with every other crash of the same bug: the process, how it failed and where.
+ ByteString signature() const;
+
Vector<Header> headers;
ByteString stack;
diff --git a/Libraries/LibWebView/CrashReportOutbox.cpp b/Libraries/LibWebView/CrashReportOutbox.cpp
new file mode 100644
index 00000000000..61f20e80ad5
--- /dev/null
+++ b/Libraries/LibWebView/CrashReportOutbox.cpp
@@ -0,0 +1,147 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <AK/AnyOf.h>
+#include <AK/NeverDestroyed.h>
+#include <LibWebView/CrashReportOutbox.h>
+
+namespace WebView {
+
+CrashReportOutbox& CrashReportOutbox::the()
+{
+ static NeverDestroyed<CrashReportOutbox> outbox;
+ return *outbox;
+}
+
+CrashReportOutbox::CrashReportOutbox(CrashReportStore& store)
+ : m_store(store)
+ , m_review(store)
+{
+ m_review.on_sent = [this] {
+ m_report_being_sent.clear();
+ send_next();
+ reports_changed();
+ };
+ m_review.on_retry = [this](auto, auto, auto, auto) {
+ m_report_being_sent_was_retried = true;
+ };
+ m_review.on_failed = [this](auto, String reason) {
+ warnln("Could not send crash report {}: {}", *m_report_being_sent, reason);
+ report_failed();
+
+ // Retries that all failed took a while, and the next report would only wait through the same ones. A report
+ // the server turned down says nothing about the others.
+ if (m_report_being_sent_was_retried) {
+ for (auto const& report : m_queue)
+ m_could_not_send.set(report.name, report.earlier_attempt);
+ m_queue.clear();
+ }
+
+ send_next();
+ reports_changed();
+ };
+}
+
+void CrashReportOutbox::send(Vector<Report> reports)
+{
+ for (auto& report : reports) {
+ if (is_sending(report.name))
+ continue;
+ if (auto earlier_attempt = m_could_not_send.take(report.name); earlier_attempt.has_value())
+ report.earlier_attempt = earlier_attempt.release_value();
+ m_queue.append(move(report));
+ }
+
+ if (!m_report_being_sent.has_value())
+ send_next();
+ reports_changed();
+}
+
+void CrashReportOutbox::send_next()
+{
+ while (!m_report_being_sent.has_value() && !m_queue.is_empty()) {
+ auto report = m_queue.take_first();
+ m_report_being_sent = report.name;
+ m_report_being_sent_was_retried = false;
+
+ if (auto opened = m_review.open(report.name, CrashReportReview::MarkAsSeen::No); opened.is_error()) {
+ warnln("Could not open crash report {}: {}", report.name, opened.error());
+ report_failed();
+ continue;
+ }
+ if (report.earlier_attempt.has_value())
+ m_review.set_prepared_submission(report.earlier_attempt.release_value());
+ if (auto reason = m_review.send(report.description, {}); reason.has_value()) {
+ warnln("Could not send crash report {}: {}", report.name, *reason);
+ report_failed();
+ }
+ }
+}
+
+void CrashReportOutbox::report_failed()
+{
+ m_could_not_send.set(m_report_being_sent.release_value(), m_review.prepared_submission());
+}
+
+void CrashReportOutbox::remove(ReadonlySpan<ByteString> names)
+{
+ for (auto const& name : names) {
+ if (is_sending(name))
+ continue;
+ if (auto result = m_store.remove_report(name); result.is_error())
+ warnln("Could not delete crash report {}: {}", name, result.error());
+ m_could_not_send.remove(name);
+ }
+ reports_changed();
+}
+
+bool CrashReportOutbox::is_sending(ByteString const& name) const
+{
+ return m_report_being_sent == name
+ || any_of(m_queue, [&](auto const& report) { return report.name == name; });
+}
+
+size_t CrashReportOutbox::waiting_report_count() const
+{
+ auto names = m_store.pending_report_names();
+ if (names.is_error())
+ return 0;
+
+ size_t count = 0;
+ for (auto const& name : names.value()) {
+ if (!is_sending(name))
+ ++count;
+ }
+ return count;
+}
+
+void CrashReportOutbox::reports_changed()
+{
+ for (auto& observer : m_observers)
+ observer.crash_reports_changed();
+}
+
+void CrashReportOutbox::add_observer(Badge<CrashReportOutboxObserver>, CrashReportOutboxObserver& observer)
+{
+ m_observers.append(observer);
+}
+
+void CrashReportOutbox::remove_observer(Badge<CrashReportOutboxObserver>, CrashReportOutboxObserver& observer)
+{
+ m_observers.remove_first_matching([&](auto& candidate) { return &candidate == &observer; });
+}
+
+CrashReportOutboxObserver::CrashReportOutboxObserver()
+{
+ CrashReportOutbox::the().add_observer({}, *this);
+}
+
+CrashReportOutboxObserver::~CrashReportOutboxObserver()
+{
+ CrashReportOutbox::the().remove_observer({}, *this);
+}
+
+}
diff --git a/Libraries/LibWebView/CrashReportOutbox.h b/Libraries/LibWebView/CrashReportOutbox.h
new file mode 100644
index 00000000000..cbdcb1ac6c2
--- /dev/null
+++ b/Libraries/LibWebView/CrashReportOutbox.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2026-present, the Ladybird developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/ByteString.h>
+#include <AK/HashMap.h>
+#include <AK/Optional.h>
+#include <AK/String.h>
+#include <AK/Vector.h>
+#include <LibWebView/CrashReportReview.h>
+#include <LibWebView/Forward.h>
+
+namespace WebView {
+
+class CrashReportOutboxObserver;
+
+// Sends the reports the user chose, one at a time, whatever becomes of the page they chose them on. A report stays in
+// the store until it has been sent, so one that could not be sent goes on waiting.
+class WEBVIEW_API CrashReportOutbox {
+public:
+ struct Report {
+ ByteString name;
+ String description;
+ Optional<CrashReportReview::PreparedSubmission> earlier_attempt {};
+ };
+
+ static CrashReportOutbox& the();
+
+ explicit CrashReportOutbox(CrashReportStore& = CrashReportStore::the());
+
+ void send(Vector<Report>);
+
+ // A report on its way is no longer the user's to delete.
+ void remove(ReadonlySpan<ByteString> names);
+
+ bool is_sending(ByteString const& name) const;
+ bool could_not_send(ByteString const& name) const { return m_could_not_send.contains(name); }
+
+ // The reports that need the user, which leaves out those on their way.
+ size_t waiting_report_count() const;
+
+ void reports_changed();
+
+ void add_observer(Badge<CrashReportOutboxObserver>, CrashReportOutboxObserver&);
+ void remove_observer(Badge<CrashReportOutboxObserver>, CrashReportOutboxObserver&);
+
+private:
+ void send_next();
+ void report_failed();
+
+ CrashReportStore& m_store;
+ CrashReportReview m_review;
+ Vector<Report> m_queue;
+ Optional<ByteString> m_report_being_sent;
+ HashMap<ByteString, Optional<CrashReportReview::PreparedSubmission>> m_could_not_send;
+ bool m_report_being_sent_was_retried { false };
+ Vector<CrashReportOutboxObserver&> m_observers;
+};
+
+class WEBVIEW_API CrashReportOutboxObserver {
+public:
+ CrashReportOutboxObserver();
+ virtual ~CrashReportOutboxObserver();
+
+ // A report was saved, sent or removed, or began or failed to be sent.
+ virtual void crash_reports_changed() = 0;
+};
+
+}
diff --git a/Libraries/LibWebView/CrashReportReview.cpp b/Libraries/LibWebView/CrashReportReview.cpp
index 352eefb8b58..98e0c2388b7 100644
--- a/Libraries/LibWebView/CrashReportReview.cpp
+++ b/Libraries/LibWebView/CrashReportReview.cpp
@@ -5,7 +5,6 @@
*/
#include <AK/AnyOf.h>
-#include <AK/Array.h>
#include <AK/Hex.h>
#include <AK/WeakPtr.h>
#include <LibCrypto/Hash/SHA2.h>
@@ -14,8 +13,6 @@
namespace WebView {
-static constexpr auto failure_headers = Array { "Verification failed"sv, "Assertion failed"sv, "Rust panic"sv, "Exit code"sv };
-
static String to_string(StringView text)
{
return String::from_utf8_with_replacement_character(text);
@@ -33,7 +30,7 @@ CrashReportReview::CrashReportReview(CrashReportStore& store)
CrashReportReview::~CrashReportReview() = default;
-ErrorOr<CrashReportReview::Report> CrashReportReview::open(Optional<ByteString> const& name)
+ErrorOr<CrashReportReview::Report> CrashReportReview::open(Optional<ByteString> const& name, MarkAsSeen mark_as_seen)
{
VERIFY(!m_submission);
@@ -54,8 +51,10 @@ ErrorOr<CrashReportReview::Report> CrashReportReview::open(Optional<ByteString>
auto saved_report = TRY(m_store.saved_report(report_name));
// Without this, a report closed rather than answered would come back on every launch.
- if (auto result = m_store.mark_seen(report_name); result.is_error())
- warnln("Could not mark crash report as seen: {}", result.error());
+ if (mark_as_seen == MarkAsSeen::Yes) {
+ if (auto result = m_store.mark_seen(report_name); result.is_error())
+ warnln("Could not mark crash report as seen: {}", result.error());
+ }
m_report_name = report_name;
m_text_digest = sha256_hex(saved_report.text.bytes());
@@ -86,7 +85,7 @@ ErrorOr<CrashReportReview::Report> CrashReportReview::open(Optional<ByteString>
if (auto crashed_at = diagnostics.crashed_at->to_string("%Y-%m-%d %H:%M:%S"sv, UnixDateTime::LocalTime::Yes); !crashed_at.is_error())
add_field("Crash date"sv, crashed_at.value().bytes_as_string_view());
}
- for (auto header : failure_headers) {
+ for (auto header : CrashReportDiagnostics::failure_headers) {
if (auto value = diagnostics.header(header); !value.is_empty()) {
add_field(header, value, true);
break;
@@ -192,6 +191,12 @@ Optional<String> CrashReportReview::send(String const& description, Optional<Str
return {};
}
+void CrashReportReview::set_prepared_submission(PreparedSubmission submission)
+{
+ m_prepared_manifest = move(submission.manifest);
+ m_prepared_description = move(submission.description);
+}
+
// The report stays on the device, and sending it again sends the same submission, which the server recognizes if the
// canceled one reached it after all.
void CrashReportReview::cancel_sending()
diff --git a/Libraries/LibWebView/CrashReportReview.h b/Libraries/LibWebView/CrashReportReview.h
index 33f197b4de4..155cc3a1cf5 100644
--- a/Libraries/LibWebView/CrashReportReview.h
+++ b/Libraries/LibWebView/CrashReportReview.h
@@ -30,6 +30,12 @@ public:
static constexpr size_t maximum_description_bytes = 16384;
static constexpr size_t maximum_url_bytes = 4096;
+ // What an earlier attempt sent, which lets another attempt count as the same submission.
+ struct PreparedSubmission {
+ ByteString manifest;
+ String description;
+ };
+
struct Report {
ByteString name;
// The fields that tell crashes apart. The rest is in the report itself, which report_text() reads.
@@ -39,9 +45,15 @@ public:
explicit CrashReportReview(CrashReportStore& = CrashReportStore::the());
~CrashReportReview();
- // Opens the named report, or the newest one awaiting review. Being shown is the user's one prompt for a report, so
- // it counts as seen from then on and declining it needs no further step.
- ErrorOr<Report> open(Optional<ByteString> const& name = {});
+ enum class MarkAsSeen : u8 {
+ No,
+ Yes,
+ };
+
+ // Opens the named report, or the newest one awaiting review. Being shown as the user's one prompt for a report makes
+ // it count as seen from then on, so declining it needs no further step. A report that goes on waiting whatever
+ // comes of this review is opened without that.
+ ErrorOr<Report> open(Optional<ByteString> const& name = {}, MarkAsSeen = MarkAsSeen::Yes);
bool has_next_report() const;
// The open report's text, exactly as it would be attached.
@@ -53,6 +65,8 @@ public:
// Returns why nothing was sent, or nothing when the report is on its way. A report on its way keeps being sent if
// the review is destroyed, which then only stops hearing about it.
Optional<String> send(String const& description, Optional<String> const& url);
+ PreparedSubmission prepared_submission() const { return { m_prepared_manifest, m_prepared_description }; }
+ void set_prepared_submission(PreparedSubmission);
bool is_sending() const { return m_submission; }
void cancel_sending();
diff --git a/Libraries/LibWebView/CrashReportStore.cpp b/Libraries/LibWebView/CrashReportStore.cpp
index 7e30e8fca5d..49f8d8494e9 100644
--- a/Libraries/LibWebView/CrashReportStore.cpp
+++ b/Libraries/LibWebView/CrashReportStore.cpp
@@ -308,7 +308,7 @@ ErrorOr<void> CrashReportStore::mark_seen(ByteString const& name) const
return {};
}
-ErrorOr<void> CrashReportStore::remove_sent_report(ByteString const& name) const
+ErrorOr<void> CrashReportStore::remove_report(ByteString const& name) const
{
if (!is_saved_report_name(name))
return Error::from_string_literal("Invalid crash report name");
@@ -318,7 +318,7 @@ ErrorOr<void> CrashReportStore::remove_sent_report(ByteString const& name) const
return {};
return Error::from_errno(errno);
}
- // The removal is only durable once the directory is, or a sent report could be offered and sent again.
+ // The removal is only durable once the directory is, or a removed report could be offered again.
if (fsync(from.fd()) < 0)
return Error::from_errno(errno);
return {};
@@ -483,7 +483,7 @@ ErrorOr<CrashReportStore::SavedReport> CrashReportStore::saved_report(ByteString
ErrorOr<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::remove_sent_report(ByteString const&) const { return {}; }
+ErrorOr<void> CrashReportStore::remove_report(ByteString const&) const { return {}; }
ErrorOr<ByteString> CrashReportStore::store_report(ProcessType, StringView, UnixDateTime) const
{
diff --git a/Libraries/LibWebView/CrashReportStore.h b/Libraries/LibWebView/CrashReportStore.h
index 98abb811259..48e10b523ba 100644
--- a/Libraries/LibWebView/CrashReportStore.h
+++ b/Libraries/LibWebView/CrashReportStore.h
@@ -41,7 +41,7 @@ public:
// 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> remove_sent_report(ByteString const& name) const;
+ ErrorOr<void> remove_report(ByteString const& name) const;
// Reports that are still unsent 30 days after their crash are deleted, whether they were seen or not.
ErrorOr<void> remove_expired_reports(UnixDateTime now = UnixDateTime::now()) const;
diff --git a/Libraries/LibWebView/CrashReportSubmission.cpp b/Libraries/LibWebView/CrashReportSubmission.cpp
index 19910dd99bc..b606cd65167 100644
--- a/Libraries/LibWebView/CrashReportSubmission.cpp
+++ b/Libraries/LibWebView/CrashReportSubmission.cpp
@@ -96,7 +96,7 @@ ErrorOr<ReportSubmission::Payload, String> CrashReportSubmission::prepare()
void CrashReportSubmission::did_send()
{
- if (auto result = m_store.remove_sent_report(m_options.report_name); result.is_error())
+ if (auto result = m_store.remove_report(m_options.report_name); result.is_error())
warnln("Could not remove the sent crash report: {}", result.error());
}
diff --git a/Tests/LibWebView/TestCrashReportReview.cpp b/Tests/LibWebView/TestCrashReportReview.cpp
index ab64bd6bd7d..f49c7e15003 100644
--- a/Tests/LibWebView/TestCrashReportReview.cpp
+++ b/Tests/LibWebView/TestCrashReportReview.cpp
@@ -167,6 +167,19 @@ TEST_CASE(an_opened_report_is_no_longer_pending)
EXPECT(review.open().is_error());
}
+TEST_CASE(a_report_opened_without_marking_it_seen_stays_pending)
+{
+ cleanup();
+ ScopeGuard guard = cleanup;
+
+ auto name = write_report("2026-10-01T12-00-00Z"sv);
+ WebView::CrashReportStore store { test_directory() };
+ CrashReportReview review { store };
+
+ EXPECT_EQ(MUST(review.open(name, CrashReportReview::MarkAsSeen::No)).name, name);
+ EXPECT(is_pending(name));
+}
+
TEST_CASE(a_report_can_be_reopened_by_name_once_seen)
{
cleanup();
diff --git a/Tests/LibWebView/TestCrashReportStore.cpp b/Tests/LibWebView/TestCrashReportStore.cpp
index d5ed094005e..1e8aca4d22a 100644
--- a/Tests/LibWebView/TestCrashReportStore.cpp
+++ b/Tests/LibWebView/TestCrashReportStore.cpp
@@ -128,7 +128,7 @@ TEST_CASE(a_name_the_store_rejects_is_never_read_or_marked)
EXPECT(MUST(test_store().pending_report_names(now)).is_empty());
EXPECT(test_store().saved_report("notes.txt"sv).is_error());
EXPECT(test_store().mark_seen("../escape.txt"sv).is_error());
- EXPECT(test_store().remove_sent_report("notes.txt"sv).is_error());
+ EXPECT(test_store().remove_report("notes.txt"sv).is_error());
}
TEST_CASE(a_seen_report_is_no_longer_pending)
@@ -252,8 +252,8 @@ TEST_CASE(sending_a_report_removes_it_wherever_it_is)
auto store = test_store();
MUST(store.mark_seen(seen_name));
- MUST(store.remove_sent_report(pending_name));
- MUST(store.remove_sent_report(seen_name));
+ MUST(store.remove_report(pending_name));
+ MUST(store.remove_report(seen_name));
EXPECT(directory_entries().is_empty());
EXPECT(directory_entries("Seen"sv).is_empty());
}
diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cpp
index 547f1658cd5..074a94d4809 100644
--- a/UI/Qt/Application.cpp
+++ b/UI/Qt/Application.cpp
@@ -1177,7 +1177,7 @@ void Application::reopen_recently_closed_tab(BrowserWindow* target_window, Optio
update_reopen_recently_closed_actions();
}
-void Application::crash_report_saved()
+void Application::crash_reports_changed()
{
update_feedback_buttons();
}
diff --git a/UI/Qt/Application.h b/UI/Qt/Application.h
index 9262f840620..6c52658c4d4 100644
--- a/UI/Qt/Application.h
+++ b/UI/Qt/Application.h
@@ -13,6 +13,7 @@
#include <LibWebCommon/Page/PageId.h>
#include <LibWebView/Application.h>
#include <LibWebView/BrowsingSession.h>
+#include <LibWebView/CrashReportOutbox.h>
#include <UI/Qt/BrowserWindow.h>
#include <QApplication>
@@ -40,7 +41,9 @@ enum class ShowWindow {
Yes,
};
-class Application final : public WebView::Application {
+class Application final
+ : public WebView::Application
+ , public WebView::CrashReportOutboxObserver {
WEB_VIEW_APPLICATION(Application)
public:
@@ -171,7 +174,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 crash_report_saved() override;
+ virtual void crash_reports_changed() override;
virtual bool supports_clipboard_type(ClipboardType) const override;
virtual Utf16String clipboard_text(ClipboardType) const override;
diff --git a/UI/Qt/WindowToolbar.cpp b/UI/Qt/WindowToolbar.cpp
index 86e850b0af0..ddc40ce52d1 100644
--- a/UI/Qt/WindowToolbar.cpp
+++ b/UI/Qt/WindowToolbar.cpp
@@ -9,7 +9,7 @@
#include <AK/kmalloc.h>
#include <LibWebView/Application.h>
-#include <LibWebView/CrashReportStore.h>
+#include <LibWebView/CrashReportOutbox.h>
#include <LibWebView/DownloadPresentation.h>
#include <LibWebView/TabPerformanceMonitor.h>
#include <LibWebView/WebCompatReport.h>
@@ -1456,8 +1456,23 @@ void WindowToolbar::update_downloads_popover()
void WindowToolbar::update_feedback_button()
{
- if (m_feedback_button)
- m_feedback_button->set_crash_reports_waiting(WebView::CrashReportStore::the().has_pending_reports());
+ if (!m_feedback_button)
+ return;
+
+ auto crash_report_count = WebView::CrashReportOutbox::the().waiting_report_count();
+ m_feedback_button->set_crash_reports_waiting(crash_report_count > 0);
+
+ if (m_feedback_popover && m_feedback_popover->isVisible()) {
+ m_feedback_popover->set_crash_report_count(crash_report_count);
+ fit_feedback_popover();
+ }
+}
+
+void WindowToolbar::fit_feedback_popover()
+{
+ m_feedback_popover->card().layout()->activate();
+ m_feedback_popover->adjustSize();
+ move_popover_below(*m_feedback_popover, *m_feedback_button, PopoverAlignment::Trailing);
}
void WindowToolbar::show_feedback_popover()
@@ -1487,16 +1502,13 @@ void WindowToolbar::show_feedback_popover()
if (m_tab->url().host().has_value())
reportable_host = qstring_from_ak_string(m_tab->url().serialized_host());
}
- auto names = WebView::CrashReportStore::the().pending_report_names();
- auto crash_report_count = names.is_error() ? 0 : names.value().size();
+ auto crash_report_count = WebView::CrashReportOutbox::the().waiting_report_count();
m_feedback_button->set_crash_reports_waiting(crash_report_count > 0);
m_feedback_popover->update_chrome_style(palette());
m_feedback_popover->set_reportable_host(reportable_host);
m_feedback_popover->set_crash_report_count(crash_report_count);
- m_feedback_popover->card().layout()->activate();
- m_feedback_popover->adjustSize();
- move_popover_below(*m_feedback_popover, *m_feedback_button, PopoverAlignment::Trailing);
+ fit_feedback_popover();
m_feedback_popover->show();
move_popover_below(*m_feedback_popover, *m_feedback_button, PopoverAlignment::Trailing);
m_feedback_popover->raise();
diff --git a/UI/Qt/WindowToolbar.h b/UI/Qt/WindowToolbar.h
index 068297d912a..9a157b2f1ae 100644
--- a/UI/Qt/WindowToolbar.h
+++ b/UI/Qt/WindowToolbar.h
@@ -83,6 +83,7 @@ private:
void update_downloads_popover();
void position_downloads_popover();
void show_feedback_popover();
+ void fit_feedback_popover();
WebView::IsPrivate m_is_private { WebView::IsPrivate::No };
QPointer<Tab> m_tab;