-
Notifications
You must be signed in to change notification settings - Fork 57
fix: prevent UI freeze in offline robot mode and stop Kokoro label stacking #121
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -949,8 +949,18 @@ def _make_personas(self): | |
| self._persona_box.show_all() | ||
|
|
||
| def _kokoro_voice_changed_event_cb(self, widget, event, voice_name): | ||
| # Remove previously shown status label to avoid stacking labels when | ||
| # users rapidly click different voices. | ||
| existing_label = getattr(self, '_kokoro_info_label', None) | ||
| if existing_label is not None: | ||
| try: | ||
| self._kokoro_voice_box.remove(existing_label) | ||
| except Exception: | ||
| pass | ||
|
|
||
| # Show info label(Indication of voice changing) upon click | ||
| info_label = Gtk.Label() | ||
| self._kokoro_info_label = info_label | ||
| info_label.set_markup('<span foreground="blue" size="large">%s</span>' % _('Please wait...')) | ||
| self._kokoro_voice_box.pack_start(info_label, False, False, style.DEFAULT_PADDING) | ||
| info_label.show() | ||
|
|
@@ -1001,7 +1011,13 @@ def async_check_and_update(): | |
| Gtk.main_iteration() | ||
|
|
||
| def _remove_info_label(): | ||
| self._kokoro_voice_box.remove(info_label) | ||
| if getattr(self, '_kokoro_info_label', None) is info_label: | ||
| try: | ||
| self._kokoro_voice_box.remove(info_label) | ||
| except Exception: | ||
| pass | ||
| self._kokoro_info_label = None | ||
| return False | ||
|
Comment on lines
+1014
to
+1020
|
||
| GLib.timeout_add(3000, _remove_info_label) | ||
|
|
||
| GLib.idle_add(async_check_and_update) | ||
|
|
@@ -1364,10 +1380,21 @@ def safe_face_say(): | |
| llm_thread.start() | ||
| else: | ||
| # No internet, try SLM -> Brain | ||
| response = self._try_slm_response(text) | ||
| if not response: | ||
| response = brain.respond(text) | ||
| self.face.say(response) | ||
| self.face.say("Thinking...") | ||
|
|
||
| def fetch_offline_response(): | ||
| response = self._try_slm_response(text) | ||
| if not response: | ||
| response = brain.respond(text) | ||
|
|
||
| def safe_face_say(): | ||
| self.face.say(response) | ||
| return False | ||
| GLib.idle_add(safe_face_say) | ||
|
|
||
| offline_thread = threading.Thread(target=fetch_offline_response) | ||
| offline_thread.daemon = True | ||
| offline_thread.start() | ||
| else: | ||
| # Use traditional brain chatbot | ||
| brain_response = brain.respond(text) | ||
|
|
||
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.
Avoid
except Exception: passwhen removing the prior Kokoro status label. It can silently mask real widget hierarchy/GTK errors and can also leave the old label in the box (so stacking may still occur) without any diagnostic. Prefer checkingexisting_label.get_parent() is self._kokoro_voice_box(or membership inget_children()) before removing, and only catch the specific GTK/Python exceptions you expect (optionally log at debug level).