Skip to content

fix(preview): preserve words, RTF emoji and raw H.264 playback - #1901

Merged
l0gicgate merged 5 commits into
mainfrom
fix/1861-preview-document-rendering
Oct 27, 2026
Merged

l0gicgate merged 5 commits into
mainfrom
fix/1861-preview-document-rendering

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Fix all three preview problems in #1861:

  • Prefer whitespace when splitting long rendered paragraphs, preserving words, styled spans and copied text while keeping the 2 KiB limit for pathological tokens.
  • Decode RTF UTF-16 surrogate pairs with the standard decoder, retaining their style and replacing malformed units instead of silently losing text.
  • Recognize .h264 through the shared filename classifier so preview, navigation, Properties and printing agree. Reuse the existing byte-content guards and sandboxed decoder, and retain valid videos with dimensions but no reported duration in navigation.

The H.264 fast path avoids the platform MIME lookup and redundant uncertain-type query; no additional file reads or decoder implementation are introduced. Existing validation fixtures now establish playback for each keymap and scroll a long context menu before clicking Properties, without removing their assertions or pointer route.

Initial full local runs had environment-sensitive/baseline failures; the final scoped reruns pass. CI's dependency audit is currently blocked by four pre-existing advisories in the unchanged zstd dependency chain; no exceptions have been added. The exact validation history and performance limitations are recorded in #1861. Opened ready for review at the owner's request.

Visual evidence

Before:
docx-paragraph
docx-word-split-detail
odt-paragraph
rtf-emoji
h264-preview

After:
docx-paragraph
docx-word-split-detail
odt-paragraph
rtf-emoji
h264-preview

How to test

  1. Open a DOCX or ODT containing a single paragraph longer than 2 KiB and press Space. Inspect the continuation of words around the former chunk breaks.
  2. Save {\rtf1\ansi\uc1 A [\u-10179?\u-8704?] B} as emoji.rtf and preview it with an emoji-capable font.
  3. Generate two raw streams, for example with ffmpeg -f lavfi -i testsrc2=size=320x180:rate=24:duration=3 -c:v libx264 -pix_fmt yuv420p -an alpha.h264, and repeat as beta.h264. Preview one, step to the next video, and open Properties with Alt+Enter. Also check that plain text named notes.h264 still previews as text.

Expected result: ordinary words are not split across virtual rows; the RTF text is A [😀] B; both raw streams display video, participate in navigation and show source dimensions in Properties. Misnamed text is not handed to the media decoder.

Related issue

Closes #1861

Keep rendered document rows bounded at word boundaries, combine RTF UTF-16 code units through the standard decoder, and reuse shared media classification across preview callers.

Retain timestamp-less raw video in navigation and make the existing handoff and Properties fixtures establish their input preconditions explicitly.

Refs #1861
Raise zstd to 0.14.3 and regenerate the lockfile with zstd-safe 8.2.0 and zstd-sys 2.1.2. These resolve RUSTSEC-2026-0391, RUSTSEC-2026-0398, RUSTSEC-2026-0403 and RUSTSEC-2026-0410 without adding audit exceptions.

Unblock the dependency policy check for #1901; retain all other dependencies, preview changes and owner-added visual evidence.
@JoeJoeflyn

Copy link
Copy Markdown
Collaborator Author

CI dependency fix

Pushed 1469e632 (fix(deps): upgrade zstd to patched releases) to this PR:

  • zstd 0.14.0 → 0.14.3, with the direct dependency minimum raised.
  • zstd-safe 8.0.0 → 8.2.0.
  • zstd-sys 2.1.0 → 2.1.2; bundled zstd remains 1.5.7.

This resolves RUSTSEC-2026-0391, RUSTSEC-2026-0398, RUSTSEC-2026-0403 and RUSTSEC-2026-0410. Cargo regenerated Cargo.lock in the verified pinned container; all other lockfile packages and the audit policy are unchanged. No new advisory exceptions, dependencies, test skips or weakened assertions were added.

Images preserved: the PR description is byte-identical to the saved owner-edited version, all ten attachment URLs remain, and all eleven original local captures (including the MP4 control) passed SHA-256 verification. This comment does not edit the description or its image section.

Local validation

