Skip to content

feat: enhance manual-exec to cycle through multiple messages#124

Open
thinktanktom wants to merge 2 commits intosmartcontractkit:mainfrom
thinktanktom:feature/manual-exec-loop
Open

feat: enhance manual-exec to cycle through multiple messages#124
thinktanktom wants to merge 2 commits intosmartcontractkit:mainfrom
thinktanktom:feature/manual-exec-loop

Conversation

@thinktanktom
Copy link

Description

Closes #111

This PR enhances the manual-exec command to allow users to cycle through multiple failed CCIP messages in a single session, eliminating the need to run the command multiple times for transactions with multiple messages.

Problem

Currently, when a transaction contains multiple CCIP messages (e.g., 6 failed messages), users must run ccip manual-exec <tx> six separate times—once for each message. This is tedious and time-consuming.

Solution

Added a while(true) loop around message selection and execution that:

  • Continues after each execution, returning to the message selection menu
  • Exits cleanly when user selects the existing "Exit" option
  • Handles execution errors gracefully without crashing the loop
  • Fetches messages once before the loop for efficiency

Changes

  • Loop implementation: Wrapped message selection and execution in while(true) loop
  • Exit handling: Added try-catch to handle CCIPError thrown when user selects "Exit"
  • Error resilience: Wrapped execution in try-catch so failed executions show error and return to menu
  • Optimization: Moved getMessagesInTx() call outside loop to avoid redundant blockchain queries
  • CHANGELOG: Added entry documenting the enhancement

Testing

  • Code compiles without errors (npm run build)
  • Linting passes (npm run lint)
  • TypeScript type checking passes
  • Follows project's error handling guidelines (uses existing CCIPError infrastructure)
  • Tested with real blockchain transactions (requires testnet setup - happy to test if maintainers provide test data)

User Experience

Before:

$ ccip-cli manualExec 0xabc123...
> Select message: Message A
✓ Executed
# CLI exits - must run again

$ ccip-cli manualExec 0xabc123...  # Run again for next message
> Select message: Message B
✓ Executed
# CLI exits - must run again

# Repeat for each message...

After:

$ ccip-cli manualExec 0xabc123...
> Select message: Message A
✓ Executed

> Select message: Message B  # Automatically returns to menu
✓ Executed

> Select message: Message C  # Can continue as needed
✓ Executed

> Select message: Exit  # Exit when done
Exiting manual execution.

Implementation Notes

  • The "Exit" option was already present in the selectRequest() utility function
  • No UI changes were needed—just proper handling of the exit behavior
  • Changes are minimal and focused on control flow in manual-exec.ts
  • No modifications to shared utilities or other commands
  • Follows project's error handling guidelines (uses CCIPError, no generic Error objects)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • My changes generate no new warnings
  • I have updated the CHANGELOG.md
  • PR title follows Conventional Commits format (feat:)
  • Focused, atomic commits

Enhances manual-exec command to allow users to cycle through and execute
multiple failed CCIP messages in a single session.

Changes:
- Wrapped message selection and execution in while(true) loop
- Added exit handling when user selects 'Exit' option
- Added error handling to prevent loop crashes on execution failures
- Moved message fetching outside loop for efficiency

Closes smartcontractkit#111
@thinktanktom thinktanktom requested a review from a team as a code owner February 1, 2026 06:47
@vercel
Copy link

vercel bot commented Feb 1, 2026

@thinktanktom is attempting to deploy a commit to the Chainlink Labs Team on Vercel.

A member of the Team first needs to authorize it.

selectRequest auto-returns when only one message exists, which would
cause the loop to execute the same message repeatedly. Added check to
exit after executing single-message transactions.
@thinktanktom
Copy link
Author

Found and fixed a bug: single-message transactions would loop infinitely because selectRequest() auto-returns when only 1 message exists (no menu shown).
Although technically users can hit Ctrl+C to exit, I wanted to cover all edge cases.
Added a check to exit the loop after executing single-message transactions.

Fixed in commit: f1151f5

@thinktanktom
Copy link
Author

Optional Enhancement

While implementing this, I considered adding execution tracking to help users keep track of which messages they've already executed in the current session.

Would add:

  • Set<string> to track executed message IDs
  • Visual indicator in the menu (e.g., [✓] next to executed messages)
  • Optional warning when attempting to re-execute

I kept the initial implementation minimal, but happy to add this enhancement if it would improve the UX. Let me know what you think!

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.

Enhance CLI manual exec to cycle through multiple failed messages

1 participant