Skip to content

Place a city's marker in its own zone when its name matches one abroad - #17855

Open
anandude wants to merge 2 commits into
omacom:quattrofrom
anandude:fix/elsewhen-geocode-zone
Open

anandude wants to merge 2 commits into
omacom:quattrofrom
anandude:fix/elsewhen-geocode-zone

Conversation

@anandude

@anandude anandude commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #17782.

What was wrong

pickGeocode() fell back to the first geocoder result whenever no result carried the row's zone. The geocoder searches by name, so a name that only survives as small settlements abroad never carries the zone — and the first result was used regardless of where it was.

For Calcutta that is not theoretical. Asia/Calcutta is a legacy alias, Asia/Kolkata is what the geocoder answers with, and a live search for "Calcutta" returns:

# Place Timezone Coordinates
0 Calcutta, Mpumalanga, South Africa Africa/Johannesburg -24.98, 31.23
1 Calcutta, Ohio, US America/New_York 40.67, -80.58

Kolkata, India is not in the top ten at all. So the marker landed in Mpumalanga — the southern-Africa placement in the report.

The reporter suspected other cities were affected, and they are: every legacy zone name the picker still offers (Asia/Calcutta, US/Pacific, Europe/Kiev, …) can never equal a geocoder answer, so each of them was placed at whatever ranked first for its name.

The change

  1. pickGeocode() only accepts a result in the row's own zone. It tries the result's own zone first, then a result whose zone resolves to the row's, so a Pacific/Chuuk answer still matches a Pacific/Truk row. When none matches it returns place: null, and the caller falls back to the zone's zone1970.tab coordinates — the offline path that already existed but was unreachable for these rows.
  2. The row's own zone is what gets matched, exactly and first. Panel.qml used to resolve the row's link and hand that to the picker, so a row whose zone the geocoder does answer with was asked about the zone it links to instead. tzdata links Africa/Kampala to Africa/Nairobi and "Mbale" answers with a Ugandan town first, so a Kampala row took the Kenyan town across the border — 110 km away, and the same swap the exact pass was added to prevent. The caller now passes the row's own zone and the picker resolves both sides inside the linked pass.
  3. zoneAliases() / canonicalZone() read the L <canonical> <alias> lines of tzdata.zi and resolve the legacy name first, so zone1970.tab and the geocoder are both asked about Asia/Kolkata rather than Asia/Calcutta. Without this, refusing the top result would have left legacy-named cities with no marker at all instead of a wrong one.
  4. A link target's coordinates are used only when both zones name the same country. Pacific/Truk links to Pacific/Port_Moresby, but Truk is in Micronesia; the target's Papua New Guinea coordinates would move the marker, the weather and the daylight strip to another country. Such a row shows no marker until a geocode lands, rather than a wrong one.

Aliases are followed through a chain with a seen-set, so an alias pointing at another alias terminates.

Verification

Against the real tzdata.zi and a live geocoder answer for "Mbale" (Uganda Africa/Kampala first, Kenya Africa/Nairobi second):

Row Marker before Marker now
Africa/Kampala 0.08213, 34.72139 (Kenya) 1.08209, 34.17503 (Uganda)
Africa/Nairobi 0.08213, 34.72139 (Kenya) 0.08213, 34.72139 (Kenya)
Asia/Calcutta -24.98, 31.23 (South Africa) 22.5333, 88.3667 (Kolkata)
Pacific/Truk none 7.4167, 151.7833 (Chuuk)
Asia/Tokyo 35.6544, 139.7447 35.6544, 139.7447

Both Kampala and Nairobi rows now keep their own town; the legacy rows (Asia/Calcutta, Pacific/Truk, US/Pacific) resolve through their links, and a name whose top hits are all foreign still yields no marker rather than a wrong one.

This branch previously added cases to test/shell.d/elsewhen-model-test.sh — the refusal, the alias table, alias chains, the legacy-zone-to-coordinates path and the exact-before-linked order. They all passed (268 assertions on the rebased tree), but #19904 deleted the elsewhen unit tests as non-essential, so the file is gone from quattro and this branch now drops them instead of fighting the suite trim. They can be restored wherever the maintainer wants them to live.

Screenshots

Opened Elsewhen on the tracked Calcutta row (Asia/Calcutta) and switched to the globe, once with the installed shell and once with this branch's shell, then restarted the installed shell.

Before / after — the same row, marked Calcutta … tracked, Asia/Calcutta:

Before: Calcutta's marker in southern Africa. After: the marker in India, next to Delhi.

Left: the old fallback takes the top geocoder hit for the name, so the marker lands in Mpumalanga. Right: with the top result refused, the legacy alias resolves to Asia/Kolkata and the marker falls back to the zone's own coordinates in India.

@greptile-apps

greptile-apps Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous wrong-country selection is fixed.

Summary

Elsewhen now rejects geocoder results outside a city's zone and resolves legacy zone names.

  • Elsewhen keeps city coordinates in the row’s own time zone.

