Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 81 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ amzn-consolas-client = { path = "crates/amzn-consolas-client" }
amzn-qdeveloper-streaming-client = { path = "crates/amzn-qdeveloper-streaming-client" }
amzn-toolkit-telemetry-client = { path = "crates/amzn-toolkit-telemetry-client" }
anstream = "0.6.13"
arboard = { version = "3.5.0", default-features = false }
arboard = { version = "3.6.1", default-features = false, features = ["image-data"] }
assert_cmd = "2.0"
async-trait = "0.1.87"
aws-config = "1.0.3"
Expand Down Expand Up @@ -73,6 +73,7 @@ owo-colors = "4.2.0"
parking_lot = "0.12.3"
paste = "1.0.11"
percent-encoding = "2.2.0"
png = "0.17.16"
predicates = "3.0"
prettyplease = "0.2.32"
quote = "1.0.40"
Expand Down
1 change: 1 addition & 0 deletions crates/chat-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ owo-colors.workspace = true
parking_lot.workspace = true
paste.workspace = true
percent-encoding.workspace = true
png.workspace = true
r2d2.workspace = true
r2d2_sqlite.workspace = true
rand.workspace = true
Expand Down
6 changes: 6 additions & 0 deletions crates/chat-cli/src/cli/chat/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod knowledge;
pub mod logdump;
pub mod mcp;
pub mod model;
pub mod paste;
pub mod persist;
pub mod profile;
pub mod prompts;
Expand All @@ -32,6 +33,7 @@ use knowledge::KnowledgeSubcommand;
use logdump::LogdumpArgs;
use mcp::McpArgs;
use model::ModelArgs;
use paste::PasteArgs;
use persist::PersistSubcommand;
use profile::AgentSubcommand;
use prompts::PromptsArgs;
Expand Down Expand Up @@ -122,6 +124,8 @@ pub enum SlashCommand {
/// View, manage, and resume to-do lists
#[command(subcommand)]
Todos(TodoSubcommand),
/// Paste an image from clipboard
Paste(PasteArgs),
}

impl SlashCommand {
Expand Down Expand Up @@ -190,6 +194,7 @@ impl SlashCommand {
// },
Self::Checkpoint(subcommand) => subcommand.execute(os, session).await,
Self::Todos(subcommand) => subcommand.execute(os, session).await,
Self::Paste(args) => args.execute(os, session).await,
}
}

Expand Down Expand Up @@ -222,6 +227,7 @@ impl SlashCommand {
},
Self::Checkpoint(_) => "checkpoint",
Self::Todos(_) => "todos",
Self::Paste(_) => "paste",
}
}

Expand Down
46 changes: 46 additions & 0 deletions crates/chat-cli/src/cli/chat/cli/paste.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use clap::Args;
use crossterm::execute;
use crossterm::style::{
self,
Color,
};

use crate::cli::chat::util::clipboard::paste_image_from_clipboard;
use crate::cli::chat::{
ChatError,
ChatSession,
ChatState,
};
use crate::os::Os;

#[derive(Debug, Args, PartialEq)]
pub struct PasteArgs;

impl PasteArgs {
pub async fn execute(
self,
_os: &mut Os,
session: &mut ChatSession,
) -> Result<ChatState, ChatError> {
match paste_image_from_clipboard() {
Ok(path) => {
Ok(ChatState::HandleInput {
input: path.display().to_string(),
})
},
Err(e) => {
execute!(
session.stderr,
style::SetForegroundColor(Color::Red),
style::Print("❌ Failed to paste image: "),
style::SetForegroundColor(Color::Reset),
style::Print(format!("{}\n", e))
)?;

Ok(ChatState::PromptUser {
skip_printing_tools: false,
})
},
}
}
}
Loading