Add card gap and quick-create in worktree dialog (#10)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
97080fc03f
commit
a9e2b49e56
|
|
@ -15,7 +15,7 @@
|
|||
"start": "electron-vite preview",
|
||||
"dev": "electron-vite dev",
|
||||
"build": "npm run typecheck && electron-vite build",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"postinstall": "pnpm rebuild electron && electron-builder install-app-deps",
|
||||
"build:unpack": "npm run build && electron-builder --dir",
|
||||
"build:win": "npm run build && electron-builder --win",
|
||||
"build:icons": "bash icon/generate.sh",
|
||||
|
|
|
|||
|
|
@ -198,9 +198,19 @@ const AddWorktreeDialog = React.memo(function AddWorktreeDialog() {
|
|||
}
|
||||
}, [isOpen, repos.length, handleOpenChange])
|
||||
|
||||
const handleKeyDown = useCallback(
|
||||
(e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey && repoId && name.trim() && !creating) {
|
||||
e.preventDefault()
|
||||
handleCreate()
|
||||
}
|
||||
},
|
||||
[repoId, name, creating, handleCreate]
|
||||
)
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={handleOpenChange}>
|
||||
<DialogContent className="max-w-md">
|
||||
<DialogContent className="max-w-md" onKeyDown={handleKeyDown}>
|
||||
<DialogHeader>
|
||||
<DialogTitle className="text-sm">New Worktree</DialogTitle>
|
||||
<DialogDescription className="text-xs">
|
||||
|
|
|
|||
|
|
@ -144,11 +144,12 @@ const WorktreeCard = React.memo(function WorktreeCard({
|
|||
}
|
||||
}, [repo, worktree.linkedIssue, issue, fetchIssue, issueCacheKey])
|
||||
|
||||
// Stable click handler
|
||||
const handleClick = useCallback(
|
||||
() => setActiveWorktree(worktree.id),
|
||||
[worktree.id, setActiveWorktree]
|
||||
)
|
||||
// Stable click handler – ignore clicks that are really text selections
|
||||
const handleClick = useCallback(() => {
|
||||
const selection = window.getSelection()
|
||||
if (selection && selection.toString().length > 0) return
|
||||
setActiveWorktree(worktree.id)
|
||||
}, [worktree.id, setActiveWorktree])
|
||||
|
||||
const handleToggleUnreadQuick = useCallback(
|
||||
(event: React.MouseEvent<HTMLButtonElement>) => {
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ const WorktreeList = React.memo(function WorktreeList() {
|
|||
const virtualizer = useVirtualizer({
|
||||
count: rows.length,
|
||||
getScrollElement: () => scrollRef.current,
|
||||
estimateSize: (index) => (rows[index].type === 'header' ? 38 : 56),
|
||||
estimateSize: (index) => (rows[index].type === 'header' ? 38 : 56 + 4),
|
||||
overscan: 10,
|
||||
getItemKey: (index) => {
|
||||
const row = rows[index]
|
||||
|
|
@ -450,7 +450,7 @@ const WorktreeList = React.memo(function WorktreeList() {
|
|||
key={vItem.key}
|
||||
data-index={vItem.index}
|
||||
ref={virtualizer.measureElement}
|
||||
className="absolute left-0 right-0"
|
||||
className="absolute left-0 right-0 pb-1"
|
||||
style={{ transform: `translateY(${vItem.start}px)` }}
|
||||
>
|
||||
<WorktreeCard
|
||||
|
|
|
|||
Loading…
Reference in New Issue