fix(terminal-dev-loop): address branch review findings

Security:
- Reject same-site and cross-site state-changing requests on cookie-authenticated routes unless the origin is trusted
- Drop Manager and ocm_preview Set-Cookie headers from preview responses
- Show and hash the full executable content of .ocm/project.json at trust time
- Restrict action URLs to http(s) and refuse symlinked repo config paths
- Keep the preview start redirect on the gateway origin

Lifecycle:
- Stop terminals in OpenCode workspace siblings when a repo is deleted
- Report preview as unavailable instead of crashing when the gateway port cannot be bound

Performance:
- Skip branch lookups when validating terminal and project-config directories
- Stop the /proc scan once all listening sockets are mapped and pause port polling while a preview is open
- Close slow WebSocket clients with 1013 so they reconnect with replay
- Lazy-load the xterm terminal view and skip unchanged resize requests
- Request uncompressed responses from preview targets

Cleanup:
- Share one repo directory resolver, trusted-origins parser, cookie prefix, WebSocket frame forwarder, header filter, icon map and dialog-param helper
- Remove unused props, options and exports

Docs: update terminal, preview, project actions, sandboxing, internal API and environment pages
This commit is contained in:
Chris Scott committed 2026-10-03 10:00:33 -04:00
1 parent 16b91ccf02
commit c60a9b35f2
72 files changed
+2039 -596

No files matched your search

@@ -60,9 +60,20 @@ describe('buildMoreItems', () => {
expect(items[11].key).toBe('logout')
})
it('omits the Actions item for an Assistant session', () => {
const items = buildMoreItems('/repos/0/sessions/abc')
expect(items).toHaveLength(11)
expect(items.map((item) => item.key)).not.toContain('actions')
expect(items[7].key).toBe('terminal')
expect(items[8].key).toBe('preview')
expect(items[8].dialog).toBe('preview')
expect(items[9].key).toBe('settings')
expect(items[10].key).toBe('logout')
})
it('returns assistant workspace items for /repos/:id/assistant', () => {
const items = buildMoreItems('/repos/42/assistant')
expect(items).toHaveLength(10)
expect(items).toHaveLength(11)
expect(items[0].key).toBe('home')
expect(items[1].key).toBe('files')
expect(items[1].dialog).toBe('files')
@@ -73,8 +84,10 @@ describe('buildMoreItems', () => {
expect(items[6].key).toBe('source-control')
expect(items[7].key).toBe('terminal')
expect(items[7].dialog).toBe('terminal')
expect(items[8].key).toBe('settings')
expect(items[9].key).toBe('logout')
expect(items[8].key).toBe('preview')
expect(items[8].dialog).toBe('preview')
expect(items[9].key).toBe('settings')
expect(items[10].key).toBe('logout')
})
it('returns only Home + Settings + Logout for /schedules', () => {
@@ -1,5 +1,6 @@
import type { LucideIcon } from 'lucide-react'
import { Plug, Sparkles, ShieldOff, CalendarClock, GitCommitHorizontal, SquareTerminal, Settings, LogOut, Bot, Folder, Home, Play, Globe } from 'lucide-react'
import { ASSISTANT_REPO_ID } from '@opencode-manager/shared/utils'
import { getAssistantPath, isAssistantPath } from '@/lib/navigation'
export interface MoreDrawerItem {
@@ -72,15 +73,19 @@ function buildRouteNavModel(pathname: string): NavModel {
const sessionDetailMatch = /^\/repos\/(\d+)\/sessions\/[^/]+$/.exec(pathname)
if (sessionDetailMatch) {
const repoId = sessionDetailMatch[1]
const isAssistantRepo = repoId === String(ASSISTANT_REPO_ID)
const items: MoreDrawerItem[] = [
{ key: 'files', label: 'Files', icon: Folder, dialog: 'files' },
{ key: 'mcp', label: 'MCP', icon: Plug, dialog: 'mcp' },
{ key: 'skills', label: 'Skills', icon: Sparkles, dialog: 'skills' },
{ key: 'reset-permissions', label: 'Reset Permissions', icon: ShieldOff, dialog: 'resetPermissions', danger: true },
{ key: 'schedules', label: 'Schedules', icon: CalendarClock, to: `/repos/${sessionDetailMatch[1]}/schedules` },
{ key: 'schedules', label: 'Schedules', icon: CalendarClock, to: `/repos/${repoId}/schedules` },
{ key: 'source-control', label: 'Source Control', icon: GitCommitHorizontal, dialog: 'sourceControl' },
{ key: 'terminal', label: 'Terminal', icon: SquareTerminal, dialog: 'terminal' },
{ key: 'actions', label: 'Actions', icon: Play, dialog: 'actions' },
...(isAssistantRepo
? []
: [{ key: 'actions', label: 'Actions', icon: Play, dialog: 'actions' }]),
{ key: 'preview', label: 'Preview', icon: Globe, dialog: 'preview' },
...baseItems,
]
@@ -100,6 +105,7 @@ function buildRouteNavModel(pathname: string): NavModel {
{ key: 'schedules', label: 'Schedules', icon: CalendarClock, to: '/repos/0/schedules' },
{ key: 'source-control', label: 'Source Control', icon: GitCommitHorizontal, dialog: 'sourceControl' },
{ key: 'terminal', label: 'Terminal', icon: SquareTerminal, dialog: 'terminal' },
{ key: 'preview', label: 'Preview', icon: Globe, dialog: 'preview' },
...baseItems,
]