fix: 🐞 Bug: Model is deleted when renaming, then pressing Ctrl-C#228
Merged
sammcj merged 2 commits intosammcj:mainfrom Dec 29, 2025
Merged
Conversation
When a user pressed Ctrl-C during a rename operation, the model would be deleted. This happened because Ctrl-C was treated the same as Enter, causing the (partial) rename to proceed and delete the original model. This fix: - Adds a 'cancelled' flag to textInputModel to track cancellation - Returns the old name when Ctrl-C or Esc is pressed - Handles cancellation in handleRenameModelKey and handleCopyModelKey - Updates the UI hint to show both cancel options Fixes sammcj#227 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: majiayu000 <1835304752@qq.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #227 where models were being deleted when users pressed Ctrl-C during a rename operation. The fix introduces a cancelled flag to explicitly track cancellation events and separates the handling of Ctrl-C/Esc from the Enter key.
Key Changes
- Added cancellation tracking in the text input model to distinguish between user cancellation (Ctrl-C/Esc) and confirmation (Enter)
- Modified rename and copy operations to detect and handle cancellation by checking if the returned name equals the original name
- Updated UI text to indicate both Esc and Ctrl-C can cancel the operation
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| text_input.go | Added cancelled boolean field and separated key handling for Ctrl-C/Esc from Enter, returning old name when cancelled |
| app_model.go | Added checks for cancellation by comparing new name with old name in both rename and copy operations |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Change promptForNewName to return (string, bool) to explicitly signal cancellation - Fix ambiguity where newName == oldName couldn't distinguish between: - User cancelled (Ctrl-C/Esc) - User intentionally kept the same name (Tab + Enter) - Remove unreachable empty name check (was dead code) - For copy: require different name, show error if same name - For rename: allow same name gracefully with "Name unchanged" message Addresses review feedback from GitHub Copilot on PR sammcj#228 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
|
Happy to help |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes #227
Changes
app_model.gotext_input.go