Reviews (7) · Last reviewed commit: "Keep the row's own zone for the exact ge..." · Reviewed by Greptile

Comment thread shell/plugins/panels/elsewhen/Panel.qml Resolved
Comment thread test/shell.d/elsewhen-model-test.sh Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 High in Codex read the diff, review discussion, and linked report #17782 and classified this as a bug fix. The required second classifier, DeepSeek V4.1 Flash, returned no classification, so the classification remains unsettled. No worker tests or second code review ran. Verification is waiting on the required second classification; no verification or readiness labels were added.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 High in Codex reviewed the diff, coordinate consumers, linked reports and competing #17789. Opus 5.5 High and muse-wonder via pi (thinking high) reviewed both diffs. Both agreed that this version covers legacy rows such as Australia/Canberra that #17789 misses; that agreement is not guaranteed to be independent.

Opus identified a match-order regression at shell/plugins/panels/elsewhen/Model.js:945, which I checked against the live geocoder response and the existing saved homeCity path. For an unpinned Mbale row on Africa/Nairobi, Open-Meteo returns Mbale, Uganda (Africa/Kampala) before Mbale, Kenya (Africa/Nairobi). Tzdata links Kampala to Nairobi, so this head accepts Uganda first; the base exact-match loop selects Kenya. This moves the marker and weather to the wrong city. Preserve preference for a result matching the row's original zone before considering alias-equivalent results.

No branch changes were pushed. Worker reproduction, the suite and visual checks were not run: the triage execution rule requires protected release branches, and GitHub reports quattro, master and dev unprotected. This is waiting on the maintainer to resolve that verification prerequisite; the match-order finding remains open, and no verification or readiness labels were added.

Comment thread shell/plugins/panels/elsewhen/Model.js Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 High in Codex reviewed the change in 4d911bb5a8e025de0d6dd2b1ebf8c4de7df5276f, its caller and coordinate consumers, and fresh geocoder data. Opus 5.5 High and muse-wonder via pi (thinking high) reviewed the same change and competing #17789. Both agreed with the finding below; independence is not guaranteed.

The new exact-match pass fixes the Nairobi case, but Greptile's Kampala finding is correct. Panel.qml:799-800 resolves row.id before calling pickGeocode(). For an unpinned Mbale|Africa/Kampala row, it passes Africa/Nairobi, and Model.js:947 selects the Kenyan Mbale instead of the Ugandan one. A saved homeCity of Mbale on the Kampala zone reaches this path without coordinates. Preserve the original row ID for the exact match, then compare both zones after alias resolution for the fallback; cover both Kampala and Nairobi rows through that caller.

The older #17789 preserves the original-zone match and remains the fix to continue reviewing. The alias-aware lookup here adds useful coverage—for example, accepting Seattle on US/Pacific when the geocoder answers America/Los_Angeles, rather than falling back to Los Angeles. I handed that improvement to #17789's own review session. Both pull requests remain open for the maintainer's decision.

CI passed on this head. Worker reproduction, mutation, suite and visual checks were not run because the triage execution rule requires protected shipping branches and GitHub reports them unprotected. No branch changes were pushed and no verification or readiness labels were added. This remains waiting on the maintainer.

…inates

