Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/development/data.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GTT rotates trip IDs between daily exports while stop IDs stay stable, and most

### Publication

**Status (2026-11): no mirror is configured and the workflow is disabled.** GTT's static-export host refuses connections from GitHub-hosted runners (two runs failed with a TCP connect timeout while the same URL answered from an Italian connection), so the pipeline cannot build in GitHub Actions. `TIMETABLE_MIRRORS` is empty, so devices make no mirror requests; timetable freshness comes with app releases, and rotated trip IDs are handled by the direct GTT identity remap. Re-enabling requires running the pipeline from a host that can reach GTT and listing the mirrors again.
**Status (2026-11): no mirror is configured and the GTT timetable workflow is disabled manually in the repository's Actions settings.** GTT's static-export host refuses connections from GitHub-hosted runners (two runs failed with a TCP connect timeout while the same URL answered from an Italian connection), so the pipeline cannot build in GitHub Actions. `TIMETABLE_MIRRORS` is empty, so devices make no mirror requests: a check returns `unsupported` without failure or backoff, and boards omit the 48-hour "unconfirmed" warning (the provenance line still shows the bundled feed version); timetable freshness comes with app releases, and rotated trip IDs are handled by the direct GTT identity remap. Re-enabling requires running the pipeline from a host that can reach GTT and listing the mirrors again.

Mirrors are an optional freshness layer: boards work fully without them (bundled package, direct GTT identity remap below, GTT realtime). The app reads an ordered list of mirrors from `TIMETABLE_MIRRORS` in `src/transit-data/config.ts` and uses the next one only when one fails: GitHub Pages (`manifest.json`, `packages/gtt-<sha256>.json`), then the assets of one rolling GitHub **prerelease** tagged `gtt-timetable` (`manifest.json`, `gtt-<sha256>.json`; release assets cannot contain `/`). The data prerelease is created with `--prerelease --latest=false`, re-asserted on every run, and its assets are replaced in place (packages first, then the manifest, then stale assets removed), so release trackers such as Obtainium keep following the app's own latest release. Its notes say it is not an app release.

Expand Down
1 change: 1 addition & 0 deletions src/features/transit/StopBoardPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const SCHEDULE_OUTCOMES = {
'outdated-manifest': 'Nessun orario più recente disponibile.', rejected: 'Pacchetto orari non valido: mantenuti gli orari attuali.',
failed: 'Controllo orari non riuscito: mantenuti gli orari attuali.', 'skipped-network': 'Aggiornamento orari in attesa del Wi-Fi.',
throttled: 'Orari controllati di recente.',
unsupported: 'Orari dal pacchetto incluso nell’app: si aggiornano con le nuove versioni. I codici corsa GTT vengono verificati direttamente su gtt.to.it.',
} as const;

