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:
chengyongru authored and GitHub committed 2026-11-05 17:09:20 +08:00
1 parent 2b44088413
commit 519ed81132
132 files changed
+4673 -1159

No files matched your search

+62 -27
View File
@@ -1,17 +1,12 @@
import {
PromptNavigationIcon,
} from "@/components/icons/product-icons";
import { useMemo, useRef, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { Search } from "lucide-react";
import { useTranslation } from "react-i18next";
import { Button } from "@/components/ui/button";
import { SearchInput } from "@/components/ui/input";
import {
Sheet,
SheetContent,
SheetTitle,
} from "@/components/ui/sheet";
import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog";
import {
type PromptAnchor,
userPromptAnchors,
@@ -24,14 +19,16 @@ interface PromptNavigatorProps {
messages: UIMessage[];
prompts?: PromptAnchor[];
onJumpToPrompt: (promptId: string) => void;
shortcutEnabled?: boolean;
}
const ROW_HEIGHT = 88;
const ROW_HEIGHT = 64;
export function PromptNavigator({
messages,
prompts: suppliedPrompts,
onJumpToPrompt,
shortcutEnabled = true,
}: PromptNavigatorProps) {
const { i18n, t } = useTranslation();
const prompts = useMemo(() => suppliedPrompts ?? userPromptAnchors(messages), [suppliedPrompts, messages]);
@@ -39,6 +36,23 @@ export function PromptNavigator({
const [query, setQuery] = useState("");
const listRef = useRef<HTMLDivElement>(null);
const [listTop, setListTop] = useState(0);
const [highlighted, setHighlighted] = useState(0);
const inputRef = useRef<HTMLInputElement>(null);
const triggerRef = useRef<HTMLButtonElement>(null);
useEffect(() => {
const keyDown = (event: KeyboardEvent) => {
if (!shortcutEnabled || !prompts.length || event.defaultPrevented || event.repeat || event.isComposing
|| event.altKey || event.shiftKey || !(event.ctrlKey || event.metaKey) || event.key.toLowerCase() !== "f") return;
if (!open && (triggerRef.current?.closest("[hidden], [aria-hidden=true]") || document.querySelector("[role=dialog][data-state=open]"))) return;
event.preventDefault();
setListTop(0); setOpen(true);
inputRef.current?.focus(); inputRef.current?.select();
};
window.addEventListener("keydown", keyDown);
return () => window.removeEventListener("keydown", keyDown);
}, [shortcutEnabled, prompts.length, open]);
useEffect(() => { if (open) { setQuery(""); setHighlighted(0); setListTop(0); } }, [open]);
const filteredPrompts = useMemo(() => {
const needle = query.trim().toLocaleLowerCase();
@@ -60,6 +74,7 @@ export function PromptNavigator({
return (
<>
<Button
ref={triggerRef}
type="button"
variant="ghost"
size="icon"
@@ -68,41 +83,53 @@ export function PromptNavigator({
"hover:text-foreground",
)}
aria-label={t("thread.promptNavigator.open")}
aria-keyshortcuts="Control+F Meta+F"
onClick={() => { setListTop(0); setOpen(true); }}
>
<PromptNavigationIcon className="h-4 w-4" />
</Button>
<Sheet open={open} onOpenChange={setOpen}>
<SheetContent
side="right"
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent
showCloseButton={false}
aria-describedby={undefined}
className="w-[min(92vw,24rem)] gap-0 p-0 sm:max-w-[24rem]"
onOpenAutoFocus={(event) => { event.preventDefault(); inputRef.current?.focus(); }}
onCloseAutoFocus={(event) => { event.preventDefault(); triggerRef.current?.focus(); }}
className="session-search-dialog flex max-h-[min(40rem,100%)] w-[calc(100vw-2rem)] max-w-[42rem] flex-col gap-0 overflow-hidden p-0"
>
<div className="border-b px-5 pb-4 pt-5">
<SheetTitle className="text-base font-medium">
<DialogTitle className="sr-only">
{t("thread.promptNavigator.title")}
</SheetTitle>
<div className="relative mt-4">
</DialogTitle>
<div className="session-search-input flex h-[62px] shrink-0 items-center gap-3 border-b border-border px-[18px]">
<Search
aria-hidden
className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
className="h-[18px] w-[18px] shrink-0 text-muted-foreground"
/>
<SearchInput
<input
ref={inputRef}
value={query}
onChange={(event) => {
setQuery(event.target.value);
setListTop(0);
setHighlighted(0);
if (listRef.current) listRef.current.scrollTop = 0;
}}
aria-label={t("thread.promptNavigator.search")}
placeholder={t("thread.promptNavigator.search")}
className="h-10 rounded-full border-border bg-background pl-9 pr-3 text-sm transition-colors"
onKeyDown={(event) => {
if (event.key === "Enter" && filteredPrompts[highlighted]) { event.preventDefault(); jump(filteredPrompts[highlighted].id); }
if ((event.key === "ArrowDown" || event.key === "ArrowUp") && filteredPrompts.length) {
event.preventDefault();
const next = (highlighted + (event.key === "ArrowDown" ? 1 : -1) + filteredPrompts.length) % filteredPrompts.length;
setHighlighted(next);
if (listRef.current) { listRef.current.scrollTop = next * ROW_HEIGHT; setListTop(next * ROW_HEIGHT); }
}
}}
className="h-full min-w-0 flex-1 bg-transparent text-[19px] font-normal leading-none text-foreground outline-none placeholder:text-muted-foreground"
/>
</div>
</div>
<div ref={listRef} className="min-h-0 flex-1 overflow-y-auto px-2 py-2"
<div ref={listRef} className="min-h-0 flex-1 overflow-y-auto overscroll-contain p-2.5 scrollbar-thin scrollbar-track-transparent"
onScroll={(event) => setListTop(event.currentTarget.scrollTop)}
onKeyDown={(event) => {
const button = (event.target as HTMLElement).closest<HTMLButtonElement>("[data-prompt-row]");
@@ -125,6 +152,8 @@ export function PromptNavigator({
<PromptNavigatorRow
key={prompt.id}
row={firstRow + offset}
highlighted={highlighted === firstRow + offset}
onHighlight={() => setHighlighted(firstRow + offset)}
locale={i18n.resolvedLanguage || i18n.language}
prompt={prompt}
onJump={jump}
@@ -137,8 +166,8 @@ export function PromptNavigator({
</div>
)}
</div>
</SheetContent>
</Sheet>
</DialogContent>
</Dialog>
</>
);
}
@@ -148,6 +177,8 @@ interface PromptNavigatorRowProps {
locale: string;
onJump: (promptId: string) => void;
prompt: PromptAnchor;
highlighted: boolean;
onHighlight: () => void;
}
function PromptNavigatorRow({
@@ -155,6 +186,8 @@ function PromptNavigatorRow({
locale,
onJump,
prompt,
highlighted,
onHighlight,
}: PromptNavigatorRowProps) {
const { t } = useTranslation();
const timestamp = fmtDateTime(prompt.createdAt, locale);
@@ -163,17 +196,19 @@ function PromptNavigatorRow({
type="button"
data-prompt-row={row}
className={cn(
"h-[88px] w-full overflow-hidden rounded-control px-3 py-3 text-left transition",
"hover:bg-accent focus-visible:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",
"h-16 w-full overflow-hidden rounded-control px-3 py-2 text-left transition-colors",
"hover:bg-muted focus-visible:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",
highlighted && "bg-muted",
)}
aria-label={t("thread.promptNavigator.jumpTo", { label: prompt.label })}
onClick={() => onJump(prompt.id)}
onMouseEnter={onHighlight}
>
<div className="line-clamp-2 whitespace-pre-wrap break-words text-sm leading-5 text-foreground">
<div className="truncate text-[14px] font-medium leading-5 text-foreground">
{prompt.preview}
</div>
{timestamp ? (
<div className="mt-1 text-[10px] leading-4 text-muted-foreground/75">
<div className="mt-1 text-[12px] leading-4 text-muted-foreground">
{timestamp}
</div>
) : null}