Skip to content

[CDF-27845] diff_table: intra-line character-level highlighting#2971

Closed
ronpal wants to merge 17 commits into
mainfrom
cdf-27845/diff-table-char-highlight
Closed

[CDF-27845] diff_table: intra-line character-level highlighting#2971
ronpal wants to merge 17 commits into
mainfrom
cdf-27845/diff-table-char-highlight

Conversation

@ronpal
Copy link
Copy Markdown
Contributor

@ronpal ronpal commented May 1, 2026

Summary

  • Adds _highlight_diff(old_str, new_str) helper that runs a second SequenceMatcher pass at character granularity on key-matched YAML line pairs
  • Changed character spans are wrapped in [bold] so readers immediately see what changed (e.g. py**311** vs py**312**) without scanning the full line
  • Wired into the key-matched branch of the replace handler in diff_table

Stacks on top of cdf-27845/tidy-deploy-output — merge that first.

Test plan

  • Run visual tests with uv run pytest tests/test_unit/test_cdf_tk/test_commands/test_deployv2/test_diff_table.py -s -v and inspect test_field_value_changed output — changed value chars should appear bold
  • Verify no regression on insert/delete rows (no highlighting expected there)
  • Verify equal rows remain dim

🤖 Generated with Claude Code

ronpal and others added 17 commits April 30, 2026 22:22
Replace bare rich.panel.Panel usage with ToolkitPanel from ui.py,
consistent with the build v2 styling improvements. Also consolidates
three separate clean-mode panels into one with dynamic flag text.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove all expand=False (ToolkitPanel expands by default, consistent
  with build output)
- Replace bare string border colors ("green"/"yellow") with AuraColor
  constants (GREEN, AMBER) in both DeployCommand and DeployV2Command
- Add AuraColor.AMBER border to the clean-mode panel in DeployCommand

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Merge _display_startup, _display_read_dir, and _display_plan into a
single _display_setup method that prints one 'Setting up deploy'
ToolkitPanel. Wraps create_deployment_plan in try/except so failures
render an amber panel showing what was collected before re-raising.

Removes the operation_noun property from DeployOptions — all display
strings now derive directly from the operation str ('deploy'/'clean').

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Auto-wrap plain string titles in a bold Text object inside
ToolkitPanel.__init__ so callers don't need [bold]...[/] markup.
Strip those wrappers from all existing call sites in build_v2,
deploy, and deploy_v2.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wrap startup_section in Padding((0,0,1,0)) so there is a blank line
before the 'Processed build directory' section, matching the spacing
already present between that section and the Plan section.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use the same pattern as build error output: hanging_indent with icon
and marker_style instead of ToolkitTable for skipped directories,
invalid directories, invalid YAML files, and skipped resources.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The panel already shows warning count and amber border when issues are
detected. Printing them again via self.warn() after the panel prints
them twice.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add diff_table(old_lines, new_lines) to ui.py: a two-column Rich table
showing CDF (left) vs Local (right), with deleted lines in red, inserted
in green, equal lines dimmed and collapsed to '…' for large unchanged
blocks (context=2). Use it in _categorize_resources verbose output.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Set highlight=False to stop Rich converting file paths to hyperlinks.
Color the column headers red/green to make the CDF vs Local distinction
immediately obvious.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…sertions

Pairing unrelated lines side-by-side with zip_longest was misleading —
e.g. 'status: Failed' appeared next to 'functionPath: handler.py'.
Show all old lines as a delete block first, then all new lines as an
insert block, so each line gets its own row.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Swap columns so Local (desired) is on the left and CDF (current) on
the right, matching the mental model of "what I want → what's there".
Remove sort_keys=True so YAML keys appear in their natural order.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Extract the key from each YAML line in a replace block and pair lines
with the same key side-by-side (local left, CDF right). Lines with no
matching key on the other side still get their own row. Adds visual
unit tests runnable with pytest -s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
_highlight_diff runs a second SequenceMatcher pass at character granularity
on key-matched YAML line pairs, wrapping changed spans in [bold] so readers
can spot the exact value difference (e.g. py311 → py312) without scanning
the full line.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Base automatically changed from cdf-27845/tidy-deploy-output to main May 5, 2026 09:06
@ronpal ronpal closed this May 6, 2026
@ronpal
Copy link
Copy Markdown
Contributor Author

ronpal commented May 6, 2026

covered in #2984

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