Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions components/app-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { useState, useEffect, createContext, useContext, useCallback } from 'react'
import { TaskSidebar } from '@/components/task-sidebar'
import { Task } from '@/lib/db/schema'
import { useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { Card, CardContent } from '@/components/ui/card'
import { Plus, Trash2 } from 'lucide-react'
Expand Down Expand Up @@ -107,7 +106,6 @@ export function AppLayout({ children, initialSidebarWidth, initialSidebarOpen, i
const [isResizing, setIsResizing] = useState(false)
const [isDesktop, setIsDesktop] = useState(!initialIsMobile)
const [hasMounted, setHasMounted] = useState(false)
const router = useRouter()

// Update sidebar width and save to cookie
const updateSidebarWidth = (newWidth: number) => {
Expand Down Expand Up @@ -210,14 +208,6 @@ export function AppLayout({ children, initialSidebarWidth, initialSidebarOpen, i
}
}

const handleTaskSelect = (task: Task) => {
router.push(`/tasks/${task.id}`)
// Close sidebar when navigating on mobile (don't save to cookie)
if (!isDesktop) {
updateSidebarOpen(false, false)
}
}

const addTaskOptimistically = (taskData: {
prompt: string
repoUrl: string
Expand Down Expand Up @@ -347,11 +337,7 @@ export function AppLayout({ children, initialSidebarWidth, initialSidebarOpen, i
width: `${sidebarWidth}px`,
}}
>
{isLoading ? (
<SidebarLoader width={sidebarWidth} />
) : (
<TaskSidebar tasks={tasks} onTaskSelect={handleTaskSelect} width={sidebarWidth} />
)}
{isLoading ? <SidebarLoader width={sidebarWidth} /> : <TaskSidebar tasks={tasks} width={sidebarWidth} />}
</div>
</div>

Expand Down
24 changes: 8 additions & 16 deletions components/task-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ const AGENT_MODELS = {

interface TaskSidebarProps {
tasks: Task[]
onTaskSelect: (task: Task) => void
width?: number
}

Expand All @@ -89,7 +88,7 @@ interface RepoInfo {
lastUsed: Date
}

export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarProps) {
export function TaskSidebar({ tasks, width = 288 }: TaskSidebarProps) {
const pathname = usePathname()
const { refreshTasks, toggleSidebar } = useTasks()
const session = useAtomValue(sessionAtom)
Expand All @@ -100,15 +99,8 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
const [deleteStopped, setDeleteStopped] = useState(true)
const [activeTab, setActiveTab] = useState<TabType>('tasks')

// Close sidebar on mobile when navigating
const handleNewTaskClick = () => {
if (typeof window !== 'undefined' && window.innerWidth < 1024) {
toggleSidebar()
}
}

// Close sidebar on mobile when selecting a repo
const handleRepoClick = () => {
// Close sidebar on mobile when clicking any link
const handleLinkClick = () => {
if (typeof window !== 'undefined' && window.innerWidth < 1024) {
toggleSidebar()
}
Expand Down Expand Up @@ -265,7 +257,7 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
>
<Trash2 className="h-4 w-4" />
</Button>
<Link href="/" onClick={handleNewTaskClick}>
<Link href="/" onClick={handleLinkClick}>
<Button variant="ghost" size="sm" className="h-8 w-8 p-0" title="New Task">
<Plus className="h-4 w-4" />
</Button>
Expand Down Expand Up @@ -336,7 +328,7 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
>
<Trash2 className="h-4 w-4" />
</Button>
<Link href="/" onClick={handleNewTaskClick}>
<Link href="/" onClick={handleLinkClick}>
<Button variant="ghost" size="sm" className="h-8 w-8 p-0" title="New Task">
<Plus className="h-4 w-4" />
</Button>
Expand All @@ -363,7 +355,7 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
<Link
key={task.id}
href={`/tasks/${task.id}`}
onClick={() => onTaskSelect(task)}
onClick={handleLinkClick}
className={cn('block rounded-lg', isActive && 'ring-1 ring-primary/50 ring-offset-0')}
>
<Card
Expand Down Expand Up @@ -443,7 +435,7 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
})}
{tasks.length >= 1 && (
<div className="pt-1">
<Link href="/tasks" onClick={handleNewTaskClick}>
<Link href="/tasks" onClick={handleLinkClick}>
<Button variant="ghost" size="sm" className="w-full justify-start h-7 px-2 text-xs">
View All Tasks
</Button>
Expand Down Expand Up @@ -473,7 +465,7 @@ export function TaskSidebar({ tasks, onTaskSelect, width = 288 }: TaskSidebarPro
<Link
key={`${repo.owner}/${repo.name}`}
href={repoPath}
onClick={handleRepoClick}
onClick={handleLinkClick}
className={cn('block rounded-lg', isActive && 'ring-1 ring-primary/50 ring-offset-0')}
>
<Card
Expand Down
Loading