Skip to content

Commit a352148

Browse files
committed
Disable chat text input when models are loading
1 parent 4e21a59 commit a352148

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/chat/chat_panel.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ enum State {
418418
Unknown,
419419
NoModelsAvailable,
420420
NoModelSelected,
421+
ModelLoading,
421422
ModelSelectedWithEmptyChat,
422423
ModelSelectedWithChat {
423424
sticked_to_bottom: bool,
@@ -573,9 +574,12 @@ impl WidgetMatchEvent for ChatPanel {
573574
impl ChatPanel {
574575
fn update_state(&mut self, scope: &mut Scope) {
575576
let store = scope.data.get_mut::<Store>().unwrap();
577+
let loader = &store.chats.model_loader;
576578

577579
self.state = if store.downloads.downloaded_files.is_empty() {
578580
State::NoModelsAvailable
581+
} else if loader.as_ref().map_or(false, |l| !l.complete) {
582+
State::ModelLoading
579583
} else if store.chats.loaded_model.is_none() {
580584
State::NoModelSelected
581585
} else {
@@ -618,6 +622,18 @@ impl ChatPanel {
618622
);
619623
self.show_prompt_input_stop_button(cx);
620624
}
625+
State::ModelLoading => {
626+
self.show_prompt_send_button(cx);
627+
self.disable_prompt_buttons(cx);
628+
629+
let prompt_input = self.text_input(id!(main_prompt_input.prompt));
630+
prompt_input.apply_over(
631+
cx,
632+
live! {
633+
draw_text: { prompt_enabled: 0.0 }
634+
},
635+
);
636+
}
621637
_ => {}
622638
}
623639
}
@@ -689,7 +705,7 @@ impl ChatPanel {
689705
fn disable_prompt_buttons(&mut self, cx: &mut Cx) {
690706
let disabled_color = vec3(0.816, 0.835, 0.867); // #D0D5DD
691707
let send_button = self.button(id!(main_prompt_input.prompt_send_button));
692-
send_button.set_enabled(true);
708+
send_button.set_enabled(false);
693709
send_button.apply_over(
694710
cx,
695711
live! {

src/chat/model_selector_loading.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ live_design! {
6363
run = {
6464
redraw: true,
6565
from: {all: Forward {duration: (ANIMATION_SPEED)}}
66-
apply: {line = { draw_bg: {dither: -0.3} }}
66+
apply: {line = { draw_bg: {dither: 0.0} }}
6767
}
6868
}
6969
}

0 commit comments

Comments
 (0)