Commit Graph
104 Commits
Author SHA1 Message Date
aksdb aa96c37860 ✨ Include the active period in the remaining time display 2026-12-03 19:17:46 +01:00
aksdb 9118663101 🍱 Update icon 2026-12-02 22:41:18 +01:00
aksdb 6b20cd9591 🐛 Fix calculation of expected hours 2026-12-02 19:47:35 +01:00
aksdb 2c2c7a97c6 🧪 Fail the build when the client bundle carries the server runtime
The postbuild step now recreates the tracked build placeholder and checks
that the client bundle holds Svelte's browser runtime and the service
worker registration, so a wrong export condition cannot ship unnoticed.
2026-12-02 19:05:47 +01:00
aksdb d804699ad0 🐛 Keep Svelte's browser runtime in the production bundle
The test setup for reactive reads set resolve.conditions for every mode.
Outside tests the empty list replaced Vite's defaults, so Svelte resolved
to its server build, where onMount is a no-op that the bundler drops. The
layout then never resolved its sign-in gate and showed "Loading…" forever.
The conditions are now only set for vitest.
2026-12-02 19:05:47 +01:00
aksdb d45c3d024f ♻️ Tighten client side validation and helpers
The settings validation now mirrors the bounds of the server, 0.01 to
168 hours and a workday mask of 1 to 127, so a row the client accepts
no longer fails on the server. stopEntry and autoStopStale end an
entry in the timezone of the settings row effective on the entry's
day, as the server does, instead of in today's. updateEntry refuses
to clear end_time while another entry is running.

safeNext falls back for a next path with a backslash, a control
character or "//". The login page opens the OAuth popup itself within
the click and says "The popup was blocked" when the browser refuses
it, where the sign-in used to hang without a word.

The sync keeps a per-collection flag for the pull of the current sync
call instead of counting pulls globally, asks for a minute before the
cursor since the server clock can move backwards, and closeDb()
clears the sync error of the session that ended. The tooltip of the
sync button shows the first line of a multi-line error.
2026-12-02 08:49:46 +01:00
aksdb 03c7b17ccb 🧪 Cover session expiry, network failures and user switches
The db tests get an echo server that honours the pull cursor, records
the filter of every pull, answers with a status of the test's choice
and keeps stale answers like the real one. New cases: a second user
opens without the collections, cursors, realtime subscriptions and
sync status of the first; wipeLocal really removes the cursors and the
database so that the next open pulls everything again; a push that
fails after a good pull and a pull that fails before the push both
keep the change records and the cursor, and the next round pushes it
all; a stale answer applies the server record and a newer local change
wins afterwards.

The stress test now compares every local record, tombstones included,
with the mock server after each round, so a divergence between the two
fails the test. closeDb() resets the last sync time for the same
reason: it belonged to the session that just ended.
2026-12-01 19:16:35 +01:00
aksdb a29cedbef1 🐛 Report every change the server rejects or overrides
Only an invalid answer set the sync error: forbidden and readonly were
silent, a stale answer to a deletion silently brought the row back,
the message named no record, and the next automatic round cleared it
before the user saw it.

Every answer the server did not apply now sets the message
"<collection> <record>: <text>", cut to 200 characters, with a text
of its own where the server sends none, and a stale answer to a
deletion says that the server kept a newer version of that record
while that version is applied. The message stays across the automatic
rounds until the user syncs by hand or another rejection replaces it;
the rounds the app starts on its own now run separately from the
manual sync for that.
2026-12-01 19:12:27 +01:00
aksdb 4359bedde4 🐛 Reload the page when a new service worker takes over
The worker is registered with autoUpdate and claims its clients, so
after a deploy the new worker took the page over while the old page
kept running with its lazy route chunks purged from the cache:
navigating then failed until the user reloaded by hand.

Once a worker controls the page, a controllerchange now reloads it,
one time per load. The check that a controller already exists keeps
the first visit from reloading, where the brand new worker claims the
page right after registering. The block runs in production only, so
tests never touch it.
2026-12-01 19:10:49 +01:00
aksdb 49538e8ae3 🐛 Stop stale running entries while offline
autoStopStale only ran through beforeSync, and syncNow skipped that
while offline: an app left open overnight offline kept yesterday's
entry running, and startEntry then threw "an entry is already running"
for an entry the Today view does not show.

A round now runs its preparation whatever the online state and only
leaves out the requests, so the minute tick stops stale entries
offline too, and startEntry stops them itself before it checks for a
running entry.
2026-12-01 19:09:48 +01:00
aksdb cb9e250f6a ♻️ Coalesce realtime changes and stay quiet offline
Every PocketBase event ran its own full sync of the collection, with
rejections nobody caught and around beforeSync and onSyncRound. A
remote change now starts a round through syncNow(), at most one per
300 ms window; one that lands while a round runs gets its own round
after it. The debounced local push is unchanged.

