Compare commits

..
Author SHA1 Message Date
陈大猫 5e4195bf7f fix(ui): snap and thicken magnified pane chrome on low-DPR displays (#4270)
Related #4168

On ~1–1.2× displays the 1px rounded accent border around a magnified
pane drops out at the corners, and a box that is not aligned to the
device-pixel grid turns the stroke into a faint, doubled hairline.

Snap the magnified terminal overlay (after the 12px inset) to integer
device pixels, and use a 2px accent stroke when devicePixelRatio is
below 1.5 on both the terminal and side-panel chrome. Higher-DPR
displays keep the existing 1px stroke.
2026-11-18 23:23:21 +08:00
陈大猫 9c292460e3 fix(ai): treat models-list 404 as a warning and send Anthropic Bearer auth (#4269)
* fix(ai): treat models-list 404 as a warning and send Anthropic Bearer on custom bases

Custom OpenAI-compatible gateways that omit a /models listing were
shown as a hard detect failure on HTTP 404. Treat 404 as a warning.
Official Anthropic stays on x-api-key only; custom Anthropic-compat
bases also send Authorization: Bearer so Agent Plan and similar
proxies authenticate.

* fix(ai): use the versioned Ark Agent Plan messages endpoint
2026-11-18 19:21:16 +08:00
6 changed files with 115 additions and 5 deletions

No files matched your search

@@ -374,3 +374,14 @@ test('side panel close button stays visible at every panel width', () => {
assert.match(closeSlice, /className="h-7 w-7 shrink-0 rounded-md p-0 hover:bg-transparent"/);
assert.doesNotMatch(closeSlice, /\bhidden\b|max-(sm|md|lg|xl):/);
});
test('magnified side-panel chrome thickens the accent stroke on low-DPR displays', () => {
const source = readFileSync(new URL('./TerminalLayerSidePanelSection.tsx', import.meta.url), 'utf8');
const overlay = source.slice(
source.indexOf('data-section="pane-magnification-overlay"'),
source.indexOf('data-section="pane-magnification-content"'),
);
assert.match(overlay, /overflow-hidden rounded-md border bg-background shadow-2xl/);
assert.match(overlay, /borderColor: sidePanelTheme\.accent,/);
assert.match(overlay, /resolveMagnifiedChromeBorderWidth\(/);
});
@@ -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 } from '../../domain/paneMagnification';
import { getPaneMagnificationShortcutLabel, resolveMagnifiedChromeBorderWidth } from '../../domain/paneMagnification';
const MemoizedSidePanelMountedContent = memo(
SidePanelMountedContent,
@@ -1545,6 +1545,9 @@ function TerminalLayerSidePanelInner({ ctx, pluginSidebar }: { ctx: SidePanelCon
className="absolute inset-3 flex flex-col overflow-hidden rounded-md border bg-background shadow-2xl animate-in fade-in zoom-in-95 duration-150"
style={{
borderColor: sidePanelTheme.accent,
borderWidth: resolveMagnifiedChromeBorderWidth(
typeof window === 'undefined' ? 1 : (window.devicePixelRatio || 1),
),
backgroundColor: sidePanelTheme.termBg,
color: sidePanelTheme.termFg,
}}
@@ -52,6 +52,7 @@ import type { ResolvedAppearance, TerminalAppearanceHostScope } from '../../doma
import type { TerminalSidePanelAutoOpenTab } from '../../domain/terminalSidePanelAutoOpen';
import type { SidePanelTool } from '../../domain/sidePanelLayout';
import {
resolveMagnifiedChromeBorderWidth,
resolvePaneMagnificationStyle,
type PaneMagnificationController,
type PaneMagnificationTarget,
@@ -1439,10 +1440,12 @@ const TerminalPane: React.FC<TerminalPaneProps> = memo(({
observer.observe(surface);
return () => observer.disconnect();
}, [isMagnified]);
const magnifiedDevicePixelRatio = typeof window === 'undefined' ? 1 : (window.devicePixelRatio || 1);
const style: React.CSSProperties = resolvePaneMagnificationStyle(
layoutStyle,
isMagnified && !!magnifiedSurfaceBounds,
magnifiedSurfaceBounds,
magnifiedDevicePixelRatio,
);
useLayoutEffect(() => {
@@ -1605,6 +1608,9 @@ const TerminalPane: React.FC<TerminalPaneProps> = memo(({
style={{
...style,
borderColor: isMagnified && magnifiedSurfaceBounds ? sessionAppearanceTheme.colors.cursor : undefined,
borderWidth: isMagnified && magnifiedSurfaceBounds
? resolveMagnifiedChromeBorderWidth(magnifiedDevicePixelRatio)
: undefined,
}}
tabIndex={-1}
onClick={handlePaneClick}
@@ -15,6 +15,14 @@ test("magnified terminal panes use the resolved terminal accent for border chrom
assert.match(paneSource, /isMagnified && magnifiedSurfaceBounds && "overflow-hidden rounded-md border shadow-2xl /);
assert.match(paneSource, /borderColor: isMagnified && magnifiedSurfaceBounds \? sessionAppearanceTheme\.colors\.cursor : undefined/);
assert.match(paneSource, /borderWidth: isMagnified && magnifiedSurfaceBounds/);
assert.match(paneSource, /resolveMagnifiedChromeBorderWidth\(magnifiedDevicePixelRatio\)/);
});
test("magnified terminal panes snap overlay bounds to the device-pixel grid", () => {
const source = readFileSync(new URL("./TerminalLayerSupport.tsx", import.meta.url), "utf8");
assert.match(source, /resolvePaneMagnificationStyle\(\s*layoutStyle,\s*isMagnified && !!magnifiedSurfaceBounds,\s*magnifiedSurfaceBounds,\s*magnifiedDevicePixelRatio,\s*\)/);
assert.match(source, /const magnifiedDevicePixelRatio = typeof window === 'undefined' \? 1 : \(window\.devicePixelRatio \|\| 1\)/);
});
test("terminal keyboard focus updates the pane selected for magnification", () => {
+49
View File
@@ -7,7 +7,9 @@ import {
isPaneMagnificationSelectionValid,
resolvePaneMagnificationCandidate,
resolvePaneMagnificationStyle,
resolveMagnifiedChromeBorderWidth,
resolveTwoPaneMagnificationStyle,
snapCssRectToDevicePixels,
type PaneMagnificationController,
} from './paneMagnification.ts';
@@ -90,6 +92,53 @@ test('magnification overlays the original layout without changing its rect', ()
});
});
test('magnified chrome uses a 2px accent stroke only below 1.5 device pixels', () => {
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).
assert.deepEqual(resolvePaneMagnificationStyle(original, true, {
left: 120,
top: 80,
width: 1400,
height: 900,
}, 1), {
position: 'fixed',
left: '132px',
top: '92px',
width: '1376px',
height: '876px',
zIndex: 50,
});
// 120.4+12=132.4 at 2x -> 264.8 rounds to 265 -> 132.5
// right: 120.4+1400-12=1508.4 at 2x -> 3016.8 rounds to 3017 -> 1508.5
const snapped = resolvePaneMagnificationStyle(original, true, {
left: 120.4,
top: 80.4,
width: 1400,
height: 900,
}, 2);
assert.deepEqual(snapped, {
position: 'fixed',
left: '132.5px',
top: '92.5px',
width: '1376px',
height: '876px',
zIndex: 50,
});
const rect = snapCssRectToDevicePixels(10.2, 20.2, 110.2, 80.2, 2);
assert.deepEqual(rect, { left: 10, top: 20, width: 100, height: 60 });
});
test('two-pane magnification keeps the dormant pane geometry unchanged', () => {
assert.deepEqual(resolveTwoPaneMagnificationStyle('left', true, true), {
left: '12px', top: '12px', width: 'calc(100% - 24px)', height: 'calc(100% - 24px)', zIndex: 50,
+37 -4
View File
@@ -92,19 +92,52 @@ 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,
right: number,
bottom: number,
devicePixelRatio = 1,
): { left: number; top: number; width: number; height: number } {
const dpr = devicePixelRatio > 0 ? devicePixelRatio : 1;
const snap = (value: number) => Math.round(value * dpr) / dpr;
const snappedLeft = snap(left);
const snappedTop = snap(top);
const snappedRight = snap(right);
const snappedBottom = snap(bottom);
return {
left: snappedLeft,
top: snappedTop,
width: Math.max(0, snappedRight - snappedLeft),
height: Math.max(0, snappedBottom - snappedTop),
};
}
export function resolvePaneMagnificationStyle(
original: React.CSSProperties,
magnified: boolean,
surfaceBounds?: { left: number; top: number; width: number; height: number } | null,
devicePixelRatio = 1,
): React.CSSProperties {
if (!magnified) return original;
if (surfaceBounds) {
const snapped = snapCssRectToDevicePixels(
surfaceBounds.left + 12,
surfaceBounds.top + 12,
surfaceBounds.left + surfaceBounds.width - 12,
surfaceBounds.top + surfaceBounds.height - 12,
devicePixelRatio,
);
return {
position: 'fixed',
left: `${surfaceBounds.left + 12}px`,
top: `${surfaceBounds.top + 12}px`,
width: `${Math.max(0, surfaceBounds.width - 24)}px`,
height: `${Math.max(0, surfaceBounds.height - 24)}px`,
left: `${snapped.left}px`,
top: `${snapped.top}px`,
width: `${snapped.width}px`,
height: `${snapped.height}px`,
zIndex: 50,
};
}