Commit Graph
86 Commits
Author SHA1 Message Date
aksdb bd2ec79a69 🐛 Silence SignalDB warnings for reads outside reactive scopes
Every read outside a reactive scope passed { reactive: false } and made
Cursor.depend() log a warning. Such reads now use a silent reactivity
adapter, and all, get, pendingCount and save release the cursor again
with cleanup(), so nothing is registered and nothing leaks. Reads inside
$derived or $effect stay reactive as before.

Vitest now resolves the browser export of Svelte. Without it
svelte/reactivity is the server stub, createSubscriber never starts and
no effect re-runs after a write in tests.
2026-12-01 17:02:53 +01:00
aksdb 73359d3f39 ♻️ Answer unknown API routes with JSON and fix stale comments
The SPA catch-all answered unknown /api paths with the index page and
status 200, so the client SDK failed to parse the body. A catch-all per
HTTP method answers them with a JSON 404 in the error shape of
PocketBase; the routes registered before keep precedence. The comment
on DataFields no longer claims the fields of the read-only collections
were client writable.
2026-12-01 16:59:19 +01:00
aksdb c3e2bd2555 ♻️ Align week recompute with week close
CloseWeek left closed days that are no workdays out of the total, but
recomputeWeek counted every closed day of the week. A closed Saturday
therefore changed the total of an already closed week as soon as another
day of that week was closed, reopened or marked. Both use the same rule
now, with the settings effective on the closed day.
2026-12-01 16:56:20 +01:00
aksdb 590758dfb6 🐛 Bound hours per week on settings
The field accepted any number from 0.01 up, so a typo or a bad client
could store more hours than a week has and break every expected value
derived from it. The initial migration limits hours_per_week to 168; no
database was ever deployed with the previous version of the migration.
2026-12-01 16:54:32 +01:00
aksdb b41f83342c 🐛 Return server errors as 500 when marking a day fails
Marking a day answered every error except an invalid day key with 422,
including database errors. Only an invalid kind is a 422 now. Server
errors are logged with their cause and answered with a generic message
instead of the error text, which can contain SQL, and the timezone
lookup logs at warn before it falls back to UTC.
2026-12-01 16:52:30 +01:00
aksdb 2bcf2d69a1 🐛 Stop stale entries without overwriting a concurrent stop
The auto-stop listed the running entries and later saved the whole stale
row, so a stop pushed by a client in between was overwritten and then
answered as stale. Each candidate is now loaded again inside its own
transaction and only saved while it is still running and not deleted.
The end of the day uses the timezone effective on the day of the entry,
and entries without a real day_key are skipped with a debug message
instead of an error every minute.
2026-12-01 16:49:15 +01:00
aksdb 0bfacb7059 🐛 Reject week keys that are not real ISO weeks
WeekDayKeys accepted W01 to W53 without checking that the year has that
week. Closing 2025-W53, a year with 52 weeks, closed the days of
2026-W01 under a second key and the balance counted them twice. The
computed Monday must now map back to the requested week key.
2026-12-01 16:43:40 +01:00
aksdb 9f0700fa1c 🐛 Reject invalid changes instead of failing the whole sync batch
Every whitelisted field was written, so a tombstone or a partial change
without the required fields failed the validation and rolled back the
whole batch with 400, which a client would retry forever. Only the keys
present in the change are set now, a change is validated on its own and
answered as invalid with the message, and a tombstone for an unknown
row is answered ok without writing anything.
2026-12-01 16:41:57 +01:00
aksdb 8898d976e6 🐛 Keep tombstones when replacing data in the legacy import
Clients only pull changed rows and never learn about hard deletes, so
a row they already pulled survived as a ghost: it kept winning against
imported rows with the same effective_from. Existing rows now become
tombstones. Closed days and weeks are overwritten in place when an
imported row has the same key, so their unique index holds.
2026-12-01 16:37:26 +01:00
aksdb 20df2918c9 ♻️ Move the settings page to PocketBase and SignalDB
The shared token form is gone. Working hours, workdays and timezone
are edited through the synced settings collection, and a new account
card shows the signed-in user, a password change and sign out.
2026-11-30 17:43:13 +00:00
aksdb cd39c7457e ♻️ Read history and balance from SignalDB
Closed weeks, closed days, the balance and the adjustments are derived
from the synced collections instead of being loaded once on mount, so
every change shows up without a reload.
2026-11-30 17:43:13 +00:00
aksdb f0cf796ef6 ♻️ Drive the day detail from SignalDB collections
The day detail panel no longer loads entries and the closed day on
demand and patches its lists after each mutation. Entries, the closed
day, the running entry and the total are derived from the synced
collections, so they update on local changes and on sync. The ticker
restarts whenever the running entry changes. Closing, marking and
reopening a day rely on the sync the domain functions trigger.
2026-11-30 17:43:13 +00:00
aksdb a47affa765 ♻️ Read the week view reactively from SignalDB
The week view no longer loads its data on demand and patches it after
each mutation. Entries, closed days, the closed week and the settings
are derived from the synced collections, so the view follows local
changes and sync results. Closing and reopening a week report errors
from the server in place.
2026-11-30 17:43:13 +00:00
aksdb f54e7238b4 ♻️ Gate the app behind PocketBase authentication
Only signed-in users reach the working pages. Everyone else lands on
the login page and returns to the page they asked for after signing in.
The manifest link moves into the page template and the service worker
is registered only in production builds.
2026-11-30 17:43:13 +00:00
aksdb 23cecdea80 ✨ Add login and sign-up page
The app no longer uses a shared bearer token. The page signs users in
or creates an account through PocketBase and offers the configured
OAuth2 providers.
2026-11-30 17:43:13 +00:00
aksdb 6a95b885b8 📝 Document the PocketBase and SignalDB stack
The README now describes the PocketBase binary, the per-user settings,
the admin UI, the sign-in page and the import-legacy command. PLAN.md
records the decisions of the migration and marks the sections that
describe the old backend as superseded.
2026-11-30 17:43:13 +00:00
aksdb 74ebd2b38f ♻️ Build on PocketBase defaults in container and tasks 2026-11-30 17:39:27 +00:00
aksdb bb5ba06110 🔧 Tidy Go modules after the legacy removal 2026-11-29 20:28:25 +00:00
aksdb cb2d090ffc 🗑️ Remove legacy SQLite store, services and handlers 2026-11-29 20:28:10 +00:00
aksdb 611a2d105a 🧪 Test day and week closing rules 2026-11-29 20:27:12 +00:00
aksdb 9489952842 ✨ Export entries, days and weeks as CSV 2026-11-29 20:24:54 +00:00
aksdb 1edaf75e4b ✨ Seed settings for new users and auto-stop stale entries 2026-11-29 20:24:48 +00:00
aksdb 31b404e27a ✨ Add day and week closing on PocketBase records 2026-11-29 20:24:40 +00:00
aksdb 39e0f69342 🧪 Test legacy import
The tests build a legacy SQLite fixture from the old migrations and
cover the field mapping, skipped invalid rows, the replace-on-rerun
behaviour, the dry run and the guarantee that the legacy file and its
directory stay untouched.
2026-11-29 20:24:32 +00:00
aksdb e190c5c919 ✨ Add import-legacy command for the SQLite database
The command copies the tables of the old wotra.db into the PocketBase
records of one user, so the tracked time survives the move to the new
backend. The legacy file is only ever read; a dry run shows what would
be imported without writing anything.
2026-11-29 20:24:29 +00:00
aksdb 1e5110f253 🧪 Test timezone helpers and local collections 2026-11-29 20:16:45 +00:00
aksdb 29f3cb9926 🐛 Push sync changes in batches of 200
The server rejects more than 500 changes per request, so one large
offline batch would otherwise stay pending forever.
2026-11-29 20:16:45 +00:00
aksdb 98f3e8048c 🔧 Stop caching API responses in the service worker 2026-11-29 20:16:45 +00:00
aksdb d9890db12f ✨ Add tracking domain functions on SignalDB 2026-11-29 20:16:41 +00:00
aksdb 6a6c2bb71d ✨ Add SignalDB collections synced with PocketBase 2026-11-29 17:21:41 +00:00
aksdb c00b393bec ✨ Add PocketBase client and session helpers 2026-11-29 17:21:36 +00:00
aksdb 58479668b6 ✨ Run PocketBase as the wotra binary
The root package is now the entry point: one binary that serves the
PocketBase API, applies the migrations and ships the SvelteKit build
from web/build as a single-page app. The legacy chi entry point is
gone.

