agent-zero
agent-zero copied to clipboard
feat: display container system time instead of browser time
Summary
Replace browser-based clock with backend-driven system time display to show the Linux container's time instead of the user's browser time.
Problem
- UI clock displayed frontend (browser) time, not the system time of the container
- Backend timezone was re-synced on every poll request based on browser timezone
- Users connecting from different timezones would override the system timezone
- This caused problems with the task scheduler and created inconsistent behavior
Solution
-
Backend (
python/api/poll.py): Addedsystem_timefield to poll response with server's localized time formatted as ISO (minutes precision) -
Timezone Persistence (
python/helpers/localization.py): Modified initialization to only persist timezone to.envonce, then respect the stored value -
Frontend Component (
webui/components/system-clock/): Created dedicated Alpine.js store and component to display backend time -
Polling Logic (
webui/index.js): Removed browser time updater, added one-time timezone sync flag, integrated system clock store updates -
Locale Preservation: Parse server ISO timestamp and format using
Intl.DateTimeFormatwithtimeZone: "UTC"to respect user locale (24h/12h, month names) while displaying container time
Changes
Backend
-
python/api/poll.py: Addsystem_timegeneration and one-time timezone sync logic -
python/helpers/localization.py: Update__init__to avoid persisting default timezone until explicitly set
Frontend (New)
-
webui/components/system-clock/system-clock.html: Clock component template -
webui/components/system-clock/system-clock-store.js: Alpine store for time state and formatting
Frontend (Modified)
-
webui/components/chat/top-section/chat-top.html: Replace inline time div with x-component -
webui/index.js: Import system clock store, removeupdateUserTime(), update poll to sync timezone once -
webui/index.css: Remove#time-dateand#user-datestyles (moved to component)