Mapping a page writes the project's existing todos onto it #78

Manually merged
jfro merged 3 commits from feature/77-seed-on-map into main 2026-11-12 01:01:45 +00:00
Owner

Closes #77

Linking a page to a Vikunja project now brings the project's existing todos onto the page (Jeremy, Nov 11: "1:1 as possible"). Design in docs/todo-sync.md → Polling, "Seeding a newly mapped page".

What happens on a new mapping

  1. Mapping (not a remap to the same project that keeps its rows, D54) leaves the page seeded_at nil and queues its poll.
  2. A poll of an unseeded page doesn't take the app's changes. It queues the page's read (SyncWorker) and waits.
  3. The first read lists the project before creating anything (Todos.Seed.plan/3, pure):
    • a page row whose text matches a task's title (normalized; an open task before a done one; each task once) is that task: nothing is created in the app and no line is written (D67). A tick on either side wins: a row ticked on the page completes the task, and a task done in the app gets a tick on the page.
    • rows that match no task are created, as before.
    • the project's other open tasks become rows pending :add, written by the next poll onto free rows in the app's order. Done tasks aren't seeded (D69).
    • a task added in the app after mapping but before this read (an unwritten :add row) that a row matches is replaced by the row, so it isn't drawn twice.
  4. seeded_at and polled_until (the listing's latest updated) are set, and the poll is queued to write.
  • If the listing fails, nothing is created and the job retries. A provider without changes_since/3 gets an empty seed.
  • More tasks than free rows: the rest wait, and the panel's poll line says page full, N not written.
  • Pages mapped before this were marked seeded by the migration, so nothing new is written onto them.

Sync panel: the first read shows N linked, N seeded. A seeded task whose line isn't written yet shows – for its row and says not on the page yet (it used to show row 1 and written on the tablet).

Tests

  • seed_test.exs (pure): empty page, title match, duplicate titles, open before done, known and blank tasks, unwritten :add replaced.
  • sync_worker_test.exs: real first read (link, create, seed, skip done, polled_until, poll queued, no second seed); ticks on both sides; a failed listing creates nothing; map queues the poll; same-project remap keeps seeded_at; another project re-seeds.
  • poll_worker_test.exs: an unseeded page waits and queues its read; the page-full message.
  • todo_sync_live_test.exs: panel counts and the unwritten row.
  • Proof C114 fails on main and passes here. mix precommit: 1353 tests pass. The live_vikunja suite passes against Vikunja 2.8.0.

Browser check at 5c4e7fa (dev, real local Vikunja 2.8.0)

Page: our template, with handwriting "Home", "Buy milk" and "Call the bank". Project: Buy milk, Water the plants, Book the dentist, Pay rent (all open) and Renew passport (done). The first read ran for real against Vikunja. Buy milk was linked to the existing task, Call the bank was created, three open tasks were queued, and Renew passport was skipped. There's no tablet cloud in dev, so the write was drawn locally with the same PageMarks plan WriteBack uses.

After the first read (390 / desktop):

After the write (390 / desktop):

The page in the viewer after the write (390 / desktop):

Not in this PR

  • Renames in the app aren't written onto the page (Haystack's question to Jeremy is still open).
  • A page with no strokes at all (no .rm yet) can't be seeded until something is written on it. The poll says the page has no strokes yet.
