Listoca

Lists and tasks

The reference feature, the two homes of a row, and the device states.

Lists, tasks, steps and marks are the app. Every later feature follows their shape: a migration with row level security, a stream, a local table, queries in packages/sync/src/queries, screens on live queries, and tests for who is refused. The plans behind them are in docs/plans/lists/.

The tables

TableHolds
listsname, description, color and icon keys, paused_at (the server's)
list_memberswho is on a list and with which role; the owner too
taskstitle, note, due day, done, an order key; list_id null is the inbox
stepsone line inside a task, with its own checkbox
task_marksone person's star, My Day, My Week and reminder; personal, never shared

The rules every client shares (colors, icons, smart lists, dates, order keys, field lengths) are packages/lists. Postgres repeats the lengths and keys as constraints.

My Day and My Week

Both are marks the person sets by hand, not date rules: Planned already lists tasks by due date. my_day_on holds the day a task is in My Day; my_week_on holds the day it was put in My Week, and the task stays there while that day falls in the current week. The week runs from the week start in the settings (the device's region by default), so the queries take Days ({ today, week }, packages/lists/src/smart.ts) instead of a plain date; useDays() in the app builds it.

The two lists never show the same task. Putting a task in My Week clears its My Day; taking it into My Day keeps my_week_on, and inMyWeek (and myWeekWhere in SQL) leaves out a task in My Day today. So a task taken from the week into today returns to My Week the next day, unless "Carry unfinished tasks to My Day" keeps it in My Day. My Week has no tile of its own. While the smartMyWeek setting is on, Home's My Day tile and the two lists carry a My Day / My Week switch (DayWeekSwitch); the last pick is the dayOrWeek setting, and the tile shows that list. Turning the setting off hides the switch and keeps the marks.

There are 30 list icons. A new icon key goes into packages/lists/src/icons.ts, a migration that replaces lists_icon_check, the glyph map (apps/native/src/components/glyph.tsx) and list.icons in each locale; sync.db.test.ts fails when the server refuses a key the app offers. An app installed before a key existed shows a synced list with that icon as the default icon.

Two homes

Every list, task, step and mark lives in one of two homes on a device:

  • the device home: local_lists, local_tasks, local_steps, local_task_marks, PowerSync local-only tables. Nothing leaves the phone.
  • the synced home: lists, tasks, steps, task_marks, plus list_members.

Both homes always exist. Reads go through the all_* views (packages/sync/src/views.ts), which combine them with a home column; PowerSync's live queries follow a view to the tables under it. Writes go to the row's home: a task has its list's home, an inbox task the writer's. Feature code never names a table: it calls the queries with a Writer ({ home, userId }).

startSyncing moves the device home into the synced home once the server confirms the Sync plan; stopSyncing moves the account's own lists back (sign-out with "Keep a copy", 30 days paused, "Keep on this device only") and clears the rest. Each is one transaction.

Device states

StateAccountSync planOwn lists live inLists shared by othersConnected
devicenothe device homenoneno
memberyesnothe device homesyncedyes
syncedyesactivethe synced homesyncedyes
pausedyesended under 30 daysthe synced home, waitingwaitingno

useSyncState() in the native app derives it from the session, the entitlement the server confirmed, and whether the account owns rows in the synced home. useFollowPlan() moves between them (Sync plan).

Deleting

Every deletion asks first (confirmDelete, apps/native/src/lib/confirm.ts) and names what goes with it. In the device home the children go in the same transaction; in the synced home only the parent's deletion uploads, the server's cascades delete the rest, and reads leave orphans out until sync removes them.

On this page