Skip to content

feat: default printer selection to a real printer instead of Auto-select#44

Merged
szrudi merged 2 commits into
mainfrom
feat/default-printer-selection
Jun 13, 2026
Merged

feat: default printer selection to a real printer instead of Auto-select#44
szrudi merged 2 commits into
mainfrom
feat/default-printer-selection

Conversation

@szrudi

@szrudi szrudi commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

Stacked under #39 (per-printer settings); no version bump — ships in the single v1.8.0 that #39 cuts. Merges before #39, which builds on it.

Why

The printer dropdown defaulted to an "Auto-select" entry — meaning no concrete printer was chosen and the server picked one only at print time. With per-printer settings (#39), that's backwards: on load you'd see app defaults (12 mm black/white) and only see a printer's saved tape/colors after manually picking it. (Found while testing #39 on the Pi.)

What

  • Default the selection to a concrete printer in setAvailablePrinters: the first printer in the list — which is the first real USB printer when present (virtual printers are listed after). So a real printer is selected on load, and (once feat: persist per-printer label settings (tape size, colors) — closes #20 #39 lands) its saved settings apply immediately.
  • Re-select the first printer if the chosen one vanishes (unplugged), so the selection is never stale.
  • Remove the "Auto-select" dropdown entry.
  • The server still accepts no printer_id and auto-selects the first available printer — that fallback is unchanged; the UI just always sends a concrete printer now.

Tests

Store: defaults to first printer, keeps a still-present selection, re-selects on vanish, clears when no printers. SettingsBar: lists printers without Auto-select, defaults to first, selecting updates the store. Frontend suite green (59); ARCHITECTURE.md updated.

🤖 Generated with Claude Code

The "Auto-select" option meant no concrete printer was chosen, so the
server picked one only at print time. With per-printer settings coming
(#39), that hides a printer's saved settings until you manually pick it.
Default the selection to the first printer in the list (the first real
USB printer when present; virtual printers listed after) in
setAvailablePrinters, re-selecting the first if the chosen printer is
unplugged, and drop the Auto-select dropdown entry. The server still
accepts no printer_id and auto-selects, so that capability is unchanged;
the UI just always sends a concrete printer.

No version bump — ships in the single v1.8.0 with the per-printer
settings work (#39), which builds on this.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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.

Pull request overview

This PR updates the frontend’s multi-printer selection behavior so the UI defaults to a concrete printer (the first in the discovered list) rather than an “Auto-select” placeholder, aligning the UX with upcoming per-printer settings in #39.

Changes:

  • Updated the Zustand store (setAvailablePrinters) to default settings.printerId to the first available printer and to re-select the first printer if the prior selection disappears.
  • Removed the “Auto-select” option from the SettingsBar printer dropdown and adjusted selection handling accordingly.
  • Updated docs and frontend tests to reflect the new default-selection behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
docs/ARCHITECTURE.md Updates the architecture notes to describe the new concrete default printer selection behavior.
client/src/state/useLabelStore.ts Implements default/repair logic for printerId when available printers are set.
client/src/state/useLabelStore.test.ts Adds unit tests for the new setAvailablePrinters selection behavior.
client/src/components/SettingsBar.tsx Removes the “Auto-select” option and updates the printer selector change handler.
client/src/components/SettingsBar.test.tsx Updates UI tests to expect no “Auto-select” option and default-first selection behavior.
Comments suppressed due to low confidence (1)

client/src/components/SettingsBar.tsx:43

  • Now that the "Auto-select" entry is removed, the can be rendered with value={settings.printerId || ""} that doesn't match any option when printerId is undefined (e.g. after importing a label file that has no printerId). This results in an invalid controlled value and can show a blank selection / React warnings. Consider deriving an effectivePrinterId that falls back to the first available printer and using it consistently for both the selected printer lookup and the value. const selectedPrinter = settings.printerId ? availablePrinters.find((p) => p.id === settings.printerId) : null; const selectedIsVirtual = selectedPrinter?.vendorProductId === "virtual"; 💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

With the Auto-select entry removed, value={settings.printerId || ""}
could be "" with no matching option when printerId is unset (e.g.
transiently after importing a label that has no printerId) — an invalid
controlled value that renders blank and warns. Derive effectivePrinterId
that falls back to the first printer, and use it for both the select
value and the selected-printer lookup. (Per Copilot review on #44.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@szrudi szrudi merged commit be77337 into main Jun 13, 2026
4 of 5 checks passed
@szrudi szrudi deleted the feat/default-printer-selection branch June 13, 2026 09:23
szrudi added a commit that referenced this pull request Jun 13, 2026
Brings in #41 (serial ids), #42 (virtual ids), #44 (default printer
selection), #45 (shared state_store + UTF-8). Conflict resolution:
- state_store.py / usb_power.py / test_state_store.py: took main's (the
  #45 versions with UTF-8 read/write + corrected comment + non-ASCII
  test) — they supersede #39's older extracted copies.
- test_smoke.py: kept #39's (superset — adds printer_settings module and
  the /api/printers/<id>/settings route on top of #45's ownership guard).
- useLabelStore setAvailablePrinters: combined main's default-printer
  selection with #39's availablePrintersLoaded flag.
- SettingsBar + its tests, useLabelStore tests, ARCHITECTURE.md:
  unioned #44's selector changes with #39's persist/load-gate.

Frontend 81, backend 276, build green.
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