Skip to content

feat(preview): print link alongside qr code#592

Open
kannwism wants to merge 1 commit into
mainfrom
feat(preview)/print-link-alongside-qr-code
Open

feat(preview): print link alongside qr code#592
kannwism wants to merge 1 commit into
mainfrom
feat(preview)/print-link-alongside-qr-code

Conversation

@kannwism
Copy link
Copy Markdown
Contributor

Summary

When creating a job definition (or order), the SDK was printing a QR code linking to the campaign preview page but only printing the URL itself if QR rendering failed. This makes the link unreachable for anyone wanting to copy-paste it.

Now print_campaign_preview_qr prints Preview at: <url> unconditionally, with the QR code rendered below it as a convenience for opening on a phone.

Test plan

  • Create a job definition via the SDK and confirm both the URL line and the QR code appear in the terminal output
  • Confirm silent_mode still suppresses both
  • Confirm that if qrcode import or render fails, the URL is still printed (and not duplicated)

🔗 Session: ${POSEIDON_SESSION_URL:-$HOSTNAME}

Previously the preview URL was only printed when QR rendering failed.
Print it unconditionally above the QR so users can copy-paste the link
without scanning.

Co-Authored-By: RapidPoseidon <poseidon@rapidata.ai>
@claude
Copy link
Copy Markdown

claude Bot commented May 13, 2026

Code Review

Overview

This PR fixes a genuine UX bug: when QR rendering succeeded, the preview URL was never shown to the user — only a bare "Preview:" label appeared. Users on headless terminals or CI environments had no way to copy-paste the link. The change makes the URL unconditionally visible and demotes the QR code to its correct role as a convenience (phone scanning), not the primary output.


Code Quality

Positive:

  • The change is minimal and surgical — only the 3 lines that needed to move/change were touched.
  • Docstring update accurately describes the new contract.
  • logger.warning in the except block now uses proper lazy %s formatting with url as a positional arg (line 66–70), which is the correct logging pattern.
  • silent_mode guard remains effective: the early return fires before managed_print, so silent mode still suppresses both the URL and the QR code.
  • No duplicate URL printing in the failure path — the managed_print was correctly removed from the except block since it now fires unconditionally above the try.

Before / After summary:

Scenario Before After
QR renders OK "Preview:" + QR (URL hidden) "Preview at: <url>" + QR
QR fails "Preview at: <url>" only "Preview at: <url>" + warning logged
Silent mode suppressed suppressed

Suggestions

  1. Visual separation (minor): Consider a blank line between the URL and the QR block so they read as distinct elements:

    managed_print(f"Preview at: {url}")
    # existing try/except that calls qr.print_ascii(invert=True)

    If qr.print_ascii doesn't add a leading newline itself, the QR could visually run into the URL text on some terminals. A managed_print("") just before qr.print_ascii(invert=True) would help.

  2. Test plan completeness: The manual test plan covers the three cases well. There are no automated tests for this module (consistent with the existing pattern for print utilities), so this is fine — just noting it for awareness.

  3. f-string vs. % style (nit): managed_print(f"Preview at: {url}") uses an f-string while logger.warning uses %s. Not an issue — f-strings are appropriate for non-logging calls — just flagging for consistency awareness.


Verdict

The logic is correct, the diff is clean, and this is a clear improvement over the previous behaviour. The only actionable suggestion is the optional visual separator (point 1 above). Ready to merge as-is or with that minor tweak.

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