fix(desktop): toggle browser icon and preserve webview state on coll… (#1424)

* fix(desktop): toggle browser icon and preserve webview state on collapse

* fix(desktop): stabilize context panel collapse behavior

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
This commit is contained in:
HearingSmile
2026-05-26 20:30:16 +03:00
committed by GitHub
co-authored by Bohdan Triapitsyn
parent 51901b980e
commit 6a173211b0
3 changed files with 92 additions and 23 deletions
+25 -2
View File
@@ -81,6 +81,7 @@ type HeaderIconActionButtonProps = {
className?: string;
Icon: IconName;
iconClassName?: string;
pressed?: boolean;
};
const HeaderIconActionButton = React.memo(function HeaderIconActionButton({
@@ -91,6 +92,7 @@ const HeaderIconActionButton = React.memo(function HeaderIconActionButton({
className,
Icon: iconName,
iconClassName,
pressed = false,
}: HeaderIconActionButtonProps) {
if (!visible) {
return null;
@@ -103,7 +105,11 @@ const HeaderIconActionButton = React.memo(function HeaderIconActionButton({
type="button"
onClick={onClick}
aria-label={ariaLabel}
className={className ?? DESKTOP_HEADER_ICON_BUTTON_CLASS}
aria-pressed={pressed}
className={cn(
className ?? DESKTOP_HEADER_ICON_BUTTON_CLASS,
pressed && 'bg-interactive-selection text-interactive-selection-foreground'
)}
>
<Icon name={iconName} className={iconClassName ?? 'h-[18px] w-[18px]'} />
</button>
@@ -1426,8 +1432,15 @@ export const Header: React.FC<HeaderProps> = ({
if (!directory) {
return;
}
const panelState = contextPanelByDirectory[directory];
if (getActiveContextMode(panelState) === 'browser') {
closeContextPanel(directory);
return;
}
openContextBrowser(directory);
}, [openContextBrowser, openDirectory]);
}, [closeContextPanel, contextPanelByDirectory, openContextBrowser, openDirectory]);
const isContextPlanActive = React.useMemo(() => {
const directory = normalize(openDirectory || '');
@@ -1438,6 +1451,15 @@ export const Header: React.FC<HeaderProps> = ({
return getActiveContextMode(panelState) === 'plan';
}, [contextPanelByDirectory, openDirectory]);
const isContextBrowserActive = React.useMemo(() => {
const directory = normalize(openDirectory || '');
if (!directory) {
return false;
}
const panelState = contextPanelByDirectory[directory];
return getActiveContextMode(panelState) === 'browser';
}, [contextPanelByDirectory, openDirectory]);
const desktopHeaderIconButtonClass = DESKTOP_HEADER_ICON_BUTTON_CLASS;
const mobileHeaderIconButtonClass = MOBILE_HEADER_ICON_BUTTON_CLASS;
const mobileActiveHeaderItem = React.useMemo(() => {
@@ -1943,6 +1965,7 @@ export const Header: React.FC<HeaderProps> = ({
title={t('contextPanel.browser.open')}
ariaLabel={t('contextPanel.browser.open')}
onClick={handleOpenContextBrowser}
pressed={isContextBrowserActive}
Icon={'global'}
/>
) : null}