Skip to content

[#7] ISSUE-006: Undo/Redo State Persistence Across Modes - #13

Merged
bonsai merged 1 commit into
mainfrom
takt/issue-7-1794481036
Nov 12, 2026
Merged

bonsai merged 1 commit into
mainfrom
takt/issue-7-1794481036

Conversation

@bonsai

@bonsai bonsai commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

Issue-006: Undo/Redo State Persistence Across Modes

Problem: The undo/redo stack doesn't properly persist or reset when switching between Normal, Insert, and Visual modes, potentially causing unexpected state.

Evidence:

  • TextBuffer::undo() and redo() operate on history and redo_stack
  • Mode changes don't trigger stack clearing or preservation
  • User might expect undo history to be mode-specific or global

Suggested Fix:

  • Clarify undo/redo semantics in documentation
  • Add mode-aware history management if needed
  • Consider user expectations for cross-mode state

Execution Report

Workflow simple-mini completed successfully.

Closes #7

Summary by Sourcery

Preserve editing history when leaving Insert or Visual mode so undo and redo remain consistent across mode changes.

Bug Fixes:

  • Preserve undo/redo state across transitions from Insert and Visual modes by recording a snapshot when returning to Normal mode.

Chores:

  • Add repository tooling ignore configuration.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Snapshot the buffer when leaving Insert or Visual mode so edits made in those modes are available to undo afterward.

  • src/app.rs L626, L661

Configuration

Add Takt-specific ignore rules to keep generated or local files out of version control.

  • .takt/.gitignore L1-25

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-12T11:16:36.062447Z
We couldn’t complete this review. Comment @codex review to try again.
90661b4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 12, 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: e21b1356-9d34-49d9-b158-632b0ff304bb
  • 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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai

sourcery-ai Bot commented Nov 12, 2026

Copy link
Copy Markdown

Linked issues

Checked at commit 90661b4

#7 ISSUE-006: Undo/Redo State Persistence Across Modes · 1 of 2 met

# Requirement Status Notes
1 Clarify undo/redo semantics in documentation ❌ Not addressed The change adds snapshots in code but does not update documentation to explain cross-mode undo/redo behavior.
2 Add mode-aware history management if needed ✅ Met Snapshots are recorded when leaving Insert or Visual mode with Esc.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/app.rs" line_range="626" />
<code_context>

         match key.code {
             KeyCode::Esc => {
+                self.buffer.snapshot();
                 self.mode = Mode::Normal;
                 self.buffer.clamp_cursor(false);
</code_context>
<issue_to_address>
**Undo skips edits and redo disappears**

When an Insert session ends after an edit, or Visual mode exits without an edit while redo history exists, the exit handlers call `snapshot()` on the current buffer, so `undo()` restores the post-edit state instead of reversing the edit; Visual-mode exits also clear `redo_stack` and add a no-op undo entry. Users see undo fail or redo history disappear.

Remove the unconditional `snapshot()` calls from both mode-exit handlers.

Also at `src/app.rs:661`.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src/app.rs:626


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src/app.rs

match key.code {
KeyCode::Esc => {
self.buffer.snapshot();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟠 High · Undo skips edits and redo disappears

When an Insert session ends after an edit, or Visual mode exits without an edit while redo history exists, the exit handlers call snapshot() on the current buffer, so undo() restores the post-edit state instead of reversing the edit; Visual-mode exits also clear redo_stack and add a no-op undo entry. Users see undo fail or redo history disappear.

Remove the unconditional snapshot() calls from both mode-exit handlers.

Also at src/app.rs:661.

Prompt for AI agents
In `src/app.rs` at line 626:

**Undo skips edits and redo disappears**

When an Insert session ends after an edit, or Visual mode exits without an edit while redo history exists, the exit handlers call `snapshot()` on the current buffer, so `undo()` restores the post-edit state instead of reversing the edit; Visual-mode exits also clear `redo_stack` and add a no-op undo entry. Users see undo fail or redo history disappear.

Remove the unconditional `snapshot()` calls from both mode-exit handlers.

Also at `src/app.rs:661`.

@bonsai
bonsai merged commit 0837c0a into main Nov 12, 2026
5 checks passed
@bonsai
bonsai deleted the takt/issue-7-1794481036 branch November 12, 2026 12:55
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.

ISSUE-006: Undo/Redo State Persistence Across Modes

1 participant