Airshift is personal web radio in the tab. I wanted a Pomodoro on the same board — focus with the crate, break when the timer says so — without a second app and without trusting a countdown that drifts when the tab sleeps.

I wrote about the architecture and keeping the board live. This is a smaller piece: wall clock vs tick counting, a tiny phase machine, and speaking transitions without walking on the DJ.

EndsAt, not tick counting

A naive timer subtracts from a remaining counter every half second. Background tabs throttle setInterval. Come back from Slack and you have “earned” a few fake minutes, or the break never fired.

Airshift stores an absolute endsAt. The clock is a cheap poll (~500ms) that asks: is now >= endsAt? If the tab was frozen for ten minutes, the next tick still advances the phase. Pause freezes leftover milliseconds into pausedRemaining and clears endsAt; resume writes a new deadline. Refresh restores the same JSON from localStorage and catches up missed phases in a short loop — pause and resume still apply, stacked chimes and speeches do not.

That lives in pomodoro.ts — pure state, no DOM. main.ts owns the interval, the Monitor chip, and the talk pipeline. Classic / Animedoro / Ultradian are just duration bags you hand the same machine.

Phases that touch the hour

Focus ending always pauses playback. The break is supposed to be impossible to miss. When the break ends, the hour resumes where you left it. Skip forces endsAt = now and runs the same transition path, so early-outs do not invent a second code path.

Speak without stomping the booth

Transitions log a line and, when On Air, try to have the DJ say it. Two gates matter:

  • If the DJ is already talking, do not queue another say on top of the break.
  • If the DJ is muted — or already talking — fire a short Web Audio chime that bypasses booth gain, pulse the Monitor chip, and vibrate when the browser allows it.

Mute still hears the cue. An in-flight break still wins the microphone.

What I left boring

A tiny checklist sticks in localStorage across stations. Timing is a Settings select. The mast and tab title keep a glanceable clock. The blog-worthy bit is the clock: wall time, phase transitions, and a talk pipeline that refuses to interrupt itself.

Try Airshift at airshift.fly.dev — start a Pomodoro on the Monitor, mute the DJ, and let a focus end.