feat(servers): harden pairing and run linked-server sessions in the UI

Replace the plaintext pairing exchange with a nonce and HMAC proof plus
AES-256-GCM encrypted credentials, bumping links to v2. Track session
ownership per linked server so activity, session picker, transcript, MCP
and skills views work against remote servers. Share encrypted secret
access, event routing and URL helpers across backend, shared and CLI.
This commit is contained in:
Chris Scott committed 2026-10-18 20:27:34 -04:00
1 parent c591c15743
commit f566556fd6
77 files changed
+3170 -702

No files matched your search

@@ -45,9 +45,12 @@ function createRepo(id: number, name: string): Repo {
function createItem(
overrides: Partial<ActiveWorkItem> & Pick<ActiveWorkItem, 'state' | 'session' | 'repo'>,
): ActiveWorkItem {
const repoId = overrides.repo?.id ?? 0
return {
key: `${overrides.repo.id}:${overrides.session.id}`,
path: `/repos/${overrides.repo.id}/sessions/${overrides.session.id}`,
key: `${repoId}:${overrides.session.id}`,
serverId: null,
serverName: null,
path: `/repos/${repoId}/sessions/${overrides.session.id}`,
updatedAt: overrides.session.time.updated,
...overrides,
}
@@ -175,6 +178,24 @@ describe('ActivityList', () => {
expect(screen.getByRole('button', { name: /Other session/ })).not.toHaveAttribute('aria-current')
})
it('labels a remote row with its server name and marks it current on its server route', () => {
const item = createItem({
state: 'needs-input',
session: createSession('s1', 'Remote session'),
repo: null,
serverId: 'srv_kitchen',
serverName: 'Kitchen',
path: '/servers/srv_kitchen/sessions/s1',
})
setGroups({ needsInput: [item] })
renderList(vi.fn(), '/servers/srv_kitchen/sessions/s1')
const row = screen.getByRole('button', { name: /Remote session/ })
expect(row).toHaveTextContent('Kitchen')
expect(row).toHaveAttribute('aria-current', 'true')
})
it('shows a loading state', () => {
mocks.useActiveWork.mockReturnValue({
groups: { needsInput: [], running: [], recent: [] },
@@ -2,7 +2,7 @@ import { useLocation } from 'react-router-dom'
import { CircleAlert, CircleCheck, CircleX } from 'lucide-react'
import { useActiveWork } from '@/hooks/useActiveWork'
import { SessionStatusIndicator } from '@/components/ui/session-status-indicator'
import { parseRepoRoute } from '@/lib/navigation'
import { parseRepoRoute, parseServerSessionRoute } from '@/lib/navigation'
import { cn, formatShortRelativeTime, getRepoBranchLabel, getRepoDisplayName } from '@/lib/utils'
import {
ACTIVE_WORK_GROUPS,
@@ -28,8 +28,27 @@ interface ActivityListProps {
variant?: 'full' | 'compact'
}
function isCurrentItem(item: ActiveWorkItem, sessionID: string | null, repoID: number | null) {
return item.repo.id === repoID && item.session.id === sessionID
function isCurrentItem(
item: ActiveWorkItem,
sessionID: string | null,
repoID: number | null,
serverID: string | null,
) {
if (item.session.id !== sessionID) return false
if (item.serverId) return item.serverId === serverID
return item.repo?.id === repoID
}
/** The row's short label: the local repo's name or the owning linked server's name. */
function activityItemLabel(item: ActiveWorkItem): string {
return item.repo ? getRepoDisplayName(item.repo) : item.serverName ?? item.serverId ?? ''
}
/** The row's identifying line: a local repo with its branch, or the owning linked server's name. */
function activityItemLine(item: ActiveWorkItem): string {
if (!item.repo) return activityItemLabel(item)
const branch = item.worktreeBranch ?? getRepoBranchLabel(item.repo)
return branch ? `${getRepoDisplayName(item.repo)} · ${branch}` : getRepoDisplayName(item.repo)
}
function activityRowClass(isCurrent: boolean, compact: boolean) {
@@ -63,11 +82,6 @@ interface ActivityRowProps {
}
function ActivityRow({ item, isCurrent, onSelect }: ActivityRowProps) {
const branch = item.worktreeBranch ?? getRepoBranchLabel(item.repo)
const repoLine = branch
? `${getRepoDisplayName(item.repo)} · ${branch}`
: getRepoDisplayName(item.repo)
return (
<button
type="button"
@@ -82,7 +96,7 @@ function ActivityRow({ item, isCurrent, onSelect }: ActivityRowProps) {
<span className="block truncate text-foreground">
{item.session.title || UNTITLED_SESSION_TITLE}
</span>
<span className="block truncate text-xs text-muted-foreground">{repoLine}</span>
<span className="block truncate text-xs text-muted-foreground">{activityItemLine(item)}</span>
</span>
<span className="shrink-0 text-xs text-muted-foreground">
{formatShortRelativeTime(new Date(item.updatedAt))}
@@ -106,7 +120,7 @@ function CompactActivityRow({ item, isCurrent, onSelect }: ActivityRowProps) {
{item.session.title || UNTITLED_SESSION_TITLE}
</span>
<span className="max-w-[35%] truncate text-xs text-muted-foreground">
{getRepoDisplayName(item.repo)}
{activityItemLabel(item)}
</span>
<span className="shrink-0 text-xs text-muted-foreground">
{formatShortRelativeTime(new Date(item.updatedAt))}
@@ -120,10 +134,18 @@ interface ActivityGroupProps {
items: ActiveWorkItem[]
currentSessionID: string | null
currentRepoId: number | null
currentServerId: string | null
onSelect: (item: ActiveWorkItem) => void
}
function ActivityGroup({ heading, items, currentSessionID, currentRepoId, onSelect }: ActivityGroupProps) {
function ActivityGroup({
heading,
items,
currentSessionID,
currentRepoId,
currentServerId,
onSelect,
}: ActivityGroupProps) {
if (items.length === 0) return null
return (
@@ -133,7 +155,7 @@ function ActivityGroup({ heading, items, currentSessionID, currentRepoId, onSele
<ActivityRow
key={item.key}
item={item}
isCurrent={isCurrentItem(item, currentSessionID, currentRepoId)}
isCurrent={isCurrentItem(item, currentSessionID, currentRepoId, currentServerId)}
onSelect={onSelect}
/>
))}
@@ -152,6 +174,8 @@ export function ActivityList({
const { groups, isLoading, isError } = useActiveWork(minutes * MS_PER_MINUTE)
const route = parseRepoRoute(location.pathname)
const serverRoute = parseServerSessionRoute(location.pathname)
const currentSessionID = route.sessionId ?? serverRoute?.sessionId ?? null
if (isLoading) {
if (hideWhenEmpty) return null
@@ -199,7 +223,7 @@ export function ActivityList({
<CompactActivityRow
key={item.key}
item={item}
isCurrent={isCurrentItem(item, route.sessionId, route.repoId)}
isCurrent={isCurrentItem(item, currentSessionID, route.repoId, serverRoute?.serverId ?? null)}
onSelect={onNavigate}
/>
))
@@ -210,8 +234,9 @@ export function ActivityList({
key={group.key}
heading={group.heading}
items={groups[group.key]}
currentSessionID={route.sessionId}
currentSessionID={currentSessionID}
currentRepoId={route.repoId}
currentServerId={serverRoute?.serverId ?? null}
onSelect={onNavigate}
/>
))}