feat(ssh): surface SSH status in worktree UI and streamline add-repo flow (#1067)
- Show SSH icon (Globe/WifiOff) beside worktree titles in jump palette and WorktreeCard so remote state is visible at a glance. - Replace inline add-repo flow in NewWorkspaceComposerCard with the existing add-repo modal for a single entry point. - When no SSH targets are configured, let users jump straight to SSH settings from the add-repo dialog, and disable remote path until a target is selected.
This commit is contained in:
@@ -19,7 +19,6 @@ import { AGENT_CATALOG } from '@/lib/agent-catalog'
|
||||
import { useAppStore } from '@/store'
|
||||
import { cn } from '@/lib/utils'
|
||||
import type { TuiAgent } from '../../../shared/types'
|
||||
import { isGitRepoKind } from '../../../shared/repo-kind'
|
||||
|
||||
const isMac = typeof navigator !== 'undefined' && navigator.userAgent.includes('Mac')
|
||||
|
||||
@@ -190,11 +189,9 @@ export default function NewWorkspaceComposerCard({
|
||||
createError
|
||||
}: NewWorkspaceComposerCardProps): React.JSX.Element {
|
||||
const { isFileDragOver, dragHandlers } = useComposerFileDragOver()
|
||||
const addRepo = useAppStore((s) => s.addRepo)
|
||||
const fetchWorktrees = useAppStore((s) => s.fetchWorktrees)
|
||||
const openModal = useAppStore((s) => s.openModal)
|
||||
const defaultTuiAgent = useAppStore((s) => s.settings?.defaultTuiAgent ?? null)
|
||||
const updateSettings = useAppStore((s) => s.updateSettings)
|
||||
const [isAddingRepo, setIsAddingRepo] = React.useState(false)
|
||||
|
||||
const handleSetDefaultAgent = React.useCallback(
|
||||
(next: TuiAgent | 'blank' | null) => {
|
||||
@@ -218,25 +215,9 @@ export default function NewWorkspaceComposerCard({
|
||||
[detectedAgentIds]
|
||||
)
|
||||
|
||||
const handleAddRepo = React.useCallback(async (): Promise<void> => {
|
||||
if (isAddingRepo) {
|
||||
return
|
||||
}
|
||||
setIsAddingRepo(true)
|
||||
try {
|
||||
const repo = await addRepo()
|
||||
if (!repo) {
|
||||
return
|
||||
}
|
||||
if (isGitRepoKind(repo)) {
|
||||
await fetchWorktrees(repo.id)
|
||||
}
|
||||
onRepoChange(repo.id)
|
||||
focusNameInput()
|
||||
} finally {
|
||||
setIsAddingRepo(false)
|
||||
}
|
||||
}, [addRepo, fetchWorktrees, focusNameInput, isAddingRepo, onRepoChange])
|
||||
const handleAddRepo = React.useCallback((): void => {
|
||||
openModal('add-repo')
|
||||
}, [openModal])
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -265,12 +246,9 @@ export default function NewWorkspaceComposerCard({
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-xs"
|
||||
disabled={isAddingRepo}
|
||||
onClick={() => void handleAddRepo()}
|
||||
onClick={handleAddRepo}
|
||||
className="size-5 shrink-0 rounded-sm text-muted-foreground hover:text-foreground"
|
||||
aria-label={
|
||||
isAddingRepo ? 'Adding folder or repository' : 'Add folder or repository'
|
||||
}
|
||||
aria-label="Add folder or repository"
|
||||
>
|
||||
<FolderPlus className="size-3" />
|
||||
</Button>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* oxlint-disable max-lines */
|
||||
import React, { useCallback, useDeferredValue, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { Globe, Plus } from 'lucide-react'
|
||||
import { Globe, Plus, WifiOff } from 'lucide-react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { getRepoMapFromState, useAllWorktrees } from '@/store/selectors'
|
||||
import {
|
||||
@@ -145,6 +145,7 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null {
|
||||
const activeBrowserTabId = useAppStore((s) => s.activeBrowserTabId)
|
||||
const browserTabsByWorktree = useAppStore((s) => s.browserTabsByWorktree)
|
||||
const browserPagesByWorkspace = useAppStore((s) => s.browserPagesByWorkspace)
|
||||
const sshConnectionStates = useAppStore((s) => s.sshConnectionStates)
|
||||
|
||||
const [query, setQuery] = useState('')
|
||||
const deferredQuery = useDeferredValue(query)
|
||||
@@ -705,6 +706,11 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null {
|
||||
)
|
||||
const statusLabel = getWorktreeStatusLabel(status)
|
||||
const isCurrentWorktree = activeWorktreeId === worktree.id
|
||||
const sshConnectionId = repo?.connectionId ?? null
|
||||
const sshStatus = sshConnectionId
|
||||
? (sshConnectionStates.get(sshConnectionId)?.status ?? 'disconnected')
|
||||
: null
|
||||
const isSshDisconnected = sshStatus != null && sshStatus !== 'connected'
|
||||
|
||||
return (
|
||||
<CommandItem
|
||||
@@ -725,6 +731,21 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null {
|
||||
<div className="flex items-center justify-between gap-2.5">
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex min-w-0 items-center gap-2">
|
||||
{sshConnectionId && (
|
||||
<span
|
||||
aria-label={isSshDisconnected ? 'SSH disconnected' : 'SSH remote'}
|
||||
className="shrink-0 inline-flex items-center"
|
||||
>
|
||||
{isSshDisconnected ? (
|
||||
<WifiOff className="size-3.5 text-red-400" aria-hidden="true" />
|
||||
) : (
|
||||
<Globe
|
||||
className="size-3.5 text-muted-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
)}
|
||||
</span>
|
||||
)}
|
||||
<span className="truncate text-[14px] font-semibold tracking-[-0.01em] text-foreground">
|
||||
{entry.match.displayNameRange ? (
|
||||
<HighlightedText
|
||||
|
||||
@@ -316,6 +316,11 @@ const AddRepoDialog = React.memo(function AddRepoDialog() {
|
||||
setRemoteError(null)
|
||||
}}
|
||||
onAdd={handleAddRemoteRepo}
|
||||
onOpenSshSettings={() => {
|
||||
closeModal()
|
||||
openSettingsTarget({ pane: 'ssh', repoId: null, sectionId: 'ssh' })
|
||||
openSettingsPage()
|
||||
}}
|
||||
/>
|
||||
) : step === 'clone' ? (
|
||||
<CloneStep
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
import React, { useCallback, useRef, useState } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import { Folder, FolderOpen } from 'lucide-react'
|
||||
import { Folder, FolderOpen, Settings } from 'lucide-react'
|
||||
import { useAppStore } from '@/store'
|
||||
import { DialogHeader, DialogTitle, DialogDescription } from '@/components/ui/dialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -148,6 +148,7 @@ type RemoteStepProps = {
|
||||
onSelectTarget: (id: string) => void
|
||||
onRemotePathChange: (value: string) => void
|
||||
onAdd: () => void
|
||||
onOpenSshSettings: () => void
|
||||
}
|
||||
|
||||
export function RemoteStep({
|
||||
@@ -158,7 +159,8 @@ export function RemoteStep({
|
||||
isAddingRemote,
|
||||
onSelectTarget,
|
||||
onRemotePathChange,
|
||||
onAdd
|
||||
onAdd,
|
||||
onOpenSshSettings
|
||||
}: RemoteStepProps): React.JSX.Element {
|
||||
const [browsing, setBrowsing] = useState(false)
|
||||
|
||||
@@ -197,9 +199,18 @@ export function RemoteStep({
|
||||
<div className="space-y-1">
|
||||
<label className="text-[11px] font-medium text-muted-foreground">SSH target</label>
|
||||
{sshTargets.length === 0 ? (
|
||||
<p className="text-xs text-muted-foreground py-2">
|
||||
No SSH targets configured. Add one in Settings first.
|
||||
</p>
|
||||
<div className="space-y-1.5 py-1">
|
||||
<p className="text-xs text-muted-foreground">No SSH targets configured.</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-7 text-xs"
|
||||
onClick={onOpenSshSettings}
|
||||
>
|
||||
<Settings className="size-3.5" />
|
||||
Add in Settings
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-1.5">
|
||||
{sshTargets.map((target) => {
|
||||
@@ -252,7 +263,7 @@ export function RemoteStep({
|
||||
}}
|
||||
placeholder="/home/user/project"
|
||||
className="h-8 text-xs flex-1"
|
||||
disabled={isAddingRemote}
|
||||
disabled={isAddingRemote || !selectedTargetId}
|
||||
/>
|
||||
<Button
|
||||
variant="outline"
|
||||
|
||||
@@ -288,6 +288,23 @@ const WorktreeCard = React.memo(function WorktreeCard({
|
||||
{/* Header row: Title and Checks */}
|
||||
<div className="flex items-center justify-between min-w-0 gap-2">
|
||||
<div className="flex items-center gap-1.5 min-w-0">
|
||||
{repo?.connectionId && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="shrink-0 inline-flex items-center">
|
||||
{isSshDisconnected ? (
|
||||
<WifiOff className="size-3 text-red-400" />
|
||||
) : (
|
||||
<Globe className="size-3 text-muted-foreground" />
|
||||
)}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" sideOffset={8}>
|
||||
{isSshDisconnected ? 'SSH disconnected' : 'Remote repository via SSH'}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
<div className="text-[12px] font-semibold text-foreground truncate leading-tight">
|
||||
{worktree.displayName}
|
||||
</div>
|
||||
@@ -352,23 +369,6 @@ const WorktreeCard = React.memo(function WorktreeCard({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{repo?.connectionId && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<span className="shrink-0 inline-flex items-center gap-0.5">
|
||||
{isSshDisconnected ? (
|
||||
<WifiOff className="size-3 text-red-400" />
|
||||
) : (
|
||||
<Globe className="size-3 text-muted-foreground" />
|
||||
)}
|
||||
</span>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="right" sideOffset={8}>
|
||||
{isSshDisconnected ? 'SSH disconnected' : 'Remote repository via SSH'}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)}
|
||||
|
||||
{isFolder ? (
|
||||
<Badge
|
||||
variant="secondary"
|
||||
|
||||
@@ -93,6 +93,7 @@ export type UISlice = {
|
||||
| 'repo'
|
||||
| 'agents'
|
||||
| 'experimental'
|
||||
| 'ssh'
|
||||
repoId: string | null
|
||||
sectionId?: string
|
||||
} | null
|
||||
|
||||
Reference in New Issue
Block a user