function SettingSwitch({ label, hint, value, onChange }: { label: string; hint?: string; value: boolean; onChange: (value: boolean) => void }) {
Expand Down
6 changes: 3 additions & 3 deletions src/services/transit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export class RealtimeUnavailableError extends ServiceError {
export async function getScheduledBoard(stopId: string, options: { signal?: AbortSignal; now?: number } = {}): Promise<StopBoard> {
const reader = await activeReader(stopId);
checkAbort(options.signal);
return composeBoard(reader, stopId, options.now ?? Date.now(), { refresh: timetableService.status().refresh });
return composeBoard(reader, stopId, options.now ?? Date.now(), { refresh: timetableService.status().refresh, updatesConfigured: timetableService.status().updateSupported });
}

/** Scheduled rows refined by the shared citywide TripUpdates feed. */
Expand All @@ -221,13 +221,13 @@ export async function getStopBoard(stopId: string, options: { signal?: AbortSign
checkAbort(options.signal);
const message = error instanceof Error ? error.message : 'Tempo reale non disponibile.';
// The opt-in per-stop source still works when the citywide feed host is down.
const board = await withStopLive(await composeBoard(reader, stopId, Date.now(), { refresh: timetableService.status().refresh, realtime: { error: message } }), reader, options.signal);
const board = await withStopLive(await composeBoard(reader, stopId, Date.now(), { refresh: timetableService.status().refresh, updatesConfigured: timetableService.status().updateSupported, realtime: { error: message } }), reader, options.signal);
throw new RealtimeUnavailableError(message, board, error instanceof ServiceError ? error.kind : 'network');
}
checkAbort(options.signal);
const realtime = await realtimeFor(feed, reader);
checkAbort(options.signal);
const board = await withStopLive(await composeBoard(reader, stopId, Date.now(), { refresh: timetableService.status().refresh, realtime, nextRefreshAt: feed.fetchedAt + ARRIVALS_REFRESH_MS }), reader, options.signal);
const board = await withStopLive(await composeBoard(reader, stopId, Date.now(), { refresh: timetableService.status().refresh, updatesConfigured: timetableService.status().updateSupported, realtime, nextRefreshAt: feed.fetchedAt + ARRIVALS_REFRESH_MS }), reader, options.signal);
// A nonempty feed with zero joins means the installed package is older than GTT's trip IDs.
if (board.realtime.state === 'unmatched') void timetableService.check('mismatch');
return board;
Expand Down
4 changes: 2 additions & 2 deletions src/transit-data/board.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function toRow(event: ScheduledEvent, prediction: Prediction, context: {
* rows joined by exact trip_id and service date. Unmatched feed counts stay out of the rows.
*/
export async function composeBoard(reader: TimetableReader, stopId: string, now: number, options: {
refresh: RefreshState; realtime?: RealtimeInput; window?: BoardWindow; limit?: number; nextRefreshAt?: number;
refresh: RefreshState; updatesConfigured?: boolean; realtime?: RealtimeInput; window?: BoardWindow; limit?: number; nextRefreshAt?: number;
}): Promise<StopBoard> {
const { meta } = reader;
const manifest = meta.manifest;
Expand Down Expand Up @@ -143,7 +143,7 @@ export async function composeBoard(reader: TimetableReader, stopId: string, now:
}
rows.sort((a, b) => a.sortAt - b.sortAt || (a.line ?? '').localeCompare(b.line ?? ''));

const notices: BoardNotice[] = scheduleNotices(meta, options.refresh, now);
const notices: BoardNotice[] = scheduleNotices(meta, options.refresh, now, { updatesConfigured: options.updatesConfigured });
if (summary.state === 'unmatched') notices.push({ code: 'realtime-unmatched', text: LABELS.unmatched, action: 'update-schedules' });
else if (summary.state === 'unavailable') notices.push({ code: 'realtime-unavailable', text: `Tempo reale GTT non disponibile: mostrati gli orari programmati.${realtime?.error ? ` ${realtime.error}` : ''}` });
else if (summary.state === 'ok' && (summary.feedUpdatedAt === undefined || now - summary.feedUpdatedAt > LIVE_MAX_AGE_MS)) notices.push({ code: 'realtime-feed-stale', text: 'Il feed tempo reale GTT non è aggiornato: le previsioni sono mostrate con la loro età.' });
Expand Down
5 changes: 4 additions & 1 deletion src/transit-data/refresh-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ export function succeededCheck(state: RefreshState, now: number, update: Partial
}

/** Schedule notices shared by every board for the active package. */
export function scheduleNotices(meta: DatasetMeta, state: RefreshState, now: number): BoardNotice[] {
export function scheduleNotices(meta: DatasetMeta, state: RefreshState, now: number, options: { updatesConfigured?: boolean } = {}): BoardNotice[] {
const notices: BoardNotice[] = [];
const today = romeDate(now);
if (coverageAt(meta, now) === 'outside') {
notices.push({ code: 'schedule-outside-coverage', text: `Orari non disponibili per oggi: il pacchetto GTT installato copre dal ${formatDate(meta.validFrom)} al ${formatDate(meta.validTo)} e gli orari non vengono stimati oltre questo periodo.`, action: 'update-schedules' });
} else if (addDays(today, 7) > meta.validTo) {
notices.push({ code: 'schedule-expiring', text: `Il pacchetto orari GTT copre solo fino al ${formatDate(meta.validTo)}.`, action: 'update-schedules' });
}
// Without a mirror there is no manifest that could confirm the package: the provenance line already
// shows the bundled feed version and date, so a permanent "unconfirmed" warning would only nag.
if (options.updatesConfigured === false) return notices;
// Only a real upstream check counts; a package prepared from a local ZIP has no confirmation.
const confirmed = Math.max(confirmedAt(state) ?? 0, (meta.manifest.upstream_checked_at ? Date.parse(meta.manifest.upstream_checked_at) : 0) || 0);
if (!confirmed) {
Expand Down
18 changes: 18 additions & 0 deletions src/transit-data/service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,21 @@ test('a different source that cannot be ordered is never an upgrade; a same-sour
assert.equal(isUpgrade(otherZip, base), false, 'same feed_version, unknown modification times, different ZIP');
assert.equal(isUpgrade({ ...base, built_at: '2026-12-01T00:00:00Z' }, base), true, 'same ZIP rebuilt later');
});

test('without a configured mirror there is no permanent "unconfirmed" warning', () => {
const reader = fixtureReader();
const checked = Date.parse(reader.meta.manifest.upstream_checked_at!);
assert.deepEqual(scheduleNotices(reader.meta, INITIAL_REFRESH_STATE, checked + 49 * HOUR, { updatesConfigured: false }), []);
assert.deepEqual(scheduleNotices(reader.meta, INITIAL_REFRESH_STATE, checked + 49 * HOUR, { updatesConfigured: true }).map(notice => notice.code), ['schedule-unconfirmed']);
});

test('without a configured mirror a check is quietly unsupported: no request, failure or backoff', async () => {
const env = setup({ mirrors: [] });
assert.equal(await env.service.check('manual'), 'unsupported');
assert.equal(await env.service.check('open'), 'unsupported');
assert.deepEqual(env.requests, [], 'no mirror request is made');
const status = env.service.status();
assert.equal(status.updateSupported, false);
assert.equal(status.refresh.failures ?? 0, 0, 'no failure is recorded');
assert.equal(status.lastError, undefined);
});
4 changes: 3 additions & 1 deletion src/transit-data/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
type CheckReason, type RefreshState,
} from './refresh-policy';

export type CheckOutcome = 'current' | 'installed' | 'not-modified' | 'outdated-manifest' | 'rejected' | 'failed' | 'skipped-network' | 'throttled';
export type CheckOutcome = 'unsupported' | 'current' | 'installed' | 'not-modified' | 'outdated-manifest' | 'rejected' | 'failed' | 'skipped-network' | 'throttled';
export interface ScheduleStatus {
phase: 'preparing' | 'ready' | 'failed';
meta?: DatasetMeta;
Expand Down Expand Up @@ -128,6 +128,8 @@ export function createTimetableService(deps: {
async function run(reason: CheckReason): Promise<CheckOutcome> {
const dataset = await ready();
let state = bindActive(status.refresh, activeMeta(dataset.meta).packageHash);
// No mirror configured: nothing to check, and no failure, backoff or error to report.
if (!mirrors.length) { update({ lastOutcome: 'unsupported' }); return 'unsupported'; }
if (!shouldCheck(state, reason, now())) { update({ lastOutcome: 'throttled' }); return 'throttled'; }
if (deps.networkAllowed) {
const allowed = await deps.networkAllowed(state.wifiOnly).catch(() => !state.wifiOnly);
Expand Down
Loading