Skip to content

feat: printer profiles, access code in the config dir, both printer modes (0.5.0) - #7

Merged
Shavvimal merged 21 commits into
mainfrom
printer-profiles-0.5.0
Oct 27, 2026
Merged

Shavvimal merged 21 commits into
mainfrom
printer-profiles-0.5.0

Conversation

@Shavvimal

Copy link
Copy Markdown
Owner

Why

On 2026-10-27 the X2D went to LAN-only mode and regenerated its LAN access code. Bambu Studio's config still held the old code, shambu had nowhere to keep an IP or a code, and every read failed until Studio's config was edited by hand. The owner wants cloud mode and LAN-only mode both supported.

The spec is docs/specs/2026-10-27-printer-profiles.md; section 11 records the decisions taken after review.

What

  • Printer profiles in printers.json under the config dir ($SHAMBU_CONFIG_DIR, else $XDG_CONFIG_HOME/shambu, else ~/.config/shambu): name, serial, last IP, mode, TLS flag, dates. Never a code.
  • The access code in credentials.json (mode 0600, dir 0700) behind a Vault Protocol (FileVault, MemoryVault for tests). Not the Keychain: a Keychain write from a non-GUI session fails or prompts.
  • shambu printer login in three forms (--ip IP [--serial SERIAL], --printer NAME [--ip IP], --from-studio), one verified read before anything is written, the code from --access-code-file, --access-code-stdin or a hidden prompt. printer list, printer forget [--keep-code], --printer NAME and the code flags on every printer-reading command, --mode lan|cloud.
  • One transport for both modes: the local MQTT read is unchanged; a profile and a stored code are what make a mode switch survivable. A refused login names the code's source and the next step for the profile's mode.
  • Discovery: a subnet pass (the default-route /24 after the ARP table) in discover, in login without an IP, and for a profile without an IP; identity-checked candidates when the serial is known; the serial read from the printer's certificate for login --ip.
  • Compatibility: with no profile and no flag, every successful 0.4.0 path has the same steps, text and exit code. The exceptions are listed in the CHANGELOG (three reworded errors, printer discover, main scrubbing codes and raw serials, --printer shadowing two argparse prefixes).

Review

Codex (gpt-6-astra, high) reviewed the plan over three rounds and the code over seven: the core (conf, profiles, vault, printer) reached accept on its third round; the facade and CLI went three rounds, every finding closed, and the last round's one finding (the credential key inside the login commit) is fixed in the final commit. Every finding was folded in or dismissed with a written reason in the session record. A rubric review against REVIEW-RUBRIC.md ran per slice and once over the merged branch. All 20 rubric items pass on this branch; make check is green (1359 passed, 9 skipped); ruff format --check is clean.

Checks

  • make check, uv run ruff format --check src tests
  • rg -n '192\.168|access_code|/Users/' over the diff: only the config-key and function names
  • One publish( (the pushall); no subprocess. outside studio.py, printer.py (arp, route, ifconfig) and facade.py (open); seven documented noqa: BLE001
  • Live on this Mac: shambu printer discover found the printer through the subnet pass with nothing in the ARP table, in 2.7 s (the 27 October failure)
  • Not yet run live: shambu printer login against the X2D with the touchscreen code, then status in both modes. That is the first thing to do after merging.

Deferred (spec section 11)

printer probe, SSDP mode detection (replaced by --mode), automatic relocation after a DHCP change (one explicit login --printer NAME --ip instead), and the code_source, model and revision profile fields.

…ificate serial, subnet probe, typed read results and relocation (0.5.0 slice C)
…drop relocation and derivable profile fields; review fixes
…es, identity deadline reserve, fsync, relative config dirs ignored
…e exits for forget, masked serial kept in errors, UTC labels, no writes before validation
…est-prefix network, deadline on every pass, identity allowance, last_resolved on failure
…ment and usage line scrubbed, forget exit 3 on a failed delete, name checked first, --wait honoured, Studio import errors bounded
…sticky TLS flag documented, evals for the printer read, precise contracts
@Shavvimal
Shavvimal merged commit b8d674d into main Oct 27, 2026
5 checks passed
@Shavvimal
Shavvimal deleted the printer-profiles-0.5.0 branch October 27, 2026 14:34
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.

1 participant