feat(webui): stabilize session transitions and goal presentation

Keep the composer stable during interruptible session changes. Move active and blocked goals into the header with localized gallery previews, and preserve focus when overlays close. Include the reviewed navigation, layout and accessibility fixes.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-13 23:37:07 +08:00
1 parent e65bec9a6e
commit ce3f36983d
58 files changed
+1874 -453

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import { useRef, type KeyboardEvent, type PointerEvent } from "react";
/** Return Escape to the control that opening an overlay interrupted. */
export function useOverlayEscapeFocus() {
const opener = useRef<HTMLElement | null>(null);
const trigger = useRef<HTMLElement | null>(null);
const escaped = useRef(false);
return {
triggerProps: {
onPointerDownCapture: (event: PointerEvent<HTMLElement>) => {
if (event.button !== 0) return;
if (!escaped.current) opener.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
escaped.current = false;
trigger.current = event.currentTarget;
},
onKeyDownCapture: (event: KeyboardEvent<HTMLElement>) => {
if (event.key === "Enter" || event.key === " ") {
escaped.current = false;
trigger.current = event.currentTarget;
opener.current = event.currentTarget;
}
},
},
contentProps: {
onEscapeKeyDown: () => { escaped.current = true; },
onCloseAutoFocus: (event: Event) => {
const target = escaped.current ? opener.current : null;
opener.current = null;
escaped.current = false;
if (!event.defaultPrevented && target?.isConnected && target !== document.body) {
event.preventDefault();
const active = document.activeElement;
if (active === document.body || active === trigger.current || (event.target instanceof HTMLElement && event.target.contains(active))) {
target.focus({ preventScroll: true });
}
}
},
},
};
}
+2
View File
@@ -9,6 +9,7 @@ import {
type ReactNode,
} from "react";
import { flushSync } from "react-dom";
import { finishSessionTransition } from "@/components/thread/session-transition";
import "./theme-transition.css";
import { useMediaQuery } from "@/hooks/useMediaQuery";
@@ -93,6 +94,7 @@ export function useTheme(): {
// Same-palette choices, such as switching to System, must remain selectable.
if (changesPalette) {
if (switchTimer.current !== null || viewTransition.current !== null) return;
finishSessionTransition();
root.dataset.themeTransition = next;
switchTimer.current = setTimeout(() => {
switchTimer.current = null;