Repository navigation
Description
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:
- Device sync: send a trip of up to 32 days as day routes and a trip object #3711 (day routes and the trip object for one part): merged.
- Planner: a strip of all days and a week in focus for trips of 15 days or more #3712 (the week; without it, a 64-day plan starts 126 night searches at once).
- The search fix (web: thin the search line until it fits the search limit #3736): the town search refuses a line of more than
line_pointspoints (the generated search contractplanner/search/query/contract.json, fromschema.py), andsearchLine(builder/web/src/lib/planner/search/plan.ts) doubles its tolerances until the line fits. This issue only depends on it.
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
donemarker 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(days1 to 64);specs/library-backup.md(the statesent)
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 akeyand no empty slot;isSentis at:241-243.deviceState(builder/web/src/pages/routes/state.ts:17-22) gives "On the device" forallOnCardwith thesentKeyof 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:105counts 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 onecurrentkey 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 tocard.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 thekey.tripKey(device-sync/trip.ts:36) hashes "‹plan id›|‹point 1 id›|‹point 2 id›|1";startDayis at:44.dayRoutesnames 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
.obcplanfile.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.mdis 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
-
64 days.
maxRidingDays= 64 (editor.ts:12); its comment says: two trip objects of 32 days.specs/planner-plan.md:34:daysis an integer from 1 to 64. -
The limit.
DayCount.svelte:38: at 64 the + hasaria-disabled="true"in place ofdisabled, so it keeps the focus, and it looks off (no hover). A press calls a new proponLimit.TripRow.svelte:49passes it on.PlannerApp.sveltesetsmessageto "64 riding days is the most a trip can have". -
The line about the device. From 33 riding days, one line in
.trip-settingsunderTripRow(PlannerApp.svelte:1242): "Goes to the bike computer in 2 parts" (13 px,--ink-soft). -
Parts (
device-sync/trip.ts,route.ts).PART_DAYS= 32 (MAX_TRIP_DAYSofobc-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).dayRoutesnames day i "Day ‹(i mod 32) + 1›", the number that the device shows.
-
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 withdays[i].gone: the ids ofdaysthat 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: thesentKeyof the plan when its last send finished, else''.
allOnCard: the entry names this card and has akey.isSentchecks 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:105counts only the days that are not ingone. The comment ofdeviceStatefollows. -
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):currentholds 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.routesminuscard.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 leaveswaiting. 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.
-
The end of a sync (
syncDevice). For each entry on this card:gone= the ids ofdaysthat the listing does not hold. A gone day does not changekey. A trip object that is gone while a day of its part is on the card empties its slot andkey, so the next send makes it again. An entry with no object left on the card goes. -
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.
-
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.
-
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, andexpectUntouchedfor 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 keepskey; 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 callsonLimitand adds no day.pages/routes/state.test.ts: an entry with akeyand a gone day is on the device; an entry with nokeyis not.
Files
builder/web/src/lib/planner/editor.ts: change:maxRidingDaysand its comment.specs/planner-plan.md: change:days1 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: passesonLimit.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 withoutgone.builder/web/src/pages/routes/state.ts,state.test.ts: change: the comment ofdeviceState; the seed:8and 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 seedsstore.test.ts:86,routes.test.js:35,route-rows.test.js:78and:310.specs/library-backup.md: change: the rowsent(: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 owndocs: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.tsandnpm run checkpass. Inbuilder/web/tests/browser:npm run test:planner -- planner/routes.test.js planner/route-rows.test.js planner/device.test.jspasses. After thedocs:commit:python3 docs/build_docs.py --check-linkspasses, andtools/obc prose --checkpasses on the branch merged withorigin/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.mjsof 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 ofbuild-3709/tools/speed.mjsthat 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: copybuild-3712/toolstobuild-3713/toolsand pointWand the paths at the worktree of this issue.run.shwithSEARCH=1starts 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 inbuild-3712/local-search(read only).exp.py afteradds the two marks as throwaway edits; drop itsmaxRidingDaysedit, which this change makes.proof.shshows the call. Do not useobc 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.shof 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 asbuild-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 makesbuild-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.- 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.
- 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.
- 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".
- 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
timohueser commentedon Nov 20, 2026
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
Merge pull request #3739 from timohueser/claude/longtrips-3713-two-parts