assistant: Restructure ambient context in preparation for adding more (#11822)
This PR restructures the ambient context in the `assistant` crate to make it more amenable to adding more kinds of ambient context. Release Notes: - N/A
This commit is contained in:
parent
bf4478703b
commit
ba4d4c8e1c
4 changed files with 35 additions and 28 deletions
8
crates/assistant/src/ambient_context.rs
Normal file
8
crates/assistant/src/ambient_context.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
mod recent_buffers;
|
||||
|
||||
pub use recent_buffers::*;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AmbientContext {
|
||||
pub recent_buffers: RecentBuffersContext,
|
||||
}
|
25
crates/assistant/src/ambient_context/recent_buffers.rs
Normal file
25
crates/assistant/src/ambient_context/recent_buffers.rs
Normal file
|
@ -0,0 +1,25 @@
|
|||
use gpui::{Subscription, Task, WeakModel};
|
||||
use language::Buffer;
|
||||
|
||||
pub struct RecentBuffersContext {
|
||||
pub enabled: bool,
|
||||
pub buffers: Vec<RecentBuffer>,
|
||||
pub message: String,
|
||||
pub pending_message: Option<Task<()>>,
|
||||
}
|
||||
|
||||
pub struct RecentBuffer {
|
||||
pub buffer: WeakModel<Buffer>,
|
||||
pub _subscription: Subscription,
|
||||
}
|
||||
|
||||
impl Default for RecentBuffersContext {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: true,
|
||||
buffers: Vec::new(),
|
||||
message: String::new(),
|
||||
pending_message: None,
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
mod ambient_context;
|
||||
pub mod assistant_panel;
|
||||
pub mod assistant_settings;
|
||||
mod codegen;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use crate::ambient_context::{AmbientContext, RecentBuffer};
|
||||
use crate::{
|
||||
assistant_settings::{AssistantDockPosition, AssistantSettings, ZedDotDevModel},
|
||||
codegen::{self, Codegen, CodegenKind},
|
||||
|
@ -1367,34 +1368,6 @@ pub struct Conversation {
|
|||
telemetry: Option<Arc<Telemetry>>,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct AmbientContext {
|
||||
recent_buffers: RecentBuffersContext,
|
||||
}
|
||||
|
||||
struct RecentBuffersContext {
|
||||
enabled: bool,
|
||||
buffers: Vec<RecentBuffer>,
|
||||
message: String,
|
||||
pending_message: Option<Task<()>>,
|
||||
}
|
||||
|
||||
struct RecentBuffer {
|
||||
buffer: WeakModel<Buffer>,
|
||||
_subscription: Subscription,
|
||||
}
|
||||
|
||||
impl Default for RecentBuffersContext {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
enabled: true,
|
||||
buffers: Vec::new(),
|
||||
message: String::new(),
|
||||
pending_message: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl EventEmitter<ConversationEvent> for Conversation {}
|
||||
|
||||
impl Conversation {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue