Files
windmill/frontend/src/lib/forLater.ts
T
hugocasaandClaude Fable 5 4de1bf5beb refactor(recordings): build recordings from the completed run (#10571)
* refactor(recordings): build recordings from the completed run instead of live event capture

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): budget and isolate replay synthesis against hostile recordings

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): capture full logs and the run-time flow, upgrade v1 files

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* feat(recordings): pick an existing run for the hub recording

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): cap recorded logs under the replay loader's text budget

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): pin picked runs to their executed version, keep v1 streamed logs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): bound pipeline finalize fan-out, pin flow schema to run version

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(recordings): warn on mixed-version fallback, bound code fetches

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 17:22:13 +02:00

40 lines
987 B
TypeScript

import { get } from 'svelte/store'
import { dbClockDrift } from './stores'
import { JobService } from './gen'
import { getActiveReplay } from './components/recording/replay.svelte'
import pLimit from 'p-limit'
function subtractSeconds(date: Date, seconds: number): Date {
date.setSeconds(date.getSeconds() - seconds)
return date
}
function adjustDate(drift: number): Date {
return new Date(Date.now() + drift)
}
export async function computeDrift() {
if (get(dbClockDrift) == undefined) {
const now = Date.now()
const dbClock = await JobService.getDbClock()
dbClockDrift.set(dbClock - now)
}
}
export function forLater(scheduled: string | number | Date): boolean {
return getDbClockNow() < subtractSeconds(new Date(scheduled), 5)
}
const limit = pLimit(1)
export function getDbClockNow() {
if (getActiveReplay()) {
return new Date()
}
let drift = get(dbClockDrift)
if (drift == undefined) {
limit(() => computeDrift())
drift = 0
}
return adjustDate(drift)
}