Skip to content

Session History Log + Dark Mode Table Fix#4

Merged
SeanathanVT merged 9 commits into
mainfrom
feature/session-history-log
May 5, 2026
Merged

Session History Log + Dark Mode Table Fix#4
SeanathanVT merged 9 commits into
mainfrom
feature/session-history-log

Conversation

@SeanathanVT
Copy link
Copy Markdown
Owner

@SeanathanVT SeanathanVT commented May 2, 2026

Summary

Implements persistent session history with a responsive recent-sessions table, CSV export, and history clearing on the start screen. Also fixes the session history table to properly support the Light/Dark theme toggle.


What's New

Session History Log

  • Persistent storage — Completed sessions are saved to session_history.json as structured JSON records containing: date, start/end time, duration, distance (km/mi), steps, calories, and average speed (km/h and mph).
  • End Session button — Red "End Session" button on Active and Paused screens explicitly ends a session, stops the belt, saves stats to history, resets all counters, and returns to the start screen.
  • Graceful shutdown hook — In-progress sessions are automatically captured on graceful shutdown (Ctrl+C or Close button) so no data is lost.
  • Thread-safe file I/O — All reads/writes protected by threading.Lock() (_history_lock) to prevent corruption across Flask request threads and the BLE thread.
  • Fault tolerance — Corrupted or missing session_history.json is handled gracefully — starts fresh with an empty array and logs a warning.

Recent Sessions Table

  • Start screen displays the last 10 sessions (configurable via HISTORY_DISPLAY_LIMIT) in a responsive table showing date, time, duration, distance, steps, calories, and average speed.
  • Fully styled with custom CSS using CSS custom properties — no Bootstrap .table class dependency.

CSV Export & Clear History

  • Export CSV/export_csv route generates a downloadable walkingdad_history.csv containing all historical sessions (full history, no limit).
  • Clear History — Button with confirmation dialog that truncates the history file via /clear_history POST endpoint.

Bugfixes

Session History Table Dark Mode

  • Table background was not following the Light/Dark theme toggle, causing white-on-white (invisible) text in dark mode.
  • Rewrote all table styling from scratch using CSS custom properties (--card-color, --text-color, --border-color, --button-hover-bg) so every color — background, borders, hover, text — properly switches with the theme toggle.

Files Changed

File Changes
app.py Added _build_session_record(), _save_session(), _load_session_history(), _clear_session_history(), _load_full_session_history() functions. Added /end_session, /export_csv, /clear_history routes. History loaded in root(). Shutdown hook calls _save_session(). New constants: HISTORY_FILE, HISTORY_DISPLAY_LIMIT, _history_lock.
templates/start_session.html Added End Session button, recent sessions table with .history-table class, Export CSV and Clear buttons, clear history JavaScript handler.
templates/active_session.html Added red "End Session" button below speed controls.
templates/paused_session.html Added red "End Session" button next to Resume.
templates/base.html Added .history-table custom CSS rules with dark mode support.
.gitignore session_history.json exclusion (already present from prior work).
CHANGELOG.md Updated to v1.2.0, restructured release entries.
ROADMAP.md Marked item 2.5 as Complete (v1.2.0).

Testing Checklist

  • Start and complete a session → verify record appears in Recent Sessions table
  • End session via button → verify belt stops, session saved, counters reset, redirected to start screen
  • Ctrl+C during active session → verify session_history.json contains the session after exit
  • Export CSV → verify all sessions included (not just last 10)
  • Clear History → confirm dialog appears, table empty afterward, history file truncated
  • Toggle Dark mode → verify table background, text, borders, and hover states all properly invert
  • Delete session_history.json while app running → app handles gracefully, no crash

…. Notify user in web UI when process dies on the back end. Adapt to multiple process termination scenarios. Update documentation.
…ssion history table dark mode support after merge revert. Re-applied .history-table custom CSS in base.html and updated start_session.html to use it instead of Bootstrap .table class. Table background, text, borders, and hover now properly follow the theme toggle.
@SeanathanVT SeanathanVT merged commit d32e7c3 into main May 5, 2026
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