summary refs log tree commit diff
path: root/src/components/smart_summary.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/smart_summary.rs')
-rw-r--r--src/components/smart_summary.rs45
1 files changed, 44 insertions, 1 deletions
diff --git a/src/components/smart_summary.rs b/src/components/smart_summary.rs
index 67419cb..5b98186 100644
--- a/src/components/smart_summary.rs
+++ b/src/components/smart_summary.rs
@@ -152,6 +152,7 @@ pub(crate) enum Error {
 #[derive(Debug)]
 pub(crate) enum Input {
     #[doc(hidden)] ButtonPressed,
+    #[doc(hidden)] WarningAccepted,
     Text(String),
     Cancel,
 }
@@ -224,7 +225,49 @@ impl Component for SmartSummaryButton {
                     log::warn!("Parent component asked us to cancel, but we're not running a task.");
                 }
             },
-            Input::ButtonPressed => if let Ok(()) = sender.output(Output::Start) {
+            Input::ButtonPressed => {
+                let settings = gio::Settings::new(crate::APPLICATION_ID);
+                if !settings.get::<bool>("smart-summary-show-warning") {
+                    return self.update(Input::WarningAccepted, sender, _root);
+                } else {
+                    // TODO: show warning dialog
+                    let skip_warning_checkbox = gtk::CheckButton::with_label(
+                        &gettext("Show this warning next time")
+                    );
+
+                    settings.bind(
+                        "smart-summary-show-warning",
+                        &skip_warning_checkbox, "active"
+                    ).get().set().build();
+
+                    let dialog = adw::AlertDialog::builder()
+                        .heading(gettext("LLMs can be deceiving"))
+                        .body(gettext("Language models inherently lack any sort of intelligence, understanding of the text they take or produce, or conscience to feel guilty for lying or deceiving their user.
+
+<b>Smart Summary</b> is only designed to generate draft-quality output that must be proof-read by a human before being posted."))
+                        .body_use_markup(true)
+                        .default_response("continue")
+                        .extra_child(&skip_warning_checkbox)
+                        .build();
+                    dialog.add_responses(&[
+                        ("close", &gettext("Cancel")),
+                        ("continue", &gettext("Proceed"))
+                    ]);
+                    dialog.choose(
+                        &_root.root().unwrap(),
+                        None::<&gio::Cancellable>,
+                        glib::clone!(
+                            #[strong] sender,
+                            move |res| match res.as_str() {
+                                "continue" => {
+                                    sender.input(Input::WarningAccepted);
+                                },
+                                _ => {},
+                            }
+                        ))
+                }
+            },
+            Input::WarningAccepted => if let Ok(()) = sender.output(Output::Start) {
                 self.waiting = true;
                 log::debug!("Requesting text to summarize from parent component...");
                 // TODO: set timeout in case parent component never replies