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

+3 -8
View File
@@ -17,7 +17,7 @@ import { useRepoActivity } from "@/hooks/useRepoActivity";
import { useCreateRepoWorkspace, useDeleteRepoWorkspaces, useRepoSiblings } from "@/hooks/useRepoSiblings";
import { useSSE } from "@/hooks/useSSE";
import { useDialogParam } from "@/hooks/useDialogParam";
import { useUrlParams } from "@/hooks/useUrlParams";
import { useOpenTerminal } from "@/hooks/useOpenTerminal";
import { useWorktreeTab } from "@/hooks/useWorktreeTab";
import { WorktreeTabs } from "@/components/repo/WorktreeTabs";
import { WorkspaceManager } from "@/components/repo/WorkspaceManager";
@@ -47,7 +47,7 @@ export function RepoDetail() {
const [workspaceSelectorOpen, setWorkspaceSelectorOpen] = useState(false);
const [activeWorkspaceDirectory, setActiveWorkspaceDirectory] = useState<string | undefined>();
const { activeTab, setActiveTab } = useWorktreeTab();
const { updateParams } = useUrlParams();
const openTerminal = useOpenTerminal();
const { data: repo, isLoading: repoLoading } = useQuery({
queryKey: ["repo", repoId],
@@ -143,12 +143,7 @@ export function RepoDetail() {
notifyWorktreeSetup(workspace.worktreeSetup);
if (workspace.worktreeSetup?.status === 'started') {
const terminalId = workspace.worktreeSetup.terminal.id;
updateParams((params) => {
params.set('repoTab', 'workspaces');
params.set('dialog', 'terminal');
params.set('terminal', terminalId);
params.delete('mobileTab');
}, 'push');
openTerminal(terminalId, { repoTab: 'workspaces' });
return;
}
setActiveTab('workspaces');
+11 -7
View File
@@ -682,7 +682,9 @@ export function SessionDetail() {
</div>
<Header.Actions className="gap-2 sm:gap-4">
<div className="flex items-center gap-1">
<ProjectActionsMenu repoId={repoId} directory={sessionDirectory} />
{!isAssistantSession && (
<ProjectActionsMenu repoId={repoId} directory={sessionDirectory} />
)}
<PendingActionsGroup />
</div>
<ContextUsageIndicator
@@ -861,12 +863,14 @@ export function SessionDetail() {
directory={repoDirectory}
/>
<RepoActionsDialog
repoId={repoId}
directory={sessionDirectory}
open={actionsDialogOpen}
onOpenChange={setActionsDialogOpen}
/>
{!isAssistantSession && (
<RepoActionsDialog
repoId={repoId}
directory={sessionDirectory}
open={actionsDialogOpen}
onOpenChange={setActionsDialogOpen}
/>
)}
<SourceControlPanel
repoId={repoId}
@@ -121,7 +121,7 @@ describe('AssistantRedirect preview routing', () => {
mocks.usePreviewPorts.mockReturnValue({
data: {
enabled: true,
ports: [{ port: 5173, host: '127.0.0.1', pid: 10, command: 'vite', cwd: assistantDirectory }],
ports: [{ port: 5173, host: '127.0.0.1', pid: 10, command: 'vite', cwd: assistantDirectory, inDirectory: true }],
},
isLoading: false,
refetch: vi.fn(),