From 45f7d343c1351a930a384f618dc429aa75333960 Mon Sep 17 00:00:00 2001 From: devon7y Date: Fri, 3 Apr 2026 13:31:26 -0600 Subject: [PATCH] Improve screen reliability and debug visibility --- .env.example | 6 + calendar_access.py | 33 ++- frontend/index.html | 17 ++ frontend/src/main.ts | 124 ++++++++++ frontend/src/style.css | 158 ++++++++++++ frontend/src/ws.ts | 16 ++ screen.py | 166 +++++++++++-- server.py | 413 ++++++++++++++++++++++++++------ tests/test_calendar_access.py | 27 +++ tests/test_debug_log_stream.py | 41 ++++ tests/test_lookup_reporting.py | 98 ++++++++ tests/test_project_discovery.py | 62 +++++ tests/test_screen.py | 30 +++ tests/test_screen_detection.py | 9 + tests/test_weather.py | 47 ++++ 15 files changed, 1157 insertions(+), 90 deletions(-) create mode 100644 tests/test_calendar_access.py create mode 100644 tests/test_debug_log_stream.py create mode 100644 tests/test_lookup_reporting.py create mode 100644 tests/test_project_discovery.py create mode 100644 tests/test_screen.py create mode 100644 tests/test_screen_detection.py create mode 100644 tests/test_weather.py diff --git a/.env.example b/.env.example index 76f8e299..3f345741 100644 --- a/.env.example +++ b/.env.example @@ -11,3 +11,9 @@ FISH_API_KEY=your-fish-audio-api-key-here # Optional: Specific Apple Calendar accounts to read (comma-separated emails) # If not set, JARVIS reads ALL calendars from Apple Calendar # CALENDAR_ACCOUNTS=you@gmail.com,work@company.com + +# Optional: override auto-detected weather location +# If not set, JARVIS uses your current public-IP location and reports Celsius. +# WEATHER_LOCATION_LABEL=Edmonton, AB +# WEATHER_LATITUDE=53.5461 +# WEATHER_LONGITUDE=-113.4938 diff --git a/calendar_access.py b/calendar_access.py index c91d0903..526a4f29 100644 --- a/calendar_access.py +++ b/calendar_access.py @@ -14,12 +14,26 @@ log = logging.getLogger("jarvis.calendar") + +def _parse_calendar_accounts(raw: str) -> list[str]: + """Parse CALENDAR_ACCOUNTS, treating empty / auto as auto-discover.""" + if not raw or not raw.strip(): + return [] + accounts = [] + for item in raw.split(","): + value = item.strip() + if not value: + continue + if value.lower() == "auto": + continue + accounts.append(value) + return accounts + + # Calendars to scan — set CALENDAR_ACCOUNTS env var to a comma-separated list, # or leave empty to auto-discover ALL calendars from Apple Calendar. _calendar_accounts_env = os.getenv("CALENDAR_ACCOUNTS", "") -USER_CALENDARS: list[str] = [ - a.strip() for a in _calendar_accounts_env.split(",") if a.strip() -] if _calendar_accounts_env.strip() else [] +USER_CALENDARS: list[str] = _parse_calendar_accounts(_calendar_accounts_env) _auto_discovered = False @@ -181,6 +195,19 @@ async def refresh_cache(): log.info(f"Calendar cache refreshed: {len(all_events)} events today ({elapsed:.1f}s)") +def configure_calendar_accounts(raw: str) -> None: + """Apply updated calendar account settings without a server restart.""" + global USER_CALENDARS, _auto_discovered, _event_cache, _cache_time + USER_CALENDARS = _parse_calendar_accounts(raw) + _auto_discovered = False + _event_cache = [] + _cache_time = 0.0 + if USER_CALENDARS: + log.info(f"Calendar accounts configured explicitly: {USER_CALENDARS}") + else: + log.info("Calendar accounts set to auto-discover") + + async def get_todays_events() -> list[dict]: """Get today's events from cache. Returns cached data immediately.""" if not _event_cache and _cache_time == 0: diff --git a/frontend/index.html b/frontend/index.html index 9440bda4..0e877911 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -27,6 +27,7 @@