Skip to content

Commit

Permalink
Disable chat text input when models are loading
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbejar committed Jul 23, 2024
1 parent 6e02f2f commit 592bef3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/chat/chat_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ enum State {
Unknown,
NoModelsAvailable,
NoModelSelected,
ModelLoading,
ModelSelectedWithEmptyChat,
ModelSelectedWithChat {
sticked_to_bottom: bool,
Expand Down Expand Up @@ -571,9 +572,12 @@ impl WidgetMatchEvent for ChatPanel {
impl ChatPanel {
fn update_state(&mut self, scope: &mut Scope) {
let store = scope.data.get_mut::<Store>().unwrap();
let loader = &store.chats.model_loader;

self.state = if store.downloads.downloaded_files.is_empty() {
State::NoModelsAvailable
} else if loader.as_ref().map_or(false, |l| !l.complete) {
State::ModelLoading
} else if store.chats.loaded_model.is_none() {
State::NoModelSelected
} else {
Expand Down Expand Up @@ -616,6 +620,18 @@ impl ChatPanel {
);
self.show_prompt_input_stop_button(cx);
}
State::ModelLoading => {
self.show_prompt_send_button(cx);
self.disable_prompt_buttons(cx);

let prompt_input = self.text_input(id!(main_prompt_input.prompt));
prompt_input.apply_over(
cx,
live! {
draw_text: { prompt_enabled: 0.0 }
},
);
}
_ => {}
}
}
Expand Down Expand Up @@ -687,7 +703,7 @@ impl ChatPanel {
fn disable_prompt_buttons(&mut self, cx: &mut Cx) {
let disabled_color = vec3(0.816, 0.835, 0.867); // #D0D5DD
let send_button = self.button(id!(main_prompt_input.prompt_send_button));
send_button.set_enabled(true);
send_button.set_enabled(false);
send_button.apply_over(
cx,
live! {
Expand Down
2 changes: 1 addition & 1 deletion src/chat/model_selector_loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ live_design! {
run = {
redraw: true,
from: {all: Forward {duration: (ANIMATION_SPEED)}}
apply: {line = { draw_bg: {dither: -0.3} }}
apply: {line = { draw_bg: {dither: 0.0} }}
}
}
}
Expand Down

0 comments on commit 592bef3

Please sign in to comment.