voelin-gpui: run starts the hotkey, the state does not
The previous commit started the global push-to-talk task in AppState::new when there was an engine, which a test of the state with a real engine has: it asked the desktop for a shortcut (the X11 backend on whatever DISPLAY is set, the portal on a Wayland session: a dialog on the user's desktop) and the task's status line came back to the foreground from a tokio thread, which the test scheduler reported as a test that is not deterministic (one run in six of closing_counts_the_sessions_the_engine_was_told_to_close). run() starts it once the window is open (AppState::start_global_ptt), the state never does, and the test says so. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
65b60f2bb7
commit
d2267e55e7
2 files changed
+17
-5
No files matched your search
@@ -403,11 +403,6 @@ impl AppState {
|
|||||||
if state.switches.voice {
|
if state.switches.voice {
|
||||||
state.transition(cx, |state, cx| logic::show_voice_view(state, cx, true));
|
state.transition(cx, |state, cx| logic::show_voice_view(state, cx, true));
|
||||||
}
|
}
|
||||||
state.set_global_ptt(hotkey_wanted(
|
|
||||||
&state.vm.settings,
|
|
||||||
state.switches.demo_ui,
|
|
||||||
state.engine.is_some(),
|
|
||||||
));
|
|
||||||
state
|
state
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -982,6 +977,16 @@ impl AppState {
|
|||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Start the global push-to-talk hotkey as the settings say (`global_ptt`,
|
||||||
|
/// `ptt_key`) when there is an engine and no sample servers. [`crate::run`]
|
||||||
|
/// calls it once the window is open; the state does not start it by itself,
|
||||||
|
/// so that a test of the state with a real engine never asks the desktop for
|
||||||
|
/// a shortcut.
|
||||||
|
pub fn start_global_ptt(&mut self) {
|
||||||
|
let key = hotkey_wanted(&self.vm.settings, self.switches.demo_ui, self.engine.is_some());
|
||||||
|
self.set_global_ptt(key);
|
||||||
|
}
|
||||||
|
|
||||||
/// Register the global push-to-talk hotkey with `key` in place of the one
|
/// Register the global push-to-talk hotkey with `key` in place of the one
|
||||||
/// registered, or none: the task starts on the engine's runtime with the
|
/// registered, or none: the task starts on the engine's runtime with the
|
||||||
/// first key ([`crate::hotkey`]; the settings page of its slice calls this
|
/// first key ([`crate::hotkey`]; the settings page of its slice calls this
|
||||||
@@ -1572,6 +1577,10 @@ mod tests {
|
|||||||
switches: Switches::default(),
|
switches: Switches::default(),
|
||||||
};
|
};
|
||||||
let app = cx.new(|cx| AppState::new(setup, cx));
|
let app = cx.new(|cx| AppState::new(setup, cx));
|
||||||
|
assert!(
|
||||||
|
app.read_with(cx, |app, _| app.ptt.is_none()),
|
||||||
|
"the state starts no hotkey by itself: run does, with the window"
|
||||||
|
);
|
||||||
assert_eq!(app.update(cx, |app, cx| app.shutdown(cx)), 0, "no session open yet");
|
assert_eq!(app.update(cx, |app, cx| app.shutdown(cx)), 0, "no session open yet");
|
||||||
tx.send(voice(VoiceState::Connected)).unwrap();
|
tx.send(voice(VoiceState::Connected)).unwrap();
|
||||||
cx.run_until_parked();
|
cx.run_until_parked();
|
||||||
|
|||||||
@@ -151,6 +151,9 @@ fn open_main_window(
|
|||||||
};
|
};
|
||||||
move |cx| AppState::new(setup, cx)
|
move |cx| AppState::new(setup, cx)
|
||||||
});
|
});
|
||||||
|
// The global push-to-talk key, on the engine's runtime (docs/ui.md): once the
|
||||||
|
// state exists, and never from a test of the state.
|
||||||
|
app.update(cx, |app, _| app.start_global_ptt());
|
||||||
let options = {
|
let options = {
|
||||||
let app = app.read(cx);
|
let app = app.read(cx);
|
||||||
window_options(switches, app.remembered_window(), app.window_title(), cx)
|
window_options(switches, app.remembered_window(), app.window_title(), cx)
|
||||||
|
|||||||
Reference in new issue
Block a user