@@ -23,12 +23,24 @@ use tokio::sync::mpsc;
2323use crate :: scheduler;
2424use crate :: Shared as MainShared ;
2525
26- /// The URL the window loaded on first paint — captured in `main.rs`'s setup
27- /// callback and used by the on_page_load script (`build_escape_script` in
28- /// main.rs) to bring the operator back to about from any external page.
29- /// Platform-specific: typically `tauri://localhost/` on Linux/macOS or
30- /// `http://tauri.localhost/` on Windows.
31- pub struct AboutUrl ( pub tauri:: Url ) ;
26+ /// Canonical in-memory target for "go to about" actions. Updated by `main.rs`
27+ /// when it sees a finished load of the bundled about page, and used by both
28+ /// the injected F1 handler and Rust-side Idle transitions.
29+ pub struct AboutUrl ( pub Mutex < tauri:: Url > ) ;
30+
31+ impl AboutUrl {
32+ pub fn new ( url : tauri:: Url ) -> Self {
33+ Self ( Mutex :: new ( url) )
34+ }
35+
36+ pub fn get ( & self ) -> tauri:: Url {
37+ self . 0 . lock ( ) . expect ( "AboutUrl poisoned" ) . clone ( )
38+ }
39+
40+ pub fn set ( & self , url : tauri:: Url ) {
41+ * self . 0 . lock ( ) . expect ( "AboutUrl poisoned" ) = url;
42+ }
43+ }
3244
3345/// Shared runtime handles for the about page snapshot + the broker dispatch
3446/// path. `make_snapshot` reads `shared`/`broker_url`/`stage_name`; the
@@ -37,9 +49,16 @@ pub struct AboutUrl(pub tauri::Url);
3749/// wire the socks inbound dispatch closure.
3850pub struct TauriCtx {
3951 pub shared : Arc < Mutex < MainShared > > ,
52+ /// Human-readable broker location for the about-page snapshot. Online
53+ /// stages expose the actual `wss://...` URL; offline modes carry the
54+ /// sentinel `"(offline)"`.
4055 pub broker_url : String ,
56+ /// True when catstage was started with `--offline` or `--url` — no broker
57+ /// task is spawned and the about page should make the operator aware.
58+ pub offline : bool ,
4159 pub sched_tx : mpsc:: Sender < scheduler:: Cmd > ,
4260 pub stage_name : String ,
61+ pub screen : Option < u32 > ,
4362}
4463
4564#[ derive( Debug , Clone , Serialize ) ]
@@ -53,6 +72,7 @@ pub struct FileEntry {
5372pub struct Snapshot {
5473 pub state : State ,
5574 pub broker_url : String ,
75+ pub offline : bool ,
5676 pub stage_name : String ,
5777 pub files : Vec < FileEntry > ,
5878 pub autostart_path : Option < String > ,
@@ -63,6 +83,7 @@ pub fn make_snapshot(ctx: &TauriCtx) -> Snapshot {
6383 Snapshot {
6484 state,
6585 broker_url : ctx. broker_url . clone ( ) ,
86+ offline : ctx. offline ,
6687 stage_name : ctx. stage_name . clone ( ) ,
6788 files : file_entries ( ) ,
6889 autostart_path : crate :: autostart:: is_installed ( ) . map ( |p| p. display ( ) . to_string ( ) ) ,
@@ -136,6 +157,23 @@ pub async fn enter_idle(ctx: tauri::State<'_, TauriCtx>) -> Result<(), String> {
136157 . map_err ( |e| e. to_string ( ) )
137158}
138159
160+ /// Resume scheduler playback from the about page. Bound to the page-local
161+ /// F2 shortcut so an operator can leave Idle without needing a separate CLI.
162+ #[ tauri:: command]
163+ pub async fn enter_play ( ctx : tauri:: State < ' _ , TauriCtx > ) -> Result < ( ) , String > {
164+ ctx. sched_tx
165+ . send ( scheduler:: Cmd :: Play )
166+ . await
167+ . map_err ( |e| e. to_string ( ) )
168+ }
169+
170+ /// Exit the catstage process when confirmed by the about page.
171+ #[ tauri:: command]
172+ pub async fn request_exit ( app : tauri:: AppHandle ) -> Result < ( ) , String > {
173+ app. exit ( 0 ) ;
174+ Ok ( ( ) )
175+ }
176+
139177/// Push the latest snapshot to the about page (via Tauri event). Called
140178/// from `SchedEvents` (and from broker dispatch handlers in `main.rs`)
141179/// after state changes.
0 commit comments