Files
apes-sidebar/tests/sidebar-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

39 lines
1.9 KiB
TypeScript

/**
* The layout-push contract is split between the shell (DOM writes) and
* layout-push.ts (the cap): these source assertions pin the seams a
* refactor silently breaks — every push must ride the shared cap, the
* keyboard inset must extend the PUSH (never the panel's own height), and
* the cap must be measured against the visual viewport.
*/
import { readFileSync } from 'node:fs'
import { describe, expect, it } from 'vitest'
const source = readFileSync('src/client/Sidebar.tsx', 'utf8')
describe('Sidebar layout-push integration', () => {
it('routes every push through the shared bottom-height cap', () => {
expect(source.match(/bottomPushHeight\(\{/g)).toHaveLength(2)
expect(source).not.toContain('Math.min(state.bottomHeight, window.innerHeight)')
})
it('caps the geometry against the visible height above the keyboard', () => {
expect(source).toContain('setVisualViewportHeight(Math.max(0, Math.round(vv.height)))')
expect(source).toContain('visualViewportHeight ?? viewport.height')
expect(source.match(/viewportHeight: layoutViewportHeight/g)).toHaveLength(2)
})
it('adds the keyboard inset to the conversation push, not the panel height', () => {
expect(source.match(/height \+ keyboardInset/g)).toHaveLength(2)
expect(source).toContain('height: bottomPanelHeight')
expect(source).not.toContain('height: bottomPanelHeight + keyboardInset')
})
it('reapplies the height clamp to every vertical drag result', () => {
// Both live pointer paths (move + up) clamp before writing or committing.
expect(source.match(/clampHeight\(startHeight \+ \(startY - event\.clientY\)\)/g)).toHaveLength(2)
// The interrupted-drag paths (pointercancel / lost capture) clamp too.
expect(source.match(/clampHeight\(bottomDrag\.current\.startHeight/g)).toHaveLength(1)
expect(source.match(/clampHeight\(lastDragHeight\.current/g)).toHaveLength(1)
})
})