Skip to content

feat: keep selected output visible with Reference Pin - #71

Open
EDToaster wants to merge 1 commit into
mainfrom
feat/reference-pin
Open

EDToaster wants to merge 1 commit into
mainfrom
feat/reference-pin

Conversation

@EDToaster

Copy link
Copy Markdown
Owner

Why this feature

Terminal output often contains something you need for the next step: an error,
a request ID, an expected value, or a command recipe. Reference Pin keeps that
text visible while you continue working, instead of requiring another trip
through scrollback or a scratch file.

I considered two other directions: a return-to-reading bookmark and persistent
token highlighting in live logs. Reference Pin is the strongest first experiment:
it supports simultaneous reference and execution, works without shell integration,
and does not depend on preserving scrollback anchors across reflow or eviction.

What changes

  • Select text and press Ctrl+Shift+P, or Cmd+Shift+P on macOS, to pin or replace it.
  • A small, nonmodal card remains at the top right while the terminal continues
    receiving input and output. Copy copies the retained snapshot; Dismiss removes it.
  • With no selection, the same shortcut dismisses the pin. With neither a selection
    nor a pin, the shortcut still reaches the application. Blank selections preserve
    the previous pin, and Escape is never repurposed.
  • One immutable, plain-text snapshot per window, kept only in memory and capped
    at 16 KiB on a grapheme boundary. The six-line preview wraps Unicode text and
    clearly distinguishes preview clipping from a capped snapshot.
  • The card scales with font/window size, hides when the window is too small,
    remains unshaded above post-processing effects, and yields to the close dialog.
  • No dependencies, shell integration, automatic execution, network access, or
    persistent storage added. The pin shortcut does not touch the clipboard;
    existing select-to-copy behavior is unchanged.

Visual proof

These are captures of the actual changed toastty binary running under Xvfb with
Vulkan llvmpipe, using synthetic data.

Before pinning, the three reference lines are part of ordinary terminal output:

Before pinning: synthetic deployment reference in the terminal

After new output has scrolled the original lines away, the reference remains
visible and the shell is still usable:

Pinned reference survives scrolling while the shell remains usable

The attached video demonstrates selection, pinning, streaming output, continued
typing, copying the snapshot, and dismissal.

reference-pin-demo.mp4
Narrow-window and Unicode check

The card shrinks to the available space, marks the clipped preview, and still
copies the full retained eight-line snapshot byte-for-byte, including CJK,
combining accents, and a ZWJ emoji.

Unicode reference at the minimum card width

Try it

Build and launch toastty, then run this inside it:

bash demos/reference-pin.sh

The demo only prints synthetic logs and waits for user input. It does not make
network calls or run deployment commands.

Validation

  • cargo test --workspace --locked --no-fail-fast: 2,564 passed, 3 ignored.
    The ignored tests are the existing live PubChem network tests.
  • cargo build --locked -p toastty: passed.
  • New tests cover shortcut modifiers/repeats/releases, blank selections,
    pin replacement/dismissal, scrollback eviction and screen switches, mouse
    capture across drags and modal dialogs, snapshot bounds, Unicode wrapping,
    geometry/hit testing, idle rendering, post-only shader frames, and restoration
    of underlying pixels after dismissal.
  • Real-app checks: select/pin, stream output, keep typing, copy exact snapshot
    through the native X11 clipboard, Unicode/preview clipping, dismiss, resize,
    font zoom, tiny-window hide/restore, and keyboard dismissal.
  • Changed Rust files pass rustfmt --check; git diff --check and
    bash -n demos/reference-pin.sh pass.
  • Scoped app/renderer Clippy runs complete with existing warnings. Repository-wide
    strict lint/format checks are not clean on the installed Rust 1.99 toolchain:
    unrelated existing warnings/formatting differences were left outside this PR.

Runtime visual testing is Linux/X11 at 1× scale. The macOS shortcut is unit-tested,
but native macOS/Wayland/HiDPI GUI behavior was not manually exercised here.

Created with Perplexity

Add an ephemeral Unicode-aware reference card with copy/dismiss actions, exact shortcut routing, paired pointer capture, and post-shader rendering support. Include input/layout/GPU regressions and a reproducible synthetic demo.

Co-authored-by: Perplexity <noreply@perplexity.ai>
@EDToaster

Copy link
Copy Markdown
Owner Author

Validation is complete for fdf24f4: Ubuntu and macOS CI both pass, alongside 2,564 passing local tests (3 existing live-network tests ignored).

The first macOS attempt stalled in the unchanged running_program_name_reports_job_started_by_interactive_shell PTY test. The same hang is present in a pre-existing main-branch run. I cancelled the stalled attempt and reran only the macOS job once; it passed without code changes or skipping tests. No unrelated PTY/test-timeout changes are included in this feature PR.

Created with Perplexity

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