rename at_image to at_clipboard_image

This commit is contained in:
pap
2025-07-27 23:26:32 +01:00
parent 68f1ceabdc
commit d58b5f9e91
3 changed files with 6 additions and 6 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ impl App<'_> {
}
},
AppEvent::DispatchAtCommand(at_command) => match at_command {
crate::at_command::AtCommand::Image => {
crate::at_command::AtCommand::ClipboardImage => {
match crate::clipboard_paste::paste_image_to_temp_png() {
Ok((path, info)) => {
tracing::info!("at_command_image imported path={:?} width={} height={} format={}", path, info.width, info.height, info.encoded_format_label);
+2 -2
View File
@@ -5,14 +5,14 @@ use strum_macros::{AsRefStr, EnumIter, EnumString, IntoStaticStr};
#[strum(serialize_all = "kebab-case")]
pub enum AtCommand {
// Order is presentation order in @ popup.
Image, // import image from clipboard
ClipboardImage, // import image from clipboard
File, // open file search popup
}
impl AtCommand {
pub fn description(self) -> &'static str {
match self {
AtCommand::Image => "Import an image from the system clipboard (can be used with ctrl+v).",
AtCommand::ClipboardImage => "Import an image from the system clipboard (can be used with ctrl+v).",
AtCommand::File => "Search for a file to insert its path.",
}
}
@@ -342,7 +342,7 @@ impl ChatComposer<'_> {
Input { key: Key::Enter, shift: false, alt: false, ctrl: false } => {
if let Some(cmd) = popup.selected_command() {
match cmd {
AtCommand::Image => {
AtCommand::ClipboardImage => {
// Dispatch image import request but only remove the @token itself (not entire input).
self.app_event_tx.send(AppEvent::DispatchAtCommand(*cmd));
self.remove_current_at_token();
@@ -1503,7 +1503,7 @@ mod tests {
}
#[test]
fn at_image_command_triggers_dispatch() {
fn at_clipboard_image_command_triggers_dispatch() {
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use std::sync::mpsc::Receiver;
use crate::app_event::AppEvent;
@@ -1518,6 +1518,6 @@ mod tests {
composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
// Expect a DispatchAtCommand(Image) or DispatchAtCommand(File); slash commands use DispatchSlashCommand
let ev = rx.try_recv().expect("expected an event");
match ev { AppEvent::DispatchAtCommand(AtCommand::Image) => {}, AppEvent::DispatchAtCommand(AtCommand::File) => {}, other => panic!("unexpected event: {:?}", other) }
match ev { AppEvent::DispatchAtCommand(AtCommand::ClipboardImage) => {}, AppEvent::DispatchAtCommand(AtCommand::File) => {}, other => panic!("unexpected event: {:?}", other) }
}
}