Skip to content

Planner: 64 riding days, sent to the bike computer as two parts #3713

Closed

Description

@timohueser

Status: done

Part of #3652 (step 5). Read the epic's section "The bike computer" first (What goes, A day route, A trip object, Progress, On the device). Where this issue and the epic differ, this issue holds.

Depends on:

Starts when all three are merged.

Build order: #3713 and #3714 can be built at the same time after #3712 merges. When #3713 is ready, it merges first, so that #3714 makes its pictures on the 64-day plan. Both change PlannerApp.svelte (other hunks), docs/design/web-planner.md (other paragraphs) and the same paragraph of docs/content/software/trips.md ("Days in the planner"): the second of the two to merge joins that paragraph by hand and runs tools/obc prose --check again. Checked against develop 1bbced3 and the head of #3712 (c32c9e8); line numbers are from them.

TL;DR

Goal: The planner allows 64 riding days. A trip of 33 to 64 days goes to the bike computer as two trips of at most 32 days. A day route that the rider deleted on the bike computer goes again only when it changes.
Problem: The planner stops at 32 days (maxRidingDays, builder/web/src/lib/planner/editor.ts:12), the device reads at most 32 days of a trip object, and the sync of #3711 writes one trip object for each plan. That sync also makes again every day route that the rider deleted on the bike computer, at the next send: a rider who deletes ridden days to make room gets them back, and with a full menu his change cannot go.
Decision: Days 1 to 32 are part 1, days 33 to 64 part 2. Each part is a trip object with its own key. The sync sends the parts in order, each only when the menu has room. The entry stores the CRC of the file of each day as sent. A day whose route is gone from the card, and whose new file has that CRC, is not made again and needs no room; its trip object keeps its old id. A changed day goes again, so only what changed takes room. At 64 days the + looks off and says why.
Rejected:

  • A done marker of the complete parts: a new name or any other change made all deleted days again and needed their room.
  • Take the id of a deleted day from the trip object on the card: the rider can delete the trip with its routes.
    Systems: route-planning, web-planner, library
    Contracts: specs/planner-plan.md (days 1 to 64); specs/library-backup.md (the state sent)
    Size: M (3 systems, a compatible contract change, a stored browser state, about 550 lines)

Facts

  • SentRoute (builder/web/src/lib/library/records.ts:147-153) is { key, card, days: string[], trip, tripKey }. allOnCard (:157) needs a key and no empty slot; isSent is at :241-243. deviceState (builder/web/src/pages/routes/state.ts:17-22) gives "On the device" for allOnCard with the sentKey of now (library/summary.ts:26, a hash of the name and the plan). "Send to device" is off then (pages/Route.svelte:145, pages/routes/SelectedCard.svelte:67). pages/Device.svelte:105 counts the day ids of these entries for "and 3 more" (:84).
  • sendRoute (builder/web/src/lib/device-sync/sync.ts:263-345): entryOn (:212) reads a stored object that the card does not hold, or that a foreign trip lists, as an empty slot, and takes a trip object by one current key or the stored key (:215, :222-225). Then: copies of lost puts (:286-290); a one-day plan removes its trip first (:293); the surplus days go first only when the new days need their room (:294-295); the room check (:297-306); put (:310-330) adds a created object to card.count (:323); the stored key, the trip object, the surplus days (:332-341). At the end of a sync (:134-146), a gone object empties its slot and the key.
  • tripKey (device-sync/trip.ts:36) hashes "‹plan id›|‹point 1 id›|‹point 2 id›|1"; startDay is at :44. dayRoutes names a day "Day ‹i + 1›" (device-sync/route.ts:46).
  • A trip object may list a route that is gone: "Dangling refs are tolerated on read", and an upload "that references unknown route ids is stored as sent" (specs/ble-interface.md §7.7). The device skips such a day, and the later days keep their numbers (firmware/obc-app/src/trip.rs:11-13, :103-118, :278-285). The card never gives an object id twice (firmware/obc-storage/src/flat/store.rs:1403-1407), so an old id in a trip object never names another object.
  • The device keeps trip progress by key. A re-upload with the same key and more days keeps it (obc-app/src/trip.rs:296-310), so a day that comes back shows as done when the rider finished it.
  • The phone reads no .obcplan file. PlannerPlan.maxDays (companion-ios/Packages/OBCKit/Sources/OBCDomain/PlannerPlan.swift:235) limits only the plans that the phone makes (:164, :241).
  • docs/content/software/trips.md is at its word budget: 2,499 of 2,500 words on the branch of Planner: a strip of all days and a week in focus for trips of 15 days or more #3712 (tools/obc prose --check). Its line 58 ("A trip has at most 32 days") is about the phone's trips from files and stays.