Closes #77 Linking a page to a Vikunja project now brings the project's existing todos onto the page (Jeremy, Nov 11: "1:1 as possible"). Design in `docs/todo-sync.md` → Polling, "Seeding a newly mapped page". ## What happens on a new mapping 1. Mapping (not a remap to the same project that keeps its rows, D54) leaves the page `seeded_at` nil and queues its poll. 2. A poll of an unseeded page doesn't take the app's changes. It queues the page's read (SyncWorker) and waits. 3. The first read lists the project **before creating anything** (`Todos.Seed.plan/3`, pure): - a page row whose text matches a task's title (normalized; an open task before a done one; each task once) **is** that task: nothing is created in the app and no line is written (D67). A tick on either side wins: a row ticked on the page completes the task, and a task done in the app gets a tick on the page. - rows that match no task are created, as before. - the project's other **open** tasks become rows pending `:add`, written by the next poll onto free rows in the app's order. Done tasks aren't seeded (D69). - a task added in the app after mapping but before this read (an unwritten `:add` row) that a row matches is replaced by the row, so it isn't drawn twice. 4. `seeded_at` and `polled_until` (the listing's latest `updated`) are set, and the poll is queued to write. - If the listing fails, nothing is created and the job retries. A provider without `changes_since/3` gets an empty seed. - More tasks than free rows: the rest wait, and the panel's poll line says `page full, N not written`. - Pages mapped before this were marked seeded by the migration, so nothing new is written onto them. Sync panel: the first read shows `N linked, N seeded`. A seeded task whose line isn't written yet shows `–` for its row and says `not on the page yet` (it used to show row 1 and `written on the tablet`). ## Tests - `seed_test.exs` (pure): empty page, title match, duplicate titles, open before done, known and blank tasks, unwritten `:add` replaced. - `sync_worker_test.exs`: real first read (link, create, seed, skip done, `polled_until`, poll queued, no second seed); ticks on both sides; a failed listing creates nothing; map queues the poll; same-project remap keeps `seeded_at`; another project re-seeds. - `poll_worker_test.exs`: an unseeded page waits and queues its read; the page-full message. - `todo_sync_live_test.exs`: panel counts and the unwritten row. - Proof C114 fails on main and passes here. `mix precommit`: 1353 tests pass. The `live_vikunja` suite passes against Vikunja 2.8.0. ## Browser check at 5c4e7fa (dev, real local Vikunja 2.8.0) Page: our template, with handwriting "Home", "Buy milk" and "Call the bank". Project: Buy milk, Water the plants, Book the dentist, Pay rent (all open) and Renew passport (done). The first read ran for real against Vikunja. Buy milk was linked to the existing task, Call the bank was created, three open tasks were queued, and Renew passport was skipped. There's no tablet cloud in dev, so the write was drawn locally with the same `PageMarks` plan WriteBack uses. After the first read (390 / desktop): <img src="https://git.knope.dev/attachments/a7cfdb27-662f-4216-a9a6-51cbed048aa6" width="300"> <img src="https://git.knope.dev/attachments/f1e0f1cb-53ef-48ad-908b-f7959b95ac2d" width="600"> After the write (390 / desktop): <img src="https://git.knope.dev/attachments/95299d34-8e70-46c6-9c3c-6b7893780e0f" width="300"> <img src="https://git.knope.dev/attachments/55593b38-f16d-4add-b648-985396a1d8b6" width="600"> The page in the viewer after the write (390 / desktop): <img src="https://git.knope.dev/attachments/4dd989bb-322a-4bf6-803d-3e92a20d4683" width="300"> <img src="https://git.knope.dev/attachments/ca4a3b35-52de-4ba1-93c7-ce2839c2b874" width="600"> ## Not in this PR - Renames in the app aren't written onto the page (Haystack's question to Jeremy is still open). - A page with no strokes at all (no `.rm` yet) can't be seeded until something is written on it. The poll says `the page has no strokes yet`.
On a new mapping the page's first read lists the project before creating
anything: rows matching a task's title are linked to it (D67), the
project's other open tasks become rows pending :add written onto free rows
in the app's order, done ones are skipped (D69). The poll waits for that
read; a full page says 'page full, N not written'. Pages mapped before
this are taken as seeded.
Nye F21: an open line matching only a done task is created as a new open
task, not linked and ticked. Nye F22: a mapped page with no .rm yet is
seeded by its poll (SyncWorker.seed_blank/2) and its open tasks written
onto Lines.Writer.blank_page/0 (author 1 a stand-in, ours in our layer);
its text is recorded empty and :drawn. If a .rm shows up before the write,
nothing is written and the normal read-first path takes it.
jfro manually merged commit f57e5e654b into main 2026-11-12 01:01:45 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!78
No description provided.