feat(ui): dock repo and session tools in a desktop side panel

Add a docked desktop tool panel with an icon rail, driven by the shared panel URL param, and keep the mobile dialogs and drawers. Extract dialog bodies into reusable content components, rename the walkthrough dialog to a sheet, and make walkthrough generation asynchronous with client polling.
This commit is contained in:
Chris Scott committed 2026-10-07 23:58:56 -04:00
1 parent bdbcc60716
commit 485ab940aa
49 files changed
+2631 -1753

No files matched your search

+26 -8
View File
@@ -17,6 +17,9 @@ import { TerminalPanel } from "@/components/terminal/TerminalPanel"
import { PreviewPanel } from "@/components/preview/PreviewPanel"
import { ResetPermissionsDialog } from "@/components/repo/ResetPermissionsDialog"
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup"
import { ToolSidePanel } from "@/components/navigation/ToolSidePanel"
import { useMobile } from "@/hooks/useMobile"
import { useToolPanel } from "@/hooks/useToolPanel"
import { Plus } from "lucide-react"
export function AssistantRedirect() {
@@ -29,6 +32,8 @@ export function AssistantRedirect() {
const [terminalOpen, setTerminalOpen] = useTerminalDialogParam()
const [previewOpen, setPreviewOpen] = useDialogParam('preview')
const [resetPermissionsOpen, setResetPermissionsOpen] = useDialogParam('resetPermissions')
const docked = !useMobile()
const toolPanel = useToolPanel(docked)
const { data: repo, isLoading: repoLoading, error: repoError } = useQuery({
queryKey: ["repo", repoId],
@@ -48,7 +53,8 @@ export function AssistantRedirect() {
}
return (
<div className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col pb-[calc(env(safe-area-inset-bottom)+56px)] sm:pb-0">
<div className="flex h-dvh max-h-dvh min-w-0">
<div className="flex-1 min-w-0 h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col pb-[calc(env(safe-area-inset-bottom)+56px)] sm:pb-0">
<Header>
<Header.BackButton to="/" />
<Header.Title>Assistant</Header.Title>
@@ -79,11 +85,11 @@ export function AssistantRedirect() {
</div>
{assistantDirectory && (
<>
<FileBrowserSheet isOpen={fileBrowserOpen} onClose={() => setFileBrowserOpen(false)} basePath={repo?.localPath} repoName="Assistant" repoId={repoId} />
<RepoMcpDialog open={mcpDialogOpen} onOpenChange={setMcpDialogOpen} directory={assistantDirectory} />
<FileBrowserSheet isOpen={!docked && fileBrowserOpen} onClose={() => setFileBrowserOpen(false)} basePath={repo?.localPath} repoName="Assistant" repoId={repoId} />
<RepoMcpDialog open={!docked && mcpDialogOpen} onOpenChange={setMcpDialogOpen} directory={assistantDirectory} />
{assistantDirectory ? (
<RepoSkillsDialog
open={skillsDialogOpen}
open={!docked && skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
sessionId="assistant-session"
@@ -91,17 +97,29 @@ export function AssistantRedirect() {
/>
) : (
<RepoSkillsDialog
open={skillsDialogOpen}
open={!docked && skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
/>
)}
<SourceControlPanel repoId={repoId} isOpen={sourceControlOpen} onClose={() => setSourceControlOpen(false)} currentBranch={repo?.currentBranch || repo?.branch || "main"} repoName="Assistant" />
<TerminalPanel repoId={0} directory={assistantDirectory} isOpen={terminalOpen} onClose={() => setTerminalOpen(false)} />
<PreviewPanel isOpen={previewOpen} onClose={() => setPreviewOpen(false)} directory={assistantDirectory} />
<SourceControlPanel repoId={repoId} isOpen={!docked && sourceControlOpen} onClose={() => setSourceControlOpen(false)} currentBranch={repo?.currentBranch || repo?.branch || "main"} repoName="Assistant" />
<TerminalPanel repoId={0} directory={assistantDirectory} isOpen={!docked && terminalOpen} onClose={() => setTerminalOpen(false)} />
<PreviewPanel isOpen={!docked && previewOpen} onClose={() => setPreviewOpen(false)} directory={assistantDirectory} />
<ResetPermissionsDialog open={resetPermissionsOpen} onOpenChange={setResetPermissionsOpen} repoId={repoId} />
</>
)}
</div>
{docked && (
<ToolSidePanel
panel={toolPanel}
repoId={repoId}
sessionId="assistant-session"
directory={assistantDirectory}
repoDirectory={assistantDirectory}
filesBasePath={repo?.localPath}
currentBranch={repo?.currentBranch || repo?.branch || "main"}
/>
)}
</div>
)
}
+27 -8
View File
@@ -20,6 +20,9 @@ import { useSSE } from "@/hooks/useSSE";
import { useDialogParam } from "@/hooks/useDialogParam";
import { useOpenTerminal, useTerminalDialogParam, useTerminalDirectoryParam } from "@/hooks/useOpenTerminal";
import { useWorktreeTab } from "@/hooks/useWorktreeTab";
import { useMobile } from "@/hooks/useMobile";
import { useToolPanel } from "@/hooks/useToolPanel";
import { ToolSidePanel } from "@/components/navigation/ToolSidePanel";
import { WorktreeTabs } from "@/components/repo/WorktreeTabs";
import { WorktreeSessionGroups } from "@/components/repo/WorktreeSessionGroups";
import { Button } from "@/components/ui/button";
@@ -51,6 +54,8 @@ export function RepoDetail() {
const { activeTab, setActiveTab } = useWorktreeTab();
const openTerminal = useOpenTerminal();
const terminalDirectory = useTerminalDirectoryParam();
const docked = !useMobile();
const toolPanel = useToolPanel(docked);
const { data: repo, isLoading: repoLoading } = useQuery({
queryKey: ["repo", repoId],
@@ -211,8 +216,9 @@ export function RepoDetail() {
const isWorktree = repo.isWorktree || false;
return (
<div className="flex h-dvh max-h-dvh min-w-0">
<div
className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col pb-[calc(env(safe-area-inset-bottom)+56px)] sm:pb-0"
className="flex-1 min-w-0 h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col pb-[calc(env(safe-area-inset-bottom)+56px)] sm:pb-0"
>
<Header>
<div className="flex items-center gap-2 sm:gap-3 min-w-0 flex-1">
@@ -297,7 +303,7 @@ export function RepoDetail() {
/>
<FileBrowserSheet
isOpen={fileBrowserOpen}
isOpen={!docked && fileBrowserOpen}
onClose={() => setFileBrowserOpen(false)}
basePath={repo.localPath}
repoName={displayName}
@@ -306,7 +312,7 @@ export function RepoDetail() {
/>
<RepoMcpDialog
open={mcpDialogOpen}
open={!docked && mcpDialogOpen}
onOpenChange={setMcpDialogOpen}
directory={baseDirectory}
/>
@@ -314,19 +320,19 @@ export function RepoDetail() {
<RepoActionsDialog
repoId={repoId}
directory={baseDirectory}
open={actionsDialogOpen}
open={!docked && actionsDialogOpen}
onOpenChange={setActionsDialogOpen}
/>
<RepoSkillsDialog
open={skillsDialogOpen}
open={!docked && skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
/>
<SourceControlPanel
repoId={repoId}
isOpen={sourceControlOpen}
isOpen={!docked && sourceControlOpen}
onClose={() => setSourceControlOpen(false)}
currentBranch={currentBranch}
repoName={repoName}
@@ -335,12 +341,12 @@ export function RepoDetail() {
<TerminalPanel
repoId={repoId}
directory={terminalDirectory ?? baseDirectory}
isOpen={terminalOpen}
isOpen={!docked && terminalOpen}
onClose={() => setTerminalOpen(false)}
/>
<PreviewPanel
isOpen={previewOpen}
isOpen={!docked && previewOpen}
onClose={() => setPreviewOpen(false)}
directory={baseDirectory}
/>
@@ -359,6 +365,19 @@ export function RepoDetail() {
onOpenChange={setMultiRunOpen}
/>
</div>
{docked && (
<ToolSidePanel
panel={toolPanel}
repoId={repoId}
directory={baseDirectory}
terminalDirectory={terminalDirectory ?? baseDirectory}
repoDirectory={baseDirectory}
filesBasePath={repo.localPath}
allowNavigateAboveBase
currentBranch={currentBranch}
/>
)}
</div>
);
}
+10 -2
View File
@@ -8,18 +8,24 @@ import { Button } from "@/components/ui/button";
import { Plus, FolderOpen, CalendarClock } from "lucide-react";
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup";
import { useDialogParam } from "@/hooks/useDialogParam";
import { useMobile } from "@/hooks/useMobile";
import { useToolPanel } from "@/hooks/useToolPanel";
import { ToolSidePanel } from "@/components/navigation/ToolSidePanel";
export function Repos() {
const navigate = useNavigate();
const [addRepoOpen, setAddRepoOpen] = useState(false);
const [fileBrowserOpen, setFileBrowserOpen] = useDialogParam('files');
const docked = !useMobile();
const toolPanel = useToolPanel(docked);
const handleCloseFileBrowser = () => {
setFileBrowserOpen(false);
};
return (
<div className="h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col">
<div className="flex h-dvh max-h-dvh min-w-0">
<div className="flex-1 min-w-0 h-dvh max-h-dvh overflow-hidden bg-gradient-to-br from-background via-background to-background flex flex-col">
<Header>
<div className="flex items-center gap-3">
<Header.Title logo>OpenCode</Header.Title>
@@ -61,12 +67,14 @@ export function Repos() {
</div>
<AddRepoDialog open={addRepoOpen} onOpenChange={setAddRepoOpen} />
<FileBrowserSheet
isOpen={fileBrowserOpen}
isOpen={!docked && fileBrowserOpen}
onClose={handleCloseFileBrowser}
basePath=""
repoName="Workspace Root"
allowNavigateAboveBase={true}
/>
</div>
{docked && <ToolSidePanel panel={toolPanel} filesBasePath="" allowNavigateAboveBase />}
</div>
);
}
+7 -351
View File
@@ -1,136 +1,25 @@
import { useEffect, useMemo, useState } from 'react'
import { useLocation, useParams } from 'react-router-dom'
import type { CreateScheduleJobRequest, ScheduleJob, ScheduleRunWorktreesMode } from '@opencode-manager/shared/types'
import {
useAllSchedules,
useCancelRepoScheduleRun,
useClearRepoScheduleRuns,
useCreateRepoSchedule,
useDeleteRepoSchedule,
useDeleteRepoScheduleRun,
useRepoSchedule,
useRepoScheduleRuns,
useRunRepoSchedule,
useScheduleWorktrees,
useUpdateRepoSchedule,
} from '@/hooks/useSchedules'
import { useRepoActivity } from '@/hooks/useRepoActivity'
import { useScheduleTarget } from '@/hooks/useScheduleTarget'
import { useScheduleUrlState } from '@/hooks/useScheduleUrlState'
import { ScheduleJobDialog, ScheduleJobsTable, ScheduleListToolbar, JobDetailTab, RunHistoryTab, ScheduleRunRemovalDialog, ScheduleTabMenu, ScheduleRepoSwitcher } from '@/components/schedules'
import { DELETE_SCHEDULE_DESCRIPTION, matchesScheduleJobSearch, toUpdateScheduleRequest } from '@/components/schedules/schedule-utils'
import type { ScheduleJobWithRepo } from '@/api/schedules'
import { ScheduleRepoSwitcher } from '@/components/schedules'
import { RepoSchedulesContent } from '@/components/schedules/RepoSchedulesContent'
import { Header } from '@/components/ui/header'
import { Button } from '@/components/ui/button'
import { Card, CardContent } from '@/components/ui/card'
import { DeleteDialog } from '@/components/ui/delete-dialog'
import { getReturnToPath } from '@/lib/navigation'
import { CalendarClock, Loader2, Plus } from 'lucide-react'
import { Loader2, Plus } from 'lucide-react'
export function Schedules() {
const { id } = useParams<{ id: string }>()
const location = useLocation()
const repoId = id ? Number(id) : undefined
const {
scheduleTab,
setScheduleTab,
dialog,
jobId,
runId,
openNewJob,
openEditJob,
openDeleteJob,
closeDialog,
selectRun,
selectJobAndView,
selectJobAndCloseDialog,
replaceUrlParams,
} = useScheduleUrlState()
const repoScheduleTab = scheduleTab === 'prompts' ? 'jobs' : scheduleTab
const { openNewJob } = useScheduleUrlState()
const { scheduleTarget, isLoading: scheduleTargetLoading } = useScheduleTarget(repoId)
useRepoActivity(repoId ?? 0, Boolean(scheduleTarget) && scheduleTarget?.kind === 'repo')
const { data: allSchedules, isLoading: jobsLoading } = useAllSchedules()
const jobs = useMemo(
() => allSchedules?.filter((job) => job.repoId === repoId),
[allSchedules, repoId],
)
const { data: selectedJob, isFetching: isJobFetching } = useRepoSchedule(repoId, jobId)
const { data: runs, isLoading: runsLoading } = useRepoScheduleRuns(repoId, jobId, 30)
const { data: scheduleWorktrees = [] } = useScheduleWorktrees(repoId, jobId)
const createMutation = useCreateRepoSchedule()
const updateMutation = useUpdateRepoSchedule()
const deleteMutation = useDeleteRepoSchedule()
const runMutation = useRunRepoSchedule()
const cancelRunMutation = useCancelRepoScheduleRun()
const clearRunsMutation = useClearRepoScheduleRuns()
const deleteRunMutation = useDeleteRepoScheduleRun()
const [jobSearch, setJobSearch] = useState('')
const [clearRunsOpen, setClearRunsOpen] = useState(false)
const [runToDelete, setRunToDelete] = useState<number | null>(null)
const clearableRuns = useMemo(() => (runs ?? []).filter((run) => run.status !== 'running'), [runs])
const affectedClearWorktreeCount = useMemo(
() => scheduleWorktrees.filter((worktree) => worktree.runId !== null && !worktree.inUse).length,
[scheduleWorktrees],
)
const runToDeleteWorktreeCount = useMemo(
() => (runToDelete !== null && scheduleWorktrees.some((worktree) => worktree.runId === runToDelete) ? 1 : 0),
[scheduleWorktrees, runToDelete],
)
useEffect(() => {
if (scheduleTab === 'prompts') {
setScheduleTab('jobs')
}
}, [scheduleTab, setScheduleTab])
const editingJob = useMemo<ScheduleJob | undefined>(
() => (dialog === 'edit' && jobId !== null ? jobs?.find((j) => j.id === jobId) : undefined),
[dialog, jobId, jobs],
)
useEffect(() => {
if (jobs === undefined) return
if (!jobs.length) {
if (jobId !== null || scheduleTab !== 'jobs') {
replaceUrlParams((p) => {
p.delete('jobId')
p.delete('scheduleTab')
})
}
return
}
const stillExists = jobId !== null && jobs.some((job) => job.id === jobId)
if (!stillExists) {
const newId = jobs[0]?.id ?? null
if (newId !== jobId || scheduleTab !== 'jobs') {
replaceUrlParams((p) => {
if (newId === null) p.delete('jobId')
else p.set('jobId', String(newId))
p.delete('scheduleTab')
})
}
}
}, [jobs, jobId, scheduleTab, replaceUrlParams])
useEffect(() => {
if (runs === undefined) return
if (runId === null) return
if (!runs.some((run) => run.id === runId)) selectRun(null)
}, [runs, runId, selectRun])
const runningRun = useMemo(() => runs?.find((run) => run.status === 'running') ?? null, [runs])
if (scheduleTargetLoading || jobsLoading) {
if (scheduleTargetLoading) {
return (
<div className="flex items-center justify-center min-h-screen bg-background">
<Loader2 className="w-8 h-8 animate-spin text-muted-foreground" />
@@ -147,115 +36,9 @@ export function Schedules() {
</div>
)
}
const hasJobs = (jobs?.length ?? 0) > 0
const backHref = getReturnToPath(location.search, scheduleTarget.backHref)
const handleCreate = (data: CreateScheduleJobRequest) => {
createMutation.mutate({ repoId: repoId!, data }, {
onSuccess: (job) => {
selectJobAndCloseDialog(job.id)
},
})
}
const handleUpdate = (data: CreateScheduleJobRequest) => {
if (dialog !== 'edit' || jobId === null) {
return
}
updateMutation.mutate({
repoId: repoId!,
jobId,
data: toUpdateScheduleRequest(data),
}, {
onSuccess: () => {
closeDialog()
},
})
}
const handleDelete = () => {
if (dialog !== 'delete' || jobId === null) {
return
}
const deletedJobId = jobId
deleteMutation.mutate({ repoId: repoId!, jobId: deletedJobId }, {
onSuccess: () => {
closeDialog()
},
})
}
const handleToggleEnabled = (job: ScheduleJob) => {
updateMutation.mutate({
repoId: repoId!,
jobId: job.id,
data: { enabled: !job.enabled },
})
}
const handleRunNow = (job: ScheduleJob) => {
runMutation.mutate({ repoId: repoId!, jobId: job.id }, {
onSuccess: (run) => {
selectRun(run.id)
},
})
}
const handleCancelRun = () => {
const target = runId !== null ? runs?.find((run) => run.id === runId) ?? null : null
if (!target || target.status !== 'running') {
return
}
cancelRunMutation.mutate({
repoId: repoId!,
jobId: target.jobId,
runId: target.id,
}, {
onSuccess: (run) => {
selectRun(run.id)
},
})
}
const handleCancelJobRun = (job: ScheduleJobWithRepo) => {
if (!job.lastRun) {
return
}
cancelRunMutation.mutate({
repoId: repoId!,
jobId: job.id,
runId: job.lastRun.id,
})
}
const handleClearHistory = (worktrees?: ScheduleRunWorktreesMode) => {
if (jobId === null) {
return
}
clearRunsMutation.mutate({ repoId: repoId!, jobId, worktrees }, {
onSuccess: () => setClearRunsOpen(false),
})
}
const handleConfirmDeleteRun = (worktrees?: ScheduleRunWorktreesMode) => {
if (jobId === null || runToDelete === null) {
return
}
deleteRunMutation.mutate({ repoId: repoId!, jobId, runId: runToDelete, worktrees }, {
onSuccess: () => setRunToDelete(null),
})
}
const handleSelectJob = (id: number) => {
selectJobAndView(id)
}
return (
<div className="h-dvh max-h-dvh overflow-hidden bg-background flex flex-col">
<Header>
@@ -277,134 +60,7 @@ export function Schedules() {
</div>
</Header>
<div className="flex flex-1 min-h-0 flex-col overflow-hidden px-2 md:px-6">
{!hasJobs ? (
<div className="flex min-h-0 flex-1 h-full items-start">
<Card className="max-w-3xl border-dashed border-border/70">
<CardContent className="flex flex-col items-start gap-4 p-8 sm:p-10">
<div className="rounded-full border border-border bg-muted/40 p-3">
<CalendarClock className="h-6 w-6 text-muted-foreground" />
</div>
<div className="space-y-2">
<p className="text-xl font-semibold tracking-tight">No schedules yet</p>
<p className="text-sm text-muted-foreground">Create a schedule for this repo to automate recurring agent work, then inspect runs, logs, and sessions here.</p>
</div>
<Button onClick={openNewJob}>
<Plus className="w-4 h-4 mr-2" />
Create First Schedule
</Button>
</CardContent>
</Card>
</div>
) : (
<>
{repoScheduleTab === 'jobs' && (
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
<ScheduleListToolbar search={jobSearch} onSearchChange={setJobSearch} searchPlaceholder="Search jobs" />
<div className="flex min-h-0 flex-1 flex-col overflow-y-auto pt-2 pb-mobile-tabbar sm:pb-2">
<div className="min-h-0 overflow-auto rounded-lg border border-border/70">
<ScheduleJobsTable
jobs={(jobs ?? []).filter((job) => matchesScheduleJobSearch(job, jobSearch))}
showRepo={false}
selectedJobId={jobId}
onOpen={(job) => handleSelectJob(job.id)}
onRunNow={handleRunNow}
onToggleEnabled={handleToggleEnabled}
onEdit={(job) => openEditJob(job.id)}
onDelete={(job) => openDeleteJob(job.id)}
onCancelRun={handleCancelJobRun}
runPending={runMutation.isPending}
cancelPending={cancelRunMutation.isPending}
/>
</div>
</div>
</div>
)}
{repoScheduleTab === 'detail' && (
<JobDetailTab
selectedJob={selectedJob}
onEdit={(job) => openEditJob(job.id)}
onDelete={openDeleteJob}
onToggleEnabled={() => { if (selectedJob) handleToggleEnabled(selectedJob) }}
onRunNow={() => { if (selectedJob) handleRunNow(selectedJob) }}
updatePending={updateMutation.isPending}
runPending={runMutation.isPending}
runningRun={Boolean(runningRun)}
isJobFetching={isJobFetching}
/>
)}
{repoScheduleTab === 'runs' && (
<RunHistoryTab
selectedJob={selectedJob}
runs={runs}
runsLoading={runsLoading}
runId={runId}
onSelectRun={selectRun}
onCancelRun={handleCancelRun}
cancelRunPending={cancelRunMutation.isPending}
onClearHistory={() => setClearRunsOpen(true)}
clearHistoryPending={clearRunsMutation.isPending}
onDeleteRun={(id) => setRunToDelete(id)}
deleteRunPending={deleteRunMutation.isPending}
/>
)}
</>
)}
</div>
{hasJobs && (
<div className="sm:block hidden">
<ScheduleTabMenu
activeTab={repoScheduleTab as 'jobs' | 'detail' | 'runs'}
onTabChange={(tab) => setScheduleTab(tab)}
/>
</div>
)}
<ScheduleJobDialog
open={dialog === 'new' || dialog === 'edit'}
onOpenChange={(open) => {
if (!open) closeDialog()
}}
job={editingJob}
repoId={repoId}
isSaving={createMutation.isPending || updateMutation.isPending}
onSubmit={dialog === 'edit' ? handleUpdate : handleCreate}
/>
<DeleteDialog
open={dialog === 'delete'}
onOpenChange={(open) => !open && closeDialog()}
onConfirm={handleDelete}
onCancel={() => closeDialog()}
title="Delete Schedule"
description={DELETE_SCHEDULE_DESCRIPTION}
isDeleting={deleteMutation.isPending}
/>
<ScheduleRunRemovalDialog
open={clearRunsOpen}
onOpenChange={(open) => !open && setClearRunsOpen(false)}
title="Clear run history"
description={
<>This permanently deletes all <strong>{clearableRuns.length}</strong> finished run{clearableRuns.length === 1 ? '' : 's'} for this schedule. A run in progress is kept. This cannot be undone.</>
}
affectedWorktreeCount={affectedClearWorktreeCount}
isPending={clearRunsMutation.isPending}
onCancel={() => setClearRunsOpen(false)}
onConfirm={handleClearHistory}
/>
<ScheduleRunRemovalDialog
open={runToDelete !== null}
onOpenChange={(open) => !open && setRunToDelete(null)}
title="Delete run"
description="This permanently deletes this run. This cannot be undone."
affectedWorktreeCount={runToDeleteWorktreeCount}
isPending={deleteRunMutation.isPending}
onCancel={() => setRunToDelete(null)}
onConfirm={handleConfirmDeleteRun}
/>
<RepoSchedulesContent repoId={repoId} embedded={false} />
</div>
)
}
+40 -17
View File
@@ -49,6 +49,7 @@ import type { PageCommandActions } from "@/lib/builtinCommands";
import { useRedoMessage, useUndoMessage } from "@/hooks/useUndoMessage";
import { usePermissions, useForms } from "@/contexts/EventContext";
import type { FormInfo, SessionMessageInfo } from "@opencode-manager/shared/opencode";
import type { SkillFileInfo } from "@opencode-manager/shared";
import { formatOpenCodeModelRef } from "@opencode-manager/shared/opencode";
import { FormPrompt } from "@/components/session/FormPrompt";
import { MinimizedFormIndicator } from "@/components/session/MinimizedFormIndicator";
@@ -64,7 +65,9 @@ import { useTerminalDialogParam } from "@/hooks/useOpenTerminal";
import { SessionMoreButton } from "@/components/navigation/SessionMoreButton";
import { SideQuestionDialog } from "@/components/session/SideQuestionDialog";
import { SessionMessagePickerDialog } from "@/components/session/SessionMessagePickerDialog";
import { ChangesWalkthroughDialog } from "@/components/session/ChangesWalkthroughDialog";
import { ChangesWalkthroughSheet } from "@/components/session/ChangesWalkthroughSheet";
import { ToolSidePanel } from "@/components/navigation/ToolSidePanel";
import { useToolPanel } from "@/hooks/useToolPanel";
const OLDER_HISTORY_SCROLL_THRESHOLD_PX = 200
@@ -141,6 +144,8 @@ export function SessionDetail() {
const [forkPickerLoading, setForkPickerLoading] = useState(false);
const isMobile = useMobile();
const docked = !isMobile;
const sidePanel = useToolPanel(docked);
const { keyboardHeight } = useVisualViewport();
const inputBottomOffset = isMobile ? keyboardHeight : 0;
const promptOverlayObserverRef = useRef<ResizeObserver | null>(null);
@@ -306,6 +311,7 @@ export function SessionDetail() {
const handleShowMcpDialog = useCallback(() => setMcpDialogOpen(true), [setMcpDialogOpen]);
const handleShowSkillsDialog = useCallback(() => setSkillsDialogOpen(true), [setSkillsDialogOpen]);
const handleShowWalkthrough = useCallback(() => setWalkthroughOpen(true), [setWalkthroughOpen]);
const handleSkillLoaded = useCallback((skill: SkillFileInfo) => showToast.success(`Loaded skill: ${skill.name}`), []);
const handleConnectProvider = useCallback(() => setSettingsTab('providers'), [setSettingsTab]);
const handleMinimizeForm = useCallback((form: FormInfo) => {
@@ -468,7 +474,7 @@ export function SessionDetail() {
undo: handleUndo,
redo: handleRedo,
fork: openForkPicker,
toggleSidebar: () => setFileBrowserOpen(!fileBrowserOpen),
toggleSidebar: () => (docked ? sidePanel.toggleTool('files') : setFileBrowserOpen(!fileBrowserOpen)),
toggleMode: () => {
const modeButton = document.querySelector(
"[data-toggle-mode]",
@@ -508,10 +514,12 @@ export function SessionDetail() {
}
}, [sessionId, updateSessionAsync]);
const handleFileBrowserClose = useCallback(() => {
setFileBrowserOpen(false)
setSelectedFilePath(undefined)
}, [setFileBrowserOpen]);
const handleFileBrowserClose = useCallback(() => setFileBrowserOpen(false), [setFileBrowserOpen]);
const filesVisible = fileBrowserOpen || sidePanel.activeTool === 'files';
useEffect(() => {
if (!filesVisible) setSelectedFilePath(undefined);
}, [filesVisible]);
const handleChildSessionClick = useCallback((childSessionId: string) => {
navigate(`/repos/${repoId}/sessions/${childSessionId}${sessionRouteSuffix}`)
@@ -714,7 +722,8 @@ export function SessionDetail() {
</div>
<div className="relative flex-1 overflow-hidden flex flex-col">
<div className="flex flex-1 min-h-0">
<div className="relative flex-1 min-w-0 overflow-hidden flex flex-col">
<div key={sessionId} data-testid="session-message-scroll" ref={messageContainerRef} onScroll={handleMessageScroll} className="flex-1 overflow-y-auto overflow-x-hidden overscroll-contain [mask-image:linear-gradient(to_bottom,transparent,black_16px,black)]" style={{ paddingBottom: promptOverlayHeight + inputBottomOffset + PROMPT_OVERLAY_CLEARANCE_PX }}>
{repoLoading || sessionLoading || messagesLoading ? (
<MessageSkeleton />
@@ -818,6 +827,20 @@ export function SessionDetail() {
</div>
)}
</div>
{docked && (
<ToolSidePanel
panel={sidePanel}
repoId={repoId}
sessionId={sessionId}
directory={sessionDirectory}
filesBasePath={workspaceBasePath}
currentBranch={repo?.currentBranch || repo?.branch || "main"}
selectedFilePath={selectedFilePath}
repoDirectory={repoDirectory}
onSkillLoaded={handleSkillLoaded}
/>
)}
</div>
{/* Sessions Dialog */}
<Dialog open={sessionsDialogOpen} onOpenChange={setSessionsDialogOpen}>
@@ -865,7 +888,7 @@ export function SessionDetail() {
)}
<FileBrowserSheet
isOpen={fileBrowserOpen}
isOpen={!docked && fileBrowserOpen}
onClose={handleFileBrowserClose}
basePath={workspaceBasePath}
repoName={workspaceDisplayName}
@@ -875,25 +898,25 @@ export function SessionDetail() {
{sessionId && (
<RepoSkillsDialog
open={skillsDialogOpen}
open={!docked && skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
sessionId={sessionId}
directory={repoDirectory}
onSkillLoaded={(skill) => showToast.success(`Loaded skill: ${skill.name}`)}
onSkillLoaded={handleSkillLoaded}
/>
)}
{sessionId && (
<ChangesWalkthroughDialog
<ChangesWalkthroughSheet
sessionId={sessionId}
open={walkthroughOpen}
open={!docked && walkthroughOpen}
onOpenChange={setWalkthroughOpen}
/>
)}
<RepoMcpDialog
open={mcpDialogOpen}
open={!docked && mcpDialogOpen}
onOpenChange={setMcpDialogOpen}
directory={repoDirectory}
/>
@@ -902,14 +925,14 @@ export function SessionDetail() {
<RepoActionsDialog
repoId={repoId}
directory={sessionDirectory}
open={actionsDialogOpen}
open={!docked && actionsDialogOpen}
onOpenChange={setActionsDialogOpen}
/>
)}
<SourceControlPanel
repoId={repoId}
isOpen={sourceControlOpen}
isOpen={!docked && sourceControlOpen}
onClose={() => setSourceControlOpen(false)}
currentBranch={repo?.currentBranch || repo?.branch || "main"}
repoName={workspaceDisplayName}
@@ -918,12 +941,12 @@ export function SessionDetail() {
<TerminalPanel
repoId={repoId}
directory={sessionDirectory}
isOpen={terminalOpen}
isOpen={!docked && terminalOpen}
onClose={() => setTerminalOpen(false)}
/>
<PreviewPanel
isOpen={previewOpen}
isOpen={!docked && previewOpen}
onClose={() => setPreviewOpen(false)}
directory={sessionDirectory}
/>
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { render, screen } from '@testing-library/react'
import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { MemoryRouter, useLocation } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
@@ -129,20 +129,24 @@ describe('AssistantRedirect preview routing', () => {
mocks.createPreviewSession.mockResolvedValue({ token: 'tok', previewPort: 5004, publicUrl: null })
})
it('opens the preview panel when a terminal localhost link is followed', async () => {
it('opens preview in the docked panel when a terminal localhost link is followed', async () => {
const user = userEvent.setup()
renderAssistantRedirect()
await user.click(await screen.findByRole('button', { name: 'local-link' }))
const iframe = await screen.findByTitle('Preview')
const iframe = await waitFor(() => {
const element = document.querySelector('iframe[title="Preview"]')
expect(element).not.toBeNull()
return element as HTMLIFrameElement
})
expect(iframe.getAttribute('src')).toContain('token=tok')
expect(iframe.getAttribute('src')).toContain('path=%2Fdashboard')
expect(mocks.createPreviewSession).toHaveBeenCalledWith(5173)
expect(screen.queryByTestId('terminal-view')).not.toBeInTheDocument()
const location = screen.getByTestId('location').textContent ?? ''
expect(location).toContain('dialog=preview')
expect(location).toContain('panel=preview')
expect(location).toContain('previewPort=5173')
expect(location).toContain('previewPath=%2Fdashboard')
})
@@ -156,8 +160,8 @@ describe('AssistantRedirect preview routing', () => {
expect(openSpy).toHaveBeenCalledWith('https://example.com/docs', '_blank', 'noopener,noreferrer')
expect(mocks.createPreviewSession).not.toHaveBeenCalled()
expect(screen.queryByTitle('Preview')).not.toBeInTheDocument()
expect(document.querySelector('iframe[title="Preview"]')).toBeNull()
expect(screen.getByTestId('terminal-view')).toBeInTheDocument()
expect(screen.getByTestId('location').textContent).toContain('dialog=terminal')
expect(screen.getByTestId('location').textContent).toContain('panel=terminal')
})
})
@@ -55,6 +55,9 @@ vi.mock('@/components/terminal/TerminalPanel', () => ({
TerminalPanel: ({ directory, isOpen }: { directory?: string; isOpen: boolean }) => (
<div data-testid="terminal-panel" data-directory={directory ?? ''} data-open={String(isOpen)} />
),
TerminalWorkspace: ({ directory }: { directory?: string }) => (
<div data-testid="terminal-workspace" data-directory={directory ?? ''} />
),
}))
vi.mock('@/components/session/SessionList', () => ({ SessionList: () => null }))
@@ -147,9 +150,9 @@ describe('RepoDetail worktree setup', () => {
expect(screen.getByTestId('location')).toHaveTextContent('repoTab=workspaces'),
)
const location = screen.getByTestId('location').textContent ?? ''
expect(location).toContain('dialog=terminal')
expect(location).toContain('panel=terminal')
expect(location).toContain('terminal=pty-new')
expect(screen.getByTestId('terminal-panel')).toHaveAttribute(
expect(await screen.findByTestId('terminal-workspace')).toHaveAttribute(
'data-directory',
newWorkspaceDirectory,
)
@@ -170,7 +173,8 @@ describe('RepoDetail worktree setup', () => {
await waitFor(() =>
expect(screen.getByTestId('location')).toHaveTextContent('repoTab=workspaces'),
)
expect(screen.getByTestId('location')).not.toHaveTextContent('dialog=terminal')
expect(screen.getByTestId('location')).not.toHaveTextContent('terminal')
expect(screen.queryByTestId('terminal-workspace')).not.toBeInTheDocument()
expect(screen.getByTestId('terminal-panel')).toHaveAttribute('data-open', 'false')
})
@@ -202,7 +202,11 @@ vi.mock('@/hooks/useSessionGoals', () => ({
useCancelSessionGoal: vi.fn(() => ({ mutate: vi.fn(), isPending: false })),
}))
vi.mock('@/components/session/SideQuestionDialog', () => ({ SideQuestionDialog: vi.fn(() => null) }))
vi.mock('@/components/session/ChangesWalkthroughDialog', () => ({ ChangesWalkthroughDialog: vi.fn(() => null) }))
vi.mock('@/components/session/ChangesWalkthroughSheet', () => ({ ChangesWalkthroughSheet: vi.fn(() => null) }))
vi.mock('@/components/navigation/ToolSidePanel', () => ({ ToolSidePanel: vi.fn(() => null) }))
vi.mock('@/hooks/useToolPanel', () => ({
useToolPanel: vi.fn(() => ({ activeTool: null, toggleTool: vi.fn(), closePanel: vi.fn() })),
}))
vi.mock('@/components/session/SessionList', () => ({ SessionList: vi.fn(() => null) }))
vi.mock('@/components/file-browser/FileBrowserSheet', () => ({ FileBrowserSheet: vi.fn(() => null) }))
vi.mock('@/components/repo/RepoMcpDialog', () => ({ RepoMcpDialog: vi.fn(() => null) }))