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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
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.