Commit 597bbf7
fix: 🐞 Bug: Model is deleted when renaming, then pressing Ctrl-C (#228)
* fix: prevent model deletion when cancelling rename with Ctrl-C or Esc
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 #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>
* fix: return explicit cancel status from promptForNewName
- 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 #228
🤖 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>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>1 parent cb1f2d8 commit 597bbf7
2 files changed
Lines changed: 33 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
688 | | - | |
689 | | - | |
690 | | - | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
691 | 695 | | |
692 | 696 | | |
693 | 697 | | |
| |||
790 | 794 | | |
791 | 795 | | |
792 | 796 | | |
793 | | - | |
794 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
795 | 801 | | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
796 | 805 | | |
797 | 806 | | |
798 | 807 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | | - | |
| 22 | + | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
| 59 | + | |
51 | 60 | | |
52 | | - | |
53 | | - | |
54 | | - | |
| 61 | + | |
| 62 | + | |
55 | 63 | | |
56 | 64 | | |
57 | | - | |
| 65 | + | |
58 | 66 | | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
65 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
66 | 78 | | |
67 | 79 | | |
68 | 80 | | |
| |||
83 | 95 | | |
84 | 96 | | |
85 | 97 | | |
86 | | - | |
| 98 | + | |
87 | 99 | | |
88 | 100 | | |
0 commit comments