Skip to content

Commit

Permalink
add saved indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
trevyn committed Jul 30, 2024
1 parent cb5a70c commit 26d384b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ pub struct App {
system_text: String,
prompt_text: String,
completion_prompt: String,
saved_version: String,

#[serde(skip)]
debounce_tx: Option<Sender<String>>,
Expand Down Expand Up @@ -206,6 +207,10 @@ impl App {
sessions: session::Session::calculate_sessions(),
completion_prompt: COMPLETION_PROMPT.lock().unwrap().clone(),
tokenizer: Some(tiktoken_rs::o200k_base().unwrap()),
saved_version: select!(Option<Document> "ORDER BY timestamp_ms DESC LIMIT 1")
.unwrap()
.unwrap_or_default()
.content,
..Default::default()
};

Expand Down Expand Up @@ -327,6 +332,7 @@ impl eframe::App for App {
}
.insert()
.unwrap();
self.saved_version = message.content.clone();
}
}
});
Expand Down Expand Up @@ -354,6 +360,15 @@ impl eframe::App for App {
SidePanel::left("left_panel").show(ctx, |ui| {
ui.label(option_env!("BUILD_ID").unwrap_or("DEV"));

let wheel_windows = WHEEL_WINDOWS.lock().unwrap();
if let Some(window) = wheel_windows.get(0)
&& let Some(message) = window.messages.get(0)
{
if self.saved_version == message.content {
ui.label("SAVED");
}
}

let mut setting2 = Setting::get("openai_api_key");
ui.label("openai api key:");
ui
Expand Down Expand Up @@ -436,7 +451,11 @@ impl eframe::App for App {
0.0,
TextFormat {
font_id: FontId::new(20.0, FontFamily::Monospace),
color: if entry.role == Assistant { Color32::LIGHT_BLUE } else { Color32::LIGHT_GRAY },
color: if entry.role == Assistant {
Color32::from_rgb(0xCD, 0xD8, 0xFF)
} else {
Color32::from_rgb(230, 230, 230)
},
..Default::default()
},
);
Expand Down

0 comments on commit 26d384b

Please sign in to comment.