refactor: remove assistant auto-launch and simplify redirect flow (#282)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-06-20 12:28:32 -04:00
1 parent 634dcd9af9
commit 5b85abd627
6 files changed
+91 -465

No files matched your search

+11 -2
View File
@@ -5,7 +5,15 @@ import { X } from "lucide-react"
import { cn } from "@/lib/utils"
import { useSwipeBack } from '@/hooks/useMobile'
const Dialog = DialogPrimitive.Root
const DialogOpenContext = React.createContext<boolean>(true)
function Dialog({ open, ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
return (
<DialogOpenContext.Provider value={open ?? true}>
<DialogPrimitive.Root open={open} {...props} />
</DialogOpenContext.Provider>
)
}
const DialogTrigger = DialogPrimitive.Trigger
@@ -45,8 +53,9 @@ const DialogContent = React.forwardRef<
DialogContentProps
>(({ className, children, hideCloseButton, fullscreen, mobileFullscreen, mobileSwipeToClose, canSwipeBack, onSwipeBack, overlayClassName, style, ...props }, ref) => {
const isMobileFullscreenMode = fullscreen || mobileFullscreen
const isDialogOpen = React.useContext(DialogOpenContext)
const [isMobile, setIsMobile] = React.useState(() => typeof window !== 'undefined' ? window.innerWidth < 768 : false)
const shouldEnableMobileSwipe = mobileSwipeToClose !== false && isMobile
const shouldEnableMobileSwipe = mobileSwipeToClose !== false && isMobile && isDialogOpen
const shouldAnimateSwipe = shouldEnableMobileSwipe && isMobileFullscreenMode
const swipeContainerRef = React.useRef<HTMLDivElement>(null)
const closeTriggerRef = React.useRef<HTMLButtonElement>(null)
@@ -1,197 +0,0 @@
import { renderHook, act } from '@testing-library/react'
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { useAssistantSessionLauncher } from './useAssistantSessionLauncher'
import { OpenCodeClient } from '@/api/opencode'
const mocks = vi.hoisted(() => ({
listSessions: vi.fn(),
listSessionsPage: vi.fn(),
createSession: vi.fn(),
sendPromptAsync: vi.fn(),
}))
vi.mock('@/api/opencode', () => ({
OpenCodeClient: vi.fn(() => ({
listSessions: mocks.listSessions,
listSessionsPage: mocks.listSessionsPage,
createSession: mocks.createSession,
sendPromptAsync: mocks.sendPromptAsync,
})),
}))
beforeEach(() => {
mocks.sendPromptAsync.mockResolvedValue(undefined)
})
describe('useAssistantSessionLauncher', () => {
beforeEach(() => {
vi.clearAllMocks()
localStorage.clear()
})
it('opens the latest root session in the assistant directory', async () => {
mocks.listSessionsPage.mockResolvedValue({
items: [
{ id: 'older', directory: '/assistant', time: { updated: 10 } },
{ id: 'newest-child', parentID: 'newest', directory: '/assistant', time: { updated: 40 } },
{ id: 'different-directory', directory: '/other', time: { updated: 50 } },
{ id: 'newest', directory: '/assistant', time: { updated: 30 } },
],
})
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
directory: '/assistant',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(OpenCodeClient).toHaveBeenCalledWith('http://localhost:5551', '/assistant')
expect(mocks.listSessionsPage).toHaveBeenCalledWith({ limit: 25, order: 'desc' })
expect(mocks.listSessions).not.toHaveBeenCalled()
expect(onNavigate).toHaveBeenCalledWith('newest')
expect(mocks.createSession).not.toHaveBeenCalled()
expect(mocks.sendPromptAsync).not.toHaveBeenCalled()
})
it('paginates assistant sessions instead of making an unbounded session list request', async () => {
mocks.listSessionsPage
.mockResolvedValueOnce({
items: [
{ id: 'newest-child', parentID: 'newest', directory: '/assistant', time: { updated: 40 } },
],
nextCursor: 'next-page',
})
.mockResolvedValueOnce({
items: [
{ id: 'newest', directory: '/assistant', time: { updated: 30 } },
],
})
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
directory: '/assistant',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(mocks.listSessionsPage).toHaveBeenNthCalledWith(1, { limit: 25, order: 'desc' })
expect(mocks.listSessionsPage).toHaveBeenNthCalledWith(2, { cursor: 'next-page' })
expect(mocks.listSessions).not.toHaveBeenCalled()
expect(onNavigate).toHaveBeenCalledWith('newest')
})
it('creates a session when the assistant directory has no root sessions', async () => {
mocks.listSessionsPage.mockResolvedValue({
items: [
{ id: 'other', directory: '/other', time: { updated: 50 } },
],
})
mocks.createSession.mockResolvedValue({ id: 'created' })
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
directory: '/assistant',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(mocks.createSession).toHaveBeenCalledWith({ title: 'Assistant' })
expect(mocks.sendPromptAsync).toHaveBeenCalledWith('created', {
parts: [
expect.objectContaining({
type: 'text',
text: expect.stringContaining('Welcome to OpenCode Manager!'),
}),
],
})
expect(onNavigate).toHaveBeenCalledWith('created')
const promptCall = mocks.sendPromptAsync.mock.calls[0]
const promptText = promptCall[1].parts[0].text as string
expect(promptText).toContain('.opencode/agents/assistant.md')
expect(promptText).toContain('AGENTS.md')
expect(promptText).toContain('.opencode/skills/')
expect(promptText).toContain('directory')
expect(promptText).toContain('durable preferences')
expect(promptText).toContain('self-editing rules')
expect(promptText).not.toContain('v file')
expect(promptText).not.toMatch(/AGENTS\.md contains workspace-level instructions, durable preferences, and self-editing rules/)
})
it('navigates after creating a session without waiting for the welcome prompt to complete', async () => {
mocks.listSessionsPage.mockResolvedValue({ items: [] })
let resolvePrompt: () => void
const promptPromise = new Promise<void>((resolve) => {
resolvePrompt = resolve
})
mocks.createSession.mockResolvedValue({ id: 'created' })
mocks.sendPromptAsync.mockImplementation(() => promptPromise)
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
directory: '/assistant',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(onNavigate).toHaveBeenCalledWith('created')
expect(mocks.sendPromptAsync).toHaveBeenCalledWith('created', {
parts: [
expect.objectContaining({
type: 'text',
text: expect.stringContaining('Welcome to OpenCode Manager!'),
}),
],
})
resolvePrompt!()
})
it('navigates even when welcome prompt fails', async () => {
mocks.listSessionsPage.mockResolvedValue({ items: [] })
mocks.createSession.mockResolvedValue({ id: 'created' })
mocks.sendPromptAsync.mockRejectedValueOnce(new Error('provider unavailable'))
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
directory: '/assistant',
onNavigate,
}))
await act(async () => {
await result.current.openAssistant()
})
expect(onNavigate).toHaveBeenCalledWith('created')
expect(mocks.sendPromptAsync).toHaveBeenCalled()
})
it('rejects when the assistant directory is unavailable', async () => {
const onNavigate = vi.fn()
const { result } = renderHook(() => useAssistantSessionLauncher({
opcodeUrl: 'http://localhost:5551',
onNavigate,
}))
await act(async () => {
await expect(result.current.openAssistant()).rejects.toThrow('Assistant workspace directory is unavailable')
})
expect(OpenCodeClient).not.toHaveBeenCalled()
expect(mocks.listSessionsPage).not.toHaveBeenCalled()
expect(mocks.createSession).not.toHaveBeenCalled()
expect(onNavigate).not.toHaveBeenCalled()
})
})
@@ -1,93 +0,0 @@
import { useCallback } from 'react'
import { OpenCodeClient } from '@/api/opencode'
import type { components } from '@/api/opencode-types'
interface UseAssistantSessionLauncherOptions {
opcodeUrl: string
directory?: string
onNavigate: (sessionId: string) => void
}
type OpenCodeSession = components['schemas']['Session']
const ASSISTANT_SESSION_LOOKUP_PAGE_SIZE = 25
function isAssistantRootSession(session: OpenCodeSession, assistantDirectory: string): boolean {
return !session.parentID && session.directory === assistantDirectory
}
function findNewestRootAssistantSession(sessions: OpenCodeSession[], assistantDirectory: string): OpenCodeSession | undefined {
return sessions
.filter((session) => isAssistantRootSession(session, assistantDirectory))
.sort((a, b) => b.time.updated - a.time.updated)[0]
}
async function getLatestAssistantSession(
client: OpenCodeClient,
assistantDirectory: string,
): Promise<OpenCodeSession | undefined> {
let page = await client.listSessionsPage({ limit: ASSISTANT_SESSION_LOOKUP_PAGE_SIZE, order: 'desc' })
let latestRootSession = findNewestRootAssistantSession(page.items, assistantDirectory)
while (!latestRootSession && page.nextCursor) {
page = await client.listSessionsPage({ cursor: page.nextCursor })
latestRootSession = findNewestRootAssistantSession(page.items, assistantDirectory)
}
return latestRootSession
}
const ASSISTANT_WELCOME_PROMPT = `Welcome to OpenCode Manager! I'm your assistant and I'm here to help you work with your code.
To get started, let's set up your assistant:
**1. Name your assistant**
What would you like to call me? This name will help personalize our interactions.
**2. Review AGENTS.md**
AGENTS.md explains the assistant workspace directory and points to the files OpenCode Manager manages.
**3. Review the assistant agent**
.opencode/agents/assistant.md contains the default Assistant Mode agent instructions, durable preferences, self-editing rules, and skill guidance.
**4. Use workspace skills**
.opencode/skills/ contains managed workspace skills for repos, schedules, notifications, and settings.
Take your time exploring and customizing these settings. Let me know when you're ready to start coding, or if you have any questions about getting set up!`
async function sendAssistantWelcomePrompt(client: OpenCodeClient, sessionId: string): Promise<void> {
await client.sendPromptAsync(sessionId, {
parts: [
{
type: 'text',
text: ASSISTANT_WELCOME_PROMPT,
},
],
}).catch(() => undefined)
}
export function useAssistantSessionLauncher({
opcodeUrl,
directory,
onNavigate,
}: UseAssistantSessionLauncherOptions) {
const openAssistant = useCallback(async () => {
if (!directory) {
throw new Error('Assistant workspace directory is unavailable')
}
const client = new OpenCodeClient(opcodeUrl, directory)
const newest = await getLatestAssistantSession(client, directory)
if (newest) {
onNavigate(newest.id)
} else {
const session = await client.createSession({ title: 'Assistant' })
onNavigate(session.id)
void sendAssistantWelcomePrompt(client, session.id)
}
}, [opcodeUrl, directory, onNavigate])
return { openAssistant }
}
+12 -20
View File
@@ -8,8 +8,8 @@ describe('getAssistantPath', () => {
});
describe('getAssistantSessionListPath', () => {
it('returns /assistant?view=sessions', () => {
expect(getAssistantSessionListPath()).toBe('/assistant?view=sessions');
it('returns /assistant', () => {
expect(getAssistantSessionListPath()).toBe('/assistant');
});
});
@@ -42,8 +42,8 @@ describe('getSessionListPath', () => {
});
it('returns assistant session list path for assistant sessions', () => {
expect(getSessionListPath(42, true)).toBe('/assistant?view=sessions');
expect(getSessionListPath('123', true)).toBe('/assistant?view=sessions');
expect(getSessionListPath(42, true)).toBe('/assistant');
expect(getSessionListPath('123', true)).toBe('/assistant');
});
it('includes tab param when tab is workspaces', () => {
@@ -56,7 +56,7 @@ describe('getSessionListPath', () => {
});
it('ignores tab param for assistant sessions', () => {
expect(getSessionListPath(42, true, 'workspaces')).toBe('/assistant?view=sessions');
expect(getSessionListPath(42, true, 'workspaces')).toBe('/assistant');
});
});
@@ -84,10 +84,10 @@ describe('getSwipeBackTarget', () => {
it('returns assistant session list path for assistant session detail with assistant=1', () => {
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?assistant=1')).toBe(
'/assistant?view=sessions'
'/assistant'
);
expect(getSwipeBackTarget('/repos/123/sessions/xyz', '?assistant=1')).toBe(
'/assistant?view=sessions'
'/assistant'
);
});
@@ -99,26 +99,18 @@ describe('getSwipeBackTarget', () => {
it('preserves tab param in back target', () => {
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?repoTab=workspaces')).toBe('/repos/42?repoTab=workspaces');
expect(getSwipeBackTarget('/repos/42/sessions/abc', '?repoTab=workspaces&assistant=1')).toBe(
'/assistant?view=sessions'
'/assistant'
);
});
});
describe('assistant route', () => {
it('returns assistant session list path for canonical assistant route', () => {
expect(getSwipeBackTarget('/assistant', '')).toBe('/assistant?view=sessions');
it('returns root for canonical assistant route', () => {
expect(getSwipeBackTarget('/assistant', '')).toBe('/');
});
it('returns root for assistant session list route', () => {
expect(getSwipeBackTarget('/assistant', '?view=sessions')).toBe('/');
});
it('returns assistant session list path for legacy assistant route', () => {
expect(getSwipeBackTarget('/repos/123/assistant', '')).toBe('/assistant?view=sessions');
});
it('returns root for legacy assistant session list route', () => {
expect(getSwipeBackTarget('/repos/42/assistant', '?view=sessions')).toBe('/');
it('returns root for legacy assistant route', () => {
expect(getSwipeBackTarget('/repos/123/assistant', '')).toBe('/');
});
});
+1 -5
View File
@@ -3,7 +3,7 @@ export function getAssistantPath(): string {
}
export function getAssistantSessionListPath(): string {
return '/assistant?view=sessions';
return '/assistant';
}
export function isAssistantPath(pathname: string): boolean {
@@ -52,10 +52,6 @@ export function getSwipeBackTarget(pathname: string, search = ''): string | null
}
if (isAssistantPath(pathname)) {
const params = new URLSearchParams(search);
if (params.get('view') !== 'sessions') {
return getAssistantSessionListPath();
}
return '/';
}
+67 -148
View File
@@ -1,8 +1,7 @@
import { useCallback, useEffect, useState } from "react"
import { useNavigate, useLocation } from "react-router-dom"
import { useState } from "react"
import { useNavigate } from "react-router-dom"
import { useQuery, useQueryClient } from "@tanstack/react-query"
import { getRepo } from "@/api/repos"
import { useAssistantSessionLauncher } from "@/hooks/useAssistantSessionLauncher"
import { useCreateSession } from "@/hooks/useOpenCode"
import { useDialogParam } from "@/hooks/useDialogParam"
import { useSSE } from "@/hooks/useSSE"
@@ -17,24 +16,19 @@ import { SourceControlPanel } from "@/components/source-control"
import { ResetPermissionsDialog } from "@/components/repo/ResetPermissionsDialog"
import { PendingActionsGroup } from "@/components/notifications/PendingActionsGroup"
import { invalidateConfigCaches } from "@/lib/queryInvalidation"
import { getSessionListPath, getAssistantPath } from "@/lib/navigation"
import { SwitchConfigDialog } from "@/components/repo/SwitchConfigDialog"
import { Loader2, Plus } from "lucide-react"
import { Plus } from "lucide-react"
export function AssistantRedirect() {
const navigate = useNavigate()
const location = useLocation()
const queryClient = useQueryClient()
const repoId = 0
const showSessionList = new URLSearchParams(location.search).get('view') === 'sessions'
const [fileBrowserOpen, setFileBrowserOpen] = useDialogParam('files')
const [mcpDialogOpen, setMcpDialogOpen] = useDialogParam('mcp')
const [skillsDialogOpen, setSkillsDialogOpen] = useDialogParam('skills')
const [sourceControlOpen, setSourceControlOpen] = useDialogParam('sourceControl')
const [resetPermissionsOpen, setResetPermissionsOpen] = useDialogParam('resetPermissions')
const [switchConfigOpen, setSwitchConfigOpen] = useState(false)
const [status, setStatus] = useState<"preparing" | "opening" | "creating" | "error">("preparing")
const [errorMessage, setErrorMessage] = useState<string | null>(null)
const opcodeUrl = OPENCODE_API_ENDPOINT
const { data: repo, isLoading: repoLoading, error: repoError } = useQuery({
@@ -42,20 +36,6 @@ export function AssistantRedirect() {
queryFn: () => getRepo(repoId),
})
const handleNavigate = useCallback((sessionId: string) => {
setStatus("opening")
if (!showSessionList) {
window.history.replaceState(window.history.state, "", getSessionListPath(repoId, true))
}
navigate(`/repos/${repoId}/sessions/${sessionId}?assistant=1`)
}, [navigate, repoId, showSessionList])
const { openAssistant } = useAssistantSessionLauncher({
opcodeUrl,
directory: repo?.fullPath,
onNavigate: handleNavigate,
})
const assistantDirectory = repo?.fullPath
const assistantFileBasePath = assistantDirectory?.split('/').filter(Boolean).at(-1)
@@ -69,134 +49,73 @@ export function AssistantRedirect() {
await createSessionMutation.mutateAsync({ agent: undefined })
}
useEffect(() => {
let cancelled = false
async function loadAndOpen() {
try {
if (showSessionList) return
setStatus("preparing")
if (repoLoading) return
if (repoError || !repo?.fullPath) throw new Error("Failed to load Assistant workspace")
if (cancelled) return
setStatus("creating")
await openAssistant()
} catch (error) {
if (cancelled) return
setStatus("error")
setErrorMessage(error instanceof Error ? error.message : "Failed to open Assistant")
}
}
loadAndOpen()
return () => {
cancelled = true
}
}, [repo?.fullPath, repoError, repoLoading, openAssistant, showSessionList])
if (showSessionList) {
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">
<Header>
<Header.BackButton to={getAssistantPath()} />
<Header.Title>Assistant</Header.Title>
<Header.Actions>
<div className="flex items-center gap-1">
<PendingActionsGroup />
</div>
<Button onClick={() => handleCreateSession()} disabled={!opcodeUrl || !assistantDirectory || createSessionMutation.isPending} size="sm" className="hidden sm:inline-flex bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105">
<Plus className="w-4 h-4 mr-2" />
<span>New Session</span>
</Button>
<Button onClick={() => handleCreateSession()} disabled={!opcodeUrl || !assistantDirectory || createSessionMutation.isPending} size="sm" className="sm:hidden h-10 w-10 p-0 bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105">
<Plus className="w-5 h-5" />
</Button>
</Header.Actions>
</Header>
<div className="flex-1 flex flex-col min-h-0">
{repoError ? (
<div className="p-4 text-sm text-muted-foreground">Failed to load Assistant sessions</div>
) : repoLoading || !repo?.fullPath ? (
<div className="p-4 text-sm text-muted-foreground">Loading Assistant sessions...</div>
) : (
<SessionList
opcodeUrl={opcodeUrl}
directory={assistantDirectory}
onSelectSession={(sessionId) => navigate(`/repos/${repoId}/sessions/${sessionId}?assistant=1`)}
/>
)}
</div>
{assistantDirectory && (
<>
<FileBrowserSheet isOpen={fileBrowserOpen} onClose={() => setFileBrowserOpen(false)} basePath={assistantFileBasePath} repoName="Assistant" repoId={repoId} />
<RepoMcpDialog open={mcpDialogOpen} onOpenChange={setMcpDialogOpen} directory={assistantDirectory} />
{assistantDirectory && opcodeUrl ? (
<RepoSkillsDialog
open={skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
sessionId="assistant-session"
opcodeUrl={opcodeUrl}
directory={assistantDirectory}
/>
) : (
<RepoSkillsDialog
open={skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
/>
)}
<SourceControlPanel repoId={repoId} isOpen={sourceControlOpen} onClose={() => setSourceControlOpen(false)} currentBranch={repo?.currentBranch || repo?.branch || "main"} repoName="Assistant" />
<ResetPermissionsDialog open={resetPermissionsOpen} onOpenChange={setResetPermissionsOpen} repoId={repoId} />
</>
)}
{repo && (
<SwitchConfigDialog
open={switchConfigOpen}
onOpenChange={setSwitchConfigOpen}
repoId={repoId}
currentConfigName={repo.openCodeConfigName}
onConfigSwitched={(configName) => {
queryClient.setQueryData(["repo", repoId], { ...repo, openCodeConfigName: configName })
invalidateConfigCaches(queryClient)
}}
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">
<Header>
<Header.BackButton to="/" />
<Header.Title>Assistant</Header.Title>
<Header.Actions>
<div className="flex items-center gap-1">
<PendingActionsGroup />
</div>
<Button onClick={() => handleCreateSession()} disabled={!opcodeUrl || !assistantDirectory || createSessionMutation.isPending} size="sm" className="hidden sm:inline-flex bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105">
<Plus className="w-4 h-4 mr-2" />
<span>New Session</span>
</Button>
<Button onClick={() => handleCreateSession()} disabled={!opcodeUrl || !assistantDirectory || createSessionMutation.isPending} size="sm" className="sm:hidden h-10 w-10 p-0 bg-blue-600 hover:bg-blue-700 text-white transition-all duration-200 hover:scale-105">
<Plus className="w-5 h-5" />
</Button>
</Header.Actions>
</Header>
<div className="flex-1 flex flex-col min-h-0">
{repoError ? (
<div className="p-4 text-sm text-muted-foreground">Failed to load Assistant sessions</div>
) : repoLoading || !repo?.fullPath ? (
<div className="p-4 text-sm text-muted-foreground">Loading Assistant sessions...</div>
) : (
<SessionList
opcodeUrl={opcodeUrl}
directory={assistantDirectory}
onSelectSession={(sessionId) => navigate(`/repos/${repoId}/sessions/${sessionId}?assistant=1`)}
/>
)}
</div>
)
}
return (
<div className="flex items-center justify-center min-h-screen bg-background">
<div className="text-center max-w-md px-4">
{status === "error" ? (
<>
<p className="text-muted-foreground mb-4">{errorMessage}</p>
<Button
onClick={() => navigate(getAssistantPath())}
variant="outline"
>
Go Back
</Button>
<Button
onClick={() => window.location.reload()}
className="ml-2"
>
Retry
</Button>
</>
) : (
<>
<Loader2 className="w-8 h-8 animate-spin text-muted-foreground mx-auto mb-4" />
<p className="text-muted-foreground">
{status === "preparing" && "Opening Assistant..."}
{status === "creating" && "Opening your last session chat..."}
{status === "opening" && "Opening your last session chat..."}
</p>
</>
)}
</div>
{assistantDirectory && (
<>
<FileBrowserSheet isOpen={fileBrowserOpen} onClose={() => setFileBrowserOpen(false)} basePath={assistantFileBasePath} repoName="Assistant" repoId={repoId} />
<RepoMcpDialog open={mcpDialogOpen} onOpenChange={setMcpDialogOpen} directory={assistantDirectory} />
{assistantDirectory && opcodeUrl ? (
<RepoSkillsDialog
open={skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
sessionId="assistant-session"
opcodeUrl={opcodeUrl}
directory={assistantDirectory}
/>
) : (
<RepoSkillsDialog
open={skillsDialogOpen}
onOpenChange={setSkillsDialogOpen}
repoId={repoId}
/>
)}
<SourceControlPanel repoId={repoId} isOpen={sourceControlOpen} onClose={() => setSourceControlOpen(false)} currentBranch={repo?.currentBranch || repo?.branch || "main"} repoName="Assistant" />
<ResetPermissionsDialog open={resetPermissionsOpen} onOpenChange={setResetPermissionsOpen} repoId={repoId} />
</>
)}
{repo && (
<SwitchConfigDialog
open={switchConfigOpen}
onOpenChange={setSwitchConfigOpen}
repoId={repoId}
currentConfigName={repo.openCodeConfigName}
onConfigSwitched={(configName) => {
queryClient.setQueryData(["repo", repoId], { ...repo, openCodeConfigName: configName })
invalidateConfigCaches(queryClient)
}}
/>
)}
</div>
)
}