Skip to content

Add diff-style red/green highlighting to replay --corrupt - #7

Merged
DENNIS-CODES merged 1 commit into
mainfrom
claude/mpesa-cli-milestones-8enz0d
Jul 28, 2026
Merged

Add diff-style red/green highlighting to replay --corrupt#7
DENNIS-CODES merged 1 commit into
mainfrom
claude/mpesa-cli-milestones-8enz0d

Conversation

@DENNIS-CODES

Copy link
Copy Markdown
Owner

Summary

Adds the red/green diff highlighting requested — modeled after the removed/added-line highlighting style from editor diff views, applied where it's actually useful in this tool: replay --corrupt.

Before sending a corrupted payload, replay now prints a git-diff-style, line-by-line comparison of the original vs. corrupted body:

  • unchanged lines: dimmed
  • removed lines: black text on a red background
  • added/changed lines: black text on a green background
   20   "CheckoutRequestID": "ws_CO_1",
 21 -  "MerchantRequestID": "m-1",
 21 +  "MerchantRequestID": " <-- truncated by mpesa-dev replay --corrupt
 22 -  "ResultCode": 0,
 23 -  "ResultDesc": "The service request is processed successfully."

This makes it obvious at a glance exactly what --corrupt did to the payload, instead of a single "payload corrupted" line with no detail.

Test plan

  • cargo build --all-targets, cargo clippy --all-targets -- -D warnings, cargo fmt --all -- --check, cargo test all pass
  • Verified locally against a real stored callback: the diff correctly splits into an unchanged prefix (dimmed), the one line where truncation happened (old red / new green), and the fully-dropped trailing lines (red)

https://claude.ai/code/session_01BE4uE4wMaDgqN43zXvbqHH


Generated by Claude Code

Before sending a corrupted payload, replay now prints a git-diff-style
line-by-line comparison of the original vs. corrupted body: unchanged
lines dimmed, removed lines on a red background, added/changed lines on
a green background. Makes it immediately visible exactly what --corrupt
did to the payload instead of just a one-line "payload corrupted" note.

Verified locally against a real stored callback: truncation splits
cleanly into an unchanged prefix, a changed line (old red / new green),
and the fully-dropped trailing lines (red), matching the intended diff
semantics.
Copilot AI review requested due to automatic review settings July 28, 2026 16:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a clearer, diff-like visualization of how replay --corrupt modifies a stored callback payload by printing a line-by-line comparison (dimmed unchanged lines, red removed lines, green added/changed lines) before the request is sent. This improves the CLI UX by making the corruption behavior immediately observable rather than only reporting that corruption happened.

Changes:

  • Update replay to print a colored, git-diff-style comparison of original vs corrupted payload when --corrupt is used.
  • Add print_diff(original, corrupted) helper to render the line-by-line diff with terminal colors.
  • Document the new --corrupt output format and provide an example in RUNNING.md.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/commands/replay.rs Prints a colored, line-by-line original vs corrupted payload diff when replay --corrupt is used.
RUNNING.md Documents the new diff-style output for replay --corrupt with an illustrative example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DENNIS-CODES
DENNIS-CODES merged commit dfcc49a into main Jul 28, 2026
3 checks passed
DENNIS-CODES added a commit that referenced this pull request Aug 11, 2026
…enz0d

Add diff-style red/green highlighting to replay --corrupt
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.

3 participants