Skip to content

93 94 95 96 contract detail improvements#157

Open
summer-0ma wants to merge 5 commits into
Tx-wat:mainfrom
summer-0ma:93-94-95-96-contract-detail-improvements
Open

93 94 95 96 contract detail improvements#157
summer-0ma wants to merge 5 commits into
Tx-wat:mainfrom
summer-0ma:93-94-95-96-contract-detail-improvements

Conversation

@summer-0ma
Copy link
Copy Markdown

Contract Detail Experience Improvements

This PR implements four focused improvements to the contract detail page and rule management experience, addressing UX, refactoring, and testing concerns.

Changes Implemented

#93: Add rule summary formatting helper

  • What: Extracted formatting logic for alert rule thresholds and function names into a reusable formatRuleSummary() helper
  • Why: Eliminates duplicate formatting code across list and detail views, ensuring consistency
  • Files:
    • lib/format.ts - New formatRuleSummary() function
    • app/contracts/[id]/page.tsx - Updated to use formatter
    • components/RuleBuilder.tsx - Updated to use formatter
  • Impact: Rule display is now consistent across all views; easier to maintain formatting logic

#94: Add cancel warning for unsaved rule edits

  • What: Added detection for unsaved changes and a confirmation modal before discarding edits
  • Why: Prevents accidental loss of rule modifications when closing the edit modal
  • Implementation:
    • hasUnsavedChanges() function compares current edits with saved rules
    • Modal appears only when user attempts to cancel with unsaved changes
    • Users can choose to keep editing or confirm discard
  • Files: app/contracts/[id]/page.tsx
  • Impact: Better UX with data loss prevention

#95: Add focused empty state when contract lookup fails

  • What: Replaced immediate redirect with a friendly, informative empty state UI
  • Why: Provides better UX when a contract is missing or deleted; gives users a clear recovery path
  • Implementation:
    • Shows "Contract Not Found" message with explanation
    • Provides "Back to Contracts" button for navigation
    • Maintains loading state until contract lookup completes
  • Files: app/contracts/[id]/page.tsx
  • Impact: Improved error handling and user guidance

#96: Add contract details page tests

  • What: Comprehensive test suite covering delete flow, rule editing, missing contract behavior, and metadata rendering
  • Why: Ensures reliability of contract detail page functionality and prevents regressions
  • Test Coverage:
    • Rule summary formatting with all rule types (LargeTransfer, FunctionCalled, AdminFunctionCalled, AnyTransaction, TransactionFailed)
    • Metadata rendering (contract info, webhook URL, alert count)
    • Missing contract empty state and navigation
    • Delete confirmation flow
    • Rule editing and unsaved changes detection
    • Alert history display
  • Files:
    • __tests__/ContractDetail.test.tsx - New test suite (7 tests, all passing)
    • vitest.config.ts - Enabled globals for test compatibility
  • Impact: 7 new tests with 100% pass rate; improved code reliability

Testing

All changes have been tested:

  • ✅ New test suite passes (7/7 tests)
  • ✅ TypeScript compilation passes with no errors
  • ✅ No new linting errors introduced in modified files
  • ✅ Existing functionality preserved

Files Modified

  • lib/format.ts - Added formatRuleSummary() helper
  • app/contracts/[id]/page.tsx - Implemented all UX improvements and empty state
  • components/RuleBuilder.tsx - Updated to use formatting helper
  • __tests__/ContractDetail.test.tsx - New comprehensive test suite
  • vitest.config.ts - Enabled test globals

Closes

Closes #93
Closes #94
Closes #95
Closes #96

- Extract formatting logic for thresholds and function names into formatRuleSummary()
- Use consistent formatting across list and detail views
- Simplify rule display in contract detail page and RuleBuilder
- Detect unsaved changes when closing edit modal
- Show confirmation dialog before discarding changes
- Allow users to keep editing or confirm discard
- Show friendly error message instead of immediate redirect
- Provide button to navigate back to contracts list
- Improve UX for missing or deleted contracts
- Add comprehensive tests for formatRuleSummary helper
- Cover delete flow, rule editing, missing contract behavior
- Test metadata rendering and alert history display
- Enable vitest globals for test compatibility
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@summer-0ma 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant