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

@@ -1,243 +0,0 @@
import { memo, useEffect, useMemo, useState } from 'react'
import { ChevronLeft, ChevronRight, Loader2, RefreshCw } from 'lucide-react'
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { DiffLines } from '@/components/file-browser/DiffLines'
import { ScheduleRunMarkdown } from '@/components/schedules/ScheduleRunMarkdown'
import { useChangeWalkthrough, useGenerateChangeWalkthrough } from '@/hooks/useChangeWalkthrough'
import { GIT_STATUS_COLORS, GIT_STATUS_LABELS } from '@/lib/git-status-styles'
import { WalkthroughOmittedFileSchema } from '@opencode-manager/shared/schemas'
import type { WalkthroughHunk, WalkthroughOmittedFile } from '@opencode-manager/shared/schemas'
interface ChangesWalkthroughDialogProps {
sessionId: string
open: boolean
onOpenChange: (open: boolean) => void
}
function isNoChangesError(error: unknown): boolean {
const code = (error as { code?: string } | null)?.code
return code === 'WALKTHROUGH_NO_CHANGES' || code === 'WALKTHROUGH_NO_TEXT_CHANGES'
}
function isContextLimitError(error: unknown): boolean {
return (error as { code?: string } | null)?.code === 'WALKTHROUGH_CONTEXT_LIMIT'
}
function omittedFilesFromError(error: unknown): WalkthroughOmittedFile[] {
const details = (error as { details?: { omittedFiles?: unknown } } | null)?.details
const parsed = WalkthroughOmittedFileSchema.array().safeParse(details?.omittedFiles)
return parsed.success ? parsed.data : []
}
function walkthroughErrorMessage(error: unknown): string {
if (isNoChangesError(error)) {
return 'This session has no text changes to walk through'
}
if (isContextLimitError(error)) {
return 'These changes are too large to walk through'
}
return error instanceof Error ? error.message : 'Failed to load the walkthrough'
}
const OMITTED_REASON_LABELS: Record<WalkthroughOmittedFile['reason'], string> = {
binary: 'binary file',
budget: 'over the diff budget',
}
export const ChangesWalkthroughDialog = memo(function ChangesWalkthroughDialog({ sessionId, open, onOpenChange }: ChangesWalkthroughDialogProps) {
const stateQuery = useChangeWalkthrough(sessionId, open)
const generate = useGenerateChangeWalkthrough(sessionId)
const [stopIndex, setStopIndex] = useState(0)
const walkthrough = stateQuery.data?.walkthrough ?? null
const stale = stateQuery.data?.stale ?? false
const error = generate.error ?? stateQuery.error
const contextLimitFiles = isContextLimitError(error) ? omittedFilesFromError(error) : []
useEffect(() => {
generate.reset()
}, [open, sessionId, generate.reset])
useEffect(() => {
setStopIndex(0)
}, [open, sessionId, walkthrough?.createdAt])
const hunksById = useMemo(
() => new Map(walkthrough?.hunks.map((hunk) => [hunk.id, hunk]) ?? []),
[walkthrough],
)
const stops = walkthrough?.stops ?? []
const clampedIndex = stops.length > 0 ? Math.min(stopIndex, stops.length - 1) : 0
const selectedStop = stops[clampedIndex] ?? null
const selectedHunks = (selectedStop?.hunkIds ?? [])
.map((id) => hunksById.get(id))
.filter((hunk): hunk is WalkthroughHunk => hunk !== undefined)
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
mobileFullscreen
keyboardAware
className="sm:max-w-3xl sm:max-h-[85vh] gap-0 flex flex-col p-0 md:p-6 pb-safe"
>
<DialogHeader className="p-4 sm:p-6 border-b shrink-0">
<DialogTitle>Change walkthrough</DialogTitle>
<DialogDescription>Walk through this session's changes, explained step by step.</DialogDescription>
</DialogHeader>
<div className="flex-1 overflow-y-auto p-4 sm:p-6 space-y-4">
{error ? (
<div className="space-y-2">
<p className="text-sm text-destructive">{walkthroughErrorMessage(error)}</p>
{contextLimitFiles.length > 0 ? (
<div className="space-y-1 rounded-md border border-border bg-muted/20 p-3">
<p className="text-xs font-medium text-muted-foreground">Omitted files</p>
{contextLimitFiles.map((omitted) => (
<p key={omitted.file} className="text-xs text-muted-foreground">
{omitted.file} — {OMITTED_REASON_LABELS[omitted.reason]}
</p>
))}
</div>
) : null}
</div>
) : null}
{stateQuery.isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : !walkthrough ? (
<div className="space-y-4">
<p className="text-sm text-muted-foreground">
Generate a step-by-step walkthrough of the changes in this session.
</p>
<Button
onClick={() => generate.mutate({})}
disabled={generate.isPending}
>
{generate.isPending ? (
<>
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
Generating walkthrough…
</>
) : (
'Generate walkthrough'
)}
</Button>
</div>
) : (
<div className="space-y-4">
{stale ? (
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2">
<p className="text-sm text-warning">
Changes have been updated since this walkthrough was generated
</p>
<Button
variant="outline"
size="sm"
onClick={() => generate.mutate({ regenerate: true })}
disabled={generate.isPending}
>
{generate.isPending ? (
<Loader2 className="mr-2 h-3.5 w-3.5 animate-spin" />
) : (
<RefreshCw className="mr-2 h-3.5 w-3.5" />
)}
Regenerate
</Button>
</div>
) : null}
<ScheduleRunMarkdown content={walkthrough.summary} />
{stops.length > 0 ? (
<div className="space-y-3">
<ol className="space-y-1">
{stops.map((stop, index) => (
<li key={index}>
<button
type="button"
onClick={() => setStopIndex(index)}
aria-current={index === clampedIndex}
className={
index === clampedIndex
? 'w-full rounded-md bg-accent/40 px-2 py-1 text-left text-sm font-medium text-foreground'
: 'w-full rounded-md px-2 py-1 text-left text-sm text-muted-foreground hover:bg-accent/20'
}
>
{index + 1}. {stop.title}
</button>
</li>
))}
</ol>
<div className="flex items-center justify-between gap-2 border-t border-border pt-3">
<Button
variant="outline"
size="sm"
onClick={() => setStopIndex(clampedIndex - 1)}
disabled={clampedIndex === 0}
>
<ChevronLeft className="mr-1 h-3.5 w-3.5" />
Previous
</Button>
<span className="text-xs text-muted-foreground">
Stop {clampedIndex + 1} of {stops.length}
</span>
<Button
variant="outline"
size="sm"
onClick={() => setStopIndex(clampedIndex + 1)}
disabled={clampedIndex >= stops.length - 1}
>
Next
<ChevronRight className="ml-1 h-3.5 w-3.5" />
</Button>
</div>
{selectedStop ? (
<div className="space-y-3">
<ScheduleRunMarkdown content={selectedStop.explanation} />
{selectedHunks.map((hunk) => (
<div key={hunk.id} className="overflow-hidden rounded-md border border-border">
<div className="flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5">
<span className="min-w-0 flex-1 truncate text-xs font-medium text-foreground">
{hunk.file}
</span>
{hunk.truncated ? (
<Badge variant="outline">truncated</Badge>
) : null}
<span className={`text-xs ${GIT_STATUS_COLORS[hunk.status]}`}>
{GIT_STATUS_LABELS[hunk.status]}
</span>
</div>
<div className="overflow-x-auto">
<DiffLines diff={hunk.text} />
</div>
</div>
))}
</div>
) : null}
</div>
) : null}
{walkthrough.omittedFiles.length > 0 ? (
<div className="space-y-1 rounded-md border border-border bg-muted/20 p-3">
<p className="text-xs font-medium text-muted-foreground">Omitted files</p>
{walkthrough.omittedFiles.map((omitted) => (
<p key={omitted.file} className="text-xs text-muted-foreground">
{omitted.file} — {OMITTED_REASON_LABELS[omitted.reason]}
</p>
))}
</div>
) : null}
</div>
)}
</div>
</DialogContent>
</Dialog>
)
})
@@ -3,7 +3,7 @@ import { render, screen, waitFor } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import type { ReactNode } from 'react'
import { ChangesWalkthroughDialog } from './ChangesWalkthroughDialog'
import { ChangesWalkthroughSheet } from './ChangesWalkthroughSheet'
import { FetchError } from '@/api/fetchWrapper'
import type { ChangeWalkthrough, ChangeWalkthroughState } from '@opencode-manager/shared/schemas'
@@ -48,7 +48,7 @@ const walkthrough: ChangeWalkthrough = {
}
function state(overrides: Partial<ChangeWalkthroughState> = {}): ChangeWalkthroughState {
return { walkthrough, currentDiffHash: 'hash-1', stale: false, ...overrides }
return { walkthrough, currentDiffHash: 'hash-1', stale: false, generating: false, error: null, ...overrides }
}
function createWrapper() {
@@ -58,16 +58,16 @@ function createWrapper() {
)
}
function renderDialog(overrides: Partial<React.ComponentProps<typeof ChangesWalkthroughDialog>> = {}) {
function renderSheet(overrides: Partial<React.ComponentProps<typeof ChangesWalkthroughSheet>> = {}) {
const onOpenChange = vi.fn()
const view = render(
<ChangesWalkthroughDialog sessionId="ses_1" open onOpenChange={onOpenChange} {...overrides} />,
<ChangesWalkthroughSheet sessionId="ses_1" open onOpenChange={onOpenChange} {...overrides} />,
{ wrapper: createWrapper() },
)
return { ...view, onOpenChange }
}
describe('ChangesWalkthroughDialog', () => {
describe('ChangesWalkthroughSheet', () => {
beforeAll(() => {
Element.prototype.hasPointerCapture ??= () => false
Element.prototype.setPointerCapture ??= () => {}
@@ -83,13 +83,13 @@ describe('ChangesWalkthroughDialog', () => {
const user = userEvent.setup()
let generated = false
mocks.getChangeWalkthrough.mockImplementation(async () =>
generated ? state() : { walkthrough: null, currentDiffHash: 'hash-1', stale: false },
generated ? state() : state({ walkthrough: null }),
)
mocks.generateChangeWalkthrough.mockImplementation(async () => {
generated = true
return walkthrough
return state()
})
renderDialog()
renderSheet()
const generate = await screen.findByRole('button', { name: 'Generate walkthrough' })
await user.click(generate)
@@ -108,7 +108,7 @@ describe('ChangesWalkthroughDialog', () => {
it('moves through the stops with the navigator in order', async () => {
const user = userEvent.setup()
mocks.getChangeWalkthrough.mockResolvedValue(state())
renderDialog()
renderSheet()
expect(await screen.findByText('Stop 1 of 2')).toBeInTheDocument()
expect(screen.getByText('src/greet.ts')).toBeInTheDocument()
@@ -130,8 +130,8 @@ describe('ChangesWalkthroughDialog', () => {
it('shows the stale warning and regenerates', async () => {
const user = userEvent.setup()
mocks.getChangeWalkthrough.mockResolvedValue(state({ stale: true, currentDiffHash: 'hash-2' }))
mocks.generateChangeWalkthrough.mockResolvedValue(walkthrough)
renderDialog()
mocks.generateChangeWalkthrough.mockResolvedValue(state({ generating: true }))
renderSheet()
expect(
await screen.findByText('Changes have been updated since this walkthrough was generated'),
@@ -144,13 +144,34 @@ describe('ChangesWalkthroughDialog', () => {
})
})
it('shows progress while the server is generating instead of the generate button', async () => {
mocks.getChangeWalkthrough.mockResolvedValue(state({ walkthrough: null, generating: true }))
renderSheet()
expect(await screen.findByText(/Generating walkthrough/)).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Generate walkthrough' })).not.toBeInTheDocument()
})
it('renders a generation failure recorded by the server', async () => {
mocks.getChangeWalkthrough.mockResolvedValue(
state({
walkthrough: null,
error: { message: 'The model did not return a usable change walkthrough', code: 'WALKTHROUGH_UNPARSEABLE' },
}),
)
renderSheet()
expect(await screen.findByText('The model did not return a usable change walkthrough')).toBeInTheDocument()
expect(screen.getByRole('button', { name: 'Generate walkthrough' })).toBeEnabled()
})
it('renders the no-changes message inline', async () => {
const user = userEvent.setup()
mocks.getChangeWalkthrough.mockResolvedValue({ walkthrough: null, currentDiffHash: null, stale: false })
mocks.getChangeWalkthrough.mockResolvedValue(state({ walkthrough: null, currentDiffHash: null }))
mocks.generateChangeWalkthrough.mockRejectedValue(
new FetchError('This session has no changes to walk through', 409, 'WALKTHROUGH_NO_CHANGES'),
)
renderDialog()
renderSheet()
await user.click(await screen.findByRole('button', { name: 'Generate walkthrough' }))
@@ -159,9 +180,9 @@ describe('ChangesWalkthroughDialog', () => {
it('renders other generation errors inline', async () => {
const user = userEvent.setup()
mocks.getChangeWalkthrough.mockResolvedValue({ walkthrough: null, currentDiffHash: null, stale: false })
mocks.getChangeWalkthrough.mockResolvedValue(state({ walkthrough: null, currentDiffHash: null }))
mocks.generateChangeWalkthrough.mockRejectedValue(new Error('model exploded'))
renderDialog()
renderSheet()
await user.click(await screen.findByRole('button', { name: 'Generate walkthrough' }))
@@ -170,7 +191,7 @@ describe('ChangesWalkthroughDialog', () => {
it('lists the omitted files when the diff is too large to walk through', async () => {
const user = userEvent.setup()
mocks.getChangeWalkthrough.mockResolvedValue({ walkthrough: null, currentDiffHash: null, stale: false })
mocks.getChangeWalkthrough.mockResolvedValue(state({ walkthrough: null, currentDiffHash: null }))
mocks.generateChangeWalkthrough.mockRejectedValue(
new FetchError('These changes are too large to walk through', 413, 'WALKTHROUGH_CONTEXT_LIMIT', undefined, {
details: {
@@ -181,7 +202,7 @@ describe('ChangesWalkthroughDialog', () => {
},
}),
)
renderDialog()
renderSheet()
await user.click(await screen.findByRole('button', { name: 'Generate walkthrough' }))
@@ -202,7 +223,7 @@ describe('ChangesWalkthroughDialog', () => {
},
}),
)
const { container } = renderDialog()
const { container } = renderSheet()
expect(await screen.findByText(/Summary/)).toBeInTheDocument()
expect(await screen.findByText(/Explanation/)).toBeInTheDocument()
@@ -218,22 +239,22 @@ describe('ChangesWalkthroughDialog', () => {
const user = userEvent.setup()
let generated = false
mocks.getChangeWalkthrough.mockImplementation(async () =>
generated ? state() : { walkthrough: null, currentDiffHash: null, stale: false },
generated ? state() : state({ walkthrough: null, currentDiffHash: null }),
)
mocks.generateChangeWalkthrough
.mockRejectedValueOnce(new FetchError(serverMessage, 409, code))
.mockImplementationOnce(async () => {
generated = true
return walkthrough
return state()
})
const { rerender, onOpenChange } = renderDialog()
const { rerender, onOpenChange } = renderSheet()
await user.click(await screen.findByRole('button', { name: 'Generate walkthrough' }))
expect(await screen.findByText('This session has no text changes to walk through')).toBeInTheDocument()
rerender(<ChangesWalkthroughDialog sessionId="ses_1" open={false} onOpenChange={onOpenChange} />)
rerender(<ChangesWalkthroughDialog sessionId="ses_1" open onOpenChange={onOpenChange} />)
rerender(<ChangesWalkthroughSheet sessionId="ses_1" open={false} onOpenChange={onOpenChange} />)
rerender(<ChangesWalkthroughSheet sessionId="ses_1" open onOpenChange={onOpenChange} />)
const generate = await screen.findByRole('button', { name: 'Generate walkthrough' })
expect(generate).toBeEnabled()
@@ -0,0 +1,250 @@
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { ChevronLeft, ChevronRight, Loader2, RefreshCw } from 'lucide-react'
import { SideDrawer, SideDrawerHeader } from '@/components/ui/side-drawer'
import { Button } from '@/components/ui/button'
import { Badge } from '@/components/ui/badge'
import { DiffLines } from '@/components/file-browser/DiffLines'
import { ScheduleRunMarkdown } from '@/components/schedules/ScheduleRunMarkdown'
import { useChangeWalkthrough, useGenerateChangeWalkthrough } from '@/hooks/useChangeWalkthrough'
import { GIT_STATUS_COLORS, GIT_STATUS_LABELS } from '@/lib/git-status-styles'
import { cn } from '@/lib/utils'
import { WalkthroughOmittedFileSchema } from '@opencode-manager/shared/schemas'
import type { WalkthroughHunk, WalkthroughOmittedFile } from '@opencode-manager/shared/schemas'
interface WalkthroughErrorLike {
message?: string
code?: string
details?: unknown
}
function errorCode(error: unknown): string | undefined {
return (error as WalkthroughErrorLike | null)?.code
}
function isNoChangesError(error: unknown): boolean {
const code = errorCode(error)
return code === 'WALKTHROUGH_NO_CHANGES' || code === 'WALKTHROUGH_NO_TEXT_CHANGES'
}
function isContextLimitError(error: unknown): boolean {
return errorCode(error) === 'WALKTHROUGH_CONTEXT_LIMIT'
}
function omittedFilesFromError(error: unknown): WalkthroughOmittedFile[] {
const details = (error as { details?: { omittedFiles?: unknown } } | null)?.details
const parsed = WalkthroughOmittedFileSchema.array().safeParse(details?.omittedFiles)
return parsed.success ? parsed.data : []
}
function walkthroughErrorMessage(error: unknown): string {
if (isNoChangesError(error)) {
return 'This session has no text changes to walk through'
}
if (isContextLimitError(error)) {
return 'These changes are too large to walk through'
}
return (error as WalkthroughErrorLike | null)?.message || 'Failed to load the walkthrough'
}
const OMITTED_REASON_LABELS: Record<WalkthroughOmittedFile['reason'], string> = {
binary: 'binary file',
budget: 'over the diff budget',
}
function OmittedFiles({ files }: { files: WalkthroughOmittedFile[] }) {
return (
<div className="space-y-1 rounded-md border border-border bg-muted/20 p-3">
<p className="text-xs font-medium text-muted-foreground">Omitted files</p>
{files.map((omitted) => (
<p key={omitted.file} className="break-all text-xs text-muted-foreground">
{omitted.file} — {OMITTED_REASON_LABELS[omitted.reason]}
</p>
))}
</div>
)
}
interface ChangesWalkthroughViewProps {
sessionId: string
active: boolean
}
/** Generates and steps through a session's change walkthrough; the caller supplies the surrounding chrome. */
export const ChangesWalkthroughView = memo(function ChangesWalkthroughView({ sessionId, active }: ChangesWalkthroughViewProps) {
const stateQuery = useChangeWalkthrough(sessionId, active)
const generate = useGenerateChangeWalkthrough(sessionId)
const resetGenerate = generate.reset
const [stopIndex, setStopIndex] = useState(0)
const detailRef = useRef<HTMLDivElement>(null)
const state = stateQuery.data
const walkthrough = state?.walkthrough ?? null
const stale = state?.stale ?? false
const generating = generate.isPending || (state?.generating ?? false)
const error = generate.error ?? stateQuery.error ?? (generating ? null : state?.error ?? null)
const contextLimitFiles = isContextLimitError(error) ? omittedFilesFromError(error) : []
useEffect(() => {
resetGenerate()
}, [active, sessionId, resetGenerate])
useEffect(() => {
setStopIndex(0)
}, [active, sessionId, walkthrough?.createdAt])
const hunksById = useMemo(
() => new Map(walkthrough?.hunks.map((hunk) => [hunk.id, hunk]) ?? []),
[walkthrough],
)
const stops = walkthrough?.stops ?? []
const clampedIndex = stops.length > 0 ? Math.min(stopIndex, stops.length - 1) : 0
const selectedStop = stops[clampedIndex] ?? null
const selectedHunks = (selectedStop?.hunkIds ?? [])
.map((id) => hunksById.get(id))
.filter((hunk): hunk is WalkthroughHunk => hunk !== undefined)
const selectStop = useCallback((index: number) => {
setStopIndex(index)
detailRef.current?.scrollIntoView?.({ block: 'start', behavior: 'smooth' })
}, [])
return (
<div className="flex min-h-0 flex-1 flex-col">
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto p-4">
{error ? (
<div className="space-y-2">
<p className="text-sm text-destructive">{walkthroughErrorMessage(error)}</p>
{contextLimitFiles.length > 0 ? <OmittedFiles files={contextLimitFiles} /> : null}
</div>
) : null}
{generating ? (
<div className="flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-sm text-muted-foreground">
<Loader2 className="h-4 w-4 shrink-0 animate-spin" />
<span>Generating walkthrough… this can take a minute or two.</span>
</div>
) : null}
{stateQuery.isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-5 w-5 animate-spin text-muted-foreground" />
</div>
) : !walkthrough ? (
generating ? null : (
<div className="space-y-4">
<p className="text-sm text-muted-foreground">
Generate a step-by-step walkthrough of the changes in this session.
</p>
<Button onClick={() => generate.mutate({})}>Generate walkthrough</Button>
</div>
)
) : (
<div className="space-y-4">
{stale && !generating ? (
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border border-warning/40 bg-warning/10 px-3 py-2">
<p className="text-sm text-warning">
Changes have been updated since this walkthrough was generated
</p>
<Button variant="outline" size="sm" onClick={() => generate.mutate({ regenerate: true })}>
<RefreshCw className="mr-2 h-3.5 w-3.5" />
Regenerate
</Button>
</div>
) : null}
<ScheduleRunMarkdown content={walkthrough.summary} />
{stops.length > 0 ? (
<ol className="space-y-0.5">
{stops.map((stop, index) => (
<li key={index}>
<button
type="button"
onClick={() => selectStop(index)}
aria-current={index === clampedIndex}
className={cn(
'w-full rounded-md px-2 py-1 text-left text-sm',
index === clampedIndex
? 'bg-accent/40 font-medium text-foreground'
: 'text-muted-foreground hover:bg-accent/20',
)}
>
{index + 1}. {stop.title}
</button>
</li>
))}
</ol>
) : null}
{selectedStop ? (
<div ref={detailRef} className="scroll-mt-4 space-y-3 border-t border-border pt-4">
<h3 className="text-sm font-semibold text-foreground">
{clampedIndex + 1}. {selectedStop.title}
</h3>
<ScheduleRunMarkdown content={selectedStop.explanation} />
{selectedHunks.map((hunk) => (
<div key={hunk.id} className="overflow-hidden rounded-md border border-border">
<div className="flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5">
<span className="min-w-0 flex-1 truncate text-xs font-medium text-foreground" title={hunk.file}>
{hunk.file}
</span>
{hunk.truncated ? <Badge variant="outline">truncated</Badge> : null}
<span className={`text-xs ${GIT_STATUS_COLORS[hunk.status]}`}>
{GIT_STATUS_LABELS[hunk.status]}
</span>
</div>
<div className="overflow-x-auto">
<DiffLines diff={hunk.text} />
</div>
</div>
))}
</div>
) : null}
{walkthrough.omittedFiles.length > 0 ? <OmittedFiles files={walkthrough.omittedFiles} /> : null}
</div>
)}
</div>
{stops.length > 0 ? (
<div className="flex shrink-0 items-center justify-between gap-2 border-t border-border bg-background px-4 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)]">
<Button variant="outline" size="sm" onClick={() => selectStop(clampedIndex - 1)} disabled={clampedIndex === 0}>
<ChevronLeft className="mr-1 h-3.5 w-3.5" />
Previous
</Button>
<span className="text-xs text-muted-foreground">
Stop {clampedIndex + 1} of {stops.length}
</span>
<Button
variant="outline"
size="sm"
onClick={() => selectStop(clampedIndex + 1)}
disabled={clampedIndex >= stops.length - 1}
>
Next
<ChevronRight className="ml-1 h-3.5 w-3.5" />
</Button>
</div>
) : null}
</div>
)
})
interface ChangesWalkthroughSheetProps {
sessionId: string
open: boolean
onOpenChange: (open: boolean) => void
}
/** The walkthrough as a right-side sheet: full screen on mobile, a drawer over the page on desktop. */
export function ChangesWalkthroughSheet({ sessionId, open, onOpenChange }: ChangesWalkthroughSheetProps) {
const close = useCallback(() => onOpenChange(false), [onOpenChange])
return (
<SideDrawer isOpen={open} onClose={close} side="right" widthClass="w-full sm:w-[min(640px,92vw)]" ariaLabel="Change walkthrough">
<SideDrawerHeader title="Change walkthrough" onClose={close} />
<ChangesWalkthroughView sessionId={sessionId} active={open} />
</SideDrawer>
)
}