fix(ui): live-tail logs when time range is a relative preset
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 1m29s
CI / docker (push) Successful in 1m13s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 38s

Page 1 refetches were using the captured timeRange.end, so rows
arriving after the initial render were outside the query window and
never surfaced. When timeRange.preset is set (e.g. 'last 1h'), each
fetch now advances 'to' to Date.now() so the poll picks up new rows.
Absolute ranges are unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-17 14:48:29 +02:00
parent 51feacec1e
commit a3429a609e

View File

@@ -184,6 +184,10 @@ export function useInfiniteApplicationLogs(
const useTimeRange = !args.exchangeId;
const fromIso = useTimeRange ? timeRange.start.toISOString() : undefined;
const toIso = useTimeRange ? timeRange.end.toISOString() : undefined;
// Relative presets (e.g. "last 1h") should live-tail: each fetch advances
// `to` to "now" so new rows that arrive after the page was first rendered
// show up on refetch. Absolute ranges keep their captured `to`.
const isLiveRange = useTimeRange && !!timeRange.preset;
const sortedSources = (args.sources ?? []).slice().sort();
const sortedLevels = (args.levels ?? []).slice().sort();
@@ -217,7 +221,8 @@ export function useInfiniteApplicationLogs(
if (sourcesParam) qp.set('source', sourcesParam);
if (levelsParam) qp.set('level', levelsParam);
if (fromIso) qp.set('from', fromIso);
if (toIso) qp.set('to', toIso);
const effectiveTo = isLiveRange ? new Date().toISOString() : toIso;
if (effectiveTo) qp.set('to', effectiveTo);
if (cursor) qp.set('cursor', cursor);
qp.set('limit', String(pageSize));
qp.set('sort', sort);