Dependency changes affect ZIP handling and Omarchy update-database decoding, so validation escalated to the complete pinned Rust and GUI selections, followed by scoped failure diagnosis only:

  • CARGO_HOME="$PWD/target/quality-container/cargo" cargo deny --locked check advisories: reproduced the four errors before the update; passed after it.
  • STRATA_QUALITY_TASK=build ./scripts/quality.sh test, then STRATA_QUALITY_TASK=shard STRATA_QUALITY_SHARD=N ./scripts/quality.sh test for N=0,1,2,3: all binaries compiled; the initial local handoff had four GUI failures, so python3 scripts/quality_ci.py verify correctly failed rather than issuing a clean receipt. Shard 1's isolated search failure stopped its main batch before execution.
  • Exact reruns of those four cases passed with the project's HeadlessDisplay/TestEnvironment in the verified pinned container. The unexecuted shard-1 batch then ran: 887 passed, 1 failed, 5 ignored. Its remaining pane-focus case also failed before this dependency update, as recorded in the earlier full-run log; unchanged-main and pre-update controls passed, and the final post-update exact rerun passed. No further full Rust run was launched. Together, the original selections and scoped completions exercised every runnable inventory entry; the initial failed handoff is not being described as a green full run.
  • The scoped helper checked the source fingerprint, compiled-binary SHA-256 and exact nonempty inventories before executing --exact --nocapture --test-threads=1. Its diagnostic files/logs remain ignored under target/1901-*; none are committed.
  • ./scripts/qa.sh: initially 608 passed, 2 failed. Both exact failures passed with ./scripts/qa.sh preview-find-navigates-content/columns-default markdown-equations-keep-prose/columns (2 passed), without scenario changes. Original failure artifacts were preserved before the scoped run.
  • ./scripts/quality.sh fmt, ./scripts/quality.sh clippy, CARGO_HOME="$PWD/target/quality-container/cargo" cargo deny --locked check, and git diff --check: clean at the final pre-push checkpoint.

CI: all executed checks are green on 1469e632 (run 40381109599): dependency/spelling policy, build/lint, all four Rust shards, the aggregate gate, release helpers and PR metadata/type policy. The GUI job is skipped by the existing PR workflow; its local results are recorded above. The dependency-audit blocker mentioned in the PR description is now resolved.

@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main at 128dcfc1c with no conflicts. main already has the zstd upgrade from #1904, so this PR's fix(deps) commit no longer changes anything: Cargo.toml and Cargo.lock are identical to main.

Review against the description and #1861

  • Whole-word splitting: confirmed. document_word_boundary moves each 2 KiB chunk end back to the last whitespace. It never returns 0, so the loop always finishes. Unbroken tokens still split at the byte limit, and the copied text joins back together exactly. There was no test that would fail without this fix, so I added one (see below).
  • RTF surrogate pairs: confirmed. A pair is decoded with the high unit's style. Text, \line and \par all emit a pending unpaired unit, and the end of the document closes the paragraph, which does the same. Covered by services::rtf::tests::unicode_surrogates_preserve_emoji_and_replace_unpaired_units. The \<newline> change, now applied only when skipped == 0, also fixes an older bug where an escaped newline inside a skipped {\*…} group ended the open paragraph.
  • Raw .h264: confirmed for preview, navigation, Properties and printing. Text or empty files named .h264 still open as text (preview_families_follow_file_bytes_not_names, preview_family_follows_bytes_when_names_disagree). Navigation keeps videos that have known dimensions but no duration (media_families_split_audio_and_video_and_skip_gifs).
  • No reviewer threads were open. The author's CI comment about the dependency audit no longer applies after the merge.

Fixes pushed

  • 6d2b8d95f test(preview): guard whole-word splitting of long rendered paragraphs. Adds services::document::tests::long_paragraphs_split_between_words, which checks ASCII prose with bold spans and CJK text separated by U+3000. It asserts that every row ends at a separator, every row is ≤ DOCUMENT_UNIT_LINE_TARGET, and the copied text joins back exactly. It fails with main's document.rs and passes with this PR.
  • ce3ed3c55 test(qa): describe the new raw H.264 and RTF scenario variants. Updates only the quality.note text.

Tests removed: none. Every added or changed test can catch a real regression. The keyboard-dispatch playback change and the Properties menu scroll set up preconditions the tests depend on; they don't weaken any assertion.

Comment audit: the PR adds two comments, the once-per-line scan in document_unit_ranges and the elementary-stream rule in entry_family. Both explain intent that isn't obvious from the code, so I kept them.

Validation

  • ./scripts/test-headless.py --lib -- services::document::tests services::rtf:: services::preview::tests adapters::local_preview::tests ui::preview::tests::video services::mime_type keyboard_dispatch::video_clips ui::browser::properties: all passed (131 in the main batch plus the isolated GTK tests)
  • ./scripts/qa.sh video-preview-badges-next-video rendered-document-word-selection media-details-properties-only (pinned container): 6 passed
  • cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings, git diff --check: clean
  • Not run: the full Rust and QA suites. The change is limited to preview classification, document chunking and RTF parsing; CI ran the full Rust suite.

Follow-ups outside this PR

  • guess_content_type now returns video/h264, which isn't registered in shared-mime-info. The list view's Type column (services::mime_type) therefore shows GLib's fallback "video/h264 type" for .h264 files instead of "Other". It's harmless but unpolished.
  • The cost entries were dropped from video-preview-badges-next-video and rendered-document-word-selection because their run labels changed. Refresh them with scripts/qa_cost.py in a later cost pass.

CI: every check passed at 04:56 UTC (the QA scenarios job is skipped by the PR workflow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview and document rendering issues from QA sweep

2 participants