summary refs log tree commit diff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/post_editor.rs368
-rw-r--r--src/components/preferences.rs119
-rw-r--r--src/components/signin.rs253
-rw-r--r--src/components/smart_summary.rs178
-rw-r--r--src/components/tag_pill.rs4
5 files changed, 563 insertions, 359 deletions
diff --git a/src/components/post_editor.rs b/src/components/post_editor.rs
index c42b06a..021ba91 100644
--- a/src/components/post_editor.rs
+++ b/src/components/post_editor.rs
@@ -1,12 +1,16 @@
-use gettextrs::*;
 use crate::components::tag_pill::*;
 use adw::prelude::*;
+use gettextrs::*;
 
 use glib::translate::IntoGlib;
-use gtk::GridLayoutChild;
-use relm4::{factory::FactoryVecDeque, gtk, prelude::{Controller, DynamicIndex}, Component, ComponentParts, ComponentSender, RelmWidgetExt};
 #[cfg(feature = "smart-summary")]
 use relm4::prelude::ComponentController;
+use relm4::{
+    factory::FactoryVecDeque,
+    gtk,
+    prelude::{Controller, DynamicIndex},
+    Component, ComponentParts, ComponentSender, RelmWidgetExt,
+};
 
 #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, glib::Enum)]
 #[enum_type(name = "MicropubVisibility")]
@@ -19,7 +23,7 @@ impl std::fmt::Display for Visibility {
     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
         f.write_str(match self {
             Self::Public => "public",
-            Self::Private => "private"
+            Self::Private => "private",
         })
     }
 }
@@ -30,43 +34,52 @@ pub struct Post {
     pub summary: Option<String>,
     pub tags: Vec<String>,
     pub content: String,
-    pub visibility: Visibility
+    pub visibility: Visibility,
+}
+
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub struct PostConversionSettings {
+    pub send_html_directly: bool,
 }
 
