[TUI] Add bounded intraline highlighting to changed diff spans
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start in codex-rs/tui/src/diff_render.rs and inspect the proposed private module under codex-rs/tui/src/diff_render/, along with the pinned similar crate and the existing syntax-highlighting and wrapping paths. Done means replacement blocks receive bounded intraline emphasis while preserving syntax colors, wrapping, terminal fallbacks, unequal line handling, and full-line styling, with tests covering the listed cases.
Written by the indexing model from the issue text.
Description
I have traced this feature to
codex-rs/tui/src/diff_render.rsand
would be very happy to implement the feature using the approach
described below. If this proposal aligns with the intended TUI
design, would a maintainer be willing to invite a pull request in
accordance with the repository's contribution policy?
What feature would you like to see?
Codex CLI's TUI currently distinguishes added and removed lines, but
it does not emphasize the specific words or expressions that changed
within a replaced line. Highlighting those intraline changes would
make small edits within long lines substantially easier to review.
The desired presentation is that of GitHub's diff viewer or tools
such as delta: retain the
existing background for the complete added or removed line, then use
a stronger background—or another emphasis style on terminals with
limited color support—only for the changed portions.
For example, in:
- The system achieved a score of 0.80 in the final test.
+ The system achieved a score of 0.85 in the final test.
The removed 0.80 and inserted 0.85 would receive stronger
emphasis, while the rest of each line would retain its normal
deletion or insertion styling.
This is the style of intraline highlighting shown in the delta
example originally referenced in #21540:
This would be particularly helpful for:
- Function calls where one argument changed or was added.
- Long configuration or source-code lines.
- Markdown, LaTeX, and prose-oriented files.
- Changes to numbers, identifiers, strings, and command arguments.
- Reviewing agent edits directly in the TUI without switching to
another diff viewer.
The feature should preserve Codex's existing syntax highlighting,
line numbers, wrapping behavior, and full-line addition/deletion
styling. It should also degrade gracefully on ANSI-16 terminals,
where bold or underline could provide intraline emphasis without
introducing overpowering background colors.
This proposal follows the same general request as #21540 and #3090.
Both were closed because they did not receive enough upvotes, rather
than because the behavior or implementation was determined to be
undesirable. This issue provides an updated and more narrowly scoped
proposal, together with an offer to implement it if invited.
Proposed scope
For an initial implementation:
- Apply intraline highlighting automatically to replacement blocks
in unified diffs. - Keep deleted and inserted versions on separate lines, as they are
today. - Support word- or token-level matching, including Unicode text.
- Handle replacement blocks containing unequal numbers of deleted
and inserted lines. - Avoid emphasizing an entire unrelated line as an intraline change;
the existing full-line styling is sufficient in that case. - Preserve syntax foreground colors when applying stronger
intraline backgrounds. - Preserve intraline styles when long lines wrap.
- Use bounded input sizes and a short computation deadline to prevent
large or pathological diffs from slowing TUI rendering. - Avoid adding a configuration option or keyboard toggle in the
initial version.
Proposed implementation
The implementation could add a small private module under
codex-rs/tui/src/diff_render/ that scans each hunk for contiguous
deletion/insertion blocks and computes emphasized byte ranges for
those lines. The workspace already pins the Rust
similar crate, whose
optional inline and Unicode functionality can refine adjacent line
replacements into intraline changes and supports a computation
deadline. The module would return ranges aligned with the original
hunk lines, keeping the diff algorithm separate from terminal styling
and avoiding a runtime dependency on the delta executable.
The existing renderer would merge those ranges with its
syntax-highlighted spans before passing them through the current
wrapping logic. Rich-color terminals could use a stronger theme-aware
insertion or deletion background for emphasized ranges, while ANSI-16
terminals could use bold or underline. Tests would cover simple
substitutions, inserted arguments, unequal line counts, unrelated
lines, Unicode boundaries, syntax-style composition, wrapped lines,
terminal color levels, and the size/deadline fallback.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.5k
- Avg merge
- 1m
- Merged PRs (30d)
- 1k
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openai/codex
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug CLI windows-os
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
macOS sandbox blocks hw.optional.arm64 sysctl, causing Flutter to misdetect Apple Silicon as x64 Openbug CLI sandbox
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug CLI TUI
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
-
CLI config enhancement skills
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
A-linter
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
oxc-project/oxc#26863 ·