Skip to content

Fix crashes and data loss, add keyboard shortcuts and 3 themes; add tests + CI - #2

Merged
akshit-python-programmer merged 6 commits into
mainfrom
c/serene-faraday-0mtjnk
Nov 15, 2026
Merged

akshit-python-programmer merged 6 commits into
mainfrom
c/serene-faraday-0mtjnk

Conversation

@akshit-python-programmer

@akshit-python-programmer akshit-python-programmer commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Bug fixes, two new features, and project setup. Each commit is self-contained and explains itself in its message.

New

  • Keyboard shortcuts (suggested by Fazal)
    • ↑/↓ or K/J select to-dos, including inside open folders
    • Space/Enter checks a to-do off or opens/closes a folder
    • 1/2/3 schedule for Today/Tomorrow/Someday
    • N adds a to-do, Delete removes the selected one, Esc clears the selection
    • ←/→, Home and W move around the calendar
    • ? opens a help overlay
  • Three new themes (suggested by Anaconda bro): Ocean Breeze, Lavender Dusk, Matcha Latte.
  • To-dos show a date pill (Today / Tomorrow / on Mon, red when overdue).

Crashes and data loss fixed

  • Opening the Add/Edit Event dialog crashed the app. It read y_offset before assigning it, raising UnboundLocalError.
  • Pressing S crashed the app. It referenced an undefined font_path, raising NameError.
  • The packaged .exe lost all user data on restart. It wrote into PyInstaller's temporary folder, which is deleted on exit. Data now goes to the OS app-data folder (assets/ from source, FOCI_DATA_DIR to override).
  • resource_path() depended on the current working directory, so assets went missing when the app was launched from another folder.

Other fixes

  • "Schedule for Tomorrow" deleted the tag it had just set.
  • Date tags didn't roll over for to-dos inside folders.
  • "Delete completed" ignored to-dos inside folders.
  • Google Calendar:
    • the google_auth_oauthlib import was misspelled, so it always failed
    • the day window was computed in UTC instead of local time
    • event times weren't converted to local time
    • all-day events were imported as 24-hour blocks
  • format_time wrapped around at 24h+, unreadable JSON crashed startup, and freeze_support() was missing for the lofi subprocess.

Project setup

  • foci_store.py: persistence, validation and to-do navigation logic, with no pygame dependency.
  • 69 tests: unit tests, plus headless UI tests that open the dialogs, drive the key handler and render every theme.
  • GitHub Actions: ruff, plus pytest on Windows/macOS/Linux × Python 3.10/3.13, plus a startup smoke test.
  • CONTRIBUTING.md, CHANGELOG.md, issue forms, PR template, and an Acknowledgements section in the README.

Testing

  • ruff check . and pytest -q pass locally (69 tests).
  • Rendered the event dialog, shortcuts overlay, keyboard selection and all three new themes headlessly and checked the screenshots.
  • Not tested: a real Windows PyInstaller build. Worth building dist/Foci.exe once, adding an event, restarting, and confirming it's still there.

🤖 Generated with Claude Code

https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw

Move JSON I/O and the settings/event/to-do sanitizers out of main.py
into a pygame-free module so they can be unit tested without opening
a window. main.py keeps thin wrappers bound to its live defaults.

Bugs fixed along the way:
- "Schedule for Tomorrow" set tag='tmr' and then deleted it on the
  next line, so tomorrow's to-dos had no tag and never rolled over to
  "today".
- Date tags only rolled forward for top-level to-dos; anything filed
  inside a folder kept a stale "today" forever.
- "Delete completed" ignored finished to-dos inside folders, and the
  button stayed disabled when only nested items were done.
- Date tags were stored but never drawn. To-dos now show a small
  Today / Tomorrow / on <Weekday> pill, red when overdue.
- Unreadable JSON (e.g. bad encoding) now falls back to defaults
  instead of raising UnicodeDecodeError at startup.

Adds tests/test_store.py (26 tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
…he script

main.spec builds a one-file executable, which unpacks itself into a
temporary sys._MEIPASS folder that is deleted when the app exits. All
user data (events, to-dos, settings, coins, Google OAuth token) was
written through resource_path() into that folder, so the packaged app
lost everything on every restart.

- Bundled resources still come from the app root; writable data now
  goes to foci_store.user_data_dir(): FOCI_DATA_DIR if set, the
  platform data dir for packaged builds (%APPDATA%\Foci,
  ~/Library/Application Support/Foci, $XDG_DATA_HOME/Foci), and
  assets/ when running from source (unchanged for existing users).
- resource_path() used the current working directory, so launching
  'python path/to/main.py' from anywhere else couldn't find fonts,
  icons or the coin sprite sheet. It now resolves relative to the
  source file.
- Call multiprocessing.freeze_support() so the lofi player subprocess
  doesn't re-launch the whole app in frozen Windows builds.
- Name the built executable Foci.exe instead of main.exe.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
- 'from google.auth_oauthlib.flow import ...' is not a real module (the
  package is google_auth_oauthlib), so google_calendar.py raised
  ImportError on import even with every dependency installed.
- The day window was a naive local midnight with 'Z' appended, which
  asked Google for the UTC day instead of the user's day. It now sends
  local-offset RFC 3339 bounds.
- Synced events took hour/minute in whatever offset Google returned;
  they are now converted to local time first.
- All-day events were parsed as a 24h block at 00:00; they are skipped
  since the timeline has no all-day row yet.
- Google libraries are now an optional import, so the module (and its
  conversion helpers) load without them.

Adds tests/test_google_calendar.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
- Drop a one-line event_add_window() stub that was silently shadowed by
  the real definition further down.
- format_time() used timedelta.seconds, which discards whole days, so
  durations of 24h+ wrapped around. Use the total seconds instead
  (utility.py and progress.py).
- Remove unused imports (multiprocessing.Queue, gfxdraw, datetime).
- Add pyproject.toml with pytest paths and a ruff config limited to
  real-bug checks (undefined names, redefinitions, syntax errors).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
…moke test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
- CONTRIBUTING.md: setup, FOCI_DATA_DIR for dev, project layout, how to
  run lint/tests, and guidelines.
- CHANGELOG.md documenting the fixes on this branch.
- Bug report and feature request issue forms, PR template.
- README: CI badge, where data lives per platform, test instructions,
  mark Google Calendar sync as experimental, and stop claiming
  drag-to-reorder in the to-do list (it isn't implemented yet).
- TECHNICAL.md: describe foci_store and the resource/data split.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158w81iQPwdBuV6B2KuQKPw
@akshit-python-programmer
akshit-python-programmer marked this pull request as ready for review November 15, 2026 05:07
@akshit-python-programmer
akshit-python-programmer merged commit 53f691e into main Nov 15, 2026
7 checks passed
@akshit-python-programmer akshit-python-programmer changed the title Fix data loss in packaged builds, to-do tag bugs and Google Calendar sync; add tests + CI Fix crashes and data loss, add keyboard shortcuts and 3 themes; add tests + CI Nov 15, 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.

2 participants