Skip to content

Share one head-and-tail cutter between the dispatcher cap and bash pipes #696

Open

Description

@hakula139

Goal

Two head-and-tail cutters implement the same line-boundary rule separately. spill::cap_output cuts a String for the dispatcher cap, while render_pipe with ends_within, prefix_within, suffix_within, char_lens, and decoded_len cuts raw byte captures for bash output and predicts how long their lossy decoding will be. Decoding each captured head and tail with from_utf8_lossy before cutting, at most twice the pipe budget times three bytes per pipe, would let both paths share one string-level "keep within budget and snap to a line within LINE_SNAP_BYTES" helper and delete the decoded-length arithmetic.

Acceptance criteria

  • One helper implements the budget and LINE_SNAP_BYTES line-snapping rule for both the dispatcher cap and the bash pipes.
  • ends_within, prefix_within, suffix_within, char_lens, and decoded_len are gone.
  • The continuation-byte trimming at the head and tail seam happens before decoding, so a split character still cannot corrupt either end.
  • Every existing truncation and bash rendering test passes, with no snapshot or marker text change.
  • The pull request records the render cost of the added bounded allocation per pipe.
  • docs/design/truncation.md describes the shared rule once.

Notes

The rule and its 1 KiB window live in crates/ox-core/src/tool/spill.rs and crates/ox-core/src/tool/bash.rs. A cut beside a marker counts raw bytes its pipe dropped while the budget counts decoded bytes, so the shared helper has to keep those two notions separate.

Activity

  1. added
    enhancement
    area: tools
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: toolsenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions