For future reference: WIP branch of copy/pasting a mixture of images and text: https://github.com/zed-industries/zed/tree/copy-paste-images - we'll come back to that one after landing this one. Release Notes: - You can now paste images into the Assistant Panel to include them as context. Currently works only on Mac, and with Anthropic models. Future support is planned for more models, operating systems, and image clipboard operations. --------- Co-authored-by: Antonio <antonio@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Jason <jason@zed.dev> Co-authored-by: Kyle <kylek@zed.dev>
81 lines
2.5 KiB
Rust
81 lines
2.5 KiB
Rust
use gpui::{actions, AppContext, ClipboardItem, PromptLevel};
|
|
use system_specs::SystemSpecs;
|
|
use util::ResultExt;
|
|
use workspace::Workspace;
|
|
|
|
pub mod feedback_modal;
|
|
|
|
actions!(feedback, [GiveFeedback, SubmitFeedback]);
|
|
|
|
mod system_specs;
|
|
|
|
actions!(
|
|
zed,
|
|
[
|
|
CopySystemSpecsIntoClipboard,
|
|
FileBugReport,
|
|
RequestFeature,
|
|
OpenZedRepo
|
|
]
|
|
);
|
|
|
|
const fn zed_repo_url() -> &'static str {
|
|
"https://github.com/zed-industries/zed"
|
|
}
|
|
|
|
const fn request_feature_url() -> &'static str {
|
|
"https://github.com/zed-industries/zed/issues/new?assignees=&labels=admin+read%2Ctriage%2Cenhancement&projects=&template=0_feature_request.yml"
|
|
}
|
|
|
|
fn file_bug_report_url(specs: &SystemSpecs) -> String {
|
|
format!(
|
|
"https://github.com/zed-industries/zed/issues/new?assignees=&labels=admin+read%2Ctriage%2Cdefect&projects=&template=1_bug_report.yml&environment={}",
|
|
urlencoding::encode(&specs.to_string())
|
|
)
|
|
}
|
|
|
|
pub fn init(cx: &mut AppContext) {
|
|
cx.observe_new_views(|workspace: &mut Workspace, cx| {
|
|
feedback_modal::FeedbackModal::register(workspace, cx);
|
|
workspace
|
|
.register_action(|_, _: &CopySystemSpecsIntoClipboard, cx| {
|
|
let specs = SystemSpecs::new(&cx);
|
|
|
|
cx.spawn(|_, mut cx| async move {
|
|
let specs = specs.await.to_string();
|
|
|
|
cx.update(|cx| cx.write_to_clipboard(ClipboardItem::new_string(specs.clone())))
|
|
.log_err();
|
|
|
|
cx.prompt(
|
|
PromptLevel::Info,
|
|
"Copied into clipboard",
|
|
Some(&specs),
|
|
&["OK"],
|
|
)
|
|
.await
|
|
.ok();
|
|
})
|
|
.detach();
|
|
})
|
|
.register_action(|_, _: &RequestFeature, cx| {
|
|
cx.open_url(request_feature_url());
|
|
})
|
|
.register_action(move |_, _: &FileBugReport, cx| {
|
|
let specs = SystemSpecs::new(&cx);
|
|
cx.spawn(|_, mut cx| async move {
|
|
let specs = specs.await;
|
|
cx.update(|cx| {
|
|
cx.open_url(&file_bug_report_url(&specs));
|
|
})
|
|
.log_err();
|
|
})
|
|
.detach();
|
|
})
|
|
.register_action(move |_, _: &OpenZedRepo, cx| {
|
|
cx.open_url(zed_repo_url());
|
|
});
|
|
})
|
|
.detach();
|
|
}
|