mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix: address findings from the full Docker evaluation of main
Critical and high: - repos: unlinking a local repo removes only the Manager reference and alias, never the repository files; confirm button reads "Unlink" - auth: rate-limit by the socket address; trust proxy headers only when AUTH_TRUSTED_PROXY_HEADERS is set (documented and forwarded in compose) - composer: per-session in-memory drafts (text, bash mode, attachments); Escape no longer clears the prompt - url params: compose same-tick updates so schedule dialogs stay closed after create/delete; delete dialog names the job Medium: - tool rows show failures (non-zero shell exit, failed exploration members) - voice conversation shows the specific error and a starting state - settings: Escape in dropdowns and the shortcut recorder no longer closes the dialog; mobile deep links open the requested section; one content tree per platform - closing pushed sheets, settings, tool panels and schedule dialogs goes back in history - login returns to the requested page; signed-out pages make no authenticated requests - action terminals keep their output (Manager-side output capture and replay) - unpushed-commit detection, commit message kept on failure - binary files with unknown extensions are detected and not editable - tool panel resizes when docked and floats as a dismissible sheet when the page is too narrow - Docker image runs tini as PID 1 Low: not-found states, add-repo and branch validation errors (4xx), search-aware empty states, mobile repo sort/filter/select cues, sidebar resize affordance and collapse shortcut, mobile unread badge, preview port filtering, terminal close handling, walkthrough empty state and helper session filtering, placeholder contrast, permission labels and focus, TTS task-list sanitizing, git identity email validation, quieter git logging, hermetic worktree tests, and accessible names for icon-only controls.
This commit is contained in:
1 parent
1c22ef6ea1
commit
4ec62cd4e7
191 files changed
+6674
-696
No files matched your search
@@ -0,0 +1,115 @@
|
||||
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
||||
import { act, renderHook } from '@testing-library/react'
|
||||
import {
|
||||
MAIN_CONTENT_MIN_WIDTH,
|
||||
TOOL_PANEL_MAX_WIDTH,
|
||||
TOOL_PANEL_MIN_WIDTH,
|
||||
TOOL_PANEL_RAIL_WIDTH,
|
||||
clampToolPanelWidth,
|
||||
maximumToolPanelWidth,
|
||||
useToolPanelLayout,
|
||||
useToolPanelWidth,
|
||||
} from './useToolPanelLayout'
|
||||
|
||||
const originalInnerWidth = window.innerWidth
|
||||
|
||||
function setViewportWidth(width: number) {
|
||||
Object.defineProperty(window, 'innerWidth', { configurable: true, value: width })
|
||||
}
|
||||
|
||||
function stubPageWidth(width: number): () => void {
|
||||
const main = document.createElement('main')
|
||||
main.getBoundingClientRect = () =>
|
||||
({ width, height: 800, top: 0, left: 0, right: width, bottom: 800, x: 0, y: 0, toJSON: () => ({}) }) as DOMRect
|
||||
document.body.append(main)
|
||||
return () => main.remove()
|
||||
}
|
||||
|
||||
describe('clampToolPanelWidth', () => {
|
||||
it('keeps the requested width when there is room for it', () => {
|
||||
expect(clampToolPanelWidth(600, 1440)).toBe(600)
|
||||
})
|
||||
|
||||
it('clamps to the panel maximum and minimum', () => {
|
||||
expect(clampToolPanelWidth(900, 1440)).toBe(TOOL_PANEL_MAX_WIDTH)
|
||||
expect(clampToolPanelWidth(100, 1440)).toBe(TOOL_PANEL_MIN_WIDTH)
|
||||
})
|
||||
|
||||
it('never takes room from the main column', () => {
|
||||
const availableWidth = 900
|
||||
const maximum = availableWidth - TOOL_PANEL_RAIL_WIDTH - MAIN_CONTENT_MIN_WIDTH
|
||||
|
||||
expect(maximumToolPanelWidth(availableWidth)).toBe(maximum)
|
||||
expect(clampToolPanelWidth(600, availableWidth)).toBe(maximum)
|
||||
})
|
||||
})
|
||||
|
||||
describe('useToolPanelLayout', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
setViewportWidth(originalInnerWidth)
|
||||
})
|
||||
|
||||
it('docks when the page has room for the rail, the panel and the main column', () => {
|
||||
const removePage = stubPageWidth(1200)
|
||||
|
||||
const { result } = renderHook(() => useToolPanelLayout())
|
||||
removePage()
|
||||
|
||||
expect(result.current).toEqual({ docked: true, showRail: true })
|
||||
})
|
||||
|
||||
it('keeps the rail and switches the panel to an overlay when docking would squeeze the main column', () => {
|
||||
const removePage = stubPageWidth(560)
|
||||
|
||||
const { result } = renderHook(() => useToolPanelLayout())
|
||||
removePage()
|
||||
|
||||
expect(result.current).toEqual({ docked: false, showRail: true })
|
||||
})
|
||||
|
||||
it('hides the rail on a mobile viewport', () => {
|
||||
setViewportWidth(390)
|
||||
|
||||
const { result } = renderHook(() => useToolPanelLayout())
|
||||
|
||||
expect(result.current).toEqual({ docked: false, showRail: false })
|
||||
})
|
||||
})
|
||||
|
||||
describe('useToolPanelWidth', () => {
|
||||
beforeEach(() => {
|
||||
localStorage.clear()
|
||||
setViewportWidth(1440)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
setViewportWidth(originalInnerWidth)
|
||||
})
|
||||
|
||||
it('persists a resized width and restores it', () => {
|
||||
const first = renderHook(() => useToolPanelWidth())
|
||||
|
||||
act(() => {
|
||||
first.result.current.setWidth(480)
|
||||
})
|
||||
|
||||
expect(first.result.current.width).toBe(480)
|
||||
expect(localStorage.getItem('oc:tool-panel:width')).toBe('480')
|
||||
first.unmount()
|
||||
|
||||
const second = renderHook(() => useToolPanelWidth())
|
||||
|
||||
expect(second.result.current.width).toBe(480)
|
||||
})
|
||||
|
||||
it('clamps the stored width to the space the page has', () => {
|
||||
setViewportWidth(900)
|
||||
const { result } = renderHook(() => useToolPanelWidth())
|
||||
|
||||
expect(result.current.width).toBe(maximumToolPanelWidth(900))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user