Skip to content

fix: 🐞 Bug: Model is deleted when renaming, then pressing Ctrl-C#228

Merged
sammcj merged 2 commits intosammcj:mainfrom
majiayu000:fix-227--bug-model-is-deleted-when-renaming-then
Dec 29, 2025
Merged

fix: 🐞 Bug: Model is deleted when renaming, then pressing Ctrl-C#228
sammcj merged 2 commits intosammcj:mainfrom
majiayu000:fix-227--bug-model-is-deleted-when-renaming-then

Conversation

@majiayu000
Copy link
Copy Markdown
Contributor

Summary

This PR fixes #227

Changes

  • app_model.go
  • text_input.go

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>
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 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.

Comment thread app_model.go
Comment thread app_model.go Outdated
Comment thread app_model.go Outdated
Comment thread app_model.go
- 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>
Copy link
Copy Markdown
Owner

@sammcj sammcj left a comment

Choose a reason for hiding this comment

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

Thanks!

@sammcj sammcj merged commit 597bbf7 into sammcj:main Dec 29, 2025
4 of 5 checks passed
@majiayu000
Copy link
Copy Markdown
Contributor Author

Happy to help

@majiayu000 majiayu000 deleted the fix-227--bug-model-is-deleted-when-renaming-then branch December 29, 2025 14:32
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.

🐞 Bug: Model is deleted when renaming, then pressing Ctrl-C

3 participants