Fix sidecar pipe crash on state changes and show logged-in state in settings
The state callback in main_headless.py wrote events to stdout synchronously, so an EINVAL on the Tauri sidecar pipe (Windows) bubbled up through _set_state and tore down engine init and reload_engine. That turned PUT /api/config into a "Failed to fetch" for the user. The print is now pipe-safe and api_server isolates the chained callback so a future misbehaving listener cannot break the engine state machine. Settings also now persists remote.email on login and shows a "Logged in as <email>" indicator with a Log out button when an auth_token is present, instead of leaving the email/password fields blank on reload. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -75,10 +75,16 @@ def main():
|
||||
# Create controller and initialize
|
||||
controller = AppController(config=config)
|
||||
|
||||
# Wire a state callback that prints the ready event
|
||||
# Wire a state callback that prints state events for the parent
|
||||
# process to read. Stdout writes can fail with EINVAL on Windows
|
||||
# when the parent stops reading the sidecar pipe; swallow those
|
||||
# so the engine state machine isn't taken down by a logging path.
|
||||
def on_state_changed(state, message):
|
||||
event = {"event": "state", "state": state, "message": message}
|
||||
print(json.dumps(event), flush=True)
|
||||
try:
|
||||
print(json.dumps(event), flush=True)
|
||||
except (OSError, ValueError):
|
||||
pass
|
||||
|
||||
controller.on_state_changed = on_state_changed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user