From 1009f131fe5c4d09d49fbafab38fcf42dee07c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=A4=A7=E7=8C=AB?= <16399091+binaricat@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:25:32 +0800 Subject: [PATCH] fix(ui): use a 1px continuous stroke for magnified pane chrome (#4168) (#4452) Co-authored-by: Codex --- .../TerminalLayerSidePanelSection.test.ts | 12 ++++++++ .../TerminalLayerSidePanelSection.tsx | 10 +++---- .../terminalLayer/TerminalLayerSupport.tsx | 9 +++--- .../TerminalLayerWorkspaceSection.test.ts | 30 +++++++++---------- domain/paneMagnification.test.ts | 10 ------- domain/paneMagnification.ts | 4 --- 6 files changed, 35 insertions(+), 40 deletions(-) diff --git a/components/terminalLayer/TerminalLayerSidePanelSection.test.ts b/components/terminalLayer/TerminalLayerSidePanelSection.test.ts index 912d261fc..c7e082f85 100644 --- a/components/terminalLayer/TerminalLayerSidePanelSection.test.ts +++ b/components/terminalLayer/TerminalLayerSidePanelSection.test.ts @@ -1,4 +1,5 @@ import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; import test from 'node:test'; import { JSDOM } from 'jsdom'; @@ -19,6 +20,17 @@ import { resolveSidePanelPortalTarget, } from './terminalLayerSidePanelSlots.tsx'; +test('magnified side panels use a continuous 1px inset outline in the side panel accent', () => { + const source = readFileSync(new URL('./TerminalLayerSidePanelSection.tsx', import.meta.url), 'utf8'); + const chromeStart = source.indexOf('className="absolute inset-3'); + const chromeSource = source.slice(chromeStart, source.indexOf('\n >', chromeStart)); + + assert.match(chromeSource, /overflow-hidden rounded-md bg-background shadow-2xl/); + assert.match(chromeSource, /outline: `1px solid \$\{sidePanelTheme\.accent\}`/); + assert.match(chromeSource, /outlineOffset: -1/); + assert.doesNotMatch(chromeSource, /\bborder(?:Color|Width|Style)?\b/); +}); + test('AI side panel shell can be force-hidden for layout isolation', () => { assert.equal(getTerminalSidePanelShellWidth({ activeSidePanelTab: 'ai', diff --git a/components/terminalLayer/TerminalLayerSidePanelSection.tsx b/components/terminalLayer/TerminalLayerSidePanelSection.tsx index b6f344fac..609cfc9db 100644 --- a/components/terminalLayer/TerminalLayerSidePanelSection.tsx +++ b/components/terminalLayer/TerminalLayerSidePanelSection.tsx @@ -64,7 +64,7 @@ import { PersistentSidePanelPortal, SidePanelMountedContent } from './terminalLa import { usePluginTerminalSidebar } from '../../application/state/usePluginTerminalSidebar'; import { PluginTerminalSidebarPageHost } from '../plugins/PluginTerminalSidebar'; import { PluginContributionIcon } from '../plugins/PluginContributionIcon'; -import { getPaneMagnificationShortcutLabel, resolveMagnifiedChromeBorderWidth } from '../../domain/paneMagnification'; +import { getPaneMagnificationShortcutLabel } from '../../domain/paneMagnification'; const MemoizedSidePanelMountedContent = memo( SidePanelMountedContent, @@ -1567,12 +1567,10 @@ function TerminalLayerSidePanelInner({ ctx, pluginSidebar }: { ctx: SidePanelCon data-section="pane-magnification-backdrop" />
= memo(({ "absolute bg-background", inActiveWorkspace && "workspace-pane", isVisible && "z-10", - magnifiedSurfaceBounds && "overflow-hidden rounded-md border shadow-2xl", + magnifiedSurfaceBounds && "overflow-hidden rounded-md shadow-2xl", )} style={{ ...style, - borderColor: magnifiedSurfaceBounds ? sessionAppearanceTheme.colors.cursor : undefined, - borderWidth: magnifiedSurfaceBounds - ? resolveMagnifiedChromeBorderWidth(magnifiedDevicePixelRatio) + outline: magnifiedSurfaceBounds + ? `1px solid ${sessionAppearanceTheme.colors.cursor}` : undefined, + outlineOffset: magnifiedSurfaceBounds ? -1 : undefined, }} tabIndex={-1} onClick={handlePaneClick} diff --git a/components/terminalLayer/TerminalLayerWorkspaceSection.test.ts b/components/terminalLayer/TerminalLayerWorkspaceSection.test.ts index 52a37890d..b35da8a5d 100644 --- a/components/terminalLayer/TerminalLayerWorkspaceSection.test.ts +++ b/components/terminalLayer/TerminalLayerWorkspaceSection.test.ts @@ -5,43 +5,43 @@ import React from "react"; import { act, create } from "react-test-renderer"; import { sidePanelLiveStore, SIDE_PANEL_INACTIVE_LIVE_SNAPSHOT } from "../../application/state/sidePanelLiveStore.ts"; import { createEmptyWorkspaceRoot } from "../../domain/workspace.ts"; -import { resolveMagnifiedChromeBorderWidth } from "../../domain/paneMagnification.ts"; import { renderToStaticMarkup } from "react-dom/server"; import { TerminalLayerWorkspaceSection } from "./TerminalLayerWorkspaceSection.tsx"; -test("terminal pane chrome follows retained surface bounds through restore", () => { +test("terminal pane chrome follows retained surface bounds through restore with a continuous 1px inset outline", () => { const source = readFileSync(new URL("./TerminalLayerSupport.tsx", import.meta.url), "utf8"); const paneSource = source.slice(source.indexOf('data-section="terminal-split-pane"'), source.indexOf(" { +test("restoring terminal chrome keeps its 1px inset outline until surface bounds clear at any DPR", () => { const source = readFileSync(new URL("./TerminalLayerSupport.tsx", import.meta.url), "utf8"); const paneSource = source.slice(source.indexOf('data-section="terminal-split-pane"'), source.indexOf(" { - assert.equal(resolveMagnifiedChromeBorderWidth(1), 2); - assert.equal(resolveMagnifiedChromeBorderWidth(1.2), 2); - assert.equal(resolveMagnifiedChromeBorderWidth(1.49), 2); - assert.equal(resolveMagnifiedChromeBorderWidth(1.5), 1); - assert.equal(resolveMagnifiedChromeBorderWidth(2), 1); - assert.equal(resolveMagnifiedChromeBorderWidth(0), 1); -}); - test('magnified surface bounds snap to the device-pixel grid after the 12px inset', () => { const original = { left: '0px', top: '0px', width: '100px', height: '100px' }; // Integer CSS pixels at 1x stay unchanged (existing contract). diff --git a/domain/paneMagnification.ts b/domain/paneMagnification.ts index 7400ebc49..55b8850fb 100644 --- a/domain/paneMagnification.ts +++ b/domain/paneMagnification.ts @@ -92,10 +92,6 @@ export function getPaneMagnificationShortcutLabel( return (hotkeyScheme === 'mac' ? binding?.mac : binding?.pc)?.replace(/ \+ /g, '+') ?? ''; } -export function resolveMagnifiedChromeBorderWidth(devicePixelRatio = 1): number { - return devicePixelRatio > 0 && devicePixelRatio < 1.5 ? 2 : 1; -} - export function snapCssRectToDevicePixels( left: number, top: number,