[codex] clipboard: add Mojo desktop clipboard helpers - #1
Draft
CodeAlexx wants to merge 3 commits into
Draft
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
clipboard/package for Linux Mojo apps.wl-copy/wl-paste, X11xclip, and X11xsel.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 failedCLIPBOARD_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-> detectedxsel,16 passed, 0 failedgit diff --checkpassed