Open modelflat opened 4 days ago
This is more of an absolute timer though, which doesn't refresh if there are more changes after the first change, right? I understood it as a (fairly short) period where there are no more changes instead.
It might be easier to implement that by tracking the timestamp of the last change. Since it's already a loop with a sleep it could be quite simple, something like
if self._last_input != new_input:
current_time = time.monotonic()
if current_time - self._last_change < grace_period:
await self._model._generate_live(new_input)
self._last_input = new_input
self._last_change = time.monotonic()
I think this would make it unnecessary to pass _last_input
to _generate_live
and call _prepare
there since that part is already handled. The just_got_here
would also not be needed, since the _last_change
timestamp would naturally be quite old in this case.
As per discussion in #1248 this PR adds logic to delay the live preview generation upon change (without the extensions mentioned in this comment).