@@ -32,6 +32,7 @@ const toneRows = document.getElementById("tone_rows") as HTMLDivElement;
3232const addToneBtn = document . getElementById ( "add_tone" ) as HTMLButtonElement ;
3333const saveKeyBtn = document . getElementById ( "save_key" ) as HTMLButtonElement ;
3434const keyStatus = document . getElementById ( "key_status" ) as HTMLSpanElement ;
35+ const autostart = document . getElementById ( "autostart" ) as HTMLInputElement ;
3536const apiKeyInput = ( ) => form . elements . namedItem ( "polish_api_key" ) as HTMLInputElement ;
3637const baseUrlInput = ( ) => form . elements . namedItem ( "polish_base_url" ) as HTMLInputElement ;
3738
@@ -126,6 +127,18 @@ form.addEventListener("input", (e) => {
126127 }
127128} ) ;
128129
130+ // Autostart is OS state (login item), not part of config.json, so apply it
131+ // immediately and revert the checkbox if the OS call fails.
132+ autostart . addEventListener ( "change" , async ( ) => {
133+ try {
134+ await invoke ( "set_autostart" , { enabled : autostart . checked } ) ;
135+ setStatus ( autostart . checked ? "Autostart enabled." : "Autostart disabled." ) ;
136+ } catch ( err ) {
137+ autostart . checked = ! autostart . checked ;
138+ setStatus ( `Autostart change failed: ${ err } ` , false ) ;
139+ }
140+ } ) ;
141+
129142function fill ( cfg : Config ) {
130143 ( form . elements . namedItem ( "aavaaz_url" ) as HTMLInputElement ) . value = cfg . aavaaz_url ;
131144 ( form . elements . namedItem ( "model" ) as HTMLSelectElement ) . value = cfg . model ;
@@ -174,6 +187,7 @@ let current: Config;
174187 current = await invoke < Config > ( "get_config" ) ;
175188 fill ( current ) ;
176189 await refreshKeyStatus ( ) ;
190+ autostart . checked = await invoke < boolean > ( "get_autostart" ) ;
177191} ) ( ) ;
178192
179193form . addEventListener ( "submit" , async ( e ) => {
0 commit comments