Skip to content

The till stays awake while it trades, and catches up the moment it wakes - #779

Merged
sridharkalaibala merged 2 commits into
developfrom
feat/the-till-stays-awake-and-drains
Sep 15, 2026
Merged

sridharkalaibala merged 2 commits into
developfrom
feat/the-till-stays-awake-and-drains

Conversation

@sridharkalaibala

Copy link
Copy Markdown
Contributor

Stage 7 of the print roadmap. The one failure that needs no queue to hurt.

What was happening

Windows sleeps an idle machine, and a restaurant till is idle for long stretches
between services. The moment it suspends, the kitchen stops receiving tickets
and handsets stop reaching it — while the screen still says Posnic and nothing
reports a fault.
The waiter presses send, the phone says sent, no paper comes
out. Nobody finds out until somebody walks to the printer.

"desktop app system got logged out or screen lock, then also our app should
keep wake."

Locking is not sleeping

Worth being exact, because the two get conflated and it sends a shop hunting the
wrong fault:

Screen locked session keeps running, printing continues. Fine, and worth encouraging.
Machine asleep process, network and printer all stop. This is what's blocked now.
Logged out session ends. Still fatal — that's Stage 8, and probably never.

A lock is logged saying the till kept running, so "it stopped when I locked it"
has an answer in the log rather than a shrug.

What is held, and what is not

prevent-app-suspension, never prevent-display-sleep. The system is kept
from suspending; the screen may still blank, and should — a kitchen display that
can never blank is one that burns in.

The block is released on shutdown. A till that looks switched off and still
refuses to sleep is a machine nobody can explain.

The wake-up is where duplicates come from

A till asleep for two hours wakes with work behind it and a 30-second poll that
did not run while it was suspended. Thirty seconds at a pass with no ticket is
how a cook reprints by hand — and that is how a wake-up becomes the duplicate
this whole area exists to prevent.

So every collector runs on resume rather than at the next timer:

kotManager._poll();        // kitchen tickets
billManager._poll();       // floor bills
billManager._pollCloud();  // cloud-relayed bills

One failing task cannot stop the others — the point of the moment is that
everything catches up at once — and a rejected promise is caught, because an
unhandled rejection on a till is a crash dialog in a restaurant.

It cannot stop a till starting

powerSaveBlocker is genuinely absent under some remote sessions, so every call
answers instead of throwing, the module loads with no Electron at all, and the
startup call sits inside a try. A test pins each of those.

Desktop 2530 pass / 0 fail.

Next in this run

needs_attention on the print queue, then kitchen tickets through the queue
itself — shadowed alongside the existing poll, not swapped.

Owner: "desktop app system got logged out or screen lock, then also our app
should keep wake." Stage 7 of the print roadmap, and the one failure that needs
no queue to hurt.

WHAT WAS HAPPENING

Windows sleeps an idle machine, and a restaurant till is idle for long stretches
between services. The moment it suspends the kitchen stops receiving tickets and
handsets stop reaching it - while the screen still says Posnic and nothing
reports a fault. The waiter presses send, the phone says sent, and no paper comes
out. Nobody finds out until somebody walks to the printer.

THE DISTINCTION THAT MATTERS

Locking is not sleeping. A locked Windows session keeps running everything and
keeps printing, so locking a till is fine and worth encouraging; LOGGING OUT
ends the session and is the thing that kills it. Conflating the two sends a shop
hunting the wrong fault, so a lock is logged saying exactly that.

WHAT IS HELD, AND WHAT IS NOT

prevent-app-suspension, never prevent-display-sleep. The system is kept from
suspending; the screen may still blank, and should - a kitchen display that can
never blank is one that burns in. The block is released on shutdown, because a
till that looks switched off and still refuses to sleep is a machine nobody can
explain.

THE WAKE-UP IS WHERE DUPLICATES COME FROM

A till asleep for two hours wakes with work behind it and a thirty second poll
that did not run while it was suspended. Thirty seconds at a pass with no ticket
is how a cook reprints by hand, and that is how a wake-up becomes the duplicate
this whole area exists to prevent. So every collector runs on resume rather than
at the next timer: kitchen tickets, floor bills, and cloud-relayed bills.

One failing task cannot stop the others - the point of the moment is that
everything catches up at once - and a rejected promise is caught, because an
unhandled rejection on a till is a crash dialog in a restaurant.

Nothing here can stop a till starting. powerSaveBlocker is genuinely absent
under some remote sessions, so every call answers instead of throwing, and the
startup call sits inside a try.

Desktop 2530 pass.
#777 added src/handset-slots.js and this one added src/till-stays-awake.js, at
the same line of build.files. Both ship. Nothing else disagreed.

build.files is an explicit allowlist, so a file left out of it is simply absent
from the installed app - the module resolves in development and is missing on a
shop's machine. Worth resolving by keeping both rather than by taking a side.
@sridharkalaibala
sridharkalaibala merged commit 839d21b into develop Sep 15, 2026
9 checks passed
@github-actions github-actions Bot added the ready for QA Merged to develop and live on develop.posnic.io - anyone can test it label Sep 15, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Merged to develop. Anyone can test this - you do not need write access.

Try it at https://develop.posnic.io, or run it yourself:

git fetch origin develop && git checkout develop
npm install && npm --prefix api install
npm run dev   # then http://localhost:3000

When you have tested it, say what you did and what happened, and set
QA passed or QA failed. If you cannot set labels, just comment -
a maintainer will.

Reporting that something is broken is as useful as fixing it. It is
better found here than by a shopkeeper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for QA Merged to develop and live on develop.posnic.io - anyone can test it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant