Skip to content

Ask the printers that did not answer as the printer list opens - #389

Merged
DL6ER merged 39 commits into
masterfrom
feature/look-on-open
Dec 5, 2026
Merged

DL6ER merged 39 commits into
masterfrom
feature/look-on-open

Conversation

@DL6ER

@DL6ER DL6ER commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

A printer on Bluetooth that did not answer, e.g., one switched on after the label designer was opened, showed "The printer cannot be reached" until "Look for printers" was clicked. Opening the printer list now asks such printers again, at most once a minute and without a Bluetooth search, so a printer that connects right then is left alone. New printers are still found by "Look for printers" and by loading the label designer.

Loading the label designer looks for printers as before, at most once a minute, and asks a printer set to save energy again only where its last answer is over an hour old. The server decides both (look=auto and look=load of printer_status), so reloads and other tabs count too.

Before and after, with a B1 switched on while the page was open:

DL6ER added 6 commits December 3, 2026 12:18
A printer switched on after the label designer was opened showed only once "Look for printers" was clicked. Opening the printer list now looks for printers by itself, at most once a minute, as each look pages the printers on Bluetooth that did not answer. The button still looks at any time.

Signed-off-by: DL6ER <dl6er@dl6er.de>
1. The list of printers opens with `look=auto`, which the server answers with a look only where no one looked within `LOOK_AUTO` seconds: also the look as the page loads, "Look for printers" in the Settings and other tabs or browsers count, and a look that failed does not. It replaces the minute kept in each tab by its clock.
2. The status is asked once at a time, so that a look and the poll no longer both place the label anew.
3. The look on opening leaves "Look for printers" as it is; a look asked for with it reads "Looking..." until it is done, also in the list opened again.
4. The list drawn again keeps the focus on its printer, e.g. as a look answers.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>

# Conflicts:
#	app/labeldesigner/routes.py
…t opens

1. `look=auto` leaves the printers that answered alone: `devices.asked_to_look` keeps the last answer of a printer that saves energy until someone asks to look for printers, as e.g. a B1 beeps at each connection.
2. The label designer looks with `auto` as it opens too, so that loading it again counts towards the one look a minute.
3. Printers that did not answer stay in `_looked_for` until they answer, so that a second look while classic Bluetooth is searched does not page them.
4. One refresh waits at most, and it looks as far as any asked for meanwhile.
5. Drawn again, the list keeps the focus on a printer among those of the same path by its place, and on the buttons of the calibration. "Look for printers" takes the focus back only where it fell off the disabled button.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>

# Conflicts:
#	app/labeldesigner/drivers/base.py
#	tests/printing/test_bluetooth.py
1. `look=auto` asks again the printers on Bluetooth that answered, as loading the label designer did before, and leaves alone only those that save energy, which beep at each connection. A printer that did not answer since its last answer is asked whatever that answer told: a switched-off printer looked for so showed as ready.
2. Looks as lists of printers open at once are one, as the minute is checked under the lock the look takes.
3. `note_answer()` takes that lock too, so a printer noted while a look moves the others is not lost.
4. Each test starts without a look before it.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Copilot AI balanced review requested due to automatic review settings December 3, 2026 20:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

DL6ER added 7 commits December 3, 2026 21:25
1. `look=load`, as the label designer loads, looks as before (it searches Bluetooth and asks every printer again) at most once a minute, and asks printers that save energy only where their last answer is over an hour old (`devices.LOADED_AGE`).
2. `look=auto`, as its list of printers opens, only asks the printers that did not answer again: no search of Bluetooth, no printer that connects gives way, and no wait for one to. It runs at most once a minute after any look.
3. A query that fails after a look began is not noted, checked under the lock against `devices.retried`, which every look sets.
4. A printer looked for stays so until it answers, also through other errors, and a printer removed from the settings is forgotten.
5. An answer of the printers counts as lost after 20 s, so a hung one holds no later refresh, and a refresh that cannot show the printers is logged instead of rejected to its callers.

Signed-off-by: DL6ER <dl6er@dl6er.de>
1. Any error of a printer that saves energy is noted, so the polls tell it without paging the printer until the next look, load or print.
2. A printer looked for that fails otherwise tells its new error while classic Bluetooth is searched, not the one from before the look.
3. A printer removed from the settings is forgotten in full: what it did not answer, when it was not reached, its last status and answer and the model ID it told. A query that began before is not noted afterwards.
4. The looks are one table in `devices.LOOKS`, and a look of no known kind is refused.
5. An answer of the printers counts as lost after 30 s, over twice what the server takes at most, and an error showing it is reported as one not caught, so the tests that watch for errors still see it.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…h printers that save energy

1. An error of a printer that saves energy is noted only on Bluetooth: one on USB that shares the settings of a B1 is asked every time.
2. The printer followed every 2 s is asked with the same 30 s limit as the list, so a lost answer no longer stops following until a reload.
3. The tests check that limit against twice what the server waits at most.

Signed-off-by: DL6ER <dl6er@dl6er.de>
A B1's settings are shared with it on USB and over USB/IP by its serial number, so `printer_settings.saving_energy()` listed those devices too. It now lists Bluetooth devices only: a printer on USB is asked every time, and `note_answer()` needs no check of its own.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…er 10 s

1. The list only has to end a request that hangs: its search may ask many printers that are off in turn.
2. The printer followed is told within the server's `FOLLOW_WAIT`, so following comes back within seconds.
3. An `AbortController` with a timer ends both, also in browsers without `AbortSignal.timeout()`, and covers reading the answer too.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Opening the printer list sends a look whose answer draws the list again. A test that read the calibration button twice could meet the old button in between, taken out of the page, and see no style. The tests now open the list with the shared `opened()`, which waits for that answer and its drawing, and every list of printers asked is answered with the printer of the test.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER changed the title Look for printers when the printer list opens Ask the printers that did not answer as the printer list opens Dec 4, 2026
DL6ER added 14 commits December 4, 2026 06:47
Signed-off-by: DL6ER <dl6er@dl6er.de>

# Conflicts:
#	app/static/designer/main.js
The look as the printer list opens draws the list again from the stubbed answer, which lost a `calibration_kind` set on the printer in the page only. The test of a sheet that offers no calibration now hands it to `_printer` and opens the list with `_panel`, which waits for that look.

Signed-off-by: DL6ER <dl6er@dl6er.de>
A status answer asked before a change made in this browser, e.g., the look as the printer list opened, brought the old values back after a calibration was kept, and the new-roll hint came back until the next poll. Status requests are numbered now, and `changedHere()` notes per printer which fields changed after which request. An answer asked before keeps those fields as shown and still brings everything else, e.g., the printers a look found.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…t prints in turn

The next print on a sheet asked where to go on from a status read after the job, which could wait behind a look for printers, and a print started before the answer of the last one offered labels that one takes. The answer of a job on a sheet now tells `continue_at` as the status does, and the designer applies it at once. Prints on one printer ask one after the other, each once the one before was sent and answered, and take a new sheet where that answer does not come. The status is read once a sheet job ended, from every place that prints, in turn with the other status requests.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…nter settings

After another sheet was chosen, "Calibrate printer" only followed once the next status read came, which can wait behind a look for printers. The answer of `POST /api/settings` now tells `calibration_kind` as the status does, and where `demo_model` changed also the model and the label sizes it takes. The designer shows them at once, with model and calibration kind matching.

Signed-off-by: DL6ER <dl6er@dl6er.de>
An office printer that does not tell its calibration kind, e.g., one kept from before that does not answer, still offered calibration on a sheet of one label. Printers that take sheets now offer it only where the status tells `sheet`, while a B1 keeps it whatever its roll.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Opening the calibration of a sheet that cannot be calibrated fell through to the dialog of a roll. `GET /api/calibration` now tells why for such a sheet, and the designer shows that message instead of opening a dialog.

Signed-off-by: DL6ER <dl6er@dl6er.de>
A look made as the printer list opened asked the printers that did not answer again only at the next detection, as the answer came from the detection of the last 10 s. A printer that was off and switched on in the meantime was then shown as unreachable for up to 20 s after opening the list. A status request now detects again where a look was made after the last detection began, also where that detection ended after the look.

The detections also run one at a time now. A status request that came during a detection detected again at the same time, found the printers held by the status queries of the first, and told them as printing. It now waits for the running detection and takes its printers.

Signed-off-by: DL6ER <dl6er@dl6er.de>
1. A print counts as sent once its request leaves, not while it waits behind another print on the same printer, so the next one waits for its answer as long as meant.
2. A print that fails before it is sent ends its turn as well, else the next one on that printer waited for it for good.
3. Sheets of one label take no turn, each print takes a new sheet anyway.

The printers shown at a path are looked up with `byPath()` now.

Signed-off-by: DL6ER <dl6er@dl6er.de>
A status request that waited for a running detection detected again once it got its turn, one after the other while a printer was busy. It now takes the printers of that detection, unless a look for printers was made after it began. A printer whose own status query runs meanwhile, e.g., one the label designer follows, is told by that query's answer instead of being asked a second time, where the detection found it held and told it as printing.

Signed-off-by: DL6ER <dl6er@dl6er.de>
The same count was in `_noting_sheet()`, `_going_on()` and `_goes_on_after()`.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…s does

After a change of the demo model, the answer told where a sheet goes on as kept, without the jobs in the queue, and the label designer kept that against status answers asked before. `_tell_going_on()` now gives both answers the same value.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Taking the answer of a status query that runs for a printer, e.g., of the label designer that follows it, grew into a change of every status query and goes into a pull request of its own. The detection asks each printer itself again, as before. A status request that waited for a running detection still takes its printers.

Signed-off-by: DL6ER <dl6er@dl6er.de>
The settings read told where a sheet goes on as kept, without the jobs in the queue, while the status and the answer of a change told it after them. All three use `_tell_going_on()` now.

Signed-off-by: DL6ER <dl6er@dl6er.de>
DL6ER added 12 commits December 5, 2026 10:22
`perSheet()` gives 1 for anything that is not a sheet of labels.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…ded meanwhile

A status request that waited for a running detection took its printers, also where a search on Bluetooth found a printer after that detection began, and the end of the detection put back the time that search had reset. The search now notes when it ended, and a detection that began before is not taken as the answer.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…etooth

A search on Bluetooth that ended between the two was told by neither that detection nor the next status query.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…g` lock

A search on Bluetooth left over from one test could make a later test that counts detections detect once more. The lock that tells each status query coming to `printer._detecting` is one helper in tests/helpers.py now.

Signed-off-by: DL6ER <dl6er@dl6er.de>
GET /api/settings, the answer of a change and the status told them in the same two steps, of the printer and where its sheets go on after the jobs in its queue.

Signed-off-by: DL6ER <dl6er@dl6er.de>
…ng times

A search that ended just before a detection took the printers found on Bluetooth made the next status request detect once more, and one that ended in the same tick as the detection began was not told at all. The detection now notes how many searches had ended as it took the printers found, and only a later one makes the next status request detect again. The tests also wait for a search one test left running.

Signed-off-by: DL6ER <dl6er@dl6er.de>
The status tells its first printer at its top and in its list, and where its sheets of labels go on was worked out for both, which may also retry saving it. `_described()` now works the settings out once for each printer and model.

Signed-off-by: DL6ER <dl6er@dl6er.de>
Tests that start a search set `printer._bluetooth_thread` with monkeypatch, which put it back before the next test could see it, so the wait at the start of a test never waited. `no_known_printers` now waits as the test ends, before monkeypatch puts back what it changed, see `search_ended()`.

Signed-off-by: DL6ER <dl6er@dl6er.de>
The settings told were kept by `printer.get('path')`, while they were worked out and noted with `printer.get('path', '')` and the lines before used `printer.get('path') or ''`. Every use in the loop takes the same path now, so `_settings_told()` is given a text again.

Signed-off-by: DL6ER <dl6er@dl6er.de>
It starts each test without a search and fails the test whose search outlived it, instead of leaving it to the next one. The tests no longer reset the thread themselves and wait for it with `search_ended()`.

Signed-off-by: DL6ER <dl6er@dl6er.de>
The join they had before failed where no search had started, `search_ended()` returned quietly. `search_ended(started=True)` asserts that one started and ended; `no_known_printers` keeps the quiet form.

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER
DL6ER merged commit c974e89 into master Dec 5, 2026
9 checks passed
@DL6ER
DL6ER deleted the feature/look-on-open branch December 5, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants