Skip to content

terminal: selection highlights the background, never the glyphs (fastfetch fix) - #176

Merged
ccclosed merged 3 commits into
devfrom
fix/terminal-selection-render
Nov 22, 2026
Merged

ccclosed merged 3 commits into
devfrom
fix/terminal-selection-render

Conversation

@ccclosed

Copy link
Copy Markdown
Owner

Баг

Выделение мышью вывода fastfetch в окне pagh-terminal стирает картинку и
текст
: цветной #-логотип и цветные пары key/value становятся однотонным
тёмно-серым, полоса цветовых фонов (ANSI 40..47/100..107) — сплошным синим
прямоугольником.

Корень

rust-apps/pagh-terminal/src/render.rs::resolve_style на выделенной клетке
делал bg = theme.selection (непрозрачно) и fg = theme.selection_fg
(#232627 — ровно цвет фона темы). fastfetch рисует логотип ANSI-цветными
глифами #, а палитру — ANSI-фонами: подмена foreground в цвет фона убирает
все цвета, непрозрачный фон затирает фоновый арт. Damage/static layer ни при
чём — пока выделение активно, FrameSnapshot::damage всегда отдаёт Full
(так было и до фикса).

Фикс

  • Выделение меняет только фон: bg = bg.lerp(theme.selection, SELECTION_BG_MIX = 0.6); foreground не трогается.
  • HIDDEN/тёмная фаза BLINK пересчитываются после подсветки (fg = bg),
    чтобы скрытый текст не проявлялся.
  • Theme::selection_fg удалён (потребителей в дереве нет).
  • TERMINAL.md описывает семантику.

Тесты

  • render.rs: цвет глифов сохраняется, полнотельные блоки не затираются,
    ANSI-фоны остаются различимыми, hidden-текст остаётся скрытым.
  • tests/render_png.rs: оракул на реальном выводе fastfetch с гостя
    (tests/fixtures/fastfetch-guest.script, serial-лог qbug3) — кадр с
    выделением пиксель-в-пиксель равен кадру без выделения с
    theme.bg = подсветка во всех клетках с дефолтным фоном.
  • tests/selection_live.rs: живой e2e — настоящий композитор (host build),
    настоящий бинарник по PDP/1, настоящие press/motion/release; PNG до/после
    и пиксельные проверки.
  • Перегенерирован screenshots/03-scrollback.png (в нём есть selection).

Evidence

.cache/pagh-agent-notes/qbug4-live/ (не коммитится):
live-before.png, live-after.png — окно реального композитора до/после
протяжки: логотип, текст и цвета целы, изменился только фон подсветки;
headless-*.png — то же без chrome, включая headless-selection-OLD-BUG.png
(старый бинарник).

Гейты

  • pagh-terminal: 152 теста, 0 failed.
  • pagh-ui: 140 тестов, 0 failed.
  • rustfmt --check по затронутым файлам — чисто.
  • musl: static-pie rust-apps/out/pagh-terminal (без INTERP), pagh-ui
    собирается под x86_64-unknown-linux-musl.
  • Kernel-файлы не тронуты → 6/6 kernel-гейтов гоняет CI на push.

Координация

PR #167 (feat/term-ux-lifecycle) трогает render.rs только добавлением
Canvas::set_pixel_rgba — пересечения с resolve_style нет; при мерже #167
ветку ребейзить. Base = dev, мерж не делаю.

Selecting fastfetch output turned its '#'-logo and every coloured key/value
into one dark grey and flattened the ANSI-background palette strip: the
renderer replaced the cell foreground with theme.selection_fg (#232627,
i.e. the theme background) and painted an opaque selection background over
the cell.  On block-art logos whose glyph fills the whole cell that hides
the highlight entirely; on ANSI text it destroys the colour.

Selection must only change the background.  A selected cell background is
now a translucent wash of theme.selection over the original background,
the foreground is left byte-identical, and HIDDEN / dark-blink cells
re-derive fg from the washed background so they stay hidden.  The wash
also keeps ANSI background art readable instead of replacing it with a
solid bar.  theme.selection_fg is removed: nothing else used it.

The fastfetch regression is covered by pixel tests (glyph colours,
full-block art, ANSI backgrounds) and by an oracle test on the guest's own
fastfetch stream: a selected frame must equal an unselected frame rendered
with theme.bg = highlight in every default-background cell.  The committed
selection screenshot (03-scrollback) is regenerated.

Without this, a text selection destroys the very content it selects.
The renderer unit test proves the pixel rule in isolation; this e2e drives
the real path a user hits: the real pagh-desktop compositor on 1280x800,
the real pagh-terminal binary over AF_UNIX/PDP/1, and real pointer
press/motion/release delivered by the compositor.  It feeds the guest's
own fastfetch byte stream, screenshots the compositor before and after the
drag, and asserts that every background pixel of the selected cells became
the translucent selection wash while glyph pixels stayed byte-identical
(no recolouring, no erased logo, no flat opaque bar).

A frame captured mid-drag or a blinking cursor must not be mistaken for
the result, so the test settles on two identical captures of the selected
region and parks the pointer outside it.  With the old selection_fg
behaviour this test fails: the selected text loses its colours.
@ccclosed
ccclosed merged commit 732bdc4 into dev Nov 22, 2026
8 checks passed
@ccclosed
ccclosed deleted the fix/terminal-selection-render branch November 22, 2026 06:35
ccclosed pushed a commit that referenced this pull request Nov 22, 2026
Sync with dev=c1e80933 (#147/#175/#176/#178: console grid from real
framebuffer, scrollback/selection, rubberband fullscreen, os-identity,
docs).

Conflict: src/test.rs only — both sides appended routines/modules at the
same two places. Resolution keeps BOTH:
- dev qbug2 "console::text grid matches the framebuffer resolution"
  (console_grid_tests) and the USB "usb::BOT/SCSI/uevent layouts and
  /usb root rule" (usb_storage_prop_tests);
- both modules are present and closed; all_tests registers 126 routines.

All USB S1 files are untouched by these dev changes, and the dev
framebuffer/console/scrollback/selection/os-identity work is preserved
verbatim. AGENTS.md auto-merged and keeps the USB S1 gap text.

Post-merge evidence: gates 6/6 (host 885/0), QEMU usb-storage acceptance
46/46, release-kernel selftest 126 routines / 0 failed / 1 skipped
(NVMe absent), in one flocked run.
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