Files
apes-sidebar/tests/layout-push.spec.ts
T
Menghuan1918 223b2545d9 refactor(shell): retire the plugin's own right panel and free windows
DSH 0.1.5 owns the right column (its native Sidebar hosts every tab type
this plugin registers), so the plugin's own right panel, its width drag /
new-session seed prefs, and the free-window feature are gone. The bottom
workbench is the only plugin-owned surface left, and its expand/collapse
control is registered into DSH's session-header utilities list slot (the
header's corner seat belongs to the native sidebar's own control).

- state: one `bottomSplits` tree; `makeDefaultState()` takes no arguments;
  `toggleBottomPanel` / `openTabInBottomPane` are the only landing
  reducers; `setBottomHeight` and `sanitizeState` share the
  `CONVERSATION_MIN` cap (a persisted tall height no longer snaps on the
  first drag).
- service: every landing in the workbench (creation or focus) expands it;
  `SIDEBAR_FEATURES` drops `'floatWindows'`; the open/close/activate tab
  pools cover the single tree.
- shell: `Sidebar.tsx` renders only the bottom workbench; the toggle lives
  in `sidebar/bottom-toggle.tsx`; layout-push pushes height only (no width,
  no `--dsh-sidebar-width`).
- prefs: `openByDefault` / `defaultWidthPercent` / `changesDiffFloat`
  removed from the schema, defaults, client parser, settings page, and all
  20 dictionaries; the retired keys in stored documents are ignored.
- tests: free-window specs deleted, panel/float assertions dropped,
  remaining suites adapted (124 files / 1287 tests); the mount lane asserts
  the header toggle and sweeps the native sidebar's guide page.
- docs: README / README_EN / guide §0,§11 / AGENTS test map.
2026-09-09 15:18:06 +08:00

38 lines
1.7 KiB
TypeScript

/**
* Layout-push size contract: the conversation column (output + composer)
* must keep at least CONVERSATION_MIN of the viewport after the bottom
* workbench claims its height. A stale persisted bottomHeight (or a cap at
* 100vh) used to crush the composer off-screen. The right column belongs to
* DSH's native Sidebar, so this shell pushes no width at all.
*/
import { describe, expect, it } from 'vitest'
import { BOTTOM_MIN, CONVERSATION_MIN } from '../src/client/state.ts'
import { bottomPushHeight } from '../src/client/layout-push.ts'
describe('bottomPushHeight', () => {
it('pushes nothing while the workbench is collapsed', () => {
expect(bottomPushHeight({ open: false, height: 400, viewportHeight: 800 })).toBe(0)
})
it('caps an oversize workbench so the conversation keeps CONVERSATION_MIN', () => {
const viewportHeight = 800
const height = bottomPushHeight({ open: true, height: 10_000, viewportHeight })
expect(height).toBe(viewportHeight - CONVERSATION_MIN)
expect(height).toBeGreaterThanOrEqual(BOTTOM_MIN)
expect(viewportHeight - height).toBeGreaterThanOrEqual(CONVERSATION_MIN)
})
it('passes an in-range open height through', () => {
expect(bottomPushHeight({ open: true, height: 220, viewportHeight: 800 })).toBe(220)
})
it('never pushes beyond a viewport smaller than the normal minima', () => {
expect(bottomPushHeight({ open: true, height: 220, viewportHeight: 200 })).toBe(0)
})
it('turns non-finite geometry into a safe zero push', () => {
expect(bottomPushHeight({ open: true, height: Number.POSITIVE_INFINITY, viewportHeight: Number.NaN })).toBe(0)
expect(bottomPushHeight({ open: true, height: Number.NaN, viewportHeight: 800 })).toBe(0)
})
})