A legacy row name is not what the geocoder or zone1970.tab answer with, so
"Calcutta" topped out at a hamlet in Mpumalanga and the marker landed in
southern Africa (omacom#17782). Read tzdata's L lines and accept a result whose
canonical zone is the row's own.

A link can cross a border: Pacific/Truk points at Pacific/Port_Moresby, whose
coordinates are in Papua New Guinea, so the offline fallback keeps the row's
own zone instead of placing Truk in another country.

A link can also be the wrong town: tzdata links Africa/Kampala to
Africa/Nairobi, and "Mbale" answers with the Ugandan town first, so take a
result that names the row's zone before one that only links to it.
@anandude
anandude force-pushed the fix/elsewhen-geocode-zone branch from 4d911bb to 8760f8f Compare November 24, 2026 07:12
@anandude

Copy link
Copy Markdown
Contributor Author

Fixed in 8760f8f9a, and the PR is rebased onto current quattro.

The match-order finding was correct, and the geocoder confirms it: a live search for "Mbale" answers a Ugandan town (Africa/Kampala, 1.08209, 34.17503) before the Kenyan one (Africa/Nairobi, 0.08213, 34.72139), and tzdata links Kampala to Nairobi, so the head took Uganda for a Nairobi row and moved the marker about 110 km north across the border. pickGeocode() now runs two passes: a result whose timezone is the row's zone exactly, then the linked-name pass. The link matching still carries Pacific/Truk rows onto a Pacific/Chuuk answer; the links just no longer outrank an exact name.

I checked the two-pass version against the old and new behaviour directly: the new case fails on the previous head and passes now, and the rest of the elsewhen model cases still pass.

The rebase also had to drop test/shell.d/elsewhen-model-test.sh: #19904 deleted the elsewhen unit tests as non-essential, so the PR is conflicting on that file. The branch now carries only Model.js and Panel.qml. I ran the earlier cases on the rebased tree before dropping them (268 assertions, all green), and the body says where they went — happy to put them back wherever you want them if the suite trim leaves a home for them.

Thanks for the captures and the comparison against #17789. That one still misses Australia/Canberra, which is why this version reads the L lines rather than a name list.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 in Codex (effort not exposed) compared 8760f8f9a8ae81258c722fd485fb0f4e45f2bc11 with the previously reviewed head, traced the production caller and checked fresh Mbale geocoder data. Model.js and Panel.qml are unchanged from 4d911bb5a8e025de0d6dd2b1ebf8c4de7df5276f, so the original-zone finding remains: Panel.qml:799–800 converts Africa/Kampala to Africa/Nairobi before the exact-match pass at Model.js:947. An unpinned Mbale|Africa/Kampala row therefore selects the Kenyan town instead of the Ugandan one. Preserve the original row ID for exact matching, then resolve both IDs for the linked fallback.

Opus 5.5 High and muse-wonder via pi, thinking high reviewed both current diffs and agreed on that defect; independence is not guaranteed. Both recommend continuing with older #17789 because it retains the original-zone match. Its new head also covers the Seattle and Canberra cases raised earlier. The remaining dynamic-alias coverage from this PR is already handed to that item's session; both PRs remain open for the maintainer's decision.

CI passed on this head; this review used source and live data only. Worker reproduction, mutation, tests and visual checks did not run: the triage execution rule requires protected shipping branches, and GitHub reports quattro, master and dev unprotected. No changes were pushed or verification/readiness labels added. This remains waiting on the maintainer.

The caller resolved the row's link before asking, so a row whose zone the
geocoder does answer with was asked about the zone it links to instead. Mbale
answers with a Ugandan town (Africa/Kampala) before the Kenyan one, and tzdata
links Kampala to Nairobi, so a Kampala row was handed the Kenyan town across
the border -- the very swap the exact pass was added to prevent.

Pass the row's own zone, and resolve both sides inside the linked pass. That
keeps Pacific/Truk rows on a Pacific/Chuuk answer and Africa/Kampala rows on
their own town.
@anandude

Copy link
Copy Markdown
Contributor Author

Right on both counts — fixed in 0595a9722.

The caller was resolving the row before asking, so the exact pass compared the geocoder's zone against the link target instead of the row. A live "Mbale" search makes it visible: Uganda Africa/Kampala first (1.08209, 34.17503), Kenya Africa/Nairobi second (0.08213, 34.72139), and with the row resolved to Nairobi first the Kenyan town won the exact pass. A Kampala row's marker, weather and daylight strip were landing 110 km north across the border.

Panel.qml now passes row.id and pickGeocode() resolves both sides only in the linked pass:

Row Marker before Marker now
Africa/Kampala 0.08213, 34.72139 (Kenya) 1.08209, 34.17503 (Uganda)
Africa/Nairobi 0.08213, 34.72139 (Kenya) 0.08213, 34.72139 (Kenya)
Asia/Calcutta -24.98, 31.23 (South Africa) 22.5333, 88.3667 (Kolkata)
Pacific/Truk none 7.4167, 151.7833 (Chuuk)
Asia/Tokyo 35.6544, 139.7447 35.6544, 139.7447

I checked each of those against the real tzdata.zi and the live answer, running the old and new callers side by side: the Kampala row is the only line that changes, and it changes from Kenya to Uganda. Legacy rows still resolve through their links, and a name whose top hits are all foreign still yields no marker rather than a wrong one.

Asia/Canberra still resolves through the L line read from tzdata.zi, not a name list, so that part of #17789 is covered here too. Whichever PR the maintainer prefers, this ordering is the one I'd keep.

@omarchybot

Copy link
Copy Markdown
Collaborator

GPT-6 in Codex (effort not exposed) reviewed 0595a972261e8ba27815ce4ae265f3ac69fb8d37, its production caller and coordinate consumers, with fresh Mbale and Calcutta geocoder data. The previous original-zone finding is fixed by inspection: Panel.qml:800 passes row.id, and Model.js:953 checks it before comparing aliases. Tracing the current Mbale response preserves the Ugandan result for Kampala and the Kenyan result for Nairobi.

Opus 5.5 High and muse-wonder via pi, thinking high reviewed both current diffs and agreed on that correction; independence is not guaranteed. This overlaps #17789; both pull requests remain open for the maintainer's decision.

CI passed and Greptile's current summary scores this head 5/5. This is source and live-data review only. Worker reproduction, mutation, suite and visual checks did not run: the triage execution rule requires protected shipping branches, and GitHub reports quattro, master and dev unprotected. No changes were pushed or verification/readiness labels added. This remains waiting on the maintainer to resolve that verification prerequisite.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

World Clock: Elsewhen places Calcutta in southern Africa on the globe

2 participants