assistant: Allow drag&dropping files/tabs into assistant panel (#17415)

This adds ability to the assistant panel's context editor to accept
files being dropped on it.

Multiple things can be dropped on the assistant panel:
- project panel entries (one or many)
- tabs (one)
- external files (one or many)


Release Notes:

- N/A


Demo:



https://github.com/user-attachments/assets/fddee751-cbdf-4e2c-ac80-35dfb857cc8a

Co-authored-by: Bennet <bennet@zed.dev>
This commit is contained in:
Thorsten Ball 2024-09-05 16:21:20 +02:00 committed by GitHub
parent 7907ab32d7
commit f2d539f762
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 185 additions and 22 deletions

View file

@ -27,8 +27,8 @@ use context_servers::ContextServerRegistry;
pub use context_store::*;
use feature_flags::FeatureFlagAppExt;
use fs::Fs;
use gpui::Context as _;
use gpui::{actions, AppContext, Global, SharedString, UpdateGlobal};
use gpui::{impl_actions, Context as _};
use indexed_docs::IndexedDocsRegistry;
pub(crate) use inline_assistant::*;
use language_model::{
@ -45,6 +45,7 @@ use slash_command::{
file_command, now_command, project_command, prompt_command, search_command, symbols_command,
tab_command, terminal_command, workflow_command,
};
use std::path::PathBuf;
use std::sync::Arc;
pub(crate) use streaming_diff::*;
use util::ResultExt;
@ -70,6 +71,14 @@ actions!(
]
);
#[derive(PartialEq, Clone, Deserialize)]
pub enum InsertDraggedFiles {
ProjectPaths(Vec<PathBuf>),
ExternalFiles(Vec<PathBuf>),
}
impl_actions!(assistant, [InsertDraggedFiles]);
const DEFAULT_CONTEXT_LINES: usize = 50;
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Serialize, Deserialize)]