| ... | ... | @@ -514,19 +514,27 @@ export default function Sidebar() { |
| 514 | 514 | |
| 515 | 515 | const commitRename = useCallback( |
| 516 | 516 | async (threadId: ThreadId, newTitle: string, originalTitle: string) => { |
| 517 | const finishRename = () => { |
| 518 | setRenamingThreadId((current) => { |
| 519 | if (current !== threadId) return current; |
| 520 | renamingInputRef.current = null; |
| 521 | return null; |
| 522 | }); |
| 523 | }; |
| 524 | |
| 517 | 525 | const trimmed = newTitle.trim(); |
| 518 | 526 | if (trimmed.length === 0) { |
| 519 | 527 | toastManager.add({ type: "warning", title: "Thread title cannot be empty" }); |
| 520 | | cancelRename(); |
| 528 | finishRename(); |
| 521 | 529 | return; |
| 522 | 530 | } |
| 523 | 531 | if (trimmed === originalTitle) { |
| 524 | | cancelRename(); |
| 532 | finishRename(); |
| 525 | 533 | return; |
| 526 | 534 | } |
| 527 | 535 | const api = readNativeApi(); |
| 528 | 536 | if (!api) { |
| 529 | | cancelRename(); |
| 537 | finishRename(); |
| 530 | 538 | return; |
| 531 | 539 | } |
| 532 | 540 | try { |
| ... | ... | @@ -543,13 +551,9 @@ export default function Sidebar() { |
| 543 | 551 | description: error instanceof Error ? error.message : "An error occurred.", |
| 544 | 552 | }); |
| 545 | 553 | } |
| 546 | | setRenamingThreadId((current) => { |
| 547 | | if (current !== threadId) return current; |
| 548 | | renamingInputRef.current = null; |
| 549 | | return null; |
| 550 | | }); |
| 554 | finishRename(); |
| 551 | 555 | }, |
| 552 | | [cancelRename], |
| 556 | [], |
| 553 | 557 | ); |
| 554 | 558 | |
| 555 | 559 | const handleThreadContextMenu = useCallback( |