Repository navigation
fix(macos): route MAS USB print via CUPS socket - #1383
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
PR Summary by QodoFix Mac App Store USB printing through the CUPS socket
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
Connect to local macOS CUPS over /private/var/run/cupsd by default (with loopback TCP 127.0.0.1:631 fallback on ENOENT) so sandboxed Mac App Store builds are permitted by application.sb under com.apple.security.print and wake cupsd via launchd socket activation. Route printViaUSB() through printViaLocalIpp() on MAS darwin, send document-format application/vnd.cups-raw for lp -o raw parity, map IPP 0x0406 missing-queue errors to actionable System Settings > Printers & Scanners guidance (failureClass: not_configured), and add unit/mock-server coverage in tests/ipp-client.test.ts. Fixes #1347
…ls to printing architecture
Use RFC 8011 0x0506 for IPP_STATUS_SERVER_ERROR_NOT_ACCEPTING_JOBS and 0x0508 for IPP_STATUS_SERVER_ERROR_JOB_CANCELED, keep UNIX socket ENOENT fallback inside the ECONNREFUSED retry loop, gate the empty-list USB queue-name mismatch warning on successful detection, guard Windows CI against filesystem socket listen errors, and document macOS CUPS queue verification details.
0d31eee to
1298553
Compare
Intent
Fix #1347 (
bug(macos): Mac App Store USB printing via CUPS/IPP (needs device repro)):main/printers/ipp-client.ts:/private/var/run/cupsdby default (with configurable endpoint override for tests and TCP127.0.0.1:631fallback onENOENT), because/System/Library/Sandbox/Profiles/application.sbblocks outbound TCP tolocalhost:631(EPERM) while allowing/private/var/run/cupsdundercom.apple.security.print, andlaunchd(org.cups.cupsd.plist) only socket-activates/private/var/run/cupsdaftercupsd's 60s idle exit.document-format = application/vnd.cups-rawinippPrintRaw()so CUPS bypasses auto-typing and PPD filters (lp -o rawparity).formatIppStatusError), mapping0x0406(client-error-not-found) to a clear actionable message instructing the user to add the USB printer in macOS System Settings > Printers & Scanners and match the CUPS queue name.main/printers/thermal.tsandfrontend/src/components/settings/PrintersSettingsTab.tsx:printViaUSB()throughprintViaLocalIpp()on macOS MAS runtime (isMasRuntime()) so all USB print entry points (receipts, KOT, delivery slip, menu, test print, active test print, cash drawer kick, and Z-report) use local IPP instead of spawning/usr/bin/lp//usr/bin/lpstat.failureClass: 'not_configured'with the actionable missing-queue message when the CUPS queue does not exist (0x0406), and show theprinterNameMismatchWarningbanner inPrintersSettingsTab.tsxeven whendetectedPrinters.length === 0.tests/ipp-client.test.ts(wired intotest:printerinpackage.json) and document macOS / Mac App Store USB printer setup indocs/printers.mdanddocs/architecture/printing.md.Fixes #1347in the PR body and keep the PR title 50 characters or fewer (fix(macos): route MAS USB print via CUPS socket).What Changed
main/printers/ipp-client.tsto connect to the local macOS CUPS UNIX domain socket/private/var/run/cupsdby default (switching to loopback TCP127.0.0.1:631across remaining retry attempts onENOENT), senddocument-format = application/vnd.cups-rawinippPrintRaw(), and map IPP status errors (0x0406missing queue,0x0506not accepting jobs, and0x0508job canceled) viaformatIppStatusError().printViaUSB()throughprintViaLocalIpp()on macOS Mac App Store builds inmain/printers/thermal.tswithclassifyPrintFailure()classification (not_configuredon missing queues), and track completed printer detection infrontend/src/components/settings/PrintersSettingsTab.tsxso the USB queue-name mismatch warning renders when zero queues are detected without false-triggering on failed detection requests.tests/ipp-client.test.ts(wired intotest:printerinpackage.json) and document macOS/MAS CUPS queue setup and socket transport indocs/printers.mdanddocs/architecture/printing.md.Fixes #1347
Risk Assessment
✅ Low: The change is well-bounded to local macOS CUPS/IPP transport, error classification, printer settings UI feedback, documentation, and mock-server unit tests, matching all requirements in the user intent with no identified defects.
Testing
Ran the targeted IPP client and printer test suites (tests/ipp-client.test.ts,npm run test:printer,npm run test:script-coverage), built the backend and static frontend (npm run build,npm run build:frontend), and drove 5 live end-to-end scenarios against the real macOS/private/var/run/cupsddaemon andsandbox-exec(application.sb), the live Express API across all 8 MAS USB print entry points over a UNIX domain socket CUPS endpoint, and the live Settings > Printers UI in Chromium, capturing 2 protocol transcripts and 4 UI screenshots in the evidence directory.Evidence: macOS App Sandbox (application.sb), real /private/var/run/cupsd socket, ENOENT->ECONNREFUSED retry, and RFC 8011 status verification transcript
Evidence: Live Express API + UNIX socket CUPS IPP transcript across all 8 MAS USB print entry points and 0x0406 missing-queue handling
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
./node_modules/.bin/ts-node --transpile-only -P tests/tsconfig.json tests/ipp-client.test.tsnpm run test:printernpm run test:script-coveragenpm run build && npm run build:frontendLive macOS/private/var/run/cupsdand/usr/bin/sandbox-exec(application.sbnetwork rules) verification ofippGetPrinters,ippGetDefaultPrinterName,ippGetPrinterAttributes,printViaUSB,ENOENT->ECONNREFUSEDretry fallback, and0x0506vs0x0508status handlingLive Express API + SQLite + UNIX domain socket CUPS IPP verification underMAS_BUILD=1acrossGET /api/printers/detect,POST /api/printers/:id/test,POST /api/printers/test-active,POST /api/printers/kick-drawer,POST /api/printers/print-bill,POST /api/printers/print-kot,POST /api/printers/print-delivery-slip,POST /api/printers/print-menu, andPOST /api/cash-closures/:id/printLive browser verification in Playwright ofSettings > Printers(PrintersSettingsTab.tsx) across 0 detected printers, failed/api/printers/detect(HTTP 500), missing CUPS queue (0x0406) Test Print error toast, and detectedEPSON_TM_T20IIUSB queue Test Print success✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.