From b8b9e57d06be25e67cb1ad7d26a567d5ba8689e0 Mon Sep 17 00:00:00 2001 From: Antonio Ledebuhr Date: Wed, 26 Aug 2026 13:51:55 +0200 Subject: [PATCH] Make the terminal dock toggle, scroll, and remember commands honestly. The desktop trigger now collapses through the shared toggle, the log stays on the newest line, Shift+K is left to the browser, history walks like a shell, and maximize keeps one accessible name. Co-authored-by: Cursor --- e2e/terminal.e2e.ts | 57 ++++++ src/app/core/content/signature-copy.ts | 3 - src/app/shared/terminal/terminal-dock.html | 5 +- src/app/shared/terminal/terminal-dock.scss | 5 + .../shared/terminal/terminal-dock.service.ts | 7 +- src/app/shared/terminal/terminal-dock.spec.ts | 182 ++++++++++++++++++ src/app/shared/terminal/terminal-dock.ts | 88 +++++++-- 7 files changed, 325 insertions(+), 22 deletions(-) diff --git a/e2e/terminal.e2e.ts b/e2e/terminal.e2e.ts index 00e6903..7fb1375 100644 --- a/e2e/terminal.e2e.ts +++ b/e2e/terminal.e2e.ts @@ -65,6 +65,63 @@ test.describe('terminal dock', () => { await expect(input).toHaveValue('navigate'); }); + test('clicking the visible desktop trigger while open collapses the panel', async ({ + page, + }, testInfo) => { + test.skip( + testInfo.project.name === 'mobile', + 'Below md the trigger is hidden while the panel is open.', + ); + + await page.goto('/'); + const trigger = page.locator('.terminal-dock-trigger'); + const panel = page.locator('.terminal-dock-panel'); + + await trigger.click(); + await expect(panel).toBeVisible(); + await expect(trigger).toBeVisible(); + await expect(trigger).toHaveAttribute('aria-expanded', 'true'); + + await trigger.click(); + await expect(panel).toHaveCount(0); + await expect(trigger).toHaveAttribute('aria-expanded', 'false'); + await expect(trigger).toBeFocused(); + }); + + test('keeps the newest echoed line in the log scrollport after overflow', async ({ page }) => { + const copy = SIGNATURE_COPY.de.terminal; + await page.goto('/'); + + const trigger = page.locator('.terminal-dock-trigger'); + const input = page.locator('#terminal-dock-input'); + const log = page.locator('.terminal-dock-log'); + + await trigger.click(); + await expect(log).toBeVisible(); + + for (let index = 0; index < 8; index += 1) { + await input.fill('help'); + await input.press('Enter'); + } + + await expect(log.locator('p.echo').last()).toHaveText(`${copy.prompt} help`); + + await expect + .poll(async () => + log.evaluate((element) => { + return element.scrollTop + element.clientHeight >= element.scrollHeight - 2; + }), + ) + .toBe(true); + + const last = log.locator('p').last(); + const logBox = await log.boundingBox(); + const lastBox = await last.boundingBox(); + expect(logBox && lastBox).toBeTruthy(); + expect(lastBox!.y).toBeGreaterThanOrEqual(logBox!.y - 1); + expect(lastBox!.y + lastBox!.height).toBeLessThanOrEqual(logBox!.y + logBox!.height + 1); + }); + test('Escape from a panel control collapses the dock and returns focus to the trigger', async ({ page, }) => { diff --git a/src/app/core/content/signature-copy.ts b/src/app/core/content/signature-copy.ts index 910f5d5..89f1341 100644 --- a/src/app/core/content/signature-copy.ts +++ b/src/app/core/content/signature-copy.ts @@ -11,7 +11,6 @@ export interface SignatureCopy { readonly inputLabel: string; readonly inputPlaceholder: string; readonly collapseLabel: string; - readonly restoreLabel: string; readonly maximizeLabel: string; readonly outputLabel: string; readonly unknownCommand: string; @@ -59,7 +58,6 @@ export const SIGNATURE_COPY: Record = { inputLabel: 'Befehl', inputPlaceholder: 'Befehl eingeben', collapseLabel: 'Terminal einklappen', - restoreLabel: 'Terminal verkleinern', maximizeLabel: 'Terminal vergrößern', outputLabel: 'Ausgabe', unknownCommand: 'Unbekannter Befehl: {command}', @@ -113,7 +111,6 @@ export const SIGNATURE_COPY: Record = { inputLabel: 'Command', inputPlaceholder: 'Type a command', collapseLabel: 'Collapse the terminal', - restoreLabel: 'Restore the terminal', maximizeLabel: 'Maximise the terminal', outputLabel: 'Output', unknownCommand: 'Unknown command: {command}', diff --git a/src/app/shared/terminal/terminal-dock.html b/src/app/shared/terminal/terminal-dock.html index d73df48..a1ca529 100644 --- a/src/app/shared/terminal/terminal-dock.html +++ b/src/app/shared/terminal/terminal-dock.html @@ -25,11 +25,11 @@