Skip to content

fix(trip-overview): keep the header and rows right across real-time updates - #456

Open
nighthawk wants to merge 7 commits into
mainfrom
fix/trip-overview-realtime-updates
Open

nighthawk wants to merge 7 commits into
mainfrom
fix/trip-overview-realtime-updates

Conversation

@nighthawk

@nighthawk nighthawk commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

This fixes a number of glitches for the routing results and trip overview cards, encountered during testing:

The header shows "walk 1 > bus 1 > walk 1" (and doesn't update with real-time data). Regression fix for an issue caused by #446, TKUITripSegmentsView re-applies its configuration whenever its size changes, e.g., on rotation, but held on to the TKSegments it was configured with. Once their references are deleted, those segments quietly return defaults: no service colour or fixed departure time, so the bus counts as non-transit, and both times fall back to "now", so every leg shows "1" minute. The view now captures what it shows when configuring. Separately, the overview's title was only configured when creating the card. It now follows the same updates as the rest of the card, so its times and segments stay current, including real-time times.

The header drops details it has room for. The title's segments view gets its width from its content, but it stopped measuring at the first segment that overflowed its initial (nib) width, and it never asked for more when configured again. So the header hid walking distances it had room for, and once real-time made the departure pill wider, it fell back to icons only. It now measures everything, rounded up to whole points as layout snaps to pixels, and invalidates its intrinsic size when that changes.

Rows jump during real-time update. The trip overview's rows were identified by their segment's template hash code. With new templates every row got a new identity, so the table animated it as "delete all rows, insert new ones", with collapsed and overlapping rows for a moment. Rows are now identified by the segment's position. TKSegment.index is now captured when building the segment, like templateHashCode: reading it live from the deleted reference returns 0 for every old row, which makes the diff throw duplicateItem.

The map's departure times don't update with real-time data. The overview only refreshed its map when showing a different trip, or once the services' content had been fetched, so the map's semaphores kept the times from then while the list moved on. It now also refreshes with every real-time update, which also replaces annotations whose segments an update replaced. The view model takes the real-time stream as an optional parameter, so tests can feed it updates.

The results list can show trips out of order. The results only rebuilt their sections, which sort a group's trips by time, when the trip groups changed or when something posted .TKUIUpdatedRealTimeData. Real-time updates change trips in place and post nothing, so rows showed the new times in the old order, e.g., a delayed 14:00 departure listed above a 13:55 one. The results now also rebuild when the request's trips change, whichever update changed them.

TKUITripSegmentsViewSizingTest covers the sizing, TKUIRoutingResultsRealTimeTest the results' rebuilding. TKUITripRealTimeUpdateTest parses a trip, updates it from the same response with every hash code shifted, and checks both. Each test fails on main for the reported reason.

Manual testing

  1. Open the overview of a trip with real-time public transport, e.g., walk > bus > walk, and keep it open until a real-time update arrives (every 10s, or background the app for a few minutes and come back).
  2. The header shows the route badge, departure time and walking distances where they fit, also once the departure turns real-time.
  3. Rotate to landscape and back: the header keeps its route badge, departure time and walking minutes.
  4. The header's times follow real-time changes, matching the rows below.
  5. When an update changes the rows' wording (e.g., "Walk for 9 min." → "Walk" / "9 min. · 600 m"), the rows change in place, without sliding or overlapping.
  6. Tapping a row after an update still opens the right segment.
  7. The departure time on the map's semaphore follows real-time changes, matching the list. Watch out for the route lines or pins flashing when an update arrives.
  8. In the results list, a trip whose departure moves with real-time data moves to its place among the group's other trips.

🤖 Generated with Claude Code

nighthawk and others added 3 commits December 4, 2026 12:51
… after an update

`TKUITripSegmentsView` re-applies its configuration when its size changes, e.g., on rotation, but held on to the segments themselves. A real-time update with new template hash codes deletes those segments' references, after which they return defaults, so every segment showed as non-transit with "1" minute. It now captures what it shows when configuring.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The trip overview's title was only configured when creating the card, so it kept the initial times, and segments that a real-time update could replace. It now follows the same updates as the rest of the card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ges templates

The trip overview's rows were identified by their segment's template hash code. A real-time update with new templates hence gave every row a new identity, which the table animated as deleting all rows and inserting new ones. Rows are now identified by their segment's position, which `TKSegment` now captures, as an update can delete the reference it used to read it from.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nighthawk

nighthawk commented Dec 4, 2026 •

Copy link
Copy Markdown
Member Author

Written by Claude on behalf of Adrian.

Suggested squash-merge message:

fix(trip-overview): keep the header and rows right across real-time updates

- Keep what `TKUITripSegmentsView` shows when it resizes, rather than re-reading segments a real-time update may have deleted, which showed every leg as "1" minute
- Make `TKUITripSegmentsView` ask for the width of everything, and again when its content changes, so the trip overview's title no longer drops details, down to only icons
- Update the trip overview's title with real-time data
- Give digits in `TKUITripSegmentsView`'s routes and times the same width, so trips with similar legs show the same details
- Refresh the trip overview's map with real-time updates, so its departure times match the list
- Rebuild the results when their trips change, so real-time updates keep a group's trips in time order
- Identify the trip overview's rows by segment position, so an update with new templates reloads them in place instead of deleting and re-inserting them
- Capture `TKSegment.index` when building the segment, like `templateHashCode`

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-04T01:55:30.420899Z ecd4a93 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

nighthawk and others added 3 commits December 4, 2026 13:41
…t changes

Where the segments view gets its width from its content, as in the trip overview's title, it stopped measuring at the first segment that didn't fit its initial size, and didn't ask for more when configured again with wider content, e.g., a real-time departure. It then showed fewer details than fit, down to only icons. It now measures everything, rounded up to whole points, and invalidates its intrinsic size when that changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The trip overview only refreshed its map when showing a different trip or once the services' content was fetched, so departure times on the map stayed as they were then. Real-time updates can also replace the segments that the map's annotations are. The map now refreshes with every real-time update, too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… updates

The results only rebuilt when their trip groups changed, or when something posted `.TKUIUpdatedRealTimeData`, which neither the results' own nor the trip overview's real-time updates do. These change trips in place, so rows showed the new times in the old order. The results now also rebuild when the request's trips change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nighthawk nighthawk self-assigned this Dec 4, 2026
@nighthawk
nighthawk requested a review from fersagui December 4, 2026 03:16
@nighthawk nighthawk added the bug label Dec 4, 2026
Otherwise a narrow "1" can be what lets one trip show its details while the
next one in the list drops them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@fersagui fersagui left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed with AI help and tested on the simulator.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants