Skip to content

fix(history_forget): correct sponge delay semantics#37

Merged
eitsupi merged 1 commit intomainfrom
fix/history-forget-sponge-delay
Feb 2, 2026
Merged

fix(history_forget): correct sponge delay semantics#37
eitsupi merged 1 commit intomainfrom
fix/history-forget-sponge-delay

Conversation

@eitsupi
Copy link
Copy Markdown
Owner

@eitsupi eitsupi commented Feb 2, 2026

Summary

  • Fix history_forget (sponge) feature to match original fish sponge plugin behavior
  • delay now means "commands to advance after failure before deleting" instead of "number of failed commands to keep"
  • Add SpongeQueue struct with comprehensive tests

Test plan

  • All existing tests pass
  • New sponge tests verify correct queue behavior
  • Manual testing with experimental.history_forget.enabled = true

🤖 Generated with Claude Code

The history_forget feature (sponge) was incorrectly tracking only failed
commands. The delay setting was acting as "number of failed commands to
keep" instead of "commands to advance after failure before deleting".

Changes:
- Add SpongeQueue struct to encapsulate the queue logic
- Track ALL commands: Some(id) for failures, None for successes
- Delete failed commands only after `delay` more commands are executed
- Add comprehensive tests using the actual SpongeQueue implementation

This matches the original fish sponge plugin behavior where failed
commands remain accessible for recall until enough new commands
have been entered.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the history_forget (sponge) feature to match the behavior of fish shell's sponge plugin. The key change is in the semantics of the delay parameter: it now represents "how many subsequent commands a failed command remains accessible for" rather than "how many failed commands to keep in the queue."

Changes:

  • Introduced SpongeQueue struct to encapsulate sponge logic with clear documentation
  • Modified delay semantics: failed commands now remain accessible for delay more commands (counting both successes and failures), not just delay failed commands
  • Added comprehensive test suite with 9 test cases covering various scenarios including edge cases

Reviewed changes

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

File Description
crates/arf-console/src/repl/state.rs Added SpongeQueue struct with methods for recording commands, draining failed IDs, and checking emptiness; replaced failed_commands_queue field with sponge_queue
crates/arf-console/src/repl/mod.rs Updated initialization and cleanup to use SpongeQueue; refactored command tracking to record all commands (not just failures) with proper handling of on_exit_only mode; added comprehensive test suite

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

@eitsupi eitsupi requested a review from Copilot February 2, 2026 13:21
@eitsupi eitsupi merged commit 4cb15b2 into main Feb 2, 2026
20 checks passed
@eitsupi eitsupi deleted the fix/history-forget-sponge-delay branch February 2, 2026 13:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


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

///
/// - `failed`: whether the command failed
/// - `history_id`: the history ID of the command (if available)
/// - `delay`: how many commands to wait before deleting failed commands
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

The documentation comment for the delay field describes the old behavior ("Number of failed commands to keep before purging older ones"). This should be updated to reflect the new semantics where delay represents the number of commands to advance after a failure before deleting it.

For example, it could say: "Number of commands to execute after a failed command before deleting it from history. For example, with delay = 2, a failed command remains accessible for 2 more commands, giving users a chance to recall and fix it with up-arrow."

Suggested change
/// - `delay`: how many commands to wait before deleting failed commands
/// - `delay`: number of commands to execute after a failed command before deleting it from history.
/// For example, with `delay = 2`, a failed command remains accessible for 2 more commands,
/// giving users a chance to recall and fix it with up-arrow.

Copilot uses AI. Check for mistakes.
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.

2 participants