commit 2fdb36475ae909e9bece5a5f508b25a4a076464c
parent 04a11fd45dc38d621732ab13224c43d0c9654d7c
Author: William Casarin <jb55@jb55.com>
Date: Mon, 21 Apr 2025 12:11:21 -0700
dave: add a few docs
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/crates/notedeck_dave/src/ui/dave.rs b/crates/notedeck_dave/src/ui/dave.rs
@@ -7,17 +7,21 @@ use nostrdb::Transaction;
use notedeck::{AppContext, NoteContext};
use notedeck_ui::{icons::search_icon, NoteOptions};
+/// DaveUi holds all of the data it needs to render itself
pub struct DaveUi<'a> {
chat: &'a [Message],
input: &'a mut String,
}
+/// The response the app generates. The response contains an optional
+/// action to take.
#[derive(Default, Clone, Debug)]
pub struct DaveResponse {
pub action: Option<DaveAction>,
}
impl DaveResponse {
+ /// Generate a send response to the controller
fn send() -> Self {
DaveResponse {
action: Some(DaveAction::Send),
@@ -29,8 +33,12 @@ impl DaveResponse {
}
}
+/// The actions the app generates. No default action is specfied in the
+/// UI code. This is handled by the app logic, however it chooses to
+/// process this message.
#[derive(Clone, Debug)]
pub enum DaveAction {
+ /// The action generated when the user sends a message to dave
Send,
}
@@ -57,6 +65,7 @@ impl<'a> DaveUi<'a> {
})
}
+ /// The main render function. Call this to render Dave
pub fn ui(&mut self, app_ctx: &mut AppContext, ui: &mut egui::Ui) -> DaveResponse {
// Scroll area for chat messages
egui::Frame::NONE
@@ -96,6 +105,7 @@ impl<'a> DaveUi<'a> {
.inner
}
+ /// Render a chat message (user, assistant, tool call/response, etc)
fn render_chat(&self, ctx: &mut AppContext, ui: &mut egui::Ui) {
for message in self.chat {
match message {