Skip to content

Conversation

@TerminallyLazy
Copy link
Contributor

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): Added system_time field 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 .env once, 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.DateTimeFormat with timeZone: "UTC" to respect user locale (24h/12h, month names) while displaying container time

Changes

Backend

  • python/api/poll.py: Add system_time generation 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, remove updateUserTime(), update poll to sync timezone once
  • webui/index.css: Remove #time-date and #user-date styles (moved to component)

- Normalize ISO strings missing timezone info by appending 'Z'
- Update toLocalTime() to detect and normalize timezone format
- Update formatDateTime() to detect and normalize timezone format
- Prevent Invalid Date errors from malformed ISO strings
Merge branch 'development' of https://github.com/agent0ai/agent-zero into feat-sys-time
…omponents

- Added `InitTimezone` API handler to initialize user timezone in the .env file if not already set.
- Updated various scheduler-related files to remove direct timezone input handling, relying on the initialized timezone instead.
- Consolidated timezone initialization in the frontend with a new `initializer.js` module to fetch and set the timezone on application startup.
- Removed redundant timezone handling from scheduler tasks, ensuring they use the initialized timezone from the backend.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant