diff --git a/src/renderer/src/components/TabBar.tsx b/src/renderer/src/components/TabBar.tsx
index f6a35badc..6c6372629 100644
--- a/src/renderer/src/components/TabBar.tsx
+++ b/src/renderer/src/components/TabBar.tsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useMemo, useState } from 'react'
+import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import {
DndContext,
closestCenter,
@@ -22,6 +22,16 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger
} from '@/components/ui/dropdown-menu'
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle
+} from '@/components/ui/dialog'
+import { Button } from '@/components/ui/button'
+import { Input } from '@/components/ui/input'
import type { TerminalTab } from '../../../shared/types'
interface SortableTabProps {
@@ -80,6 +90,29 @@ function SortableTab({
}
const [menuOpen, setMenuOpen] = useState(false)
const [menuPoint, setMenuPoint] = useState({ x: 0, y: 0 })
+ const [renameOpen, setRenameOpen] = useState(false)
+ const [renameValue, setRenameValue] = useState('')
+ const renameInputRef = useRef
(null)
+
+ const handleRenameOpen = useCallback(() => {
+ setRenameValue(tab.customTitle ?? tab.title)
+ setRenameOpen(true)
+ }, [tab.customTitle, tab.title])
+
+ const handleRenameSubmit = useCallback(() => {
+ const trimmed = renameValue.trim()
+ onSetCustomTitle(tab.id, trimmed.length > 0 ? trimmed : null)
+ setRenameOpen(false)
+ }, [renameValue, onSetCustomTitle, tab.id])
+
+ useEffect(() => {
+ if (!renameOpen) return
+ const frame = requestAnimationFrame(() => {
+ renameInputRef.current?.focus()
+ renameInputRef.current?.select()
+ })
+ return () => cancelAnimationFrame(frame)
+ }, [renameOpen])
useEffect(() => {
const closeMenu = (): void => setMenuOpen(false)
@@ -181,16 +214,7 @@ function SortableTab({
Close Tabs To The Right
- {
- const next = window.prompt('Change tab title', tab.customTitle ?? tab.title)
- if (next === null) return
- const trimmed = next.trim()
- onSetCustomTitle(tab.id, trimmed.length > 0 ? trimmed : null)
- }}
- >
- Change Title
-
+ Change Title
Tab Color
@@ -223,6 +247,44 @@ function SortableTab({
+
>
)
}
diff --git a/src/renderer/src/components/sidebar/AddWorktreeDialog.tsx b/src/renderer/src/components/sidebar/AddWorktreeDialog.tsx
index 500643e88..6a5b9a917 100644
--- a/src/renderer/src/components/sidebar/AddWorktreeDialog.tsx
+++ b/src/renderer/src/components/sidebar/AddWorktreeDialog.tsx
@@ -82,6 +82,13 @@ const AddWorktreeDialog = React.memo(function AddWorktreeDialog() {
}
}, [isOpen, repos, repoId])
+ // Safety guard: creating a worktree requires at least one repo.
+ React.useEffect(() => {
+ if (isOpen && repos.length === 0) {
+ handleOpenChange(false)
+ }
+ }, [isOpen, repos.length, handleOpenChange])
+
return (