Skip to content

cmd/loop: CLI session recording and replay tests#1072

Open
starius wants to merge 15 commits intolightninglabs:masterfrom
starius:cli-tests20
Open

cmd/loop: CLI session recording and replay tests#1072
starius wants to merge 15 commits intolightninglabs:masterfrom
starius:cli-tests20

Conversation

@starius
Copy link
Collaborator

@starius starius commented Feb 5, 2026

This work adds a repeatable, high-level testing path for the Loop CLI by recording real command runs and replaying them in tests. The goal is to make CLI behavior verifiable and regression-resistant without depending on a live loopd or local environment details. The recorded sessions become fixtures that exercise success and error paths across subcommands and flags, while replay ensures deterministic output checks in CI.

What changed

  • Added a session recorder that captures CLI stdin/stdout/stderr and gRPC traffic when LOOP_SESSION_RECORD=true is set.
  • Wired a pluggable gRPC transport, stdio hooks, and a test clock so recording and replay use the same code paths as normal CLI execution.
  • Normalized help output to show home paths as ~ and normalized JSON output and timestamps during replay so sessions are portable across machines.
  • Added replay tests that load fixtures, inject recorded env/stdin, replay the recorded gRPC stream, and compare outputs.
  • Recorded a broad set of CLI scenarios into cmd/loop/testdata/sessions/ and documented how to add more.

Why this approach

The CLI previously relied on manual testing or live daemons, which makes it hard to detect regressions and impossible to run in CI without complex setup. Recording/replay gives us deterministic, reproducible coverage of real behavior, including error messaging, output formatting, and gRPC request/response handling, while still exercising the production code paths.

How it works

Recording wraps the CLI process and intercepts stdio and gRPC calls, saving a JSON session file with events and metadata. Replay loads these events, supplies recorded input, and provides a recorded gRPC connection so commands run without a live daemon. Output is normalized where needed so sessions can be replayed across machines.

Testing

  • go test ./cmd/loop -v
  • To record a session: LOOP_SESSION_RECORD=true loop <command> --network regtest

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

@gemini-code-assist
Copy link

Summary of Changes

Hello @starius, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the testing infrastructure for the Loop CLI by introducing a robust session recording and replay mechanism. The primary goal is to establish a high-level, deterministic, and regression-resistant testing path that does not depend on a live loopd daemon or specific local environment details. By capturing and replaying real command executions, the CLI's behavior, including output formatting, error messaging, and gRPC interactions, can be thoroughly verified in a controlled and reproducible manner, greatly improving the reliability of future changes.

Highlights

  • CLI Session Recording: Introduced a session recorder that captures CLI stdin, stdout, stderr, and gRPC traffic when the LOOP_SESSION_RECORD=true environment variable is set. This allows for repeatable, high-level testing of the Loop CLI.
  • Pluggable Transport and I/O Hooks: Implemented a pluggable gRPC transport, standard I/O hooks, and a test clock. This ensures that both recording and replaying CLI sessions utilize the same code paths as normal CLI execution, enhancing test reliability.
  • Output Normalization: Added logic to normalize help output (e.g., home paths as ~) and JSON output/timestamps during replay. This makes recorded sessions portable and ensures deterministic output checks across different environments.
  • Comprehensive Replay Tests: Developed replay tests that load recorded session fixtures, inject environment variables and stdin, replay the recorded gRPC stream, and compare outputs. This provides robust regression resistance for CLI behavior.
  • Extensive Recorded Scenarios: A broad set of CLI scenarios have been recorded into cmd/loop/testdata/sessions/, covering various commands like terms, getinfo, quote in/out, listauth, fetchl402, getparams, setrule, suggestswaps, reservations list, instantout, listinstantouts, static withdraw/listwithdrawals/listswaps, listswaps, swapinfo, loop out, and abandonswap.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • cmd/loop/debug.go
    • Modified getDebugClient to use the new sessionTransport.Dial for gRPC connection, integrating it with the session recording/replay system.
  • cmd/loop/default_path_text_test.go
    • Added a new test file default_path_text_test.go to verify the defaultPathText function's behavior for HOME-based path elision.
  • cmd/loop/loopout.go
    • Replaced time.Now() with cliClock.Now() when setting swapDeadline to ensure deterministic timestamps in recorded sessions.
  • cmd/loop/main.go
    • Added imports for os/signal, syscall, and github.com/lightningnetwork/lnd/clock to support session recording features.
    • Updated loopDirFlag, tlsCertFlag, and macaroonPathFlag to use the new defaultPathText function for normalized help output.
    • Introduced global variables cliClock, sessionRec, and forceDeterministicJSON to manage the CLI's clock, active session recorder, and JSON output determinism.
    • Added installSessionSignalHandler to record signals and manage context cancellation during session recording.
    • Implemented defaultPathText to replace user home directories with ~ in path strings for consistent output.
    • Modified printJSON and printRespJSON to use maybeNormalizeJSON for stable JSON output across different Go versions and environments.
    • Updated the fatal error handling function to finalize the session recorder on exit.
    • Refactored the main function to initialize the sessionRecorder, hook the clock and gRPC transport, and install a signal handler if session recording is enabled.
    • Changed getClient and getClientWithConn to utilize the sessionTransport.Dial method, allowing for gRPC interception during recording/replay.
    • Added hookClock to override the CLI's time source for deterministic testing.
    • Implemented maybeNormalizeJSON to re-encode JSON output using the standard library for stable formatting.
  • cmd/loop/quote.go
    • Replaced time.Now() with cliClock.Now() when setting swapDeadline to ensure deterministic timestamps in recorded sessions.
  • cmd/loop/session_recorder.go
    • Added a new file session_recorder.go containing the sessionRecorder struct and its associated methods.
    • Implemented functionality to create and manage session files, including metadata (args, env, version, duration, error).
    • Developed logEvent to record timestamped payloads for stdout, stderr, stdin, gRPC, exit, and signal events.
    • Provided Start and stopHooks methods to attach and detach standard I/O hooks for capturing CLI interactions.
    • Implemented logExit to record the final outcome and duration of a CLI session.
    • Added Finalize to write the complete recorded session to a JSON file.
    • Included Dial, UnaryInterceptor, and StreamInterceptor methods to integrate gRPC traffic capture into the recording process.
    • Developed utility functions deriveSessionSlug, sanitizeSlug, nextSessionCounter, and parseSessionCounter for managing session file naming and numbering.
  • cmd/loop/session_recorder_test.go
    • Added a new test file session_recorder_test.go to verify the correctness of deriveSessionSlug, sanitizeSlug, and parseSessionCounter functions.
  • cmd/loop/session_replay_test.go
    • Added a new test file session_replay_test.go containing the TestRecordedSessions function to replay all recorded CLI sessions.
    • Implemented recordedSession struct and loadRecordedSessionFS/parseRecordedSession to load recorded data.
    • Developed applyEnv to set environment variables for replay and replayTransport to provide a recorded gRPC connection.
    • Created recordedClientConn and replayStream to simulate gRPC interactions based on recorded events.
    • Included compareMessageWithContext and compareJSONWithContext for detailed comparison of actual vs. recorded gRPC messages.
    • Added normalizeTimestamps to ensure consistent timestamp comparison during replay.
    • Implemented cloneCommandForReplay and related helper functions (cloneCommandStruct, cloneCommands, cloneFlagsWithGroups, cloneFlags, cloneMutuallyExclusiveFlags, cloneFlag, cloneArguments, cloneArgument, cloneStructWithExportedFields, copyExportedFields, cloneValue) to create fresh CLI command instances for each test, preventing state leakage.
  • cmd/loop/session_stdio.go
    • Added a new file session_stdio.go providing hookStdout, hookStderr, and hookStdin functions to intercept and record standard I/O streams.
    • Implemented composeWriter and chunkWriter helpers for flexible output handling and chunking.
  • cmd/loop/session_transport.go
    • Added a new file session_transport.go defining the grpcTransport interface and its directGrpcTransport implementation.
    • Introduced daemonConn interface to abstract gRPC client connection details.
    • Provided hookGrpc to dynamically switch the active gRPC transport for session recording/replay.
    • Implemented dialDirectConn as the standard method for establishing gRPC connections.
  • cmd/loop/stop.go
    • Updated waitForDaemonShutdown to accept the new daemonConn interface, making it compatible with the pluggable transport.
  • cmd/loop/swaps.go
    • Removed the cmd.IsSet("id") check in abandonSwap as the ID is now expected as a positional argument.
  • cmd/loop/testdata/sessions/AGENTS.md
    • Added a new Markdown file documenting how to record sessions, control panel HTTP server helpers, useful regtest flow observations, coverage notes, and replay stability notes.
  • cmd/loop/testdata/sessions/basic-swaps/01_loop-out.json
    • Added a new JSON fixture for a successful loop out command.
  • cmd/loop/testdata/sessions/basic-swaps/02_loop-in.json
    • Added a new JSON fixture for a successful loop in command.
  • cmd/loop/testdata/sessions/basic-swaps/03_loop-monitor.json
    • Added a new JSON fixture for the loop monitor command, including multiple swap statuses and a simulated interrupt.
  • cmd/loop/testdata/sessions/getinfo/01_loop-getinfo.json
    • Added a new JSON fixture for the loop getinfo command.
  • cmd/loop/testdata/sessions/instantout/01_loop-reservations-list.json
    • Added a new JSON fixture for listing instant out reservations.
  • cmd/loop/testdata/sessions/instantout/02_loop-instantout.json
    • Added a new JSON fixture for a successful loop instantout command using 'ALL' reservations.
  • cmd/loop/testdata/sessions/instantout/03_loop-listinstantouts.json
    • Added a new JSON fixture for listing instant outs.
  • cmd/loop/testdata/sessions/instantout/04_loop-instantout-no-confirmed.json
    • Added a new JSON fixture for loop instantout when no confirmed reservations are found.
  • cmd/loop/testdata/sessions/instantout/05_loop-instantout-cancel.json
    • Added a new JSON fixture for a canceled loop instantout command.
  • cmd/loop/testdata/sessions/instantout/06_loop-instantout-invalid-selection.json
    • Added a new JSON fixture for loop instantout with an invalid reservation selection.
  • cmd/loop/testdata/sessions/instantout/07_loop-instantout-channel.json
    • Added a new JSON fixture for loop instantout specifying a channel.
  • cmd/loop/testdata/sessions/instantout/08_loop-instantout-select-index.json
    • Added a new JSON fixture for loop instantout with a specific index selection.
  • cmd/loop/testdata/sessions/l402/01_loop-listauth.json
    • Added a new JSON fixture for listing L402 tokens.
  • cmd/loop/testdata/sessions/l402/02_loop-fetchl402.json
    • Added a new JSON fixture for fetching an L402 token.
  • cmd/loop/testdata/sessions/liquidity/01_loop-getparams.json
    • Added a new JSON fixture for getting liquidity parameters.
  • cmd/loop/testdata/sessions/liquidity/02_loop-setparams-no-flags.json
    • Added a new JSON fixture for loop setparams with no flags, resulting in an error.
  • cmd/loop/testdata/sessions/liquidity/03_loop-setparams-feepercent.json
    • Added a new JSON fixture for loop setparams with feepercent.
  • cmd/loop/testdata/sessions/liquidity/04_loop-setparams-feepercent-conflict.json
    • Added a new JSON fixture for loop setparams with conflicting feepercent and sweeplimit flags.
  • cmd/loop/testdata/sessions/liquidity/05_loop-setrule-missing-threshold.json
    • Added a new JSON fixture for loop setrule with a missing threshold, resulting in an error.
  • cmd/loop/testdata/sessions/liquidity/06_loop-setrule-no-args.json
    • Added a new JSON fixture for loop setrule with no arguments, resulting in an error.
  • cmd/loop/testdata/sessions/liquidity/07_loop-suggestswaps.json
    • Added a new JSON fixture for loop suggestswaps with no rules set, resulting in an error.
  • cmd/loop/testdata/sessions/liquidity/08_loop-setrule-success.json
    • Added a new JSON fixture for a successful loop setrule command.
  • cmd/loop/testdata/sessions/liquidity/09_loop-suggestswaps-success.json
    • Added a new JSON fixture for a successful loop suggestswaps command.
  • cmd/loop/testdata/sessions/liquidity/10_loop-setrule-incoming.json
    • Added a new JSON fixture for loop setrule with an incoming threshold.
  • cmd/loop/testdata/sessions/liquidity/11_loop-setrule-outgoing-type-in.json
    • Added a new JSON fixture for loop setrule with an outgoing threshold and type 'in', resulting in an error.
  • cmd/loop/testdata/sessions/liquidity/12_loop-setrule-clear.json
    • Added a new JSON fixture for loop setrule with the --clear flag.
  • cmd/loop/testdata/sessions/liquidity/13_loop-setparams-many-flags-error.json
    • Added a new JSON fixture for loop setparams with many flags, resulting in a sweep fee rate error.
  • cmd/loop/testdata/sessions/liquidity/14_loop-setparams-many-flags-error-minamt.json
    • Added a new JSON fixture for loop setparams with many flags, resulting in a minimum swap amount error.
  • cmd/loop/testdata/sessions/liquidity/15_loop-setparams-many-flags.json
    • Added a new JSON fixture for loop setparams with many flags, successfully setting parameters.
  • cmd/loop/testdata/sessions/liquidity/16_loop-setparams-destaddr.json
    • Added a new JSON fixture for loop setparams with a destination address.
  • cmd/loop/testdata/sessions/liquidity/17_loop-setparams-account.json
    • Added a new JSON fixture for loop setparams with an account and account address type.
  • cmd/loop/testdata/sessions/liquidity/18_loop-setparams-includeallpeers.json
    • Added a new JSON fixture for loop setparams with easyautoloop_includeallpeers.
  • cmd/loop/testdata/sessions/liquidity/19_loop-setrule-type-out.json
    • Added a new JSON fixture for loop setrule with an incoming threshold and type 'out'.
  • cmd/loop/testdata/sessions/loopin/01_loop-in-invalid-amount.json
    • Added a new JSON fixture for loop in with an invalid amount.
  • cmd/loop/testdata/sessions/loopin/02_loop-in-external-conf-target.json
    • Added a new JSON fixture for loop in with conflicting external and conf_target flags.
  • cmd/loop/testdata/sessions/loopin/03_loop-in-route-hints-private.json
    • Added a new JSON fixture for loop in with conflicting route_hints and private flags.
  • cmd/loop/testdata/sessions/loopin/04_loop-in-external-cancel.json
    • Added a new JSON fixture for a canceled external loop in.
  • cmd/loop/testdata/sessions/loopin/05_loop-in-external-verbose-cancel.json
    • Added a new JSON fixture for a verbose and canceled external loop in.
  • cmd/loop/testdata/sessions/loopin/06_loop-in-external-force.json
    • Added a new JSON fixture for a forced external loop in.
  • cmd/loop/testdata/sessions/loopout/01_loop-out.json
    • Added a new JSON fixture for a forced and fast loop out.
  • cmd/loop/testdata/sessions/loopout/02_loop-out-invalid-amount.json
    • Added a new JSON fixture for loop out with an invalid amount.
  • cmd/loop/testdata/sessions/loopout/03_loop-out-addr-account.json
    • Added a new JSON fixture for loop out with conflicting addr and account flags.
  • cmd/loop/testdata/sessions/loopout/04_loop-out-invalid-account-addr-type.json
    • Added a new JSON fixture for loop out with an invalid account address type.
  • cmd/loop/testdata/sessions/loopout/05_loop-out-amt-channel-maxfee-timeout.json
    • Added a new JSON fixture for loop out with amount, channel, max routing fee, and payment timeout flags.
  • cmd/loop/testdata/sessions/loopout/06_loop-out-addr-flag.json
    • Added a new JSON fixture for loop out with an address flag.
  • cmd/loop/testdata/sessions/loopout/07_loop-out-addr-positional.json
    • Added a new JSON fixture for loop out with a positional address argument.
  • cmd/loop/testdata/sessions/loopout/08_loop-out-account.json
    • Added a new JSON fixture for loop out with an account and account address type.
  • cmd/loop/testdata/sessions/misc/01_loop-terms.json
    • Added a new JSON fixture for the loop terms command.
  • cmd/loop/testdata/sessions/quote/01_loop-quote-out.json
    • Added a new JSON fixture for loop quote out.
  • cmd/loop/testdata/sessions/quote/02_loop-quote-in-help.json
    • Added a new JSON fixture for loop quote in --help.
  • cmd/loop/testdata/sessions/quote/03_loop-quote-out-help.json
    • Added a new JSON fixture for loop quote out --help.
  • cmd/loop/testdata/sessions/quote/04_loop-quote-in.json
    • Added a new JSON fixture for loop quote in with a deposit outpoint.
  • cmd/loop/testdata/sessions/quote/05_loop-quote-in-last-hop.json
    • Added a new JSON fixture for loop quote in with a last hop.
  • cmd/loop/testdata/sessions/quote/06_loop-quote-out-verbose.json
    • Added a new JSON fixture for a verbose loop quote out.
  • cmd/loop/testdata/sessions/quote/07_loop-quote-in-verbose.json
    • Added a new JSON fixture for a verbose loop quote in.
  • cmd/loop/testdata/sessions/static-filters/01_loop-static-listdeposits-deposited.json
    • Added a new JSON fixture for loop static listdeposits --filter deposited.
  • cmd/loop/testdata/sessions/static-filters/02_loop-static-listdeposits-withdrawing.json
    • Added a new JSON fixture for loop static listdeposits --filter withdrawing.
  • cmd/loop/testdata/sessions/static-filters/03_loop-static-listdeposits-withdrawn.json
    • Added a new JSON fixture for loop static listdeposits --filter withdrawn.
  • cmd/loop/testdata/sessions/static-filters/04_loop-static-listdeposits-looping_in.json
    • Added a new JSON fixture for loop static listdeposits --filter looping_in.
  • cmd/loop/testdata/sessions/static-filters/05_loop-static-listdeposits-looped_in.json
    • Added a new JSON fixture for loop static listdeposits --filter looped_in.
  • cmd/loop/testdata/sessions/static-filters/06_loop-static-listdeposits-publish_expired_deposit.json
    • Added a new JSON fixture for loop static listdeposits --filter publish_expired_deposit.
  • cmd/loop/testdata/sessions/static-filters/07_loop-static-listdeposits-sweep_htlc_timeout.json
    • Added a new JSON fixture for loop static listdeposits --filter sweep_htlc_timeout.
  • cmd/loop/testdata/sessions/static-filters/08_loop-static-listdeposits-htlc_timeout_swept.json
    • Added a new JSON fixture for loop static listdeposits --filter htlc_timeout_swept.
  • cmd/loop/testdata/sessions/static-filters/09_loop-static-listdeposits-wait_for_expiry_sweep.json
    • Added a new JSON fixture for loop static listdeposits --filter wait_for_expiry_sweep.
  • cmd/loop/testdata/sessions/static-filters/10_loop-static-listdeposits-expired.json
    • Added a new JSON fixture for loop static listdeposits --filter expired.
  • cmd/loop/testdata/sessions/static-filters/11_loop-static-listdeposits-failed.json
    • Added a new JSON fixture for loop static listdeposits --filter failed.
  • cmd/loop/testdata/sessions/static-loop-in/01_loop-static-new.json
    • Added a new JSON fixture for loop static new.
  • cmd/loop/testdata/sessions/static-loop-in/04_loop-static.json
    • Added a new JSON fixture for loop static (help output).
  • cmd/loop/testdata/sessions/static-loop-in/05_loop-static-listunspent.json
    • Added a new JSON fixture for loop static listunspent.
  • cmd/loop/testdata/sessions/static-loop-in/06_loop-static-l.json
    • Added a new JSON fixture for loop static l (alias for listunspent).
  • cmd/loop/testdata/sessions/static-loop-in/07_loop-static-listdeposits.json
    • Added a new JSON fixture for loop static listdeposits.
  • cmd/loop/testdata/sessions/static-loop-in/08_loop-static-listunspent.json
    • Added a new JSON fixture for loop static listunspent (with confirmations).
  • cmd/loop/testdata/sessions/static-loop-in/09_loop-static-listunspent.json
    • Added a new JSON fixture for loop static listunspent (with more confirmations).
  • cmd/loop/testdata/sessions/static-loop-in/10_loop-static-listdeposits.json
    • Added a new JSON fixture for loop static listdeposits (with a deposited item).
  • cmd/loop/testdata/sessions/static-loop-in/11_loop-static-summary.json
    • Added a new JSON fixture for loop static summary.
  • cmd/loop/testdata/sessions/static-loop-in/12_loop-static-in.json
    • Added a new JSON fixture for loop static in with an unknown quote request error.
  • cmd/loop/testdata/sessions/static-loop-in/13_loop-static-in.json
    • Added a new JSON fixture for loop static in --all with a swap amount too high error.
  • cmd/loop/testdata/sessions/static-loop-in/14_loop-static-in.json
    • Added a new JSON fixture for loop static in --help.
  • cmd/loop/testdata/sessions/static-loop-in/15_loop-static-in.json
    • Added a new JSON fixture for a successful loop static in with amount and all deposits.
  • cmd/loop/testdata/sessions/static-loop-in/16_loop-static-in-duplicate-outpoints.json
    • Added a new JSON fixture for loop static in with duplicate outpoints, resulting in an error.
  • cmd/loop/testdata/sessions/static-loop-in/17_loop-static-in-positional-low-amt.json
    • Added a new JSON fixture for loop static in with a positional low amount, resulting in an error.
  • cmd/loop/testdata/sessions/static-loop-in/18_loop-static-in-positional-payment-timeout.json
    • Added a new JSON fixture for loop static in with positional amount, payment timeout, and last hop.
  • cmd/loop/testdata/sessions/static-loop-in/19_loop-static-in-all-cancel.json
    • Added a new JSON fixture for a canceled loop static in --all command.
  • cmd/loop/testdata/sessions/static/01_loop-static-withdraw-no-selection.json
    • Added a new JSON fixture for loop static withdraw with no selection, resulting in an error.
  • cmd/loop/testdata/sessions/static/02_loop-static-listwithdrawals.json
    • Added a new JSON fixture for loop static listwithdrawals.
  • cmd/loop/testdata/sessions/static/03_loop-static-listswaps.json
    • Added a new JSON fixture for loop static listswaps.
  • cmd/loop/testdata/sessions/static/04_loop-static-withdraw-invalid-utxo.json
    • Added a new JSON fixture for loop static withdraw with an invalid UTXO format.
  • cmd/loop/testdata/sessions/static/05_loop-static-withdraw-all.json
    • Added a new JSON fixture for loop static withdraw --all.
  • cmd/loop/testdata/sessions/static/06_loop-static-withdraw-utxo-destaddr.json
    • Added a new JSON fixture for loop static withdraw with a specific UTXO and destination address.
  • cmd/loop/testdata/sessions/swaps/01_loop-listswaps.json
    • Added a new JSON fixture for loop listswaps.
  • cmd/loop/testdata/sessions/swaps/02_loop-swapinfo.json
    • Added a new JSON fixture for loop swapinfo.
  • cmd/loop/testdata/sessions/swaps/03_loop-abandonswap.json
    • Added a new JSON fixture for loop abandonswap (help output).
  • cmd/loop/testdata/sessions/swaps/04_loop-listswaps-conflicting-filters.json
    • Added a new JSON fixture for loop listswaps with conflicting filters (--loop_out_only and --loop_in_only).
  • cmd/loop/testdata/sessions/swaps/05_loop-swapinfo-invalid-id.json
    • Added a new JSON fixture for loop swapinfo with an invalid ID.
  • cmd/loop/testdata/sessions/swaps/06_loop-abandonswap-invalid-id.json
    • Added a new JSON fixture for loop abandonswap with an invalid ID.
  • cmd/loop/testdata/sessions/swaps/07_loop-listswaps-loop-out-filtered.json
    • Added a new JSON fixture for loop listswaps filtered by loop out, channel, last hop, label, start time, and max swaps.
  • cmd/loop/testdata/sessions/swaps/08_loop-listswaps-loop-in-only.json
    • Added a new JSON fixture for loop listswaps filtered by loop in only.
  • cmd/loop/testdata/sessions/swaps/09_loop-swapinfo-id-flag-parse-error.json
    • Added a new JSON fixture for loop swapinfo with an ID flag that causes a parsing error.
  • cmd/loop/testdata/sessions/swaps/10_loop-swapinfo-id-flag.json
    • Added a new JSON fixture for loop swapinfo with an ID flag, resulting in an invalid swap ID error.
  • cmd/loop/testdata/sessions/swaps/11_loop-abandonswap-success.json
    • Added a new JSON fixture for a successful loop abandonswap.
  • go.mod
    • Added github.com/google/go-cmp v0.7.0 to module dependencies.
Activity
  • The pull request introduces a new testing framework for the CLI, involving significant code additions for session recording, replay, and related utilities.
  • Numerous test data files (JSON fixtures) have been added, representing a wide range of CLI command executions and their expected outputs.
  • The core CLI logic has been modified to integrate with the new session recording and replay mechanisms, including changes to gRPC client connections and standard I/O handling.
  • The changes reflect an initial implementation phase, focusing on establishing the framework and populating it with comprehensive test cases.
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
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a comprehensive session recording and replay framework for testing the Loop CLI. This is a significant improvement that will make the CLI more robust and regression-resistant. The implementation is well-structured, abstracting away dependencies like the gRPC connection, clock, and stdio to allow for deterministic testing. The recorded test sessions are extensive and cover a wide range of commands and scenarios. The code is of high quality, and I only have one minor suggestion to improve the clarity of the replay logic.

@starius starius marked this pull request as ready for review February 5, 2026 07:02
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