Note that the image is embedded unconditionally, so a Go build needs
at least the tracked web/build/.gitkeep and a web build has to run
first to get a working UI.
2026-11-29 17:06:46 +00:00
aksdb 03c1a1f8d9 🗑️ Remove legacy asset embedding and command wiring
The repo root was the legacy "assets" package and cmd/wotra held the
old chi entry point. Go does not allow "package main" next to another
package in the same directory, so both have to go before the
PocketBase entry point can live at the root and embed web/build from
there.

The remaining legacy packages (internal/store, service, handler,
domain, config, clock) are untouched and keep building as a
reference.
2026-11-29 17:05:19 +00:00
aksdb fcb008dd57 🧪 Test sync push endpoint
Covers create, update, stale, forbidden and readonly answers, the
guard for the last settings row, request validation, the missing auth
token and that a failing change rolls back the whole batch. Also
checks that regular users cannot write synced collections over REST
and that superuser writes keep the owner and rev consistent.
2026-11-29 17:03:45 +00:00
aksdb f63fe1b549 ✨ Add batch push endpoint for synced collections
POST /api/sync/push applies up to 500 client changes of a signed-in
user in one transaction. Every change is answered with ok, stale,
forbidden or readonly, so the client can reconcile its local state
with the server state.

closed_days and closed_weeks are answered as readonly because only
the server computes them. The last remaining settings row of a user
cannot be deleted either; such a change is answered as stale, which
clients already treat as "server wins".
2026-11-29 17:03:42 +00:00
aksdb a2507d22d3 ✨ Scaffold PocketBase app with embedded UI
Add PocketBase v0.40.6 as a dependency together with the pieces the
new backend is built from: the list of synced collections with their
client-writable fields, the initial migration that creates the five
per-user collections (entries, closed_days, closed_weeks,
settings_history, balance_adjustments), and empty Register stubs for
the tracking and legacy import packages.

