mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
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
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { act } from '@testing-library/react'
|
|
import { renderHookWithRouterAndLocation } from '@/test/test-utils'
|
|
import { useOpenTerminal } from './useOpenTerminal'
|
|
|
|
describe('useOpenTerminal', () => {
|
|
it('opens the terminal dialog with the terminal id', () => {
|
|
const { result, capturedSearch } = renderHookWithRouterAndLocation(
|
|
() => useOpenTerminal(),
|
|
['/repos/1'],
|
|
)
|
|
|
|
act(() => {
|
|
result.current('pty-1')
|
|
})
|
|
|
|
const params = new URLSearchParams(capturedSearch.current)
|
|
expect(params.get('dialog')).toBe('terminal')
|
|
expect(params.get('terminal')).toBe('pty-1')
|
|
})
|
|
|
|
it('merges extra params and clears mobileTab in the same navigation', () => {
|
|
const { result, capturedSearch } = renderHookWithRouterAndLocation(
|
|
() => useOpenTerminal(),
|
|
['/repos/1?mobileTab=more'],
|
|
)
|
|
|
|
act(() => {
|
|
result.current('pty-2', { repoTab: 'workspaces' })
|
|
})
|
|
|
|
const params = new URLSearchParams(capturedSearch.current)
|
|
expect(params.get('dialog')).toBe('terminal')
|
|
expect(params.get('terminal')).toBe('pty-2')
|
|
expect(params.get('repoTab')).toBe('workspaces')
|
|
expect(params.has('mobileTab')).toBe(false)
|
|
})
|
|
})
|