-impl From<Post> for microformats::types::Item {
-    fn from(post: Post) -> Self {
-        use microformats::types::{Item, Class, KnownClass, PropertyValue};
+impl Post {
+    pub fn into_mf2(self, settings: PostConversionSettings) -> microformats::types::Item {
+        use microformats::types::{Class, Fragment, Item, KnownClass, PropertyValue};
         let mut mf2 = Item::new(vec![Class::Known(KnownClass::Entry)]);
 
-        if let Some(name) = post.name {
-            mf2.properties.insert(
-                "name".to_owned(), vec![PropertyValue::Plain(name)]
-            );
+        if let Some(name) = self.name {
+            mf2.properties
+                .insert("name".to_owned(), vec![PropertyValue::Plain(name)]);
         }
 
-        if let Some(summary) = post.summary {
-            mf2.properties.insert(
-                "summary".to_owned(),
-                vec![PropertyValue::Plain(summary)]
-            );
+        if let Some(summary) = self.summary {
+            mf2.properties
+                .insert("summary".to_owned(), vec![PropertyValue::Plain(summary)]);
         }
 
-        if !post.tags.is_empty() {
+        if !self.tags.is_empty() {
             mf2.properties.insert(
                 "category".to_string(),
-                post.tags.into_iter().map(PropertyValue::Plain).collect()
+                self.tags.into_iter().map(PropertyValue::Plain).collect(),
             );
         }
 
         mf2.properties.insert(
             "visibility".to_string(),
-            vec![PropertyValue::Plain(post.visibility.to_string())]
+            vec![PropertyValue::Plain(self.visibility.to_string())],
         );
 
-        mf2.properties.insert(
-            "content".to_string(),
-            vec![PropertyValue::Plain(post.content)]
-        );
+        let content = if settings.send_html_directly {
+            PropertyValue::Fragment(Fragment {
+                html: self.content.clone(),
+                value: self.content,
+                lang: None,
+            })
+        } else {
+            PropertyValue::Plain(self.content)
+        };
+
+        mf2.properties.insert("content".to_string(), vec![content]);
 
         mf2
     }
@@ -75,22 +88,35 @@ impl From<Post> for microformats::types::Item {
 #[tracker::track]
 #[derive(Debug)]
 pub(crate) struct PostEditor<E> {
-    #[no_eq] smart_summary_busy_guard: Option<gtk::gio::ApplicationBusyGuard>,
+    #[no_eq]
+    smart_summary_busy_guard: Option<gtk::gio::ApplicationBusyGuard>,
     sending: bool,
-
-    #[do_not_track] name_buffer: gtk::EntryBuffer,
-    #[do_not_track] summary_buffer: gtk::EntryBuffer,
-    #[do_not_track] content_buffer: gtk::TextBuffer,
-
-    #[do_not_track] pending_tag_buffer: gtk::EntryBuffer,
-    #[do_not_track] tags: relm4::factory::FactoryVecDeque<TagPill>,
+    #[do_not_track]
+    #[allow(dead_code)]
+    spell_checker: spelling::Checker,
+    #[do_not_track]
+    spelling_adapter: spelling::TextBufferAdapter,
+
+    #[do_not_track]
+    name_buffer: gtk::EntryBuffer,
+    #[do_not_track]
+    summary_buffer: gtk::EntryBuffer,
+    #[do_not_track]
+    content_buffer: sourceview5::Buffer,
+
+    #[do_not_track]
+    pending_tag_buffer: gtk::EntryBuffer,
+    #[do_not_track]
+    tags: relm4::factory::FactoryVecDeque<TagPill>,
     visibility: Visibility,
 
-    #[do_not_track] wide_layout: gtk::GridLayout,
+    #[do_not_track]
+    narrow_layout: gtk::BoxLayout,
 
     #[cfg(feature = "smart-summary")]
-    #[do_not_track] smart_summary: Controller<crate::components::SmartSummaryButton>,
-    _err: std::marker::PhantomData<E>
+    #[do_not_track]
+    smart_summary: Controller<crate::components::SmartSummaryButton>,
+    _err: std::marker::PhantomData<E>,
 }
 
 impl<E> PostEditor<E> {
@@ -107,13 +133,17 @@ impl<E> PostEditor<E> {
 #[allow(clippy::manual_non_exhaustive)] // false positive
 pub enum Input<E: std::error::Error + std::fmt::Debug + Send + 'static> {
     #[cfg(feature = "smart-summary")]
-    #[doc(hidden)] SmartSummary(crate::components::smart_summary::Output),
-    #[doc(hidden)] VisibilitySelected(Visibility),
-    #[doc(hidden)] AddTagFromBuffer,
-    #[doc(hidden)] RemoveTag(DynamicIndex),
+    #[doc(hidden)]
+    SmartSummary(crate::components::smart_summary::Output),
+    #[doc(hidden)]
+    VisibilitySelected(Visibility),
+    #[doc(hidden)]
+    AddTagFromBuffer,
+    #[doc(hidden)]
+    RemoveTag(DynamicIndex),
     Submit,
     SubmitDone(glib::Uri),
-    SubmitError(E)
+    SubmitError(E),
 }
 
 #[relm4::component(pub)]
@@ -137,20 +167,21 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
 
                 gtk::ScrolledWindow {
                     #[name = "content"]
-                    gtk::Box {
+                    gtk::Grid {
                         set_orientation: gtk::Orientation::Vertical,
-                        set_spacing: 5,
+                        set_column_homogeneous: false,
+                        set_row_spacing: 10,
                         set_margin_all: 5,
 
                         #[name = "name_label"]
-                        gtk::Label {
+                        attach[0, 0, 1, 1] = &gtk::Label {
                             set_markup: &gettext("Name"),
                             set_margin_horizontal: 10,
                             set_halign: gtk::Align::Start,
                             set_valign: gtk::Align::Center,
                         },
                         #[name = "name_field"]
-                        gtk::Entry {
+                        attach[1, 0, 1, 1] = &gtk::Entry {
                             set_hexpand: true,
                             set_buffer: &model.name_buffer,
                             #[track = "model.changed(Self::sending())"]
@@ -158,14 +189,14 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                         },
 
                         #[name = "summary_label"]
-                        gtk::Label {
+                        attach[0, 1, 1, 1] = &gtk::Label {
                             set_markup: &gettext("Summary"),
                             set_margin_horizontal: 10,
                             set_halign: gtk::Align::Start,
                             set_valign: gtk::Align::Center,
                         },
                         #[name = "summary_field"]
-                        gtk::Box {
+                        attach[1, 1, 1, 1] = &gtk::Box {
                             set_orientation: gtk::Orientation::Horizontal,
                             add_css_class: "linked",
 
@@ -178,14 +209,14 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                         },
 
                         #[name = "tag_label"]
-                        gtk::Label {
+                        attach[0, 2, 1, 1] = &gtk::Label {
                             set_markup: &gettext("Tags"),
                             set_margin_horizontal: 10,
                             set_halign: gtk::Align::Start,
                             set_valign: gtk::Align::Center,
                         },
                         #[name = "tag_holder"]
-                        gtk::Box {
+                        attach[1, 2, 1, 1] = &gtk::Box {
                             set_hexpand: true,
                             set_orientation: gtk::Orientation::Vertical,
                             set_spacing: 5,
@@ -211,22 +242,10 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                             },
                         },
 
-                        #[name = "tag_viewport"]
-                        gtk::ScrolledWindow {
-                            set_height_request: 32,
-                            set_valign: gtk::Align::Center,
-
-                            gtk::Viewport {
-                                set_scroll_to_focus: true,
-                                set_valign: gtk::Align::Center,
-
-                                #[wrap(Some)]
-                                set_child = model.tags.widget(),
-                            }
-                        },
+                        attach[1, 3, 1, 1] = model.tags.widget(),
 
                         #[name = "content_label"]
-                        gtk::Label {
+                        attach[0, 4, 1, 1] = &gtk::Label {
                             set_markup: &gettext("Content"),
                             set_halign: gtk::Align::Start,
                             set_valign: gtk::Align::Start,
@@ -235,12 +254,15 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                         },
 
                         #[name = "content_textarea_wrapper"]
-                        gtk::ScrolledWindow {
+                        attach[1, 4, 1, 1] = &gtk::ScrolledWindow {
                             set_vexpand: true,
                             set_height_request: 200,
                             #[name = "content_textarea"]
                             gtk::TextView {
                                 set_buffer: Some(&model.content_buffer),
+                                set_extra_menu: Some(&model.spelling_adapter.menu_model()),
+                                insert_action_group: ("spelling", Some(&model.spelling_adapter)),
+
                                 set_hexpand: true,
                                 #[iterate]
                                 add_css_class: &["frame", "view"],
@@ -260,7 +282,7 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                         },
 
                         #[name = "misc_prop_wrapper"]
-                        gtk::Box {
+                        attach[0, 5, 2, 1] = &gtk::Box {
                             set_hexpand: true,
 
                             gtk::FlowBox {
@@ -315,19 +337,17 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                     },
                 },
 
+                // We could've used AdwMultiLayoutView, but a raw
+                // breakpoint makes a bit more sense since we need to
+                // change some properties along the way.
                 add_breakpoint = adw::Breakpoint::new(
                     adw::BreakpointCondition::new_length(
-                        adw::BreakpointConditionLengthType::MinWidth,
+                        adw::BreakpointConditionLengthType::MaxWidth,
                         512.0,
                         adw::LengthUnit::Px
                     )
                 ) {
-                    add_setter: (&content, "layout_manager", Some(&model.wide_layout.to_value())),
-                    add_setter: (&name_label, "halign", Some(&gtk::Align::End.to_value())),
-                    add_setter: (&summary_label, "halign", Some(&gtk::Align::End.to_value())),
-                    add_setter: (&tag_label, "halign", Some(&gtk::Align::End.to_value())),
-                    add_setter: (&content_label, "halign", Some(&gtk::Align::End.to_value())),
-                    add_setter: (&pending_tag_entry, "hexpand", Some(&false.to_value())),
+                    add_setter: (&content, "layout_manager", Some(&model.narrow_layout.to_value())),
                 },
 
             }
@@ -337,34 +357,46 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
     fn init(
         init: Self::Init,
         root: Self::Root,
-        sender: ComponentSender<Self>
+        sender: ComponentSender<Self>,
     ) -> ComponentParts<Self> {
         #[cfg(feature = "smart-summary")]
         let (http, init) = init;
 
+        let spell_checker = spelling::Checker::default();
+        let content_buffer = Default::default();
+
         let mut model = Self {
             smart_summary_busy_guard: None,
             sending: false,
 
+            spelling_adapter: spelling::TextBufferAdapter::new(&content_buffer, &spell_checker),
+            spell_checker,
+
             name_buffer: gtk::EntryBuffer::default(),
             summary_buffer: gtk::EntryBuffer::default(),
-            content_buffer: gtk::TextBuffer::default(),
-            pending_tag_buffer: gtk::EntryBuffer::default(),
+            content_buffer,
 
+            pending_tag_buffer: gtk::EntryBuffer::default(),
             tags: FactoryVecDeque::builder()
                 .launch({
                     let listbox = gtk::Box::default();
-                    listbox.set_orientation(gtk::Orientation::Horizontal);
-                    listbox.set_spacing(5);
+                    let layout = adw::WrapLayout::builder()
+                        .child_spacing(5)
+                        .line_spacing(5)
+                        .build();
+
+                    listbox.set_layout_manager(Some(layout));
                     listbox
                 })
-                .forward(
-                    sender.input_sender(),
-                    |del: TagPillDelete| Input::RemoveTag(del.0)
-                ),
+                .forward(sender.input_sender(), |del: TagPillDelete| {
+                    Input::RemoveTag(del.0)
+                }),
             visibility: Visibility::Public,
 
-            wide_layout: gtk::GridLayout::new(),
+            narrow_layout: gtk::BoxLayout::builder()
+                .orientation(gtk::Orientation::Vertical)
+                .spacing(5)
+                .build(),
 
             #[cfg(feature = "smart-summary")]
             smart_summary: crate::components::SmartSummaryButton::builder()
@@ -378,19 +410,20 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
         let visibility_model = adw::EnumListModel::new(Visibility::static_type());
 
         let widgets = view_output!();
-
         #[cfg(feature = "smart-summary")]
         widgets.summary_field.append(model.smart_summary.widget());
 
-        widgets.visibility_selector.set_expression(Some(
-            gtk::ClosureExpression::new::<String>(
+        model.spelling_adapter.set_enabled(true);
+
+        widgets
+            .visibility_selector
+            .set_expression(Some(gtk::ClosureExpression::new::<String>(
                 [] as [gtk::Expression; 0],
                 glib::closure::RustClosure::new(|v| {
                     let list_item = v[0].get::<adw::EnumListItem>().unwrap();
                     Some(gettext(list_item.name().as_str()).into())
-                })
-            )
-        ));
+                }),
+            )));
 
         if let Some(post) = init {
             if let Some(name) = post.name {
@@ -401,108 +434,68 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
             }
 
             let mut tags = model.tags.guard();
-            post.tags.into_iter().for_each(|t| { tags.push_back(t.into_boxed_str()); });
+            post.tags.into_iter().for_each(|t| {
+                tags.push_back(t.into_boxed_str());
+            });
 
             model.content_buffer.set_text(&post.content);
 
-            widgets.visibility_selector.set_selected(
-                visibility_model.find_position(post.visibility.into_glib())
-            );
+            widgets
+                .visibility_selector
+                .set_selected(visibility_model.find_position(post.visibility.into_glib()));
             model.visibility = post.visibility;
         }
 
-        let prev_layout = widgets.content.layout_manager().unwrap();
-        let layout = &model.wide_layout;
-        widgets.content.set_layout_manager(Some(layout.clone()));
-        layout.set_column_homogeneous(false);
-        layout.set_row_spacing(10);
-
-        enum Row<'a> {
-            TwoColumn(&'a gtk::Label, &'a gtk::Widget),
-            Span(&'a gtk::Widget),
-            SecondColumn(&'a gtk::Widget)
-        }
-
-        for (row, content) in [
-            Row::TwoColumn(&widgets.name_label, widgets.name_field.upcast_ref::<gtk::Widget>()),
-            Row::TwoColumn(&widgets.summary_label, widgets.summary_field.upcast_ref::<gtk::Widget>()),
-            Row::TwoColumn(&widgets.tag_label, widgets.tag_holder.upcast_ref::<gtk::Widget>()),
-            Row::SecondColumn(widgets.tag_viewport.upcast_ref::<gtk::Widget>()),
-            Row::TwoColumn(&widgets.content_label, widgets.content_textarea_wrapper.upcast_ref::<gtk::Widget>()),
-            Row::Span(widgets.misc_prop_wrapper.upcast_ref::<gtk::Widget>()),
-        ].into_iter().enumerate() {
-            match content {
-                Row::TwoColumn(label, field) => {
-                    let label_layout = layout.layout_child(label)
-                        .downcast::<GridLayoutChild>()
-                        .unwrap();
-                    label_layout.set_row(row as i32);
-                    label_layout.set_column(0);
-
-                    let field_layout = layout.layout_child(field)
-                        .downcast::<GridLayoutChild>()
-                        .unwrap();
-                    field_layout.set_row(row as i32);
-                    field_layout.set_column(1);
-                },
-                Row::Span(widget) => {
-                    let widget_layout = layout.layout_child(widget)
-                        .downcast::<GridLayoutChild>()
-                        .unwrap();
-                    widget_layout.set_row(row as i32);
-                    widget_layout.set_column_span(2);
-                },
-                Row::SecondColumn(widget) => {
-                    let widget_layout = layout.layout_child(widget)
-                        .downcast::<GridLayoutChild>()
-                        .unwrap();
-                    widget_layout.set_row(row as i32);
-                    widget_layout.set_column(1);
-                }
-            }
-        }
-
-        widgets.content.set_layout_manager(Some(prev_layout));
-
         ComponentParts { model, widgets }
     }
 
-    fn update_with_view(&mut self, widgets: &mut Self::Widgets, msg: Self::Input, sender: ComponentSender<Self>, root: &Self::Root) {
+    fn update_with_view(
+        &mut self,
+        widgets: &mut Self::Widgets,
+        msg: Self::Input,
+        sender: ComponentSender<Self>,
+        root: &Self::Root,
+    ) {
         self.reset();
         match msg {
             #[cfg(feature = "smart-summary")]
             Input::SmartSummary(crate::components::SmartSummaryOutput::Start) => {
                 widgets.content_textarea.set_sensitive(false);
                 if self.content_buffer.char_count() == 0 {
-                    let _ = self.smart_summary.sender().send(
-                        crate::components::SmartSummaryInput::Cancel
-                    );
+                    let _ = self
+                        .smart_summary
+                        .sender()
+                        .send(crate::components::SmartSummaryInput::Cancel);
                 } else {
                     let text = self.content_buffer.text(
                         &self.content_buffer.start_iter(),
                         &self.content_buffer.end_iter(),
-                        false
+                        false,
                     );
 
-                    self.set_smart_summary_busy_guard(
-                        Some(relm4::main_adw_application().mark_busy())
-                    );
-                    if self.smart_summary.sender().send(
-                        crate::components::SmartSummaryInput::Text(text.into())
-                    ).is_ok() {
+                    self.set_smart_summary_busy_guard(Some(
+                        relm4::main_adw_application().mark_busy(),
+                    ));
+                    if self
+                        .smart_summary
+                        .sender()
+                        .send(crate::components::SmartSummaryInput::Text(text.into()))
+                        .is_ok()
+                    {
                         self.summary_buffer.set_text("");
                     }
                 }
                 widgets.content_textarea.set_sensitive(true);
-            },
+            }
             #[cfg(feature = "smart-summary")]
             Input::SmartSummary(crate::components::SmartSummaryOutput::Chunk(text)) => {
-                self.summary_buffer.insert_text(self.summary_buffer.length(), text);
-            },
+                self.summary_buffer
+                    .insert_text(self.summary_buffer.length(), text);
+            }
             #[cfg(feature = "smart-summary")]
             Input::SmartSummary(crate::components::SmartSummaryOutput::Done) => {
                 self.set_smart_summary_busy_guard(None);
-            },
+            }
             #[cfg(feature = "smart-summary")]
             Input::SmartSummary(crate::components::SmartSummaryOutput::Error(err)) => {
                 self.set_smart_summary_busy_guard(None);
@@ -511,44 +504,51 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                 toast.set_timeout(0);
                 toast.set_priority(adw::ToastPriority::High);
                 root.add_toast(toast);
-            },
+            }
             Input::VisibilitySelected(vis) => {
                 log::debug!("Changed visibility: {}", vis);
                 self.visibility = vis;
-            },
+            }
             Input::AddTagFromBuffer => {
                 let tag = String::from(self.pending_tag_buffer.text());
                 if !tag.is_empty() {
-                    self.tags.guard().push_back(
-                        tag.into_boxed_str()
-                    );
+                    self.tags.guard().push_back(tag.into_boxed_str());
                     self.pending_tag_buffer.set_text("");
                 }
-            },
+            }
             Input::RemoveTag(idx) => {
                 self.tags.guard().remove(idx.current_index());
-            },
+            }
             Input::Submit => {
                 self.sending = true;
                 let post = if self.content_buffer.char_count() > 0 {
                     Some(Post {
                         name: if self.name_buffer.length() > 0 {
                             Some(self.name_buffer.text().into())
-                        } else { None },
+                        } else {
+                            None
+                        },
                         summary: if self.summary_buffer.length() > 0 {
                             Some(self.summary_buffer.text().into())
-                        } else { None },
+                        } else {
+                            None
+                        },
                         tags: self.tags.iter().map(|t| t.0.clone().into()).collect(),
-                        content: self.content_buffer.text(
-                            &self.content_buffer.start_iter(),
-                            &self.content_buffer.end_iter(),
-                            false
-                        ).into(),
+                        content: self
+                            .content_buffer
+                            .text(
+                                &self.content_buffer.start_iter(),
+                                &self.content_buffer.end_iter(),
+                                false,
+                            )
+                            .into(),
                         visibility: self.visibility,
                     })
-                } else { None };
+                } else {
+                    None
+                };
                 let _ = sender.output(post);
-            },
+            }
             Input::SubmitDone(location) => {
                 self.name_buffer.set_text("");
                 self.summary_buffer.set_text("");
@@ -560,18 +560,22 @@ impl<E: std::error::Error + std::fmt::Debug + Send + 'static> Component for Post
                     gtk::UriLauncher::new(&location.to_string()).launch(
                         None::<&adw::ApplicationWindow>,
                         None::<&gio::Cancellable>,
-                        glib::clone!(#[weak] toast, move |result| {
-                            if let Err(err) = result {
-                                log::warn!("Error opening post URI: {}", err);
-                            } else {
-                                toast.dismiss()
+                        glib::clone!(
+                            #[weak]
+                            toast,
+                            move |result| {
+                                if let Err(err) = result {
+                                    log::warn!("Error opening post URI: {}", err);
+                                } else {
+                                    toast.dismiss()
+                                }
                             }
-                        })
+                        ),
                     );
                 });
 
                 root.add_toast(toast);
-            },
+            }
             Input::SubmitError(err) => {
                 let toast = adw::Toast::new(&gettext!("Error sending post: {}", err));
                 toast.set_timeout(0);
diff --git a/src/components/preferences.rs b/src/components/preferences.rs
index fbf406d..27f84a9 100644
--- a/src/components/preferences.rs
+++ b/src/components/preferences.rs
@@ -1,4 +1,5 @@
-use gio::prelude::*;
+use gettextrs::*;
+
 use adw::prelude::*;
 use relm4::prelude::*;
 
@@ -6,6 +7,55 @@ pub struct Preferences {
     settings: gio::Settings,
 }
 
+#[allow(dead_code)]
+struct ComposerPreferencesWidgets {
+    page: adw::PreferencesPage,
+    general_group: adw::PreferencesGroup,
+    send_html_directly: adw::SwitchRow,
+}
+
+impl ComposerPreferencesWidgets {
+    fn new(settings: &gio::Settings) -> Self {
+        let page = adw::PreferencesPage::builder()
+            .title(gettext("Post composer"))
+            .description(gettext(
+                "Settings for composing new posts and editing existing ones.",
+            ))
+            .icon_name("editor-symbolic")
+            .build();
+        let general_group = adw::PreferencesGroup::builder()
+            .title(gettext("General"))
+            .build();
+        let send_html_directly = adw::SwitchRow::new();
+        general_group.add(&send_html_directly);
+        page.add(&general_group);
+
+        let widgets = Self {
+            page,
+            general_group,
+            send_html_directly,
+        };
+
+        let schema = settings.settings_schema().unwrap();
+
+        #[expect(clippy::single_element_loop)]
+        for (row, key, property) in [(
+            widgets
+                .send_html_directly
+                .upcast_ref::<adw::PreferencesRow>(),
+            "send-html-directly",
+            "active",
+        )] {
+            let key_data = schema.key(key);
+            settings.bind(key, row, property).get().set().build();
+            row.set_title(&gettext(key_data.summary().unwrap()));
+            row.set_tooltip_markup(key_data.description().map(gettext).as_deref());
+        }
+
+        widgets
+    }
+}
+
 #[cfg(feature = "smart-summary")]
 #[allow(dead_code)]
 struct LanguageModelPreferencesWidgets {
@@ -13,6 +63,7 @@ struct LanguageModelPreferencesWidgets {
 
     general_group: adw::PreferencesGroup,
     llm_endpoint: adw::EntryRow,
+    smart_summary_show_warning: adw::SwitchRow,
 
     smart_summary_group: adw::PreferencesGroup,
     smart_summary_model: adw::EntryRow,
@@ -24,19 +75,19 @@ struct LanguageModelPreferencesWidgets {
 #[cfg(feature = "smart-summary")]
 impl LanguageModelPreferencesWidgets {
     fn new(settings: &gio::Settings) -> Self {
-        use gettextrs::*;
-
         let page = adw::PreferencesPage::builder()
-            .title(gettext("Language Models"))
+            .title(gettext("Language models"))
             .description(gettext("Settings for the language model integrations."))
-            .icon_name("magic-wand")
+            .icon_name("brain-augemnted") // sic!
             .build();
 
         let general_group = adw::PreferencesGroup::builder()
             .title(gettext("General"))
             .build();
         let llm_endpoint = adw::EntryRow::new();
+        let smart_summary_show_warning = adw::SwitchRow::new();
         general_group.add(&llm_endpoint);
+        general_group.add(&smart_summary_show_warning);
         page.add(&general_group);
 
         let smart_summary_group = adw::PreferencesGroup::builder()
@@ -57,28 +108,53 @@ impl LanguageModelPreferencesWidgets {
 
             general_group,
             llm_endpoint,
+            smart_summary_show_warning,
 
             smart_summary_group,
             smart_summary_model,
             smart_summary_system_prompt,
             smart_summary_prompt_prefix,
-            smart_summary_prompt_suffix
+            smart_summary_prompt_suffix,
         };
 
         let schema = settings.settings_schema().unwrap();
 
-        for (row, key) in [
-            (&widgets.llm_endpoint, "llm-endpoint"),
-            (&widgets.smart_summary_model, "smart-summary-model"),
-            (&widgets.smart_summary_system_prompt, "smart-summary-system-prompt"),
-            (&widgets.smart_summary_prompt_prefix, "smart-summary-prompt-prefix"),
-            (&widgets.smart_summary_prompt_suffix, "smart-summary-prompt-suffix"),
+        for (row, key, property) in [
+            (
+                widgets.llm_endpoint.upcast_ref::<adw::PreferencesRow>(),
+                "llm-endpoint",
+                "text",
+            ),
+            (
+                widgets.smart_summary_show_warning.upcast_ref::<_>(),
+                "smart-summary-show-warning",
+                "active",
+            ),
+            (
+                widgets.smart_summary_model.upcast_ref::<_>(),
+                "smart-summary-model",
+                "text",
+            ),
+            (
+                widgets.smart_summary_system_prompt.upcast_ref::<_>(),
+                "smart-summary-system-prompt",
+                "text",
+            ),
+            (
+                widgets.smart_summary_prompt_prefix.upcast_ref::<_>(),
+                "smart-summary-prompt-prefix",
+                "text",
+            ),
+            (
+                widgets.smart_summary_prompt_suffix.upcast_ref::<_>(),
+                "smart-summary-prompt-suffix",
+                "text",
+            ),
         ] {
-            settings.bind(key, row, "text")
-                .get()
-                .set()
-                .build();
-            row.set_title(&gettext(schema.key(key).summary().unwrap()));
+            let key_data = schema.key(key);
+            settings.bind(key, row, property).get().set().build();
+            row.set_title(&gettext(key_data.summary().unwrap()));
+            row.set_tooltip_markup(key_data.description().map(gettext).as_deref());
         }
 
         widgets
@@ -86,8 +162,9 @@ impl LanguageModelPreferencesWidgets {
 }
 
 pub struct PreferencesWidgets {
+    composer: ComposerPreferencesWidgets,
     #[cfg(feature = "smart-summary")]
-    llm: LanguageModelPreferencesWidgets
+    llm: LanguageModelPreferencesWidgets,
 }
 
 impl Component for Preferences {
@@ -114,18 +191,18 @@ impl Component for Preferences {
         model.settings.delay();
 
         let widgets = PreferencesWidgets {
+            composer: ComposerPreferencesWidgets::new(&model.settings),
             #[cfg(feature = "smart-summary")]
             llm: LanguageModelPreferencesWidgets::new(&model.settings),
         };
+        root.add(&widgets.composer.page);
         #[cfg(feature = "smart-summary")]
         root.add(&widgets.llm.page);
 
         root.connect_closed(glib::clone!(
             #[strong(rename_to = settings)]
             model.settings,
-            move |_| {
-                settings.apply()
-            }
+            move |_| settings.apply()
         ));
 
         ComponentParts { model, widgets }
diff --git a/src/components/signin.rs b/src/components/signin.rs
index 53c3670..972ab43 100644
--- a/src/components/signin.rs
+++ b/src/components/signin.rs
@@ -2,7 +2,9 @@ use gettextrs::*;
 use std::cell::RefCell;
 
 use adw::prelude::*;
-use kittybox_indieauth::{AuthorizationRequest, AuthorizationResponse, Error as IndieauthError, GrantResponse, Metadata};
+use kittybox_indieauth::{
+    AuthorizationRequest, AuthorizationResponse, Error as IndieauthError, GrantResponse, Metadata,
+};
 use relm4::prelude::*;
 use soup::prelude::{ServerExt, ServerExtManual, SessionExt};
 
@@ -33,7 +35,7 @@ pub struct SignIn {
     state: kittybox_indieauth::State,
     code_verifier: kittybox_indieauth::PKCEVerifier,
     micropub_uri: Option<glib::Uri>,
-    metadata: Option<Metadata>
+    metadata: Option<Metadata>,
 }
 
 #[derive(Debug, thiserror::Error)]
@@ -67,7 +69,10 @@ pub enum Input {
     Callback(Result<AuthorizationResponse, Error>),
 }
 
-pub async fn get_metadata(http: soup::Session, url: glib::Uri) -> Result<(Metadata, glib::Uri), Error> {
+pub async fn get_metadata(
+    http: soup::Session,
+    url: glib::Uri,
+) -> Result<(Metadata, glib::Uri), Error> {
     // Fire off a speculative request at the well-known URI. This could
     // improve UX by parallelizing how we query the user's website.
     //
@@ -75,15 +80,13 @@ pub async fn get_metadata(http: soup::Session, url: glib::Uri) -> Result<(Metada
     // RECOMMENDED though optional according to IndieAuth specification
     // § 4.1.1, so we could use that if it's there to speed up the
     // process.
-    let metadata = relm4::spawn_local(
-        SignIn::well_known_metadata(http.clone(), url.clone())
-    );
+    let metadata = relm4::spawn_local(SignIn::well_known_metadata(http.clone(), url.clone()));
     let msg = soup::Message::from_uri("GET", &url);
     let body = http.send_future(&msg, glib::Priority::DEFAULT).await?;
 
     let mf2 = microformats::from_reader(
         std::io::BufReader::new(body.into_read()),
-        url.to_string().parse().unwrap()
+        url.to_string().parse().unwrap(),
     )?;
 
     let rels = mf2.rels.by_rels();
@@ -98,7 +101,7 @@ pub async fn get_metadata(http: soup::Session, url: glib::Uri) -> Result<(Metada
         // The new versions are superior by providing more features that
         // were previously proprietary extensions, and are more clearer in
         // general.
-        return Err(Error::MetadataNotFound)
+        return Err(Error::MetadataNotFound);
     };
 
     let micropub_uri = if let Some(url) = rels
@@ -108,26 +111,33 @@ pub async fn get_metadata(http: soup::Session, url: glib::Uri) -> Result<(Metada
     {
         glib::Uri::parse(url.as_str(), glib::UriFlags::NONE).unwrap()
     } else {
-        return Err(Error::MicropubLinkNotFound)
+        return Err(Error::MicropubLinkNotFound);
     };
 
     if let Ok(Some(metadata)) = metadata.await {
         Ok((metadata, micropub_uri))
     } else {
         let msg = soup::Message::from_uri("GET", &metadata_url);
-        msg.request_headers().unwrap().append("Accept", "application/json");
-        match http.send_and_read_future(&msg, glib::Priority::DEFAULT).await {
+        msg.request_headers()
+            .unwrap()
+            .append("Accept", "application/json");
+        match http
+            .send_and_read_future(&msg, glib::Priority::DEFAULT)
+            .await
+        {
             Ok(body) if msg.status() == soup::Status::Ok => {
                 let metadata = serde_json::from_slice(&body)?;
                 Ok((metadata, micropub_uri))
-            },
+            }
             Ok(_) => Err(Error::MetadataEndpointFailed(msg.status())),
             Err(err) => Err(err.into()),
         }
     }
 }
 
-fn callback_handler(sender: AsyncComponentSender<SignIn>) -> impl Fn(&soup::Server, &soup::ServerMessage, &str, std::collections::HashMap<&str, &str>) {
+fn callback_handler(
+    sender: AsyncComponentSender<SignIn>,
+) -> impl Fn(&soup::Server, &soup::ServerMessage, &str, std::collections::HashMap<&str, &str>) {
     move |server, msg, _, _| {
         let server = ObjectExt::downgrade(server);
         let sender = sender.clone();
@@ -148,7 +158,7 @@ fn callback_handler(sender: AsyncComponentSender<SignIn>) -> impl Fn(&soup::Serv
                 msg.set_response(
                     Some("text/plain; charset=\"utf-8\""),
                     soup::MemoryUse::Static,
-                    gettext("Thank you! This window can now be closed.").as_bytes()
+                    gettext("Thank you! This window can now be closed.").as_bytes(),
                 );
                 msg.connect_finished(move |_| {
                     sender.input(Input::Callback(Ok(response.take().unwrap())));
@@ -157,7 +167,7 @@ fn callback_handler(sender: AsyncComponentSender<SignIn>) -> impl Fn(&soup::Serv
                         soup::prelude::ServerExt::disconnect(&server);
                     }
                 });
-            },
+            }
             Err(err) => {
                 msg.set_status(400, soup::Status::phrase(400).as_deref());
                 if let Ok(err) = serde_urlencoded::from_str::<IndieauthError>(q.as_str()) {
@@ -185,19 +195,27 @@ fn callback_handler(sender: AsyncComponentSender<SignIn>) -> impl Fn(&soup::Serv
 }
 
 impl SignIn {
+    const WELL_KNOWN_METADATA_ENDPOINT_PATH: &str = "/.well-known/oauth-authorization-server";
+
     pub fn scopes() -> kittybox_indieauth::Scopes {
         kittybox_indieauth::Scopes::new(vec![
             kittybox_indieauth::Scope::Profile,
             kittybox_indieauth::Scope::Create,
-            kittybox_indieauth::Scope::Media
+            kittybox_indieauth::Scope::Media,
         ])
     }
 
-    fn bail_out(&mut self, widgets: &mut <Self as AsyncComponent>::Widgets, sender: AsyncComponentSender<Self>, err: Error) {
-        widgets.toasts.add_toast(adw::Toast::builder()
-            .title(err.to_string())
-            .priority(adw::ToastPriority::High)
-            .build()
+    fn bail_out(
+        &mut self,
+        widgets: &mut <Self as AsyncComponent>::Widgets,
+        sender: AsyncComponentSender<Self>,
+        err: Error,
+    ) {
+        widgets.toasts.add_toast(
+            adw::Toast::builder()
+                .title(err.to_string())
+                .priority(adw::ToastPriority::High)
+                .build(),
         );
         // Reset all the state for the component for security reasons.
         self.busy_guard = None;
@@ -210,31 +228,45 @@ impl SignIn {
     }
 
     async fn well_known_metadata(http: soup::Session, url: glib::Uri) -> Option<Metadata> {
-        let well_known = url.parse_relative(
-            "/.well-known/oauth-authorization-server",
-            glib::UriFlags::NONE
-        ).unwrap();
+        let well_known = url
+            .parse_relative(
+                Self::WELL_KNOWN_METADATA_ENDPOINT_PATH,
+                glib::UriFlags::NONE,
+            )
+            .unwrap();
         // Speculatively check for metadata at the well-known path
         let msg = soup::Message::from_uri("GET", &well_known);
-        msg.request_headers().unwrap().append("Accept", "application/json");
-        match http.send_and_read_future(&msg, glib::Priority::DEFAULT).await {
-            Ok(body) if msg.status() == soup::Status::Ok => {
-                match serde_json::from_slice(&body) {
-                    Ok(metadata) => {
-                        log::info!("Speculative metadata request successful: {:#?}", metadata);
-                        Some(metadata)
-                    },
-                    Err(err) => {
-                        log::warn!("Parsing OAuth2 metadata from {} failed: {}", well_known, err);
-                        None
-                    }
+        msg.request_headers()
+            .unwrap()
+            .append("Accept", "application/json");
+        match http
+            .send_and_read_future(&msg, glib::Priority::DEFAULT)
+            .await
+        {
+            Ok(body) if msg.status() == soup::Status::Ok => match serde_json::from_slice(&body) {
+                Ok(metadata) => {
+                    log::info!("Speculative metadata request successful: {:#?}", metadata);
+                    Some(metadata)
+                }
+                Err(err) => {
+                    log::warn!(
+                        "Parsing OAuth2 metadata from {} failed: {}",
+                        well_known,
+                        err
+                    );
+                    None
                 }
             },
             Ok(_) => {
-                log::warn!("Speculative request to {} returned {:?} ({})", well_known, msg.status(), msg.reason_phrase().unwrap());
+                log::warn!(
+                    "Speculative request to {} returned {:?} ({})",
+                    well_known,
+                    msg.status(),
+                    msg.reason_phrase().unwrap()
+                );
 
                 None
-            },
+            }
             Err(err) => {
                 log::warn!("Speculative request to {} failed: {}", well_known, err);
 
@@ -342,7 +374,13 @@ impl AsyncComponent for SignIn {
         std::future::ready(AsyncComponentParts { model, widgets })
     }
 
-    async fn update_with_view(&mut self, widgets: &mut Self::Widgets, msg: Self::Input, sender: AsyncComponentSender<Self>, _root: &Self::Root) {
+    async fn update_with_view(
+        &mut self,
+        widgets: &mut Self::Widgets,
+        msg: Self::Input,
+        sender: AsyncComponentSender<Self>,
+        _root: &Self::Root,
+    ) {
         match msg {
             Input::Start => {
                 self.busy_guard = Some(relm4::main_adw_application().mark_busy());
@@ -354,30 +392,25 @@ impl AsyncComponent for SignIn {
                     None => {
                         self.me_buffer.insert_text(0, "https://");
                         url = self.me_buffer.text().into();
-                    },
+                    }
                     Some(scheme) => {
                         if scheme != "https" && scheme != "http" {
-                            return self.bail_out(
-                                widgets, sender,
-                                Error::WrongScheme
-                            );
+                            return self.bail_out(widgets, sender, Error::WrongScheme);
                         }
-                    },
+                    }
                 }
                 let url = match glib::Uri::parse(url.as_str(), glib::UriFlags::SCHEME_NORMALIZE) {
                     Ok(url) => url,
                     Err(err) => {
-                        return self.bail_out(
-                            widgets, sender,
-                            err.into()
-                        );
-                    },
+                        return self.bail_out(widgets, sender, err.into());
+                    }
                 };
 
-                let (metadata, micropub_uri) = match get_metadata(self.http.clone(), url.clone()).await {
-                    Ok((metadata, micropub_uri)) => (metadata, micropub_uri),
-                    Err(err) => return self.bail_out(widgets, sender, err)
-                };
+                let (metadata, micropub_uri) =
+                    match get_metadata(self.http.clone(), url.clone()).await {
+                        Ok((metadata, micropub_uri)) => (metadata, micropub_uri),
+                        Err(err) => return self.bail_out(widgets, sender, err),
+                    };
 
                 let auth_request = AuthorizationRequest {
                     response_type: kittybox_indieauth::ResponseType::Code,
@@ -385,15 +418,17 @@ impl AsyncComponent for SignIn {
                     redirect_uri: REDIRECT_URI.parse().unwrap(),
                     state: self.state.clone(),
                     code_challenge: kittybox_indieauth::PKCEChallenge::new(
-                        &self.code_verifier, kittybox_indieauth::PKCEMethod::S256
+                        &self.code_verifier,
+                        kittybox_indieauth::PKCEMethod::S256,
                     ),
                     scope: Some(Self::scopes()),
-                    me: Some(url.to_str().parse().unwrap())
+                    me: Some(url.to_str().parse().unwrap()),
                 };
 
                 let auth_url = {
                     let mut url = metadata.authorization_endpoint.clone();
-                    url.query_pairs_mut().extend_pairs(auth_request.as_query_pairs());
+                    url.query_pairs_mut()
+                        .extend_pairs(auth_request.as_query_pairs());
 
                     url
                 };
@@ -405,40 +440,57 @@ impl AsyncComponent for SignIn {
                     server.add_handler(None, callback_handler(sender.clone()));
                     match server.listen_local(60000, soup::ServerListenOptions::empty()) {
                         Ok(()) => server,
-                        Err(err) => return self.bail_out(widgets, sender, err.into())
+                        Err(err) => return self.bail_out(widgets, sender, err.into()),
                     }
                 });
 
-                if let Err(err) = gtk::UriLauncher::new(auth_url.as_str()).launch_future(
-                    None::<&adw::ApplicationWindow>
-                ).await {
-                    return self.bail_out(widgets, sender, err.into())
+                if let Err(err) = gtk::UriLauncher::new(auth_url.as_str())
+                    .launch_future(None::<&adw::ApplicationWindow>)
+                    .await
+                {
+                    return self.bail_out(widgets, sender, err.into());
                 };
 
                 self.busy_guard = None;
                 self.update_view(widgets, sender);
-            },
+            }
             Input::Callback(Ok(res)) => {
                 // Immediately drop the event if we didn't take a server.
-                if self.callback_server.take().is_none() { return; }
+                if self.callback_server.take().is_none() {
+                    return;
+                }
                 self.busy_guard = Some(relm4::main_adw_application().mark_busy());
                 let metadata = self.metadata.take().unwrap();
                 let micropub_uri = self.micropub_uri.take().unwrap();
 
                 if res.state != self.state {
-                    return self.bail_out(widgets, sender, IndieauthError {
-                        kind: kittybox_indieauth::ErrorKind::InvalidRequest,
-                        msg: Some(gettext("state doesn't match what we remember, ceremony aborted")),
-                        error_uri: None,
-                    }.into())
+                    return self.bail_out(
+                        widgets,
+                        sender,
+                        IndieauthError {
+                            kind: kittybox_indieauth::ErrorKind::InvalidRequest,
+                            msg: Some(gettext(
+                                "state doesn't match what we remember, ceremony aborted",
+                            )),
+                            error_uri: None,
+                        }
+                        .into(),
+                    );
                 }
 
                 if res.iss != metadata.issuer {
-                    return self.bail_out(widgets, sender, IndieauthError {
-                        kind: kittybox_indieauth::ErrorKind::InvalidRequest,
-                        msg: Some(gettext("issuer doesn't match what we remember, ceremony aborted")),
-                        error_uri: None,
-                    }.into())
+                    return self.bail_out(
+                        widgets,
+                        sender,
+                        IndieauthError {
+                            kind: kittybox_indieauth::ErrorKind::InvalidRequest,
+                            msg: Some(gettext(
+                                "issuer doesn't match what we remember, ceremony aborted",
+                            )),
+                            error_uri: None,
+                        }
+                        .into(),
+                    );
                 }
 
                 let code = res.code;
@@ -448,21 +500,28 @@ impl AsyncComponent for SignIn {
                     redirect_uri: REDIRECT_URI.parse().unwrap(),
                     code_verifier: std::mem::replace(
                         &mut self.code_verifier,
-                        kittybox_indieauth::PKCEVerifier::new()
-                    )
+                        kittybox_indieauth::PKCEVerifier::new(),
+                    ),
                 };
 
-                let url = glib::Uri::parse(metadata.token_endpoint.as_str(), glib::UriFlags::NONE).unwrap();
+                let url = glib::Uri::parse(metadata.token_endpoint.as_str(), glib::UriFlags::NONE)
+                    .unwrap();
                 let msg = soup::Message::from_uri("POST", &url);
                 let headers = msg.request_headers().unwrap();
                 headers.append("Accept", "application/json");
                 msg.set_request_body_from_bytes(
                     Some("application/x-www-form-urlencoded"),
                     Some(&glib::Bytes::from_owned(
-                        serde_urlencoded::to_string(token_grant).unwrap().into_bytes()
-                    ))
+                        serde_urlencoded::to_string(token_grant)
+                            .unwrap()
+                            .into_bytes(),
+                    )),
                 );
-                match self.http.send_and_read_future(&msg, glib::Priority::DEFAULT).await {
+                match self
+                    .http
+                    .send_and_read_future(&msg, glib::Priority::DEFAULT)
+                    .await
+                {
                     Ok(body) if msg.status() == soup::Status::Ok => {
                         match serde_json::from_slice::<GrantResponse>(&body) {
                             Ok(GrantResponse::ProfileUrl(_)) => unreachable!(),
@@ -474,16 +533,16 @@ impl AsyncComponent for SignIn {
                                 state: _,
                                 expires_in,
                                 profile,
-                                refresh_token
+                                refresh_token,
                             }) => {
                                 let _ = sender.output(Output {
-                                    me: glib::Uri::parse(me.as_str(), glib::UriFlags::NONE).unwrap(),
+                                    me: glib::Uri::parse(me.as_str(), glib::UriFlags::NONE)
+                                        .unwrap(),
                                     scope: scope.unwrap_or_else(Self::scopes),
                                     micropub: micropub_uri,
-                                    userinfo: metadata.userinfo_endpoint
-                                        .map(|u| glib::Uri::parse(
-                                            u.as_str(), glib::UriFlags::NONE
-                                        ).unwrap()),
+                                    userinfo: metadata.userinfo_endpoint.map(|u| {
+                                        glib::Uri::parse(u.as_str(), glib::UriFlags::NONE).unwrap()
+                                    }),
                                     access_token,
                                     refresh_token,
                                     expires_in: expires_in.map(std::time::Duration::from_secs),
@@ -491,22 +550,18 @@ impl AsyncComponent for SignIn {
                                 });
                                 self.busy_guard = None;
                                 self.update_view(widgets, sender);
-                            },
+                            }
                             Err(err) => self.bail_out(widgets, sender, err.into()),
                         }
+                    }
+                    Ok(body) => match serde_json::from_slice::<IndieauthError>(&body) {
+                        Ok(err) => self.bail_out(widgets, sender, err.into()),
+                        Err(err) => self.bail_out(widgets, sender, err.into()),
                     },
-                    Ok(body) => {
-                        match serde_json::from_slice::<IndieauthError>(&body) {
-                            Ok(err) => self.bail_out(widgets, sender, err.into()),
-                            Err(err) => self.bail_out(widgets, sender, err.into())
-                        }
-                    },
-                    Err(err) => self.bail_out(widgets, sender, err.into())
+                    Err(err) => self.bail_out(widgets, sender, err.into()),
                 }
-            },
-            Input::Callback(Err(err)) => {
-                self.bail_out(widgets, sender, err)
-            },
+            }
+            Input::Callback(Err(err)) => self.bail_out(widgets, sender, err),
         }
     }
 
diff --git a/src/components/smart_summary.rs b/src/components/smart_summary.rs
index 2795b09..e876195 100644
--- a/src/components/smart_summary.rs
+++ b/src/components/smart_summary.rs
@@ -1,10 +1,14 @@
 #![cfg(feature = "smart-summary")]
+use adw::prelude::*;
 use futures::AsyncBufReadExt;
+use gettextrs::*;
 use gio::prelude::SettingsExtManual;
+use relm4::{
+    gtk,
+    prelude::{Component, ComponentParts},
+    ComponentSender,
+};
 use soup::prelude::*;
-use adw::prelude::*;
-use gettextrs::*;
-use relm4::{gtk, prelude::{Component, ComponentParts}, ComponentSender};
 
 // All of this is incredibly minimalist.
 // This should be expanded later.
@@ -23,7 +27,7 @@ pub(crate) struct OllamaChunk {
 
 #[derive(Debug, serde::Deserialize)]
 pub(crate) struct OllamaError {
-    error: String
+    error: String,
 }
 impl std::error::Error for OllamaError {}
 impl std::fmt::Display for OllamaError {
@@ -43,12 +47,11 @@ impl From<OllamaResult> for Result<OllamaChunk, OllamaError> {
     fn from(val: OllamaResult) -> Self {
         match val {
             OllamaResult::Ok(chunk) => Ok(chunk),
-            OllamaResult::Err(err) => Err(err)
+            OllamaResult::Err(err) => Err(err),
         }
     }
 }
 
-
 #[derive(Debug, Default)]
 pub(crate) struct SmartSummaryButton {
     task: Option<relm4::JoinHandle<()>>,
@@ -65,41 +68,48 @@ impl SmartSummaryButton {
     ) {
         let settings = gio::Settings::new(crate::APPLICATION_ID);
         // We shouldn't let the user record a bad setting anyway.
-        let endpoint = glib::Uri::parse(
-            &settings.string("llm-endpoint"),
-            glib::UriFlags::NONE,
-        ).unwrap();
+        let endpoint =
+            glib::Uri::parse(&settings.string("llm-endpoint"), glib::UriFlags::NONE).unwrap();
         let model = settings.get::<String>("smart-summary-model");
         let system_prompt = settings.get::<String>("smart-summary-system-prompt");
         let prompt_prefix = settings.get::<String>("smart-summary-prompt-prefix");
         let mut prompt_suffix = settings.get::<String>("smart-summary-prompt-suffix");
 
-        let endpoint = endpoint.parse_relative("./api/generate", glib::UriFlags::NONE).unwrap();
+        let endpoint = endpoint
+            .parse_relative("./api/generate", glib::UriFlags::NONE)
+            .unwrap();
         log::debug!("endpoint: {}, model: {}", endpoint, model);
         log::debug!("system prompt: {}", system_prompt);
 
-        let msg = soup::Message::from_uri(
-            "POST",
-            &endpoint
-        );
+        let msg = soup::Message::from_uri("POST", &endpoint);
 
         if !prompt_suffix.is_empty() {
             prompt_suffix = String::from("\n\n") + &prompt_suffix;
         }
-        msg.set_request_body_from_bytes(Some("application/json"),
-            Some(&glib::Bytes::from_owned(serde_json::to_vec(&OllamaRequest {
-                model, system: system_prompt, prompt: format!("{}\n\n{}{}", prompt_prefix, text, prompt_suffix),
-            }).unwrap()))
+        msg.set_request_body_from_bytes(
+            Some("application/json"),
+            Some(&glib::Bytes::from_owned(
+                serde_json::to_vec(&OllamaRequest {
+                    model,
+                    system: system_prompt,
+                    prompt: format!("{}\n\n{}{}", prompt_prefix, text, prompt_suffix),
+                })
+                .unwrap(),
+            )),
         );
 
         let mut stream = match http.send_future(&msg, glib::Priority::DEFAULT).await {
             Ok(stream) => stream.into_async_buf_read(128),
             Err(err) => {
                 let _ = sender.send(Err(err.into()));
-                return
+                return;
             }
         };
-        log::debug!("response: {:?} ({})", msg.status(), msg.reason_phrase().unwrap_or_default());
+        log::debug!(
+            "response: {:?} ({})",
+            msg.status(),
+            msg.reason_phrase().unwrap_or_default()
+        );
         let mut buffer = Vec::with_capacity(2048);
         const DELIM: u8 = b'\n';
         loop {
@@ -107,28 +117,36 @@ impl SmartSummaryButton {
                 Ok(len) => len,
                 Err(err) => {
                     let _ = sender.send(Err(err.into()));
-                    return
+                    return;
                 }
             };
-            log::debug!("Got chunk ({} bytes): {}", len, String::from_utf8_lossy(&buffer));
-            let response: Result<OllamaResult, serde_json::Error> = serde_json::from_slice(&buffer[..len]);
+            log::debug!(
+                "Got chunk ({} bytes): {}",
+                len,
+                String::from_utf8_lossy(&buffer)
+            );
+            let response: Result<OllamaResult, serde_json::Error> =
+                serde_json::from_slice(&buffer[..len]);
             match response.map(Result::from) {
-                Ok(Ok(OllamaChunk { response: chunk, done })) => {
+                Ok(Ok(OllamaChunk {
+                    response: chunk,
+                    done,
+                })) => {
                     if !chunk.is_empty() {
                         sender.emit(Ok(chunk));
                     }
                     if done {
                         sender.emit(Ok(String::new()));
-                        return
+                        return;
                     }
-                },
+                }
                 Ok(Err(err)) => {
                     sender.emit(Err(err.into()));
-                    return
+                    return;
                 }
                 Err(err) => {
                     sender.emit(Err(err.into()));
-                    return
+                    return;
                 }
             }
             buffer.truncate(0);
@@ -146,12 +164,15 @@ pub(crate) enum Error {
     #[allow(private_interfaces)]
     Ollama(#[from] OllamaError),
     #[error("i/o error: {0}")]
-    Io(#[from] std::io::Error)
+    Io(#[from] std::io::Error),
 }
 
 #[derive(Debug)]
 pub(crate) enum Input {
-    #[doc(hidden)] ButtonPressed,
+    #[doc(hidden)]
+    ButtonPressed,
+    #[doc(hidden)]
+    WarningAccepted,
     Text(String),
     Cancel,
 }
@@ -162,7 +183,7 @@ pub(crate) enum Output {
     Chunk(String),
     Done,
 
-    Error(Error)
+    Error(Error),
 }
 
 #[relm4::component(pub(crate))]
@@ -186,7 +207,9 @@ impl Component for SmartSummaryButton {
             if model.task.is_some() || model.waiting {
                 gtk::Spinner { set_spinning: true }
             } else {
-                gtk::Label { set_markup: "✨" }
+                gtk::Image {
+                    set_icon_name: Some("brain-augemnted") // sic!
+                }
             }
 
         }
@@ -195,7 +218,7 @@ impl Component for SmartSummaryButton {
     fn init(
         init: Self::Init,
         root: Self::Root,
-        sender: ComponentSender<Self>
+        sender: ComponentSender<Self>,
     ) -> ComponentParts<Self> {
         let model = Self {
             http: init,
@@ -206,12 +229,7 @@ impl Component for SmartSummaryButton {
         ComponentParts { model, widgets }
     }
 
-    fn update(
-        &mut self,
-        msg: Self::Input,
-        sender: ComponentSender<Self>,
-        _root: &Self::Root
-    ) {
+    fn update(&mut self, msg: Self::Input, sender: ComponentSender<Self>, _root: &Self::Root) {
         match msg {
             Input::Cancel => {
                 self.waiting = false;
@@ -219,34 +237,86 @@ impl Component for SmartSummaryButton {
                     log::debug!("Parent component asked us to cancel.");
                     task.abort();
                 } else {
-                    log::warn!("Parent component asked us to cancel, but we're not running a task.");
+                    log::warn!(
+                        "Parent component asked us to cancel, but we're not running a task."
+                    );
                 }
-            },
-            Input::ButtonPressed => 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
-                // This shouldn't happen, but I feel like we should handle this case.
-            },
+            }
+            Input::ButtonPressed => {
+                let settings = gio::Settings::new(crate::APPLICATION_ID);
+                if !settings.get::<bool>("smart-summary-show-warning") {
+                    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| if 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
+                    // This shouldn't happen, but I feel like we should handle this case.
+                }
+            }
             Input::Text(text) => {
                 log::debug!("Would generate summary for the following text:\n{}", text);
 
                 log::debug!("XDG_DATA_DIRS={:?}", std::env::var("XDG_DATA_DIRS"));
                 let sender = sender.command_sender().clone();
-                relm4::spawn_local(Self::summarize(
-                    sender, self.http.clone(), text
-                ));
+                relm4::spawn_local(Self::summarize(sender, self.http.clone(), text));
             }
         }
     }
 
-    fn update_cmd(&mut self, msg: Self::CommandOutput, sender: ComponentSender<Self>, _root: &Self::Root) {
+    fn update_cmd(
+        &mut self,
+        msg: Self::CommandOutput,
+        sender: ComponentSender<Self>,
+        _root: &Self::Root,
+    ) {
         match msg {
             Ok(chunk) if chunk.is_empty() => {
                 self.task = None;
                 self.waiting = false;
                 let _ = sender.output(Output::Done);
-            },
+            }
             Err(err) => {
                 self.task = None;
                 self.waiting = false;
@@ -254,7 +324,7 @@ impl Component for SmartSummaryButton {
             }
             Ok(chunk) => {
                 let _ = sender.output(Output::Chunk(chunk));
-            },
+            }
         }
     }
 }
diff --git a/src/components/tag_pill.rs b/src/components/tag_pill.rs
index 0dc9117..89b35af 100644
--- a/src/components/tag_pill.rs
+++ b/src/components/tag_pill.rs
@@ -70,8 +70,6 @@ impl FactoryComponent for TagPill {
         root.append(&label);
         root.append(&button);
 
-        Self::Widgets {
-            label, button
-        }
+        Self::Widgets { label, button }
     }
 }