mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
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:
1 parent
c591c15743
commit
f566556fd6
77 files changed
+3170
-702
No files matched your search
@@ -361,7 +361,7 @@ describe('MoreDrawer', () => {
|
||||
expect(handleClose).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('offers only account items on a linked-server route', () => {
|
||||
it('offers only the remote-capable project items on a linked-server route', () => {
|
||||
mockAuth()
|
||||
mockServerHealth()
|
||||
setActivityGroups({ recent: [createActiveWorkItem()] })
|
||||
@@ -371,13 +371,16 @@ describe('MoreDrawer', () => {
|
||||
})
|
||||
|
||||
expect(screen.getByText('Home')).toBeInTheDocument()
|
||||
expect(screen.getByText('MCP')).toBeInTheDocument()
|
||||
expect(screen.getByText('Skills')).toBeInTheDocument()
|
||||
expect(screen.getByText('Settings')).toBeInTheDocument()
|
||||
expect(screen.getByText('Logout')).toBeInTheDocument()
|
||||
expect(screen.queryByText('Files')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Source Control')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Terminal')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('MCP')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Preview')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Schedules')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Reset Permissions')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Repos')).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: 'Assistant' })).not.toBeInTheDocument()
|
||||
expect(screen.queryByRole('heading', { name: 'Activity' })).not.toBeInTheDocument()
|
||||
|
||||
@@ -149,6 +149,23 @@ function HomeHarness() {
|
||||
)
|
||||
}
|
||||
|
||||
function RemoteHarness() {
|
||||
const panel = useToolPanel(true)
|
||||
return (
|
||||
<>
|
||||
<ToolSidePanel
|
||||
panel={panel}
|
||||
repoId={0}
|
||||
sessionId="ses_remote"
|
||||
directory="/home/me/app"
|
||||
repoDirectory="/home/me/app"
|
||||
filesBasePath={undefined}
|
||||
/>
|
||||
<LocationProbe />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
activityMocks.useActiveWorkCounts.mockReturnValue({ needsInput: 0, running: 0 })
|
||||
@@ -330,6 +347,25 @@ describe('ToolSidePanel', () => {
|
||||
expect(buttons[0]).toHaveAccessibleName('Activity')
|
||||
})
|
||||
|
||||
it('shows only the remote-capable tools on a linked-server route', async () => {
|
||||
const user = userEvent.setup()
|
||||
render(
|
||||
<MemoryRouter initialEntries={['/servers/srv_kitchen/sessions/ses_remote']}>
|
||||
<RemoteHarness />
|
||||
</MemoryRouter>,
|
||||
)
|
||||
|
||||
const rail = screen.getByRole('navigation', { name: 'Tools' })
|
||||
expect(
|
||||
within(rail)
|
||||
.getAllByRole('button')
|
||||
.map((button) => button.getAttribute('aria-label') ?? button.textContent?.trim()),
|
||||
).toEqual(['Activity', 'MCP', 'Skills'])
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'MCP' }))
|
||||
expect(await screen.findByText('mcp-tool')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('opens the Activity panel with rows and the window label when clicked', async () => {
|
||||
const user = userEvent.setup()
|
||||
setActivityGroups([createActivityItem('other', 'Other Session', 2, 'Beta')])
|
||||
|
||||
@@ -31,11 +31,14 @@ import { formatActivityWindow } from '@/lib/activeWork'
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
import { restoreOverlayFocus } from '@/lib/overlayFocus'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { isLocalOpenCodeServer, useRouteOpenCodeServerId } from '@/contexts/OpenCodeServerContext'
|
||||
|
||||
const PANEL_WIDTH_CLASSES: Partial<Record<PanelTool, string>> = {
|
||||
activity: 'w-80',
|
||||
}
|
||||
|
||||
const REMOTE_TOOL_KEYS: ReadonlySet<string> = new Set(['activity', 'mcp', 'skills'])
|
||||
|
||||
function ActivityWindowLabel() {
|
||||
const minutes = useActivityWindowMinutes()
|
||||
return (
|
||||
@@ -157,6 +160,7 @@ export function ToolSidePanel({
|
||||
const { activeTool, toggleTool, closePanel } = panel
|
||||
const location = useLocation()
|
||||
const openNavItem = useOpenNavItem()
|
||||
const isRemoteRoute = !isLocalOpenCodeServer(useRouteOpenCodeServerId())
|
||||
const railRef = useRef<HTMLElement>(null)
|
||||
const previousActiveToolRef = useRef(activeTool)
|
||||
|
||||
@@ -173,6 +177,7 @@ export function ToolSidePanel({
|
||||
const panelTools: Array<{ item: MoreDrawerItem; tool: PanelTool }> = []
|
||||
const actionItems: MoreDrawerItem[] = []
|
||||
for (const item of buildToolItems(location.pathname)) {
|
||||
if (isRemoteRoute && !REMOTE_TOOL_KEYS.has(item.key)) continue
|
||||
const tool = toolKeyOf(item)
|
||||
if (isPanelTool(tool)) panelTools.push({ item, tool })
|
||||
else actionItems.push(item)
|
||||
|
||||
@@ -62,6 +62,11 @@ describe('buildMoreItems', () => {
|
||||
expect(items[12].key).toBe('logout')
|
||||
})
|
||||
|
||||
it('returns only the server tools a linked server can serve for /servers/:id/sessions/:sid', () => {
|
||||
const items = buildMoreItems('/servers/srv_kitchen/sessions/abc')
|
||||
expect(items.map((item) => item.key)).toEqual(['home', 'mcp', 'skills', 'settings', 'logout'])
|
||||
})
|
||||
|
||||
it('omits the Actions item for an Assistant session', () => {
|
||||
const items = buildMoreItems('/repos/0/sessions/abc')
|
||||
expect(items).toHaveLength(12)
|
||||
@@ -164,6 +169,14 @@ describe('buildToolItems', () => {
|
||||
])
|
||||
})
|
||||
|
||||
it('returns the linked-server session tools for the tool rail', () => {
|
||||
expect(buildToolItems('/servers/srv_kitchen/sessions/abc').map((item) => item.key)).toEqual([
|
||||
'activity',
|
||||
'mcp',
|
||||
'skills',
|
||||
])
|
||||
})
|
||||
|
||||
it('returns the home route tools', () => {
|
||||
expect(buildToolItems('/').map((item) => item.key)).toEqual(['activity', 'all-schedules', 'files'])
|
||||
})
|
||||
|
||||
@@ -48,6 +48,7 @@ function getBaseItems(): MoreDrawerItem[] {
|
||||
}
|
||||
|
||||
const SESSION_DETAIL_PATH = /^\/repos\/(\d+)\/sessions\/[^/]+$/
|
||||
const SERVER_SESSION_DETAIL_PATH = /^\/servers\/[^/]+\/sessions\/[^/]+$/
|
||||
|
||||
export function isSessionDetailPath(pathname: string): boolean {
|
||||
return SESSION_DETAIL_PATH.test(pathname)
|
||||
@@ -62,8 +63,6 @@ const MANAGER_ONLY_ITEM_KEYS: ReadonlySet<string> = new Set([
|
||||
'preview',
|
||||
'walkthrough',
|
||||
'actions',
|
||||
'mcp',
|
||||
'skills',
|
||||
'reset-permissions',
|
||||
'schedules',
|
||||
'all-schedules',
|
||||
@@ -88,6 +87,17 @@ export function toolKeyOf(item: MoreDrawerItem): string | null {
|
||||
function buildRouteNavModel(pathname: string): NavModel {
|
||||
const baseItems = getBaseItems()
|
||||
|
||||
if (SERVER_SESSION_DETAIL_PATH.test(pathname)) {
|
||||
return {
|
||||
primary: [getAssistantNavItem()],
|
||||
items: [
|
||||
{ key: 'mcp', label: 'MCP', icon: Plug, dialog: 'mcp' },
|
||||
{ key: 'skills', label: 'Skills', icon: Sparkles, dialog: 'skills' },
|
||||
...baseItems,
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
const repoDetailMatch = /^\/repos\/(\d+)$/.exec(pathname)
|
||||
if (repoDetailMatch) {
|
||||
const id = repoDetailMatch[1]
|
||||
|
||||
Reference in new issue
Block a user