assistant2: Derive the Context icon at render time instead of storing (#22397)

This PR is a follow up to #22385 that makes it so we treat the icon as
derived state.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-12-24 11:13:35 -05:00 committed by GitHub
parent 564936e1fe
commit 4c84600630
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 22 deletions

View file

@ -1,7 +1,6 @@
use gpui::SharedString;
use language_model::{LanguageModelRequestMessage, MessageContent};
use serde::{Deserialize, Serialize};
use ui::prelude::*;
use util::post_inc;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Serialize, Deserialize)]
@ -20,10 +19,9 @@ pub struct Context {
pub name: SharedString,
pub kind: ContextKind,
pub text: SharedString,
pub icon: IconName,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum ContextKind {
File,
Directory,
@ -31,17 +29,6 @@ pub enum ContextKind {
Thread,
}
impl ContextKind {
pub fn icon(&self) -> IconName {
match self {
ContextKind::File => IconName::File,
ContextKind::Directory => IconName::Folder,
ContextKind::FetchedUrl => IconName::Globe,
ContextKind::Thread => IconName::MessageCircle,
}
}
}
pub fn attach_context_to_message(
message: &mut LanguageModelRequestMessage,
context: impl IntoIterator<Item = Context>,