fix(ui): live-tail logs when time range is a relative preset
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user