fix(tours): keep unknown actual tracks unknown and name every track a link replaces (ACT-01)

A tour detail that cannot be read (offline without a cached copy, or a server
error) no longer shows "No actual track yet" while the trip list names tracks
of the tour; the section says they could not be loaded and offers no link over
them.

The day a track was recorded on is the viewer's calendar day of its first time
stamp, not the UTC one, in the tour detail, the link dialog and the GPX
preview alike, through one helper.

Taking a tour off a day keeps its actual track without a day, so "no day" can
hold several. A change now starts on the track it was asked for, and the link
dialog names every track it replaces, as the server clears all of them. The
migration, repository, service and MCP texts say so.

The refusal for linking a tour to itself or a track with tracks of its own now
reads "This track cannot be linked to this tour", which is true of both, and
the offline helper of the tour cache sits above the doc of replaceTripTours
again.
This commit is contained in:
Maurice
2026-10-20 12:50:38 +02:00
parent d0cc6fc2f4
commit a8be1c5b45
46 changed files with 243 additions and 100 deletions
@@ -7,11 +7,12 @@ import { Migration } from '@mikro-orm/migrations';
* name and provenance, and the planned tour keeps its line, measures and times
* untouched. `assignment_id` is the execution, the day assignment of the tour
* the recording belongs to; NULL for a tour done without a day. One recording
* documents one tour (`track_place_id UNIQUE`) and an execution has one
* recording (the partial unique index); an execution without a day is held to
* one by the service, which also refuses a tour as its own recording. Taking
* the tour off a day keeps the recording and only forgets the day; deleting
* either tour takes the assignment with it.
* documents one tour (`track_place_id UNIQUE`) and a day's execution has one
* recording (the partial unique index). Without a day there can be several:
* taking the tour off a day keeps its recording and only forgets the day, so
* it joins any that had none. Linking a recording to "no day" replaces all of
* them, and the app names each before it does. Deleting either tour takes the
* assignment with it.
* `assigned_by` names who assigned it, kept as unknown when that account goes.
*
* Not to be confused with `tours.recorded_route_geometry`: that is the line an
@@ -112,7 +112,8 @@ export class TourActivitiesRepository extends TrekRepository<TourActivities> {
/**
* Clears the way for a new assignment of `track_place_id` to this execution
* of the tour: the recording the execution had, and the execution this
* of the tour: the recordings the execution had (a day has one; "no day" can
* have several once the days they were on are gone), and the execution this
* recording had on the same tour. Inside the caller's transaction, before
* {@link insertActivity}.
*/
+1 -1
View File
@@ -56,7 +56,7 @@ export class TourActivitiesMcp {
@Tool({
name: 'assign_tour_track',
description:
'Assign a recorded track to a saved tour, as the way the tour was actually done, once the user has chosen the track and confirmed it. The track is another tour of the same trip that came in through the GPX import or from wanderer and was not planned over (list_tours: origin gpx or wanderer, has_waypoints false); it keeps its own name and source. assignment_id is the execution, one of the day assignments of the tour (find_tours_for_day and get_tour_plan show its days), or null for none; an execution that already has a track gets this one instead, and the track moves there if it was on another execution of the same tour. A track documents one tour only. The planned line, measures and times of the tour stay exactly as they are; what the recording measures (distance, ascent, descent, and the time from its first to its last point, only where the file carried times) is answered under activities and read again with get_tour_plan. Never assign a track the user did not pick.',
'Assign a recorded track to a saved tour, as the way the tour was actually done, once the user has chosen the track and confirmed it. The track is another tour of the same trip that came in through the GPX import or from wanderer and was not planned over (list_tours: origin gpx or wanderer, has_waypoints false); it keeps its own name and source. assignment_id is the execution, one of the day assignments of the tour (find_tours_for_day and get_tour_plan show its days), or null for none; an execution that already has a track gets this one instead (null replaces every track without a day, of which there can be several once their days are gone), and the track moves there if it was on another execution of the same tour. A track documents one tour only. The planned line, measures and times of the tour stay exactly as they are; what the recording measures (distance, ascent, descent, and the time from its first to its last point, only where the file carried times) is answered under activities and read again with get_tour_plan. Never assign a track the user did not pick.',
inputSchema: {
tripId: idSchema,
placeId: idSchema.describe('The place id of the planned tour, as list_tours gives it'),
@@ -39,8 +39,9 @@ export class TourActivitiesService {
/**
* The recording becomes the track this execution of the tour was done with,
* in place of the one it had; a recording already on another execution of
* the same tour moves here. Answers the tour as the detail reads it.
* in place of the ones it had (one for a day; "no day" can hold several once
* the days they were on are gone); a recording already on another execution
* of the same tour moves here. Answers the tour as the detail reads it.
*/
async assign(
tripId: string,