-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy model switch #210
Lazy model switch #210
Conversation
noxware
commented
Aug 8, 2024
•
edited
Loading
edited
- Design
@@ -538,7 +541,11 @@ impl WidgetMatchEvent for ChatPanel { | |||
self.redraw(cx); | |||
} | |||
ChatLineAction::Edit(id, updated, regenerate) => { | |||
store.chats.edit_chat_message(id, updated, regenerate); | |||
if regenerate { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flag was completely changing what the function does, so I spitted the function (motivated by this).
src/chat/model_selector.rs
Outdated
_ => false, | ||
}; | ||
|
||
let text_enabled_color = hex_rgb_color(0x000000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if makepad gives us some helper to build vec4 colors outside of the DSL so I made this util.
This avoids needing to clarify which color this vector represents and also is recognized by vs code extensions like colorize.
let command_sender = backend.command_sender.clone(); | ||
thread::spawn(move || { | ||
if let Err(err) = model_loader.load_blocking(wanted_file.id, command_sender.clone()) { | ||
eprintln!("Error loading model: {}", err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future idea: Eventually, all eprintln
we have around in the codebase could trigger a Cx::post_action(ErrorNotification(...))
with the latest updates in makepad, to get feedback in the UI.
src/data/chats/model_loader.rs
Outdated
Self::default() | ||
} | ||
|
||
pub fn load_blocking( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having blocking functions by default instead of implicit threading functions makes code more composable and avoids creating extra threads when you are already in a separate synchronous thread (like the thread spawned by send message function).
src/data/chats/model_loader.rs
Outdated
|
||
pub fn load(&mut self, file_id: FileID, command_sender: Sender<Command>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provided just to have a function with the previous behavior although, forcing the caller to be explicit about spawning a thread would be also an option.
pub fn load_blocking( | ||
&mut self, | ||
file_id: FileID, | ||
command_sender: Sender<Command>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The backend type is just this actually and this works better in multithreading contexts as you can clone it. We could make the Backend
type Clone
just to have the pretty type backend: Backend
and also remove the Rc<Backend>
we have in store but is not a big deal for me.
f468606
to
f807178
Compare
a3c0e56
to
4d486f1
Compare
and make the status clone
4d486f1
to
2d0dd6e
Compare
3a42db2
to
f1865ea
Compare
Remove "Resume chat"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!