feat(webui): inspect file context in a live graph sidebar (#6562)
* feat(webui): inspect file context in a live graph sidebar * refactor(webui): place preview controls in the shared sidebar header * fix(webui): synchronize npm lockfile for graph dependencies * fix(webui): preserve compacted context and refine graph inspection * fix(context): harden provenance, request usage, and drawer lifecycle * fix(webui): align source skeleton and browser fixtures * perf(context): reuse source analysis and capture request graphs once * perf(webui): compact graph history and render graph motion on canvas * fix(webui): remove redundant context sidebar header * style(webui): clarify context replay icon * perf(webui): pace context replay on an adaptive timeline * feat(webui): briefly reveal labels for new context nodes * fix(webui): reveal new labels only for loaded context files * fix(webui): restart graph animation clock after idle * fix(webui): reveal labels when replay reverses node exit * refactor(context): project file-use facts without retention tracking * refactor(context): observe file reads outside agent execution * fix(webui): animate context sidebar closing * refactor(context): remove unused graph and usage panel code * refactor(context): isolate prompt observation from execution metadata * fix(webui): clarify cache rate and show context token usage * fix(webui): abbreviate context token counts in thousands * fix(webui): omit token unit from context usage details * fix(webui): restore large source preview highlighting and panel elevation * fix(webui): distinguish modifier scrolling from keyboard focus * fix(webui): align preview tab and panel corner radii * fix(webui): attach file tabs to the header divider * fix(webui): use one action to toggle file preview mode * fix(webui): use hover hint for context replay * fix(webui): share composer layout between graph and file sidebars * fix(webui): align sidebar bottom with composer surface * fix(webui): restore mobile graph drawing and touch file details * test(webui): align legacy cache assertions with current label * perf(context): retain source analysis and bound graph animation work * style(webui): add light elevation to user messages * test(webui): await lazy graph scene before replay assertions * fix(webui): align preview skeleton and browser contracts
This commit is contained in:
1 parent
2b44088413
commit
519ed81132
132 files changed
+4673
-1159
No files matched your search
@@ -0,0 +1,68 @@
|
||||
import { createContext, forwardRef, useCallback, useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
|
||||
import { useReducedMotion } from "motion/react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface SidebarPanelProps extends HTMLAttributes<HTMLElement> {
|
||||
header?: ReactNode;
|
||||
width: number;
|
||||
isClosing?: boolean;
|
||||
open?: boolean;
|
||||
floating?: boolean;
|
||||
contentClassName?: string;
|
||||
}
|
||||
|
||||
export const SidebarPanelActionsContext = createContext<HTMLElement | null>(null);
|
||||
|
||||
/** Retain the same surface through exit, including an interrupted close. */
|
||||
export const SidebarPanel = forwardRef<HTMLElement, SidebarPanelProps>(function SidebarPanel({
|
||||
open = true, isClosing, ...props
|
||||
}, ref) {
|
||||
const [present, setPresent] = useState(open);
|
||||
const reducedMotion = useReducedMotion();
|
||||
useEffect(() => {
|
||||
if (open) { setPresent(true); return; }
|
||||
const timer = window.setTimeout(() => setPresent(false), reducedMotion ? 0 : 300);
|
||||
return () => window.clearTimeout(timer);
|
||||
}, [open, reducedMotion]);
|
||||
return open || present ? <SidebarPanelContent {...props} ref={ref} isClosing={isClosing || !open} /> : null;
|
||||
});
|
||||
|
||||
/** Shared nonmodal side slot. Contents keep their final width while the slot opens. */
|
||||
const SidebarPanelContent = forwardRef<HTMLElement, SidebarPanelProps>(function SidebarPanelContent({
|
||||
width, isClosing = false, floating = false, header, contentClassName, className, style, children, ...props
|
||||
}, forwardedRef) {
|
||||
const panel = useRef<HTMLElement | null>(null);
|
||||
const [entered, setEntered] = useState(false);
|
||||
const [actionsHost, setActionsHost] = useState<HTMLElement | null>(null);
|
||||
const setPanel = useCallback((node: HTMLElement | null) => {
|
||||
panel.current = node;
|
||||
if (typeof forwardedRef === "function") forwardedRef(node);
|
||||
else if (forwardedRef) forwardedRef.current = node;
|
||||
}, [forwardedRef]);
|
||||
useLayoutEffect(() => {
|
||||
// Commit the outgoing slot width before transitioning to the replacement width.
|
||||
panel.current?.getBoundingClientRect();
|
||||
let frame = requestAnimationFrame(() => { frame = requestAnimationFrame(() => setEntered(true)); });
|
||||
return () => cancelAnimationFrame(frame);
|
||||
}, []);
|
||||
return <aside {...props} ref={setPanel} data-closing={isClosing || undefined}
|
||||
style={{
|
||||
"--file-preview-width": `${width}px`,
|
||||
"--file-preview-slot-width": isClosing ? "0px" : !entered ? "var(--sidebar-enter-width, 0px)" : `${width}px`,
|
||||
"--file-preview-mobile-width": isClosing ? "0px" : !entered ? "var(--sidebar-enter-mobile-width, 0px)" : "100%",
|
||||
...style,
|
||||
} as CSSProperties}
|
||||
className={cn("file-preview-pane z-30 min-h-0 w-[var(--file-preview-mobile-width)] overflow-hidden duration-300 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none",
|
||||
entered ? "transition-[width]" : "transition-none",
|
||||
floating ? "fixed inset-y-2 right-2 max-w-[420px]" : "absolute inset-y-0 right-0", isClosing && "pointer-events-none", className)}>
|
||||
<div className={cn("file-preview-content absolute inset-y-2 right-2 flex min-h-0 w-[calc(100cqw-1rem)] flex-col pb-[env(safe-area-inset-bottom)] transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none",
|
||||
floating && "w-[calc(min(420px,100vw)-1rem)]",
|
||||
!entered || isClosing ? "translate-x-2 opacity-0" : "translate-x-0 opacity-100", contentClassName)}>
|
||||
{header && <div className="flex min-h-10 shrink-0 items-center gap-1 border-b border-border/40 px-2 pt-2">
|
||||
{header}
|
||||
<div ref={setActionsHost} className="shrink-0" />
|
||||
</div>}
|
||||
<SidebarPanelActionsContext.Provider value={actionsHost}>{children}</SidebarPanelActionsContext.Provider>
|
||||
</div>
|
||||
</aside>;
|
||||
});
|
||||
Reference in new issue
Block a user