A failed pull or push no longer sets the sync error while the browser
is offline, since the layout shows "Offline" then. A failed round
reports the distinct errors of its syncs on one line instead of the
heading syncAll() puts above them.
2026-12-01 19:08:57 +01:00
aksdb d5b21c431e 🐛 Surface storage errors and ignore a late gate resolution
When IndexedDB rejected or blocked the open, resolveGate() rejected,
the gate stayed null and the app showed "Loading…" forever. A failed
open now cleans up and rejects with a reason, a blocked open gives up
after eight seconds, and resolveGate() turns that into an error gate:
the layout shows the message with a Retry button instead of the loading
line, and the sign-in itself is kept.

logout() clears the auth store and the session before it closes and
wipes the local data, and swallows a failing wipe, so the user is never
left half logged out. activate() sets the session only after the
database is open and only if the auth store is still valid with the
same token, so a resolution that finishes after a logout or another
sign-in no longer reopens the app for the wrong user. openDb() hands
out an in-flight open only to the same user; another user's open waits
for it and then replaces it.
2026-12-01 19:07:11 +01:00
aksdb d387854329 🐛 Merge entry edits after pending sync data has landed
update() read the record before save() waited for the sync to apply
server state, and the record finally written was that stale read plus
the patch with a fresh client_updated_at: an edit silently reverted
what another device had changed in between, and the server took it as
the newer version.

update() and remove() now patch the record after the wait, so every
field they do not touch keeps the value the pull just applied. The
test holds an update while a round applies a remote change to the same
record and fails on the old code with the reverted field.
2026-12-01 19:04:50 +01:00
aksdb d750b8c3c9 🐛 Recover the app when the session expires
A 401 mid-session made the PocketBase SDK drop the auth store, while
session.userId and the gate of the layout stayed set: the user remained
in the app, every round failed, /login was bounced back and a token-less
pull was even taken for a successful round.

The sync layer now ends the session through an onSessionExpired hook
when a round fails with 401 or finds the auth store cleared, and reports
no round as synced without a valid auth store. The session module tries
one token refresh before it clears the session, and the layout resolves
the gate again whenever the auth store is no longer valid, so the user
lands on the login page and the next sign-in brings the data back.
2026-12-01 19:04:06 +01:00
aksdb e630f9fd66 ♻️ Drop legacy browser storage on sign-in
Browsers of users of the Dexie based version still hold its token in
the auth_token key of localStorage and its database named wotra, next
to the per user databases of this version. resolveGate() now removes
both whenever it lets the user into the app, the first open included.
The removal resolves on success, error and block, like wipeLocal, and
never throws, so a browser that denies storage cannot keep the user
out.
2026-12-01 18:07:31 +01:00
aksdb 1c899b2743 🗑️ Remove the Dexie data layer and its dependencies
The API client and the two stores on Dexie have been dead since the
collections took over every read and write, and nothing imports them
any more. Dexie and workbox-window go with them; the service worker is
registered by hand and needs no client library.

The static adapter wipes build/ on every build, which dropped the
tracked placeholder that keeps the directory in the repository. A
postbuild step writes it back.
2026-12-01 18:06:39 +01:00
aksdb bddabbf93d 🐛 Surface changes rejected by the server
The server now answers an invalid change per item instead of failing
the whole batch, and the client dropped such a change silently: the
round went through and nothing told the user that the edit never
reached the server. A rejected change now sets the sync status to
"<collection>: <error>", cut to 200 characters, so the sync button
shows its warning state. The change is not retried, as before.

The message survives the collections that still succeed in the same
round, since each of them used to clear the error. The next round
without a rejection clears it.
2026-12-01 17:59:29 +01:00
aksdb 6ce66f81c7 🐛 Stop the sync from undoing writes made during a round
The sync manager learns of a local write only from the change record
it creates after the write finished, and it applies the pulled server
state without regard to newer local changes. A write made while a
round was pulling or pushing was therefore replaced by the older
server version, or removed as unknown to the snapshot, until the next
round pushed it again: a deleted adjustment came back, an edit
reverted, a new row vanished for a moment.

Each pull now waits for the writes in flight on the collection and on
the change records, keeps the server version of items whose change
record the round did not push, and local writes wait while the sync
applies server state to their collection; network requests stay
exempt. The stress test writes to four collections for 300 rounds,
with the sync idle and with a push held in flight, and asserts that
reactive and plain reads always show the last write. Without the fix
it fails in the first round.
2026-12-01 17:56:43 +01:00
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