Skip to content

Improve live timer sync on home and timers pages#10

Merged
Fingolfin7 merged 1 commit intomasterfrom
codex/improve-responsiveness-of-timers-page
Apr 13, 2026
Merged

Improve live timer sync on home and timers pages#10
Fingolfin7 merged 1 commit intomasterfrom
codex/improve-responsiveness-of-timers-page

Conversation

@Fingolfin7
Copy link
Copy Markdown
Owner

Motivation

  • Timers started/stopped outside the web UI (e.g. via the CLI/API) were not reflected promptly on the timers page or the home timers section, requiring manual refreshes.
  • The previous JS updated every .card on the page which touched unrelated elements and performed unnecessary DOM work.

Description

  • Limit duration updates to timer cards inside #active-timers by changing the selector to #active-timers .card[id^="timer-"] in core/static/core/js/dynamic_timers.js to avoid touching unrelated cards.
  • Add a polling sync loop in core/static/core/js/dynamic_timers.js that calls /api/list_active_sessions/ every 5 seconds and compares server-side active session IDs with locally rendered timer IDs, triggering window.location.reload() when they differ so CLI/API changes appear quickly.
  • Add helper getLocalTimerIds() and syncActiveTimers() in the same JS file to support the above comparison and run an initial sync on page load.
  • Update list_active_sessions in core/api.py to apply filter_by_active_context(...) so the polled API mirrors the UI's active-context filtering and avoids false positives when comparing IDs.

Testing

  • Ran python manage.py check which failed in this environment because required environment variables are not set (SECRET_KEY), so the project-level Django system checks could not complete; no other automated tests were executed in this session.

Codex Task

@Fingolfin7 Fingolfin7 merged commit 27f0f8d into master Apr 13, 2026
3 checks passed
@Fingolfin7 Fingolfin7 deleted the codex/improve-responsiveness-of-timers-page branch April 13, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant