@devries-cameron20 / t3code Mirror · read-only / commits / 5a0006f7ef
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 11:00 UTC

Guard all commitRename cleanup paths against concurrent renames

All exit paths in commitRename now use a thread-guarded finishRename helper that only clears renamingThreadId when it still matches the original threadId. Prevents a stale onBlur from cancelling a newly started rename on a different thread. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Julius Marminge committed Mar 2, 2026 at 13:47 UTC 5a0006f7efabb03888573a2029f1d0a30b614422
1 file changed +13 -9
apps/web/src/components/Sidebar.tsx
+13 -9
@@ -514,19 +514,27 @@ export default function Sidebar() {
514
515 const commitRename = useCallback(
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 +
525 const trimmed = newTitle.trim();
526 if (trimmed.length === 0) {
527 toastManager.add({ type: "warning", title: "Thread title cannot be empty" });
520 - cancelRename();
528 + finishRename();
529 return;
530 }
531 if (trimmed === originalTitle) {
524 - cancelRename();
532 + finishRename();
533 return;
534 }
535 const api = readNativeApi();
536 if (!api) {
529 - cancelRename();
537 + finishRename();
538 return;
539 }
540 try {
@@ -543,13 +551,9 @@ export default function Sidebar() {
551 description: error instanceof Error ? error.message : "An error occurred.",
552 });
553 }
546 - setRenamingThreadId((current) => {
547 - if (current !== threadId) return current;
548 - renamingInputRef.current = null;
549 - return null;
550 - });
554 + finishRename();
555 },
552 - [cancelRename],
556 + [],
557 );
558
559 const handleThreadContextMenu = useCallback(