diff --git a/apps/desktop/e2e/session-workbar.spec.ts b/apps/desktop/e2e/session-workbar.spec.ts index c7c2124b0b..8b6e3d1270 100644 --- a/apps/desktop/e2e/session-workbar.spec.ts +++ b/apps/desktop/e2e/session-workbar.spec.ts @@ -186,7 +186,7 @@ test('Git changes re-read the workspace after the app regains focus', async ({ await expect(panel.getByText('新增 5 行')).toBeVisible(); }); -test('Terminal ownership follows the active Session and stops the old resource', async ({ +test('Terminal fits its panel without growing and stops when its Session changes', async ({ window: page, }) => { const { composer, sessionId, sidebar } = await createSession( @@ -210,6 +210,23 @@ test('Terminal ownership follows the active Session and stops the old resource', ) .toBe('running'); + // Exercise real layout across frames: a Section's implicit grid row used to + // grow with xterm, continuously triggering fit/resize even at an idle prompt. + const fitsPanel = () => terminal.evaluate(async (element) => { + const panel = element.closest('.maka-session-workbar-panel')!; + const host = element.querySelector('.maka-session-terminal-xterm')!; + for (let frame = 0; frame < 12; frame += 1) { + await new Promise((resolve) => requestAnimationFrame(() => resolve())); + const bounds = panel.getBoundingClientRect(); + const terminalBounds = host.getBoundingClientRect(); + if (terminalBounds.height <= 0 || terminalBounds.bottom > bounds.bottom + 1) { + return false; + } + } + return true; + }); + await expect.poll(fitsPanel).toBe(true); + await sidebar.getByRole('button', { name: '新任务', exact: true }).click(); await expect(terminal).toHaveCount(0); await expect diff --git a/apps/desktop/src/renderer/styles/workbar/shell.css b/apps/desktop/src/renderer/styles/workbar/shell.css index 36fc0cd910..42dfc00063 100644 --- a/apps/desktop/src/renderer/styles/workbar/shell.css +++ b/apps/desktop/src/renderer/styles/workbar/shell.css @@ -133,6 +133,11 @@ } .maka-session-workbar-panel[data-overlay] { + display: grid; + /* Section adds an inner wrapper with height: 100%. An implicit auto row + can grow with xterm's content, feeding ResizeObserver -> fit -> resize + back into layout indefinitely. Bound the row to the available panel. */ + grid-template-rows: minmax(0, 1fr); position: relative; z-index: 1; overflow: hidden; @@ -147,6 +152,8 @@ leaving its own overflow scroller with nothing to scroll. */ display: grid; grid-template-rows: minmax(0, 1fr); + /* One stretched track, like the frame: the face fills the height and the + column can be aligned as a whole. */ padding-top: var(--maka-plate-titlebar-clearance); }