From 1435d9c9099646a864a68883f71031a85e150ed5 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 02:31:39 +0000 Subject: [PATCH] ui: links open, and Copy text and Quote on every message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Links in chat did nothing. classify_link (vm/bbcode.rs) sorts an address into a web page, a TeamSpeak server, a channel file or no link, and only those reach TextRun.link. A click on a web link opens it through App::open_url, the one place a platform without xdg-open can hook; one whose text is not its address first shows where it goes (LinkDialog). TeamSpeak links are copied until Voelin opens them. A right-click on a link opens or copies it. The hover bar was there only for messages a gateway knows. Every message now has it, with Quote ("> Author: …" lines at the start of the composer; TeamSpeak clients show [quote] as it is) and Copy text, and a right-click menu. After Quote the composer has the focus, its cursor below the quote, and grows to show the quote's lines: its field is one line high, so an answer typed after clicking into it went into the quote's last line. The bar keeps itself shown while the pointer is on it or on the message's links and reactions: it reaches above its row, where the row's hover ended, so its buttons could not be clicked. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AVRENKftQqGoEeswiR9TDQ --- CHANGELOG.md | 6 + crates/voelin-ui/src/app.rs | 7 + crates/voelin-ui/src/bind/chat.rs | 4 + crates/voelin-ui/src/chat.rs | 37 +- crates/voelin-ui/src/dev.rs | 22 +- crates/voelin-ui/src/vm/bbcode.rs | 227 +++++++++++-- crates/voelin-ui/src/vm/chat.rs | 72 +++- crates/voelin-ui/ui/app.slint | 6 +- crates/voelin-ui/ui/assets/icons/quote.svg | 16 + crates/voelin-ui/ui/bridge.slint | 11 +- crates/voelin-ui/ui/components/emoji.slint | 29 +- .../voelin-ui/ui/components/text-field.slint | 9 + crates/voelin-ui/ui/icons.slint | 1 + crates/voelin-ui/ui/nav.slint | 21 ++ crates/voelin-ui/ui/screens/chat.slint | 317 +++++++++++------- crates/voelin-ui/ui/screens/dialogs.slint | 68 +++- docs/ui.md | 16 +- 17 files changed, 700 insertions(+), 169 deletions(-) create mode 100644 crates/voelin-ui/ui/assets/icons/quote.svg diff --git a/CHANGELOG.md b/CHANGELOG.md index d131e4b..683662d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,12 @@ User-visible changes of the apps and the `tsgw` gateway. The format follows - Other people's myTeamSpeak badges: up to three pictures after their name in the channel tree and the members panel, and their names on the member card (what each is for on hover). +- Links in chat open in the browser; one whose text is not its address + first shows where it goes. A right-click on a link opens or copies it; + TeamSpeak links are copied for now. +- Every message can be quoted into the composer (`> ` lines) and its text + copied, from the actions on hover or a right-click menu, also on servers + without a gateway. ### Changed diff --git a/crates/voelin-ui/src/app.rs b/crates/voelin-ui/src/app.rs index c842fcd..ff312ee 100644 --- a/crates/voelin-ui/src/app.rs +++ b/crates/voelin-ui/src/app.rs @@ -865,6 +865,13 @@ impl App { } } + /// Open a page on the web in the browser. Pages open through here, so + /// a platform without a desktop opener (Android) can open them its own + /// way. + pub(crate) fn open_url(&self, url: &str) -> std::io::Result<()> { + open_target(std::ffi::OsStr::new(url)) + } + /// Nav.copy put text on the clipboard: one toast says so. pub fn copied(&mut self) { let text = self.copy_note.take().unwrap_or_else(|| "Copied".to_owned()); diff --git a/crates/voelin-ui/src/bind/chat.rs b/crates/voelin-ui/src/bind/chat.rs index ed9a7dc..23a9d8a 100644 --- a/crates/voelin-ui/src/bind/chat.rs +++ b/crates/voelin-ui/src/bind/chat.rs @@ -55,6 +55,10 @@ pub(super) fn wire(ui: &MainWindow) { bridge.on_create_topic(|key, title| { with_app(|app| app.create_topic(key, title.to_string())); }); + bridge.on_open_link(|link, masked| { + with_app(|app| app.open_link_text(&link, masked)).unwrap_or_default().into() + }); + bridge.on_quote_text(|author, text| crate::vm::chat::quote(&author, &text).into()); bridge.on_open_member(|id| { with_app(|app| app.open_member(id)); }); diff --git a/crates/voelin-ui/src/chat.rs b/crates/voelin-ui/src/chat.rs index 5b9bdab..7a2ef12 100644 --- a/crates/voelin-ui/src/chat.rs +++ b/crates/voelin-ui/src/chat.rs @@ -21,9 +21,10 @@ use voelin_core::{ use voelin_gateway_proto::{ErrorCode, TopicInfo, feature}; use voelin_model::{ChatMessage, ChatTarget, HostMessageMode, ServerDetails}; -use crate::app::{App, Bridge, ChatLine, ChatTab, FileItem, Msg, PinItem, SessionView, Tab}; +use crate::app::{App, Bridge, ChatLine, ChatTab, FileItem, Msg, Nav, PinItem, SessionView, Tab}; use crate::settings::UI_IMAGE_PREVIEW_KB; use crate::vm; +use crate::vm::bbcode::LinkKind; use crate::vm::chat::{LineCache, LineCtx, Previous}; /// Where the server's welcome and host message keep what their lines were @@ -350,7 +351,8 @@ impl App { } /// What the server says to everyone who connects ([`server_texts`]) as - /// the first lines of the server chat: by the server, without actions. + /// the first lines of the server chat: by the server, without reactions + /// or pins. fn server_lines( view: &SessionView, pictures: Option<&HashMap>, @@ -545,6 +547,37 @@ impl App { vm::list::sync(&self.models.topic_messages, &self.lines_of(view, tab, false)); } + /// A link in a message was clicked (`masked`: its text shows something + /// else, [`vm::bbcode::is_masked`]). A page on the web opens in the + /// browser, a masked one once the user saw where it goes (Nav.link-open); + /// a TeamSpeak link is copied until Voelin opens them. Returns what to + /// copy ("": nothing). + pub(crate) fn open_link_text(&mut self, link: &str, masked: bool) -> String { + match vm::bbcode::classify_link(link) { + LinkKind::Web(url) if masked => { + if let Some(ui) = self.ui.upgrade() { + let nav = ui.global::