Dawnline 0.4.2
Build packages / Version (push) Waiting to run

- Connections show up at once: the agent looks at the tunnels every
  second and, the moment a device connects or roams, writes it to the
  activity log, updates traffic and the map, and locates the new address
- A device counts as gone when its WireGuard session expires (1-3 min
  after it leaves), so a phone asleep no longer flaps between
  disconnect and connect
- The admin pages follow along within seconds: Overview, People, the
  person page and the device panel refresh when something happens, with
  a light check every 2 s instead of reloading everything every 10 s
- The personal portal no longer refreshes itself in the background:
  every request costs the router a CGI process, so it loads once and
  after the visitor's own changes
- Agent guidance and code standards (backend, frontend, shell, UI) now
  live in the repository: AGENTS.md and rules/
This commit is contained in:
Aemeath committed 2026-10-16 03:52:21 +03:00
1 parent 6444722d14
commit 29b1d7dfd7
26 files changed
+419 -104

No files matched your search

+19 -6
View File
@@ -2,6 +2,8 @@
// region alone while the keyboard focus is inside it (typing, a picker, a
// focused button), so a background refresh never takes it away.
import { onLiveChange } from './live';
/**
* Request tickets: an answer is shown only if nothing newer was shown before
* it. `claim()` invalidates everything in flight (an edit's own answer wins).
@@ -24,14 +26,16 @@ export class Sequence {
}
export interface PollerOptions<T> {
/** One request; rejections and null count as "no answer". */
fetch: () => Promise<T | null>;
/** One request (`live`: the live revision moved); rejections and null count as "no answer". */
fetch: (live: boolean) => Promise<T | null>;
/** Paint an answer; `quiet` for the periodic ones. */
apply: (data: T, quiet: boolean) => void;
/** Seconds between ticks. */
every: number;
/** Ticks are skipped while this is false (e.g. the page is not on screen). */
active?: () => boolean;
/** Also refresh as soon as the live revision moves (state/live.ts); `every` is then the fallback. */
live?: boolean;
}
export interface Poller<T> {
@@ -44,16 +48,25 @@ export interface Poller<T> {
export function createPoller<T>(o: PollerOptions<T>): Poller<T> {
const seq = new Sequence();
const refresh = async (quiet = false): Promise<T | null> => {
const load = async (quiet: boolean, live: boolean): Promise<T | null> => {
const t = seq.next();
const d = await o.fetch().catch(() => null);
const d = await o.fetch(live).catch(() => null);
if (d == null || !seq.take(t)) return null;
o.apply(d, quiet);
return d;
};
const tick = () => ((o.active?.() ?? true) ? refresh(true) : Promise.resolve(null));
const refresh = (quiet = false) => load(quiet, false);
const tick = () => ((o.active?.() ?? true) ? load(true, false) : Promise.resolve(null));
poll.add(tick, o.every);
return { refresh, claim: () => seq.claim(), stop: () => poll.remove(tick) };
const off = o.live ? onLiveChange(() => void ((o.active?.() ?? true) && load(true, true))) : null;
return {
refresh,
claim: () => seq.claim(),
stop: () => {
poll.remove(tick);
off?.();
},
};
}
/** The keyboard focus (or an open native picker's input) is inside `el`. */