Skip to content

feat(tui): Implement Ratatui State Inspector Widget for TUI Debugger (#485) - #499

Merged
codeZe-us merged 2 commits into
Toolbox-Lab:mainfrom
olatecki:feat/485-ratatui-state-inspector-widget
Oct 25, 2026
Merged

codeZe-us merged 2 commits into
Toolbox-Lab:mainfrom
olatecki:feat/485-ratatui-state-inspector-widget

Conversation

@olatecki

Copy link
Copy Markdown

Description

Implements the
ender_inspector function in crates/cli/src/tui/widgets/inspector.rs, replacing the empty stub with a fully functional Ratatui Table widget that displays storage state changes for the currently selected invocation frame in the TUI debugger.

How It Was Done

  • inspector.rs: Added
    ender_inspector(frame, area, state_diff, selected, scroll) which:

    • Renders a bordered Ratatui panel titled with the selected contract/function
    • Filters out Unchanged entries and renders only meaningful diffs
    • Colour-codes rows: green for Added, red for Deleted, yellow for Modified
    • Shows \Before\ / \After\ hex values in columns with 20-char truncation
    • Displays an argument summary line above the diff table when a frame is selected
    • Clamps \scroll_offset\ so navigating past the list end never panics
    • Retains the legacy no-arg
      ender()\ stub for backward compatibility
  • state.rs: Extended \TuiState\ with:

    • \selected_invocation: Option\ — the focused trace frame
    • \state_diff: StateDiff\ — the current storage diff
    • Derived \Default\ so construction is ergonomic
  • �pp.rs: Updated \TuiState\ initialisation to include the two new fields.

Issues Encountered (If Any)

None. The existing \StateDiff, \LedgerEntryDiff, and \DiffChangeType\ types in \grat-core\ provided exactly the right data model.

Related Issue

Closes #485

How It Was Tested

Seven unit tests added directly in \inspector.rs:

Test What it checks
\ runcate_short_string\ Short strings pass through unchanged
\ runcate_long_string\ Long strings are shortened and end with \…\
\�uild_row_created_entry\ Created rows don't panic
\�uild_row_deleted_entry\ Deleted rows don't panic
\�uild_row_updated_entry\ Updated rows don't panic
\scroll_clamp\ Scroll offset is clamped to list length
\unchanged_entries_are_filtered\ Unchanged entries are excluded from the table

Screenshots / Video (If Applicable)

Widget renders as a bordered table panel:

\
┌ Inspector ─ GABC…::transfer ──────────────────────────────────────┐
│ Args: GABC…, GDEF…, 1000 │
│ Change Key Before After │
│ │
│ + Added contract_data::balance — 0000beef │
│ ~ Modified contract_data::counter 00000001 00000002 │
│ - Deleted contract_data::temp_lock deadbeef — │
└───────────────────────────────────────────────────────────────────┘
\\

- Replace empty render() stub in inspector.rs with a full Ratatui Table
  widget that displays storage diffs (StateDiff / LedgerEntryDiff) for
  the currently selected invocation frame
- Color-code rows: green for Added, red for Deleted, yellow for Modified;
  Unchanged entries are filtered out of the view
- Add scroll-offset support so long diff lists can be navigated
- Render a one-line argument summary above the diff table when an
  invocation frame is selected
- Extend TuiState with selected_invocation and state_diff fields so the
  app can pass live data to the inspector
- Update app.rs to initialise TuiState with the new fields
- Retain legacy render() no-op stub for backward compatibility
- Add unit tests for truncation, row building, scroll clamping, and
  Unchanged-entry filtering

Closes Toolbox-Lab#485
@mintlify

mintlify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 148f317.

Approve preview

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

@olatecki Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 578d9fc0-250f-402b-9cb0-ab6c9d0fd15a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@olatecki

Copy link
Copy Markdown
Author

@mergebot merge

@olatecki

Copy link
Copy Markdown
Author

please kindly merge

@codeZe-us
codeZe-us self-requested a review October 23, 2026 01:57
@codeZe-us

Copy link
Copy Markdown
Contributor

@olatecki please fix conflicts in your PR

@olatecki

olatecki commented Oct 23, 2026 via email

Copy link
Copy Markdown
Author

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@olatecki

Copy link
Copy Markdown
Author

conficts fixed please merge,thank you.

@codeZe-us

@olatecki

olatecki commented Oct 24, 2026 via email

Copy link
Copy Markdown
Author

@olatecki

Copy link
Copy Markdown
Author

please sir merge. Thank you.

@codeZe-us
codeZe-us merged commit 45a753f into Toolbox-Lab:main Oct 25, 2026
2 checks passed
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.

Implement Ratatui State Inspector Widget for TUI Debugger

2 participants