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

@@ -13,7 +13,7 @@ import { BranchCombobox } from '@/components/repo/BranchCombobox'
import { ModelCheckboxList } from '@/components/repo/ModelCheckboxList'
import { MultiRunCard } from '@/components/repo/MultiRunCard'
import { FusionComposer, type FusionComposerSubmission } from '@/components/repo/FusionComposer'
import { ChangesWalkthroughDialog } from '@/components/session/ChangesWalkthroughDialog'
import { ChangesWalkthroughSheet } from '@/components/session/ChangesWalkthroughSheet'
import { useModelSections } from '@/hooks/useModelSections'
import { useDiscardMultiRunEntry, useFuseMultiRun, useLaunchMultiRun, useMultiRuns } from '@/hooks/useMultiRuns'
import { filterModelSections } from '@/lib/modelSections'
@@ -252,7 +252,7 @@ export function MultiRunSheet({ repoId, directory, defaultBaseRef, open, onOpenC
/>
{walkthroughSessionId ? (
<ChangesWalkthroughDialog
<ChangesWalkthroughSheet
sessionId={walkthroughSessionId}
open
onOpenChange={(next) => {
@@ -2,7 +2,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest'
import { render, screen, waitFor, within } from '@testing-library/react'
import userEvent, { type UserEvent } from '@testing-library/user-event'
import { FetchError } from '@opencode-manager/shared'
import { RepoActionsDialog } from './RepoActionsDialog'
import { RepoActionsContent, RepoActionsDialog } from './RepoActionsDialog'
import type { ProjectConfigResponse } from '@opencode-manager/shared/types'
const mocks = vi.hoisted(() => ({
@@ -78,6 +78,27 @@ describe('RepoActionsDialog', () => {
vi.clearAllMocks()
})
it('renders the actions content standalone without the dialog shell', () => {
mockConfig(baseConfig())
const view = render(<RepoActionsContent repoId={1} directory="/repo" open />)
expect(screen.getByText('No actions configured')).toBeInTheDocument()
expect(screen.queryByText('Project Actions')).not.toBeInTheDocument()
mockConfig(
baseConfig({
actions: [
{ id: 'personal-1', name: 'Dev server', command: 'pnpm dev', autoOpenUrl: false, source: 'personal' },
],
}),
)
view.rerender(<RepoActionsContent repoId={1} directory="/repo" open />)
expect(screen.getByText('Dev server')).toBeInTheDocument()
expect(screen.getByRole('tab', { name: /actions/i })).toBeInTheDocument()
expect(screen.queryByText('Project Actions')).not.toBeInTheDocument()
})
it('sends the full personal list when adding an action', async () => {
mockConfig(
baseConfig({
+270 -258
View File
@@ -191,14 +191,13 @@ function TabCount({ count }: { count: number }) {
return <span className="ml-1.5 text-xs tabular-nums text-muted-foreground">{count}</span>
}
interface RepoActionsDialogProps {
interface RepoActionsContentProps {
repoId: number
directory: string | undefined
open: boolean
onOpenChange: (open: boolean) => void
}
export function RepoActionsDialog({ repoId, directory, open, onOpenChange }: RepoActionsDialogProps) {
export function RepoActionsContent({ repoId, directory, open }: RepoActionsContentProps) {
const configQuery = useProjectConfig(repoId, directory, open && !!directory)
const updateActions = useUpdateProjectActions(repoId, directory)
const updateSetup = useUpdateWorktreeSetup(repoId, directory)
@@ -329,263 +328,251 @@ export function RepoActionsDialog({ repoId, directory, open, onOpenChange }: Rep
)
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
mobileFullscreen
className="flex flex-col gap-0 overflow-hidden p-0 pb-safe sm:h-auto sm:max-h-[85vh] sm:max-w-[560px] sm:p-0"
>
<DialogHeader className="shrink-0 border-b border-border px-4 py-4 sm:px-6">
<DialogTitle>Project Actions</DialogTitle>
<DialogDescription>Commands and setup steps for this location.</DialogDescription>
</DialogHeader>
{configQuery.isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-4 w-4 animate-spin text-primary" />
</div>
) : !config ? (
<p className="px-4 py-4 text-sm text-destructive sm:px-6">
{configQuery.error instanceof Error ? configQuery.error.message : 'No configuration available.'}
</p>
) : (
<>
{hasRepoFileStatus && (
<div className="shrink-0 space-y-2 px-4 pt-3 sm:px-6">
{config.repoFile.error && (
<p role="alert" className="text-sm text-destructive">
{config.repoFile.error}
</p>
)}
{config.repoFile.warnings.map((warning) => (
<p key={warning} className="text-xs text-warning">
{warning}
</p>
))}
{needsTrust && (
<div className="flex items-center gap-3 rounded-lg border border-warning/50 bg-warning/10 p-3">
<ShieldAlert className="h-4 w-4 shrink-0 text-warning" />
<div className="min-w-0 flex-1">
<p className="text-sm font-medium">Repository commands are not trusted</p>
<p className="text-xs text-muted-foreground">They won't run until you review and trust them.</p>
</div>
<Button type="button" size="sm" variant="outline" className="shrink-0" onClick={openTrustReview}>
Review
</Button>
</div>
)}
<div className="flex min-h-0 flex-1 flex-col">
{configQuery.isLoading ? (
<div className="flex items-center justify-center py-8">
<Loader2 className="h-4 w-4 animate-spin text-primary" />
</div>
) : !config ? (
<p className="px-4 py-4 text-sm text-destructive sm:px-6">
{configQuery.error instanceof Error ? configQuery.error.message : 'No configuration available.'}
</p>
) : (
<>
{hasRepoFileStatus && (
<div className="shrink-0 space-y-2 px-4 pt-3 sm:px-6">
{config.repoFile.error && (
<p role="alert" className="text-sm text-destructive">
{config.repoFile.error}
</p>
)}
{config.repoFile.warnings.map((warning) => (
<p key={warning} className="text-xs text-warning">
{warning}
</p>
))}
{needsTrust && (
<div className="flex items-center gap-3 rounded-lg border border-warning/50 bg-warning/10 p-3">
<ShieldAlert className="h-4 w-4 shrink-0 text-warning" />
<div className="min-w-0 flex-1">
<p className="text-sm font-medium">Repository commands are not trusted</p>
<p className="text-xs text-muted-foreground">They won't run until you review and trust them.</p>
</div>
<Button type="button" size="sm" variant="outline" className="shrink-0" onClick={openTrustReview}>
Review
</Button>
</div>
)}
<Tabs defaultValue="actions" className="flex min-h-0 flex-1 flex-col">
<div className="shrink-0 px-4 pt-3 sm:px-6">
<TabsList className="w-full justify-start">
<TabsTrigger value="actions">
Actions
<TabCount count={personalActions.length + repoActions.length} />
</TabsTrigger>
<TabsTrigger value="setup">
Worktree setup
<TabCount count={setupCommands.length + repoSetup.length} />
</TabsTrigger>
</TabsList>
</div>
<TabsContent value="actions" className="mt-0 flex min-h-0 flex-1 flex-col px-0">
<div className="flex shrink-0 items-center justify-between gap-3 px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground">Start these from the actions menu in the header.</p>
<Button
type="button"
size="sm"
variant="outline"
className="shrink-0"
onClick={() => setDraft(emptyActionDraft())}
>
<Plus className="h-4 w-4 mr-1" />
Add action
</Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-4 sm:px-6 sm:pb-6">
<SettingsList
isEmpty={personalActions.length === 0 && repoActions.length === 0 && !isAddingAction}
emptyTitle="No actions configured"
emptyHint="Add a command you run often, like a dev server or test watcher."
maxHeightClassName="max-h-none"
>
{personalActions.map((action) =>
draft?.id === action.id ? (
renderActionForm(draft)
) : (
<SettingsListRow
key={action.id}
className={COMPACT_ROW_CLASS}
title={<ActionTitle action={action} />}
description={<span className="font-mono" title={action.command}>{action.command}</span>}
belowDescription={<ActionUrl url={action.url} />}
onClick={() => setDraft(actionToDraft(action))}
trailing={
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8"
aria-label={`Edit ${action.name}`}
onClick={() => setDraft(actionToDraft(action))}
>
<Pencil className="h-4 w-4" />
</Button>
}
actions={[
{
label: 'Move to repository',
onClick: () => moveAction(action, 'repo'),
disabled: moveItem.isPending,
},
{
label: 'Delete',
destructive: true,
separatorBefore: true,
onClick: () => handleDeleteAction(action.id),
disabled: updateActions.isPending,
},
]}
actionsLabel={`Actions for ${action.name}`}
/>
),
)}
{isAddingAction && draft && renderActionForm(draft)}
{repoActions.map((action) => (
<SettingsListRow
key={`repo:${action.id}`}
className={COMPACT_ROW_CLASS}
title={<ActionTitle action={action} />}
badges={<Badge variant="secondary" className="shrink-0">In repo</Badge>}
description={<span className="font-mono" title={action.command}>{action.command}</span>}
belowDescription={<ActionUrl url={action.url} />}
actions={[
{
label: 'Move to my settings',
onClick: () => moveAction(action, 'personal'),
disabled: moveItem.isPending,
},
]}
actionsLabel={`Actions for ${action.name}`}
/>
))}
</SettingsList>
</div>
</TabsContent>
<TabsContent value="setup" className="mt-0 flex min-h-0 flex-1 flex-col px-0">
<div className="flex shrink-0 items-center justify-between gap-3 px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground">
Run in order after a new worktree is created.{' '}
<code className="font-mono">$ROOT_PROJECT_PATH</code> points to the main checkout.
</p>
<Button type="button" size="sm" variant="outline" className="shrink-0" onClick={addSetupCommand}>
<Plus className="h-4 w-4 mr-1" />
Add command
</Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-4 sm:px-6">
<SettingsList
isEmpty={setupCommands.length === 0 && repoSetup.length === 0}
emptyTitle="No setup commands"
emptyHint="Add commands such as pnpm install to prepare new worktrees."
maxHeightClassName="max-h-none"
>
{setupCommands.map((command, index) => (
<div key={index} className="flex items-center gap-1 bg-card px-3 py-2">
<Input
aria-label={`Setup command ${index + 1}`}
autoFocus={index === focusSetupIndex}
value={command}
className="mr-1 h-9 min-w-0 flex-1 font-mono md:text-xs"
onChange={(event) =>
setSetupCommands((current) =>
current.map((item, itemIndex) => (itemIndex === index ? event.target.value : item)),
)
}
/>
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8 shrink-0"
aria-label="Move up"
disabled={index === 0}
onClick={() => setSetupCommands((current) => arrayMove(current, index, index - 1))}
>
<ArrowUp className="h-4 w-4" />
</Button>
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8 shrink-0"
aria-label="Move down"
disabled={index === setupCommands.length - 1}
onClick={() => setSetupCommands((current) => arrayMove(current, index, index + 1))}
>
<ArrowDown className="h-4 w-4" />
</Button>
<SettingsListRowActionsMenu
label={`Actions for setup command ${index + 1}`}
actions={[
{
label: 'Move to repository',
onClick: () => moveSetup(command, 'repo'),
disabled: setupDirty || moveItem.isPending,
},
{
label: 'Remove',
destructive: true,
separatorBefore: true,
onClick: () =>
setSetupCommands((current) => current.filter((_, itemIndex) => itemIndex !== index)),
},
]}
/>
</div>
))}
{repoSetup.map((item) => (
<SettingsListRow
key={`repo:${item.command}`}
className={COMPACT_ROW_CLASS}
title={<span title={item.command}>{item.command}</span>}
titleClassName="font-mono text-xs font-normal"
badges={<Badge variant="secondary" className="shrink-0">In repo</Badge>}
actions={[
{
label: 'Move to my settings',
onClick: () => moveSetup(item.command, 'personal'),
disabled: moveItem.isPending,
},
]}
actionsLabel={`Actions for ${item.command}`}
/>
))}
</SettingsList>
</div>
<div className="flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground" aria-live="polite">
{setupDirty ? 'Unsaved changes' : ''}
</p>
<Button
type="button"
size="sm"
onClick={handleSaveSetup}
disabled={!setupDirty || !setupValid || updateSetup.isPending}
>
Save setup
</Button>
</div>
</TabsContent>
</Tabs>
</>
</div>
)}
</DialogContent>
</Dialog>
<Tabs defaultValue="actions" className="flex min-h-0 flex-1 flex-col">
<div className="shrink-0 px-4 pt-3 sm:px-6">
<TabsList className="w-full justify-start">
<TabsTrigger value="actions">
Actions
<TabCount count={personalActions.length + repoActions.length} />
</TabsTrigger>
<TabsTrigger value="setup">
Worktree setup
<TabCount count={setupCommands.length + repoSetup.length} />
</TabsTrigger>
</TabsList>
</div>
<TabsContent value="actions" className="mt-0 flex min-h-0 flex-1 flex-col px-0">
<div className="flex shrink-0 items-center justify-between gap-3 px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground">Start these from the actions menu in the header.</p>
<Button
type="button"
size="sm"
variant="outline"
className="shrink-0"
onClick={() => setDraft(emptyActionDraft())}
>
<Plus className="h-4 w-4 mr-1" />
Add action
</Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-4 sm:px-6 sm:pb-6">
<SettingsList
isEmpty={personalActions.length === 0 && repoActions.length === 0 && !isAddingAction}
emptyTitle="No actions configured"
emptyHint="Add a command you run often, like a dev server or test watcher."
maxHeightClassName="max-h-none"
>
{personalActions.map((action) =>
draft?.id === action.id ? (
renderActionForm(draft)
) : (
<SettingsListRow
key={action.id}
className={COMPACT_ROW_CLASS}
title={<ActionTitle action={action} />}
description={<span className="font-mono" title={action.command}>{action.command}</span>}
belowDescription={<ActionUrl url={action.url} />}
onClick={() => setDraft(actionToDraft(action))}
trailing={
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8"
aria-label={`Edit ${action.name}`}
onClick={() => setDraft(actionToDraft(action))}
>
<Pencil className="h-4 w-4" />
</Button>
}
actions={[
{
label: 'Move to repository',
onClick: () => moveAction(action, 'repo'),
disabled: moveItem.isPending,
},
{
label: 'Delete',
destructive: true,
separatorBefore: true,
onClick: () => handleDeleteAction(action.id),
disabled: updateActions.isPending,
},
]}
actionsLabel={`Actions for ${action.name}`}
/>
),
)}
{isAddingAction && draft && renderActionForm(draft)}
{repoActions.map((action) => (
<SettingsListRow
key={`repo:${action.id}`}
className={COMPACT_ROW_CLASS}
title={<ActionTitle action={action} />}
badges={<Badge variant="secondary" className="shrink-0">In repo</Badge>}
description={<span className="font-mono" title={action.command}>{action.command}</span>}
belowDescription={<ActionUrl url={action.url} />}
actions={[
{
label: 'Move to my settings',
onClick: () => moveAction(action, 'personal'),
disabled: moveItem.isPending,
},
]}
actionsLabel={`Actions for ${action.name}`}
/>
))}
</SettingsList>
</div>
</TabsContent>
<TabsContent value="setup" className="mt-0 flex min-h-0 flex-1 flex-col px-0">
<div className="flex shrink-0 items-center justify-between gap-3 px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground">
Run in order after a new worktree is created.{' '}
<code className="font-mono">$ROOT_PROJECT_PATH</code> points to the main checkout.
</p>
<Button type="button" size="sm" variant="outline" className="shrink-0" onClick={addSetupCommand}>
<Plus className="h-4 w-4 mr-1" />
Add command
</Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto px-4 pb-4 sm:px-6">
<SettingsList
isEmpty={setupCommands.length === 0 && repoSetup.length === 0}
emptyTitle="No setup commands"
emptyHint="Add commands such as pnpm install to prepare new worktrees."
maxHeightClassName="max-h-none"
>
{setupCommands.map((command, index) => (
<div key={index} className="flex items-center gap-1 bg-card px-3 py-2">
<Input
aria-label={`Setup command ${index + 1}`}
autoFocus={index === focusSetupIndex}
value={command}
className="mr-1 h-9 min-w-0 flex-1 font-mono md:text-xs"
onChange={(event) =>
setSetupCommands((current) =>
current.map((item, itemIndex) => (itemIndex === index ? event.target.value : item)),
)
}
/>
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8 shrink-0"
aria-label="Move up"
disabled={index === 0}
onClick={() => setSetupCommands((current) => arrayMove(current, index, index - 1))}
>
<ArrowUp className="h-4 w-4" />
</Button>
<Button
type="button"
size="icon"
variant="ghost"
className="h-8 w-8 shrink-0"
aria-label="Move down"
disabled={index === setupCommands.length - 1}
onClick={() => setSetupCommands((current) => arrayMove(current, index, index + 1))}
>
<ArrowDown className="h-4 w-4" />
</Button>
<SettingsListRowActionsMenu
label={`Actions for setup command ${index + 1}`}
actions={[
{
label: 'Move to repository',
onClick: () => moveSetup(command, 'repo'),
disabled: setupDirty || moveItem.isPending,
},
{
label: 'Remove',
destructive: true,
separatorBefore: true,
onClick: () =>
setSetupCommands((current) => current.filter((_, itemIndex) => itemIndex !== index)),
},
]}
/>
</div>
))}
{repoSetup.map((item) => (
<SettingsListRow
key={`repo:${item.command}`}
className={COMPACT_ROW_CLASS}
title={<span title={item.command}>{item.command}</span>}
titleClassName="font-mono text-xs font-normal"
badges={<Badge variant="secondary" className="shrink-0">In repo</Badge>}
actions={[
{
label: 'Move to my settings',
onClick: () => moveSetup(item.command, 'personal'),
disabled: moveItem.isPending,
},
]}
actionsLabel={`Actions for ${item.command}`}
/>
))}
</SettingsList>
</div>
<div className="flex shrink-0 items-center justify-between gap-3 border-t border-border px-4 py-3 sm:px-6">
<p className="text-xs text-muted-foreground" aria-live="polite">
{setupDirty ? 'Unsaved changes' : ''}
</p>
<Button
type="button"
size="sm"
onClick={handleSaveSetup}
disabled={!setupDirty || !setupValid || updateSetup.isPending}
>
Save setup
</Button>
</div>
</TabsContent>
</Tabs>
</>
)}
<ConfirmDestructiveDialog
open={open && trustReview !== null}
@@ -599,6 +586,31 @@ export function RepoActionsDialog({ repoId, directory, open, onOpenChange }: Rep
pendingLabel="Trusting…"
isPending={trustConfig.isPending}
/>
</>
</div>
)
}
interface RepoActionsDialogProps {
repoId: number
directory: string | undefined
open: boolean
onOpenChange: (open: boolean) => void
}
export function RepoActionsDialog({ repoId, directory, open, onOpenChange }: RepoActionsDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent
mobileFullscreen
className="flex flex-col gap-0 overflow-hidden p-0 pb-safe sm:h-auto sm:max-h-[85vh] sm:max-w-[560px] sm:p-0"
>
<DialogHeader className="shrink-0 border-b border-border px-4 py-4 sm:px-6">
<DialogTitle>Project Actions</DialogTitle>
<DialogDescription>Commands and setup steps for this location.</DialogDescription>
</DialogHeader>
<RepoActionsContent repoId={repoId} directory={directory} open={open} />
</DialogContent>
</Dialog>
)
}
+53 -45
View File
@@ -15,7 +15,12 @@ interface RepoMcpDialogProps {
directory: string | undefined
}
export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogProps) {
interface RepoMcpContentProps {
open: boolean
directory: string
}
export function RepoMcpContent({ open, directory }: RepoMcpContentProps) {
const queryClient = useQueryClient()
const [localStatus, setLocalStatus] = useState<Record<string, McpStatus>>({})
const [isLoadingStatus, setIsLoadingStatus] = useState(false)
@@ -26,8 +31,6 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
const serverIds = Object.keys(localStatus)
const fetchStatus = useCallback(async () => {
if (!directory) return
setIsLoadingStatus(true)
try {
setLocalStatus(await mcpApi.getStatus(directory))
@@ -39,8 +42,6 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
const toggleMutation = useMutation({
mutationFn: async ({ serverId, enable }: { serverId: string; enable: boolean }) => {
if (!directory) throw new Error('No directory provided')
if (enable) {
await mcpApi.connect(serverId, directory)
} else {
@@ -59,7 +60,6 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
const removeAuthMutation = useMutation({
mutationFn: async (serverId: string) => {
if (!directory) throw new Error('No directory provided')
await mcpApi.removeAuth(serverId, directory)
},
onSuccess: async () => {
@@ -79,7 +79,7 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
}
const handleOAuthCheckStatus = async (): Promise<boolean> => {
if (!authDialogServerId || !directory) return false
if (!authDialogServerId) return false
const status = await mcpApi.getStatus(directory)
if (status[authDialogServerId]?.status === 'connected') {
setLocalStatus(status)
@@ -94,16 +94,58 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
}
useEffect(() => {
if (open && directory) {
if (open) {
fetchStatus()
}
}, [open, directory, fetchStatus])
}, [open, fetchStatus])
return (
<div className="flex min-h-0 flex-1 flex-col">
<RepoMcpServerList
hasFetchedStatus={hasFetchedStatus}
serverIds={serverIds}
isLoadingStatus={isLoadingStatus}
localStatus={localStatus}
toggleMutation={toggleMutation}
removeAuthMutation={removeAuthMutation}
onAuthClick={setAuthDialogServerId}
onRemoveAuthClick={setRemoveAuthConfirmServer}
/>
<DeleteDialog
open={!!removeAuthConfirmServer}
onOpenChange={() => setRemoveAuthConfirmServer(null)}
onConfirm={() => {
if (removeAuthConfirmServer) {
removeAuthMutation.mutate(removeAuthConfirmServer)
}
}}
onCancel={() => setRemoveAuthConfirmServer(null)}
title="Remove Authentication"
description="This will remove the OAuth credentials for this MCP server at this location. You will need to re-authenticate to use this server here again."
itemName={removeAuthConfirmServer ? formatMcpServerName(removeAuthConfirmServer) : ''}
isDeleting={removeAuthMutation.isPending}
/>
<McpOAuthDialog
open={!!authDialogServerId}
onOpenChange={(o) => !o && setAuthDialogServerId(null)}
serverName={authDialogServerId || ''}
onStartAuth={handleOAuthStartAuth}
onCheckStatus={handleOAuthCheckStatus}
onSuccess={handleOAuthSuccess}
directory={directory}
/>
</div>
)
}
export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogProps) {
if (!directory) return null
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent mobileFullscreen className="sm:fixed sm:left-1/2 sm:top-1/2 sm:-translate-x-1/2 sm:-translate-y-1/2 sm:w-[400px] sm:max-w-[400px] sm:h-auto sm:max-h-[80vh] flex flex-col gap-0 pb-safe">
<DialogContent mobileFullscreen className="sm:fixed sm:left-1/2 sm:top-1/2 sm:-translate-x-1/2 sm:-translate-y-1/2 sm:w-[400px] sm:max-w-[400px] sm:h-auto sm:max-h-[80vh] flex flex-col gap-0 pb-safe">
<DialogHeader className="px-4 sm:px-6 pt-4 sm:pt-6 pb-2 sm:pb-3 shrink-0 ">
<DialogTitle>MCP for This Location</DialogTitle>
<DialogDescription>
@@ -111,41 +153,7 @@ export function RepoMcpDialog({ open, onOpenChange, directory }: RepoMcpDialogPr
</DialogDescription>
</DialogHeader>
<RepoMcpServerList
hasFetchedStatus={hasFetchedStatus}
serverIds={serverIds}
isLoadingStatus={isLoadingStatus}
localStatus={localStatus}
toggleMutation={toggleMutation}
removeAuthMutation={removeAuthMutation}
onAuthClick={setAuthDialogServerId}
onRemoveAuthClick={setRemoveAuthConfirmServer}
/>
<DeleteDialog
open={!!removeAuthConfirmServer}
onOpenChange={() => setRemoveAuthConfirmServer(null)}
onConfirm={() => {
if (removeAuthConfirmServer) {
removeAuthMutation.mutate(removeAuthConfirmServer)
}
}}
onCancel={() => setRemoveAuthConfirmServer(null)}
title="Remove Authentication"
description="This will remove the OAuth credentials for this MCP server at this location. You will need to re-authenticate to use this server here again."
itemName={removeAuthConfirmServer ? formatMcpServerName(removeAuthConfirmServer) : ''}
isDeleting={removeAuthMutation.isPending}
/>
<McpOAuthDialog
open={!!authDialogServerId}
onOpenChange={(o) => !o && setAuthDialogServerId(null)}
serverName={authDialogServerId || ''}
onStartAuth={handleOAuthStartAuth}
onCheckStatus={handleOAuthCheckStatus}
onSuccess={handleOAuthSuccess}
directory={directory}
/>
<RepoMcpContent open={open} directory={directory} />
</DialogContent>
</Dialog>
)
@@ -1,7 +1,7 @@
import { useState } from 'react'
import { useQuery, useQueryClient } from '@tanstack/react-query'
import { Download } from 'lucide-react'
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Button } from '@/components/ui/button'
import { DeleteDialog } from '@/components/ui/delete-dialog'
import { SkillLibraryList } from '@/components/skills/SkillLibraryList'
@@ -12,25 +12,30 @@ import { useDeleteSkill } from '@/hooks/useDeleteSkill'
import { invalidateSkillCaches } from '@/lib/queryInvalidation'
import type { SkillFileInfo } from '@opencode-manager/shared'
type RepoSkillsDialogBaseProps = {
type RepoSkillsSessionProps =
| { sessionId: string; directory?: string; onSkillLoaded?: (skill: SkillFileInfo) => void }
| { sessionId?: undefined; directory?: undefined; onSkillLoaded?: undefined }
type RepoSkillsDialogProps = {
open: boolean
onOpenChange: (open: boolean) => void
repoId: number
}
} & RepoSkillsSessionProps
type RepoSkillsDialogProps = RepoSkillsDialogBaseProps & (
| { sessionId: string; directory?: string; onSkillLoaded?: (skill: SkillFileInfo) => void }
| { sessionId?: undefined; directory?: undefined; onSkillLoaded?: undefined }
)
type RepoSkillsContentProps = {
open: boolean
repoId: number
onDone: () => void
} & RepoSkillsSessionProps
export function RepoSkillsDialog({
export function RepoSkillsContent({
open,
onOpenChange,
repoId,
sessionId,
directory,
onSkillLoaded,
}: RepoSkillsDialogProps) {
onDone,
}: RepoSkillsContentProps) {
const queryClient = useQueryClient()
const [installDialogOpen, setInstallDialogOpen] = useState(false)
const { deleteSkill, setDeleteSkill, confirmDelete, isDeleting } = useDeleteSkill()
@@ -49,49 +54,37 @@ export function RepoSkillsDialog({
const handleLoad = (skill: SkillFileInfo) => {
loadSkill.mutate({ skillName: skill.name })
onSkillLoaded?.(skill)
onOpenChange(false)
onDone()
}
const handleInstalled = () => {
invalidateSkillCaches(queryClient)
}
if (!repoId && !sessionId) {
return null
}
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent mobileFullscreen 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">
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
<div>
<DialogTitle>Skills</DialogTitle>
<DialogDescription>
{canLoad ? 'Search and load a skill into the current session' : 'Skills available for this repository'}
</DialogDescription>
</div>
<Button type="button" variant="outline" size="sm" onClick={() => setInstallDialogOpen(true)}>
<Download className="h-4 w-4 mr-1" />
Install Skill
</Button>
</div>
</DialogHeader>
<div className="flex-1 overflow-y-auto p-4 sm:p-6">
<SkillLibraryList
isLoading={isLoading}
data={data}
error={error as Error | null}
primaryAction={canLoad ? { label: 'Load', onClick: handleLoad } : undefined}
rowActions={[{ label: 'Delete', onClick: setDeleteSkill, destructive: true }]}
emptyTitle="No skills found"
emptyHint="Install a skill or add one to .opencode/skills/<name>/SKILL.md."
maxHeightClassName="max-h-[55vh]"
/>
</div>
</DialogContent>
</Dialog>
<div className="flex min-h-0 flex-1 flex-col">
<div className="flex shrink-0 items-center justify-between gap-2 px-4 py-3 sm:px-6">
<p className="text-sm text-muted-foreground">
{canLoad ? 'Search and load a skill into the current session' : 'Skills available for this repository'}
</p>
<Button type="button" variant="outline" size="sm" onClick={() => setInstallDialogOpen(true)}>
<Download className="h-4 w-4 mr-1" />
Install Skill
</Button>
</div>
<div className="min-h-0 flex-1 overflow-y-auto p-4 sm:p-6">
<SkillLibraryList
isLoading={isLoading}
data={data}
error={error as Error | null}
primaryAction={canLoad ? { label: 'Load', onClick: handleLoad } : undefined}
rowActions={[{ label: 'Delete', onClick: setDeleteSkill, destructive: true }]}
emptyTitle="No skills found"
emptyHint="Install a skill or add one to .opencode/skills/<name>/SKILL.md."
maxHeightClassName="max-h-none"
/>
</div>
<SkillInstallDialog
open={installDialogOpen}
@@ -109,6 +102,23 @@ export function RepoSkillsDialog({
itemName={deleteSkill?.name}
isDeleting={isDeleting}
/>
</>
</div>
)
}
export function RepoSkillsDialog({ onOpenChange, ...props }: RepoSkillsDialogProps) {
if (!props.repoId && !props.sessionId) {
return null
}
return (
<Dialog open={props.open} onOpenChange={onOpenChange}>
<DialogContent mobileFullscreen 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>Skills</DialogTitle>
</DialogHeader>
<RepoSkillsContent {...props} onDone={() => onOpenChange(false)} />
</DialogContent>
</Dialog>
)
}