fix: harden layout push bounds

This commit is contained in:
Zzy
2026-08-21 23:41:33 +08:00
parent 8ceaefcfc7
commit 965ec49c16
4 changed files with 44 additions and 9 deletions
+8 -1
View File
@@ -16,7 +16,14 @@ describe('layout.css conversation column', () => {
it('allows the center column to shrink and wrap long tokens', () => {
expect(css).toMatch(/min-height:\s*0/)
expect(css).toMatch(/overflow:\s*hidden/)
expect(css).toMatch(/overflow-wrap:\s*anywhere/)
})
it('leaves overflow ownership to the host conversation descendants', () => {
const conversationRule = css.match(
/#root \[data-dsh-frame\][\s\S]*?\{([\s\S]*?)\n\}/,
)?.[1]
expect(conversationRule).toBeDefined()
expect(conversationRule).not.toMatch(/(?:^|[;\s])overflow\s*:/)
})
})
+24
View File
@@ -72,4 +72,28 @@ describe('layoutPushSize', () => {
viewportHeight: 800,
})).toEqual({ width: 400, height: 220 })
})
it('never pushes beyond a viewport smaller than the normal panel minima', () => {
expect(layoutPushSize({
narrow: false,
panelOpen: true,
bottomOpen: true,
width: 400,
bottomHeight: 220,
viewportWidth: 200,
viewportHeight: 200,
})).toEqual({ width: 200, height: 0 })
})
it('turns non-finite geometry into a safe zero push', () => {
expect(layoutPushSize({
narrow: false,
panelOpen: true,
bottomOpen: true,
width: Number.NaN,
bottomHeight: Number.POSITIVE_INFINITY,
viewportWidth: Number.NaN,
viewportHeight: Number.POSITIVE_INFINITY,
})).toEqual({ width: 0, height: 0 })
})
})