Plan

  1. 64 days. maxRidingDays = 64 (editor.ts:12); its comment says: two trip objects of 32 days. specs/planner-plan.md:34: days is an integer from 1 to 64.

  2. The limit. DayCount.svelte:38: at 64 the + has aria-disabled="true" in place of disabled, so it keeps the focus, and it looks off (no hover). A press calls a new prop onLimit. TripRow.svelte:49 passes it on. PlannerApp.svelte sets message to "64 riding days is the most a trip can have".

  3. The line about the device. From 33 riding days, one line in .trip-settings under TripRow (PlannerApp.svelte:1242): "Goes to the bike computer in 2 parts" (13 px, --ink-soft).

  4. Parts (device-sync/trip.ts, route.ts). PART_DAYS = 32 (MAX_TRIP_DAYS of obc-route).

    • tripKey(id, trip, part) hashes "‹plan id›|‹point 1 id›|‹point 2 id›|‹part›". Part 1 keeps the key of Device sync: send a trip of up to 32 days as day routes and a trip object #3711.
    • Name of a part: the plan name with " 1/2" or " 2/2" at the end, inside 48 bytes (cut the plan name, never the suffix). One part keeps the plan name. The trip object and its put use this name.
    • startDay(trip, part): 0 with no start date. Else the start date plus 32 × (part − 1) plus the rest days after nights 1 to 32 × (part − 1) (restAfter).
    • dayRoutes names day i "Day ‹(i mod 32) + 1›", the number that the device shows.
  5. Stored state (library/records.ts). SentRoute = { key: string; card: string; days: string[]; crcs: number[]; gone: string[]; trips: string[]; tripKeys: string[] }:

    • days[i]: the id of the route of day i as last put, '' before its first put. A route that is gone from the card keeps its id here.
    • crcs[i]: the CRC-32 of the file of day i as last put or found on the card. The sync writes it together with days[i].
    • gone: the ids of days that the last listing of the card did not hold.
    • trips[p], tripKeys[p]: the trip object and the stored key of part p + 1, '' for none.
    • key: the sentKey of the plan when its last send finished, else ''.

    allOnCard: the entry names this card and has a key. isSent checks the new form. A value of the one-part form fails it and reads as empty (no migration, as with Device sync: send a trip of up to 32 days as day routes and a trip object #3711). Device.svelte:105 counts only the days that are not in gone. The comment of deviceState follows.

  6. One send of a plan (sendRoute). It keeps the order of Device sync: send a trip of up to 32 days as day routes and a trip object #3711:

    • entryOn(card, id, current): current holds the keys of both parts, always, so a lost entry of a plan that dropped part 2 still reads "2/2" as the planner's. It keeps a stored day id that the card does not hold. A day that a foreign trip lists empties its slot, as today. For each part with no trip object, it takes the trip object with that part's current or stored key.
    • Each day is one of four cases. On the card with the new file: skip. On the card with another file: replace in place. Left out: gone from the card, and its new file has the CRC in crcs: no put, no room, and its trip object lists its old id. Else: made with a new id (first the copy of a lost put, as today).
    • First the trip objects of the parts that the plan no longer has go (for a one-day plan all of them, then its days 2 and later, as today).
    • Then part 1, then part 2. A part whose days are all left out is skipped: the sync makes, changes and removes nothing of it. Else Device sync: send a trip of up to 32 days as day routes and a trip object #3711's steps for the part: when its days to make need more room than the menu has, the surplus days go first, the last first; the room check against MENU.routes minus card.count.routes (the count already holds the routes that part 1 made); a part with no trip object on the card needs a trip slot; the days; the stored key of the part; its trip object.
    • A part that does not fit stops the plan, and the plan stays in waiting. A part that went stays on the device. Part 1 has the sentence of Device sync: send a trip of up to 32 days as day routes and a trip object #3711. Part 2: "Part 2 of “‹name›” waits: the bike computer has room for ‹n› more routes, it needs ‹m›. Remove ridden or unused routes on the bike computer." The trip limit sentence has the same start.
    • After all parts, the surplus days go, the last first. Then key = sentKey(plan), and the plan leaves waiting. So after the sync no trip object names a day that the sync removed.
    • A removal of the plan (leaving) removes all its trip objects, then its days, the last first. A gone object counts as removed.
  7. The end of a sync (syncDevice). For each entry on this card: gone = the ids of days that the listing does not hold. A gone day does not change key. A trip object that is gone while a day of its part is on the card empties its slot and key, so the next send makes it again. An entry with no object left on the card goes.

  8. What the planner shows. "On the device" means: the bike computer holds the plan as it is now, except the routes that the rider deleted there. A plan whose ridden days the rider deleted still shows "On the device", and "Send to device" is off, because a send puts nothing. After a change: "Changed since it was sent", and a send puts only what changed. When nothing of the plan is left on the bike computer (the rider deleted its trips with their routes), the entry goes, the plan is not on the device, and a send puts all of it again.

  9. The walk. A 40-day plan "Alps" with all nights kept. The card holds 30 routes of the rider and a trip of the phone.

    • Sync 1: part 1 needs 32 routes and a trip, room 34: it goes (62 routes). Part 2 needs 8, room 2: "Part 2 of “Alps” waits: the bike computer has room for 2 more routes, it needs 8. Remove ridden or unused routes on the bike computer." The plan shows "Waits for the device".
    • The rider rides days 1 to 20 and deletes those 20 day routes on the bike computer (42 routes).
    • Sync 2: days 1 to 20 are left out. Days 21 to 32 and "Alps 1/2" did not change. Part 2 needs 8, room 22: it goes (50 routes). The plan shows "On the device". The 30 routes of the rider and the trip of the phone stay, all in the menu.
    • A stop of day 35 changes: day 35 ("Day 3" of part 2) is replaced in place. Nothing else goes, and it needs no room.
    • A stop of day 5 changes: day 5 is made again with a new id (51 routes), and "Alps 1/2" is replaced in place with the new id of day 5 and the old ids of the other deleted days. So a deleted day that changed comes back. The device keeps the progress, so day 5 shows as done.
    • A new name, "Alps north": the day files hold no plan name and do not change. The two trip objects are replaced in place as "Alps north 1/2" and "Alps north 2/2". No room is needed.
    • No change: "Send to device" is off, and a sync puts and removes nothing.
    • The plan goes to a second bike computer: the entry names the first card, so it counts as no entry there, and all 40 days go.
  10. Tests.

    • builder/web/src/lib/device-sync/sync.test.ts (fake device; a card of 256 objects where it holds more than 64 routes):
      • A 40-day plan on an empty card: "‹name› 1/2" with 32 days, "‹name› 2/2" with 8 days, day 33 is "Day 1 ‹place›", two different keys, and the start date of part 2 counts a rest day before day 33.
      • The walk of step 9 with 30 seeded routes and seedPhoneTrip: for each case the puts (vi.spyOn(rig.client, 'put')), the sentence, allOnCard, and expectUntouched for the routes of the rider and the phone trip after each sync.
      • 40 → 30 days: "2/2" goes first, "1/2" is replaced in place with 30 days, then days 40 to 31 go, the last first; no trip object names a removed day.
      • 30 → 40 days: "Alps" is replaced in place with the same id and key, as "Alps 1/2" with 32 days; "Alps 2/2" is new.
      • Room for 39 routes: part 1 goes, part 2 waits with its sentence.
      • After 40 → 30 days with the entry lost: the send reads "2/2" as the planner's by the key of part 2 and removes it.
      • Change :362 (a deleted day keeps key; another bike type changes every file, so day 4 is made again) and :459 (change the file of day 4, so that it is made again).
    • trip.test.ts: the key of part 2 differs from part 1, part 1 has the key of Device sync: send a trip of up to 32 days as day routes and a trip object #3711, and a long plan name keeps its suffix inside 48 bytes.
    • DayCount.svelte.test.ts: at 64 the + keeps the focus, and a press calls onLimit and adds no day.
    • pages/routes/state.test.ts: an entry with a key and a gone day is on the device; an entry with no key is not.

Files

  • builder/web/src/lib/planner/editor.ts: change: maxRidingDays and its comment.
  • specs/planner-plan.md: change: days 1 to 64.
  • builder/web/src/components/planner/DayCount.svelte, DayCount.svelte.test.ts: change: the limit, onLimit.
  • builder/web/src/components/planner/TripRow.svelte: change: passes onLimit.
  • builder/web/src/components/planner/PlannerApp.svelte: change: the limit sentence, the line about the device.
  • builder/web/src/lib/device-sync/trip.ts, trip.test.ts: change: PART_DAYS, the key, name and start date of a part.
  • builder/web/src/lib/device-sync/route.ts: change: the day number in its part.
  • builder/web/src/lib/device-sync/sync.ts, sync.test.ts: change: parts, left-out days, the end of a sync; the one-part seeds :177, :239, :252, :372, :406.
  • builder/web/src/lib/library/records.ts: change: SentRoute, isSent, allOnCard.
  • builder/web/src/pages/Device.svelte: change: the count without gone.
  • builder/web/src/pages/routes/state.ts, state.test.ts: change: the comment of deviceState; the seed :8 and the cases.
  • builder/web/test-support/device-sync/fake-device.ts: change: the seed :92.
  • builder/web/src/lib/library/store.test.ts, builder/web/tests/browser/planner/routes.test.js, route-rows.test.js: change: the seeds store.test.ts:86, routes.test.js:35, route-rows.test.js:78 and :310.
  • specs/library-backup.md: change: the row sent (:103).
  • docs/design/web-planner.md: change: "On the device" (:83), parts and left-out days in the send (:180-185), the end of a sync (:186), the row Routes (:211).
  • docs/content/software/trips.md: change, in its own docs: commit: one sentence under "Days in the planner" (64 days; above 32 days two trips "‹name› 1/2" and "‹name› 2/2"). The page is at its budget: cut as many words as the sentence adds, in other places of the page.

Done when

  • In builder/web: npx vitest run src/lib/device-sync src/lib/library src/pages/routes/state.test.ts src/components/planner/DayCount.svelte.test.ts src/components/planner/PlannerApp.svelte.test.ts src/lib/planner/editor.test.ts src/lib/planner/trip-validation.test.ts src/lib/planner/gpx-import.test.ts src/lib/planner/search/actions.test.ts and npm run check pass. In builder/web/tests/browser: npm run test:planner -- planner/routes.test.js planner/route-rows.test.js planner/device.test.js passes. After the docs: commit: python3 docs/build_docs.py --check-links passes, and tools/obc prose --check passes on the branch merged with origin/develop.

  • The speed gate of the 64-day plan with town answers (the epic gives it to this step). Plan: the 64-day cycling test plan (bike-64.json, 3,909 km). Measure: speed.mjs of Planner: a strip of all days and a week in focus for trips of 15 days or more #3712 (/media/timo/OSM1/tmp/explore-3506/build-3712/tools/speed.mjs, the copy of build-3709/tools/speed.mjs that Planner: a strip of all days and a week in focus for trips of 15 days or more #3712 extended): from the navigation start to the later of the first map idle with the line (obc:idle) and the answers of the week's nights (obc:nights). Setup that works: copy build-3712/tools to build-3713/tools and point W and the paths at the worktree of this issue. run.sh with SEARCH=1 starts the route service of build-3709 with 2 workers, the proxy, the dev page, and the town search of the worktree (planner/search/server.mjs) on the search files in build-3712/local-search (read only). exp.py after adds the two marks as throwaway edits; drop its maxRidingDays edit, which this change makes. proof.sh shows the call. Do not use obc data serve local: it starts two route services and two searches, and the 3 GB cap killed it. Conditions: dev page at 1920 × 1080, headless Chromium on the GTX 1660, one 3 GB cap at nice 19 (tools/heavy.sh of the explore folder), median of 3 loads. The pull request says whether the terrain run was active, gives the load average and the 3 loads, and shows that each load got the answers of the week's nights. Gate: the measured median plus 15 %. The pull request writes the gate into the Done when of Plan trips of one to two months: the planner screen and the bike computer limits #3652.

  • The owner's check on his bike computer, with the planner of the pull request's head served on the build PC (build-3713/serve.sh, made as build-3712/serve.sh). The device checks of Route files: keep a point at each 3 m height change (web planner and phone) #3710 and Device sync: send a trip of up to 32 days as day routes and a trip object #3711 can go in the same session. The implementer makes build-3713/plans/days-40-kept.obcplan, a 40-day cycling plan of the served region with every night kept, and names it in the pull request.

    1. Before this step, the bike computer holds at most 24 routes of his own, so that the 40 day routes fit in its menu of 64. With more, part 2 waits as designed: the Device page says "Part 2 of “‹name›” waits: …", and he removes routes on the bike computer and syncs again. He opens the file in the planner, saves it and sends it. Pass: the trip menu shows "‹name› 1/2" with 32 days and "‹name› 2/2" with 8 days; day 1 of "2/2" is "Day 1 ‹place›"; "next day" works in each (he opens "2/2" himself); all his own routes are still in the route menu.
    2. He rides (or marks done) day 1, changes a stop of day 20 in the planner and sends again. Pass: day 1 still shows done, and day 20 has the new stop.
    3. He deletes days 2 and 3 on the bike computer, renames the plan and sends again. Pass: both trips have the new name, days 2 and 3 do not come back, and the planner shows "On the device".
    4. He sets 64 days in the planner. Pass: the + looks off, and a press says "64 riding days is the most a trip can have".

    Fail when a trip shows more than 32 days, a part is missing, or one of his own routes left the menu.

Limits

  • A day route that the rider deleted on the bike computer comes back only when its file changes, or when nothing of the plan is left there. To have deleted days back, the rider deletes the trips of the plan on the bike computer and sends the plan again.
  • Without kept nights, a change early in the trip moves the later day ends, so those days change and go again. A new routing package can change the file of every day; a send after it makes the deleted days again, and they need their room.
  • The entry knows one card: a send to another bike computer and back makes the deleted days again on the first one.

Public docs: trips.md (own docs: commit).

Activity

  1. timohueser commented on Nov 20, 2026

    @timohueser
    OwnerAuthor

    The owner decided: #3739 merges now on the review and the simulated-device proof ("Yes, merge it"); he tests on the real bike computer later, in one session with the open checks of #3710 and #3711. The steps are in the owner brief of this pull request.


    Generated by Claude Code

  2. added a commit that references this issue on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions