Skip to content

[codex] clipboard: add Mojo desktop clipboard helpers - #1

Draft
CodeAlexx wants to merge 3 commits into
mainfrom
codex/clipboard-lib
Draft

[codex] clipboard: add Mojo desktop clipboard helpers#1
CodeAlexx wants to merge 3 commits into
mainfrom
codex/clipboard-lib

Conversation

@CodeAlexx

Copy link
Copy Markdown
Owner

What changed

  • Added a new clipboard/ package for Linux Mojo apps.
  • Implemented text clipboard read/write/clear with runtime backend detection for Wayland wl-copy/wl-paste, X11 xclip, and X11 xsel.
  • Added explicit OSC52 sequence support for terminal clipboard writes.
  • Documented the package in clipboard/README.md, updated the root README, and updated the chat UI planning doc to list clipboard copy/paste as available.

Why

Mojo apps in this repo stack needed a reusable clipboard layer for copying generated paths, prompts, logs, and selected text without app-local shell snippets.

Notes

Payload text is streamed over provider stdin/stdout via libc popen/fread/fwrite; it is not interpolated into provider command strings. The current production scope is Linux text clipboard support. macOS/Windows and rich MIME clipboard formats are not implemented.

Validation

  • pixi run --manifest-path /home/alex/mojodiffusion/pixi.toml mojo run -I . -I /home/alex/MOJO-libs /home/alex/MOJO-libs/clipboard/tests/clipboard_test.mojo -> 14 passed, 0 failed
  • CLIPBOARD_TEST_REAL=1 pixi run --manifest-path /home/alex/mojodiffusion/pixi.toml mojo run -I . -I /home/alex/MOJO-libs /home/alex/MOJO-libs/clipboard/tests/clipboard_test.mojo -> detected xsel, 16 passed, 0 failed
  • git diff --check passed

CodeAlexx and others added 3 commits June 12, 2026 01:29
…mbols + hash + diff)

New MOJO-libs lib for indexing/tracking a project tree without re-reading every
file. A snapshot captures the file tree (size+lines), a per-extension language
table, a top-level symbol map (Mojo struct/trait/def/fn, Python class/def, Rust
fn/struct/enum/trait/impl), and an FNV-1a-64 content hash per source file so two
snapshots can be diffed (added/removed/changed).

- snapshot/snapshot.mojo : FileEntry/Config/Snapshot, walk+excludes, hashing,
  symbol extraction, markdown + TSV-manifest rendering
- snapshot/diff.mojo     : parse two TSV manifests, report added/removed/changed
- snapshot/cli.mojo      : `snapshot <dir> [-o PREFIX] [--brief]` / `--diff a b`
- snapshot/tests/        : 9 pure-function units (9/9 pass)
- snapshot/README.md     : usage + API

100% Mojo + libc (std.os walk, std.ffi time, pure-Mojo string work). Binary /
files >2 MiB recorded size-only (no read) — scans a 6.6 GB tree in ~1 s.
Build from repo root with -I . ; snapshot/snapshot binary is gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… console text)

Three capture sources behind one CLI/lib:
- x11: X11 desktop (root window or --rect) -> RGB -> PNG. Verified live (matches
  xwininfo dims; PNG decodes in PIL as correct-color desktop). Xlib's opaque
  Display* segfaults across Mojo FFI, so the few Xlib calls live in a C floor
  (cshim/screen_shim.c) per the repo's "C for the gaps" pattern; Mojo drives it.
- fb: Linux framebuffer /dev/fb0 (geometry from sysfs) -> RGB -> PNG, BGRX/BGR.
- vcsa: virtual-console text grid /dev/vcsaN -> text.

PNG output reuses the image/ lib. fb/vcsa decode logic is unit-tested (4/4);
their live reads fail loud without the video/tty group.

Files: screen/{x11,framebuffer,vcsa,cli,__init__}.mojo, cshim/screen_shim.c,
tests/screen_test.mojo, README.md. Build the shim with
`gcc -shared -fPIC -O2 screen/cshim/screen_shim.c -o screen/cshim/screen_shim.so -lX11`
and run from repo root (-I .); .so + binary are gitignored.

FFI gotcha (1.0.0b1): OwnedDLHandle is destroyed ASAP (dlclose) at last use, so
the 2nd FFI call segfaults — every function ends with `_ = lib^` to hold it alive.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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