Skip to content

Commit 592bef3

Browse files
committed
Disable chat text input when models are loading
1 parent 6e02f2f commit 592bef3

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
@@ -416,6 +416,7 @@ enum State {
416416
Unknown,
417417
NoModelsAvailable,
418418
NoModelSelected,
419+
ModelLoading,
419420
ModelSelectedWithEmptyChat,
420421
ModelSelectedWithChat {
421422
sticked_to_bottom: bool,
@@ -571,9 +572,12 @@ impl WidgetMatchEvent for ChatPanel {
571572
impl ChatPanel {
572573
fn update_state(&mut self, scope: &mut Scope) {
573574
let store = scope.data.get_mut::<Store>().unwrap();
575+
let loader = &store.chats.model_loader;
574576

575577
self.state = if store.downloads.downloaded_files.is_empty() {
576578
State::NoModelsAvailable
579+
} else if loader.as_ref().map_or(false, |l| !l.complete) {
580+
State::ModelLoading
577581
} else if store.chats.loaded_model.is_none() {
578582
State::NoModelSelected
579583
} else {
@@ -616,6 +620,18 @@ impl ChatPanel {
616620
);
617621
self.show_prompt_input_stop_button(cx);
618622
}
623+
State::ModelLoading => {
624+
self.show_prompt_send_button(cx);
625+
self.disable_prompt_buttons(cx);
626+
627+
let prompt_input = self.text_input(id!(main_prompt_input.prompt));
628+
prompt_input.apply_over(
629+
cx,
630+
live! {
631+
draw_text: { prompt_enabled: 0.0 }
632+
},
633+
);
634+
}
619635
_ => {}
620636
}
621637
}
@@ -687,7 +703,7 @@ impl ChatPanel {
687703
fn disable_prompt_buttons(&mut self, cx: &mut Cx) {
688704
let disabled_color = vec3(0.816, 0.835, 0.867); // #D0D5DD
689705
let send_button = self.button(id!(main_prompt_input.prompt_send_button));
690-
send_button.set_enabled(true);
706+
send_button.set_enabled(false);
691707
send_button.apply_over(
692708
cx,
693709
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)