Repository navigation
Conversation
File > Print could only open a PDF in the system viewer. When the host lists printers, the Print page now has a Printer list (the PDF viewer first, then the system's printers) and Copies; with a printer chosen the PDF of the chosen pages goes straight to it. The desktop app lists printers with `lpstat -e` and prints with `lp -d <printer> -n <copies> -- <file>`, refusing names that could be read as options. Windows and the web keep the viewer / download path. Co-authored-by: Cursor <cursoragent@cursor.com>
9de1c54 to
632badf
Compare
FredApps
left a comment
There was a problem hiding this comment.
ReviewerA — source-read COMMENT (not an approval)
I read the head of the diff: printing lets the user choose a printer and the number of copies, through CUPS on Linux and macOS. The application runs lpstat -e to list printers and lp to print, and on Windows opens the PDF in the viewer as before. Running external commands is acceptable here if the arguments are passed as a vector (no shell) and values from the user (printer name, copies) are validated: a printer name that starts with - could be taken as an option by lp, so the name must follow -d as an argument or be checked against the list that lpstat returned; the copy count must be a bounded integer. The PDF is written to a temporary file with restricted permissions, and removed after printing. I have not run it, and no exact-head CI result exists for this head. Nothing was run.
I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.
Status: waiting_author.
aiongg
left a comment
There was a problem hiding this comment.
AI-generated review (Opus). Not a maintainer decision.
Changes needed (not certain):
On Linux and macOS, the Print page now has a Printer list and a Copies count, and the PDF goes straight to the system print spooler. Windows and the web still use the viewer and download paths. The argument handling is safe; threading and how much code is duplicated need attention.
- apps/deckcraft/src/main.rs:146-153: arguments go to lp as a vector after -d and --, option-like names are refused, and copies are clamped. This is safe against argument injection.
- crates/ui-egui/src/backstage.rs:1042-1043:
lpstat -eruns on the UI thread when the Print page first shows. -e also lists network-discovered printers and can take seconds, so the window freezes meanwhile. Listing printers on a worker would avoid that. - crates/ui-egui/src/lib.rs:836:
lpalso runs synchronously in the frame that handles the click. - The craft-libs
printcrate already lists CUPS printers and submits jobs with copies (streaming through stdin, with no temp file) and has a Windows backend. DeckCraft already depends on craft-libs, so using it would avoid a second CUPS implementation and would cover Windows. - apps/deckcraft/src/main.rs:151: the job title is always 'DeckCraft'. The presentation's title would make jobs easier to find in the queue.
- crates/ui-egui/src/lib.rs:827-828: app.print now accepts
printerandcopiesfrom the control channel. These params are not documented, and the name is not checked against the listed printers.
Claims checked:
- verified: When the host can list printers, the Print page shows a Printer list with the PDF viewer entry first, followed by the system's printers. (crates/ui-egui/src/backstage.rs:1042-1045 fetches services.printers once. backstage.rs:1061-1073 shows the ComboBox only when the list is not empty, with the vie…
- verified: Choosing a printer shows Copies (1–999). (crates/ui-egui/src/backstage.rs:1074-1079: a DragValue with range 1..=999, shown only when a printer is chosen.)
- verified: Print sends the PDF of the chosen pages straight to the chosen printer and reports 'Sent to …' or the error in the status bar, with no viewer opened. (crates/ui-egui/src/backstage.rs:1052-1058 adds printer/copies to the print_params. crates/ui-egui/src/lib.rs:827-847 strips them, runs file.export,…
- verified: On Unix, the desktop app gets the printer list from the system print spooler and submits the file to the chosen printer with a copy count and a job title. Printer names that could be read as options are refused. (apps/deckcraft/src/main.rs:123-124 fills the hooks under cfg!(unix). main.rs:135-140 r…
- verified: Windows, the web and hosts without a printer list keep the existing path. (apps/deckcraft/src/main.rs:123-124 gives None when not unix. crates/ui-egui/src/lib.rs:816-820 still downloads when pick_save is None. backstage.rs:1061 hides the list when it is empty, so direct stays false.)
- verified: docs/gaps.md notes that printer choice exists on CUPS systems. (docs/gaps.md:288-289 drops 'printer choice' from the missing list and adds that it is CUPS-only (Linux and macOS).)
Recommendation: update the pull request; it will be reviewed again.
Reviewed at 632badf.
Summary
Services::printersandServices::print_filehooks. The desktop app fills them on Unix with CUPS:lpstat -elists the printers, andlp -d <printer> -n <copies> -t DeckCraft -- <file>prints. Printer names that could be read as options are refused.No issue exists for this. It's the gaps.md "printer choice" item. There's no overlap with the open browser-print PR, which is web only.
Test plan
print_sends_the_pdf_to_a_chosen_printer(ui-egui harness): the host's printers are listed and the page starts on the viewer. With a printer and 3 copies chosen, Print hands a real PDF toprint_filewith those values and no viewer URL is openedlpstat_lines_are_printer_names: parsinglpstat -eoutput, "No destinations" gives none, and a printer name that looks like an option is refusedprint_previews_pages_and_prints_a_pdfstill passes (the viewer path)cargo xtask ci