Clients only get read access to their own rows over REST; writes are
meant to go through the sync push endpoint. web/build is now ignored
except for a tracked placeholder so the built SPA can be embedded.

The entry point (main.go) and the UI embedding (ui.go) are not part
of this commit: the repo root is still the legacy "assets" package,
and Go does not allow "package main" in the same directory.
2026-11-29 16:58:41 +00:00
aksdb 3b024b6766 ⬆️ Add SignalDB and PocketBase client dependencies 2026-11-29 16:57:28 +00:00
aksdb ab5749107c ♻️ Bootstrap when syncmarker is zero 2026-08-20 15:53:39 +00:00
aksdb 29284a024d 🐛 Fix sync from zero 2026-08-20 17:35:43 +02:00
aksdb babc9a8096 🧪 Reproduce failing sync from zero 2026-08-20 16:42:08 +02:00
aksdb 4fa598e5ce ⬆️ Update dependencies 2026-08-20 16:34:55 +02:00
aksdb 8cd58fbd2c fix: closing the week early should count properly 2026-05-13 20:47:39 +00:00
aksdb c617012401 test: expect proper midweek handling 2026-05-13 20:44:14 +00:00
aksdb ca5f5f95e2 refactor: introduce clock to make tests reproducible 2026-05-13 20:24:56 +00:00
aksdb 7e6c47a50e refactor: default to today-view 2026-05-08 20:40:20 +00:00
aksdb d3faf79b57 fix: service worker registration 2026-05-08 19:27:07 +02:00
aksdb 68e16fa4ca build: force vite-plugin-pwa to use project vite instance 2026-05-01 22:37:42 +02:00
aksdb 905d668847 build: replace install task with mise deps for automatic dependency management 2026-05-01 22:34:46 +02:00
aksdb fe5603e206 build: add Containerfile for multi-stage container image
Three stages: node:24-alpine builds the Svelte SPA, golang:1.26-alpine
compiles the Go binary with embedded assets (-tags production), and
alpine:3.21 is the minimal runtime.

Runs as unprivileged user (uid 1000). DB_PATH defaults to /data/wotra.db
so a volume mount at /data provides persistent storage.

  podman run -e AUTH_TOKEN=secret -p 8080:8080 -v wotra-data:/data wotra
2026-05-01 22:05:29 +02:00
aksdb a372c17860 feat: sync status indicator in nav
Shows a sync button in the top-right corner of the nav bar with live
status: spinning while syncing, warning icon on error, grey when idle.
Tooltip shows last synced time or error message. An orange badge
appears when there are pending outbox items.

- sync.ts: add syncState store (status, lastSynced, pendingCount,
  error); guard against concurrent sync cycles with syncInFlight flag
- layout: sync button wired to triggerSync(); ticks every 15s so the
  'Xs ago' label stays current
2026-05-01 21:44:50 +02:00