feat: default printer selection to a real printer instead of Auto-select#44
Merged
Conversation
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>
There was a problem hiding this comment.
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 defaultsettings.printerIdto 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
effectivePrinterIdthat 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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
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.printer_idand 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