Skip to content

os/mini: the console can open the web app - a clickable link, and a QR code to scan - #600

Merged
bong-water-water-bong merged 4 commits into
mainfrom
1bit/os-menu-qr
Oct 26, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
1bit/os-menu-qr

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Addendum to the TTUI brief (owner, looking at c10's menu over JetKVM): "you need to make the link for
the url clickable also"
. A video console cannot be clicked, so this does both halves, one PR.

1. OSC 8 hyperlinks (terminal)

The Web app and API URLs in the header are wrapped in
\033]8;;<url>\033\\<url>\033]8;;\033\\, which a modern terminal renders as a clickable link: ssh from
any terminal app, the serial console inside one. Guarded on TERM: the VT reports TERM=linux and the
escape is never sent, so the raw console shows the URL as plain text rather than stray characters.

2. A QR code (physical console)

u, or menu entry 8 Phone, draws the web app URL with qrencode -t ANSIUTF8 - half blocks, two QR
rows per text row in an 8x16 console font, so this URL's 29x29 modules with their margin are 17 text rows
and fit an 80x25 screen. The URL is printed under it (still a link where the terminal supports it), and
a switches to -t ASCII for a console font without the block glyphs, with a note when that form needs a
taller screen than the console has. The header carries the hint: On a phone press u.

How qrencode ships

libqrencode 4.1.1 (LGPL-2.1-or-later), the route Dropbear and mtools already take: mkimage.sh adds
qrencode + libqrencode4 to tool_debs, unpacks the two Ubuntu .debs into
~/.cache/1bit-os/tools/x on first use (the guard now also checks $tools/usr/bin/qrencode, so a
populated cache re-unpacks), copies /usr/bin/qrencode to /bin/qrencode, and resolves what it links
with ldd under that tree - libqrencode.so.4 from the package plus libpng16/libz/libm/libc,
which the image already carries or takes from Ubuntu.

Licences: os/licenses/qrencode/LICENSE (LGPL-2.1 text) and SOURCE (project, release, packaging route,
why it ships), copied into /usr/share/licenses/1bit-os/qrencode/ beside ryzenadj's; each package's
/usr/share/doc/<pkg>/copyright goes into the image exactly as Dropbear's does (they are unpacked, not
dpkg-installed, so packages.txt cannot name them); os/LICENSES.md has the Ubuntu-table row.

Kept from main

Rebased on 73d6008; #595 (web app URL first, the up/starting probe, the API line under it) and
#582/#593/#596 are all intact - the header keeps #595's structure and wording, with both URLs wrapped
and the new hint line between them. (#595's API line still wraps at 80 columns because of its
key: grep ... tail; left as written.)

