Prompt library updates (#11988)

Restructure prompts & the prompt library.

- Prompts are now written in markdown
- The prompt manager has a picker and editable prompts
- Saving isn't wired up yet
- This also removes the "Insert active prompt" button as this concept doesn't exist anymore, and will be replaced with slash commands.

I didn't staff flag this, but if you do play around with it expect it to still be pretty rough.

Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <1789+nathansobo@users.noreply.github.com>
Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nate Butler 2024-05-22 18:04:47 -04:00 committed by GitHub
parent a73a3ef243
commit 0a848f29e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 964 additions and 679 deletions

View file

@ -41,6 +41,25 @@ pub trait FluentBuilder {
})
}
/// Conditionally unwrap and modify self with one closure if the given option is Some, or another if it is None.
fn when_some_else<T>(
self,
option: Option<T>,
then: impl FnOnce(Self, T) -> Self,
otherwise: impl FnOnce(Self) -> Self,
) -> Self
where
Self: Sized,
{
self.map(|this| {
if let Some(value) = option {
then(this, value)
} else {
otherwise(this)
}
})
}
/// Conditionally modify self with one closure or another
fn when_else(
self,

View file

@ -46,6 +46,7 @@ use std::{
};
use util::post_inc;
use util::{measure, ResultExt};
use uuid::Uuid;
mod prompts;
@ -4514,6 +4515,8 @@ pub enum ElementId {
Integer(usize),
/// A string based ID.
Name(SharedString),
/// A UUID.
Uuid(Uuid),
/// An ID that's equated with a focus handle.
FocusHandle(FocusId),
/// A combination of a name and an integer.
@ -4528,6 +4531,7 @@ impl Display for ElementId {
ElementId::Name(name) => write!(f, "{}", name)?,
ElementId::FocusHandle(_) => write!(f, "FocusHandle")?,
ElementId::NamedInteger(s, i) => write!(f, "{}-{}", s, i)?,
ElementId::Uuid(uuid) => write!(f, "{}", uuid)?,
}
Ok(())
@ -4594,6 +4598,12 @@ impl From<(&'static str, u64)> for ElementId {
}
}
impl From<Uuid> for ElementId {
fn from(value: Uuid) -> Self {
Self::Uuid(value)
}
}
impl From<(&'static str, u32)> for ElementId {
fn from((name, id): (&'static str, u32)) -> Self {
ElementId::NamedInteger(name.into(), id as usize)