Proof (ryzen; no GPU, no box)

  • bash -n, sh -n, busybox sh -n, dash -n clean on the menu and mkimage.sh.
  • 80x25 tmux pane, TERM=xterm-256color, the staged qrencode (/bin/qrencode + its own
    libqrencode.so.4, nothing installed on the host), a local HTTP server on 13305 so the probe says
    up:
    • Web app and API both carry the OSC 8 sequence (2 in the header);
    • u draws the code, entry 8 draws it again, a toggles ASCII, any key returns to the menu;
  • the same pane with TERM=linux: zero OSC 8 sequences, URLs as plain text, QR unaffected;
  • the code the menu draws is the URL: the half-block rows captured from the pane, turned back into a
    module matrix, are identical to qrencode -t ASCII's matrix for the same URL (0 differing modules of
    725), and zbarimg reads that matrix as http://192.168.50.100:13305/;
  • the mkimage staging snippet run against the unpacked .debs: /bin/qrencode plus libqrencode.so.4,
    libpng16, libz, libm, libc land, and that copy runs with LD_LIBRARY_PATH at the staged tree
    only (~150 KB new: qrencode + libqrencode; libpng/zlib/libc are already in the image);
  • init.sh is untouched here; its pty proof (13 checks: SIGKILL + stty sane, Ctrl-C restart, q to
    the plain shell, os: a usable console - kernel messages off the shell, a visible prompt #582's PS1) still passes with the new frames.

One bug found on the way: the QR screen's hint passed three arguments to a two-%s printf, which a
POSIX printf repeats - it printed a second, garbled hint line under the code. Caught on the pane, fixed
before hardware.

Co-Authored-By: Claude Fable 5.1 [email protected]

…R code to scan

The owner, looking at c10's menu over JetKVM: "you need to make the link for the url clickable also".
A video console cannot be clicked, so this does both halves (addendum to the TTUI brief):

1. OSC 8 hyperlinks. The Address in the header is now wrapped in
   `\033]8;;<url>\033\\<url>\033]8;;\033\\`, which any modern terminal (ssh, a serial console in a
   terminal app) renders as a clickable link. It is guarded on TERM: the VT reports TERM=linux and
   never sees the escape, so the raw console shows the URL as plain text instead of stray characters.
2. A QR code on the physical console. `u`, or menu entry 8 "Phone", draws the web app URL with
   `qrencode -t ANSIUTF8` (half blocks: this URL's 29x29 modules with margin come to 17 text rows and
   fit an 80x25 screen), the URL underneath (still a link where the terminal supports it), and `a`
   switches to `-t ASCII` for a console font without the block glyphs - with a note when that form
   needs a taller screen than the console has. The header carries the hint: "On a phone   press u".

qrencode ships with the image: libqrencode 4.1.1 (LGPL-2.1-or-later). It rides the path Dropbear and
mtools already use - mkimage.sh unpacks the Ubuntu qrencode and libqrencode4 .debs into
~/.cache/1bit-os/tools/x on first use, copies /usr/bin/qrencode to /bin/qrencode and resolves what it
links with ldd under that tree (libqrencode.so.4 from that package, plus libpng16/libz/libm/libc,
which the image already carries or takes from Ubuntu). Licences: os/licenses/qrencode/LICENSE (the
LGPL-2.1 text) and SOURCE (project, release, packaging route, why), copied into
/usr/share/licenses/1bit-os/qrencode/ with ryzenadj's; each package's own copyright file goes to
/usr/share/doc/<pkg>/copyright, exactly as Dropbear's does (they are unpacked, not dpkg-installed, so
packages.txt cannot name them); os/LICENSES.md lists them.

Proved on ryzen (no GPU, no box):
* `bash -n`, `sh -n`, `busybox sh -n`, `dash -n` clean on the menu and mkimage.sh.
* In an 80x25 tmux pane with TERM=xterm-256color and the *staged* qrencode (its own libqrencode.so.4,
  nothing installed on the host): the Address line carries the OSC 8 sequence
  (`\033]8;;http://192.168.50.100:13305\033\\...`), `u` draws the code, entry 8 does the same, `a`
  toggles ASCII, and any key returns. With TERM=linux the same pane has **zero** OSC 8 sequences and
  the URL as plain text.
* The console-drawn code is the URL: the half-block rows as captured from the pane, turned back into a
  module matrix, are identical to `qrencode -t ASCII`'s matrix for the same URL (0 differing modules
  of 725), and `zbarimg` on that matrix rendered as an image reads
  `http://192.168.50.100:13305`.
* The mkimage staging snippet was run against the unpacked .debs: /bin/qrencode lands with
  libqrencode.so.4, libpng16, libz, libm, libc, and that copy runs with LD_LIBRARY_PATH pointed at the
  staged tree only.
* init.sh's restart loop is untouched; its pty proof (13 checks: crash/stty sane, Ctrl-C, q, and
  #582's PS1) still passes with the new frames.

Also fixed while proving: the QR screen's hint line passed three arguments to a two-`%s` printf, which
a POSIX printf repeats - it printed a second, garbled line under the code. Caught on the pane before
it ever reached hardware.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit eff9e36)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

595 - Partially compliant

Compliant requirements:

  • The web app URL is displayed in the console header
  • The status ("up" or "starting") is shown next to the URL
  • The URL is wrapped in OSC 8 escape sequences for clickable links in supported terminals

Non-compliant requirements:

  • None

Requires further human verification:

  • None

582 - Partially compliant

Compliant requirements:

  • Kernel messages are suppressed after system boot
  • Console level is set to emergencies only
  • The prompt is set to 1bit-os:\w # in /etc/profile

Non-compliant requirements:

  • None

Requires further human verification:

  • None

593 - Partially compliant

Compliant requirements:

  • The qrencode tool and its dependencies are added to the image
  • The tool is included in the tool_debs list in mkimage.sh
  • The probe script hwprobe.py is included and checks for missing drivers
  • The modules are added to the init's load loop

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing License File

The PR adds qrencode and libqrencode4 to the image, but the LICENSE file for qrencode is not included in the os/licenses/qrencode/ directory. The LICENSE file is present in the diff, but it's not clear if it's correctly placed or if it's the full license file. This could be a compliance issue if the license file is not properly included in the image.

mkdir -p "$doc/qrencode"
cp -a "$lic/qrencode/LICENSE" "$lic/qrencode/SOURCE" "$doc/qrencode/" 2>/dev/null || true
Potential QR Code Display Issue

The QR code display logic in act_qr function uses qrencode -t ANSIUTF8 -m 2 "$URL" and qrencode -t ASCII -m 2 "$URL" to generate QR codes. If the qrencode command fails or produces no output, the display will show a message indicating that qrencode is not in the image. However, there is no explicit check for whether the QR code generation actually produces a valid QR code, which could lead to an empty or malformed display.

act_qr() {
    facts                       # the URL, even if this screen is ever reached without a frame first
    q_mode=utf8
    while :; do
        cls
        printf '  %sOpen on your phone%s: point the camera at this code\033[K\n\n' "$BOLD" "$RESET"
        if command -v qrencode >/dev/null 2>&1; then
            if [ "$q_mode" = ascii ]; then
                qrencode -t ASCII -m 2 "$URL" 2>/dev/null | while IFS= read -r q_line; do
                    printf '%s\033[K\n' "$q_line"
                done
            else
                # ANSIUTF8 draws the light modules as white blocks and the dark ones as the black
                # background, which is a printed QR's polarity (paper light, ink dark) - the strict
                # scanner in the proof reads it, so nothing is inverted here on purpose.
                qrencode -t ANSIUTF8 -m 2 "$URL" 2>/dev/null | while IFS= read -r q_line; do
                    printf '%s\033[K\n' "$q_line"
                done
            fi
            printf '%s' "$RESET"
        else
            printf '  %sno qrencode in this image, so no code to scan here%s\033[K\n' "$GREY" "$RESET"
        fi
        printf '\n  '
        link "$URL"
        printf '%s\033[K\n' "$RESET"
        printf '\n%s  any key goes back   a = %s\033[K%s\n' "$GREY" \
            "$( [ "$q_mode" = utf8 ] && echo 'ASCII blocks instead' || echo 'half blocks instead' )" "$RESET"
        # the ASCII form is 2 characters per module: 29 rows for this URL, where the half-block form
        # needs 17. A 25-row text console cannot show all of it, so say that instead of letting it scroll.
        if [ "$q_mode" = ascii ] && [ "$ROWS" -lt 32 ]; then
            printf '%s  (ASCII needs a taller screen: %s rows, this console has %s)%s\033[K\n' \
                "$GREY" "$(qrencode -t ASCII -m 2 "$URL" 2>/dev/null | wc -l)" "$ROWS" "$RESET"
        fi
        readkey
        case "$KEY" in
            a|A) [ "$q_mode" = utf8 ] && q_mode=ascii || q_mode=utf8 ;;
            *) return ;;
        esac
    done
}

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit eff9e36

@bong-water-water-bong
bong-water-water-bong merged commit 262f509 into main Oct 26, 2026
8 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/os-menu-qr branch October 26, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant