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:
1 parent
e65bec9a6e
commit
ce3f36983d
58 files changed
+1874
-453
No files matched your search
@@ -0,0 +1,107 @@
|
||||
import { CircleAlert } from "lucide-react";
|
||||
import { useLayoutEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { MarkdownText, preloadMarkdownText } from "@/components/MarkdownText";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { useOverlayEscapeFocus } from "@/hooks/useOverlayEscapeFocus";
|
||||
import type { GoalStateWsPayload } from "@/lib/types";
|
||||
|
||||
import "./goal-island.css";
|
||||
|
||||
export function GoalIsland({ goal }: { goal: GoalStateWsPayload }) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [scrollBody, setScrollBody] = useState<HTMLDivElement | null>(null);
|
||||
const panelRef = useRef<HTMLDivElement>(null);
|
||||
const escapeFocus = useOverlayEscapeFocus();
|
||||
const changeOpen = (nextOpen: boolean) => {
|
||||
const panel = panelRef.current;
|
||||
const surface = panel?.querySelector<HTMLElement>(":scope > .goal-island-surface");
|
||||
const content = panel?.querySelector<HTMLElement>(".goal-island-panel-content");
|
||||
if (panel && surface && content) {
|
||||
const shape = getComputedStyle(surface);
|
||||
const text = getComputedStyle(content);
|
||||
panel.style.setProperty("--goal-from-width", shape.width);
|
||||
panel.style.setProperty("--goal-from-height", shape.height);
|
||||
panel.style.setProperty("--goal-from-radius", shape.getPropertyValue("--goal-island-radius"));
|
||||
panel.style.setProperty("--goal-from-opacity", text.opacity);
|
||||
panel.style.setProperty("--goal-from-transform", text.transform);
|
||||
}
|
||||
setOpen(nextOpen);
|
||||
};
|
||||
const summary = goal.ui_summary?.trim() ?? "";
|
||||
const objective = goal.objective?.trim() ?? "";
|
||||
const label = summary || objective || t("thread.composer.goalStateFallback");
|
||||
const status = goal.status === "blocked" ? "blocked" : "active";
|
||||
const recap = goal.recap?.trim() ?? "";
|
||||
const collapsedLabel = status === "blocked" ? recap : label;
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!scrollBody) return;
|
||||
if (status === "blocked") scrollBody.scrollTop = 0;
|
||||
const measure = () => {
|
||||
scrollBody.toggleAttribute("data-overflow-top", scrollBody.scrollTop > 1);
|
||||
scrollBody.toggleAttribute("data-overflow-bottom", scrollBody.scrollHeight - scrollBody.clientHeight - scrollBody.scrollTop > 1);
|
||||
};
|
||||
measure();
|
||||
const observer = new ResizeObserver(measure);
|
||||
observer.observe(scrollBody);
|
||||
if (scrollBody.firstElementChild) observer.observe(scrollBody.firstElementChild);
|
||||
scrollBody.addEventListener("scroll", measure, { passive: true });
|
||||
return () => {
|
||||
observer.disconnect();
|
||||
scrollBody.removeEventListener("scroll", measure);
|
||||
};
|
||||
}, [scrollBody, status]);
|
||||
|
||||
return (
|
||||
<div className="goal-island-position">
|
||||
<Popover open={open} onOpenChange={changeOpen}>
|
||||
<div className="goal-island" data-goal-status={status} data-detail-mounted={!!scrollBody} role="status" aria-label={status === "blocked" ? [t("thread.composer.goalBlocked"), recap].filter(Boolean).join(" · ") : t("thread.composer.goalStateStrip", { label })}>
|
||||
<PopoverTrigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
className="goal-island-trigger"
|
||||
aria-label={t("thread.composer.goalStateExpandAria")}
|
||||
{...escapeFocus.triggerProps}
|
||||
onPointerEnter={() => { void preloadMarkdownText(); }}
|
||||
onFocus={() => { void preloadMarkdownText(); }}
|
||||
>
|
||||
<span className="goal-island-surface" aria-hidden />
|
||||
{status === "blocked" ? <CircleAlert className="goal-island-status-icon" strokeWidth={2.5} aria-hidden="true" /> : null}
|
||||
{collapsedLabel ? <span className={status === "blocked" ? "goal-island-reason min-w-0 truncate" : "min-w-0 truncate"}>{collapsedLabel}</span> : null}
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
</div>
|
||||
<PopoverContent
|
||||
ref={panelRef}
|
||||
{...escapeFocus.contentProps}
|
||||
className="goal-island-panel max-h-[min(25dvh,var(--radix-popover-content-available-height))] overflow-visible rounded-t-none rounded-b-[28px] bg-transparent p-0 shadow-none dark:shadow-none"
|
||||
motionClassName=""
|
||||
data-goal-status={status}
|
||||
side="bottom"
|
||||
sideOffset={-40}
|
||||
collisionPadding={{ top: 0, bottom: 12, left: 32, right: 32 }}
|
||||
aria-label={t("thread.composer.goalStateSheetTitle")}
|
||||
>
|
||||
<div className="goal-island-surface" aria-hidden />
|
||||
<div className="goal-island-panel-content">
|
||||
{status !== "blocked" && summary ? <div className="goal-island-summary markdown-content"><h2>{summary}</h2></div> : null}
|
||||
<div ref={setScrollBody} className="goal-island-body">
|
||||
<div className="goal-island-document">
|
||||
{status === "blocked" ? <div className="goal-island-blocked">
|
||||
<CircleAlert className="goal-island-status-icon" strokeWidth={2.5} aria-hidden="true" />
|
||||
<span className="sr-only">{t("thread.composer.goalBlocked")}</span>
|
||||
{recap ? <MarkdownText className="goal-island-reason">{recap}</MarkdownText> : null}
|
||||
</div> : null}
|
||||
{objective ? <MarkdownText className={status === "blocked" ? "mt-4" : undefined}>{objective}</MarkdownText> : null}
|
||||
{status !== "blocked" && recap ? <MarkdownText className="mt-4 text-muted-foreground">{recap}</MarkdownText> : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
|
||||
import { useLogoFallback } from "@/hooks/useLogoFallback";
|
||||
import { useOverlayEscapeFocus } from "@/hooks/useOverlayEscapeFocus";
|
||||
import { inferProviderFromModelName, providerBrand } from "@/lib/provider-brand";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -124,6 +125,8 @@ export function ModelPresetBadge({
|
||||
const [motionWidth, setMotionWidth] = useState<number | null>(null);
|
||||
const gestureRef = useRef<PresetGesture | null>(null);
|
||||
const suppressClickRef = useRef(false);
|
||||
const escapeFocus = useOverlayEscapeFocus();
|
||||
const focusAfterClose = useRef<"composer" | "management" | null>(null);
|
||||
const activeName = modelPreset?.trim() || "";
|
||||
const listedIndex = modelPresets.findIndex((preset) => preset.name === activeName);
|
||||
const activePreset: ModelPresetOption = {
|
||||
@@ -158,12 +161,14 @@ export function ModelPresetBadge({
|
||||
});
|
||||
|
||||
const selectPreset = (name: string) => {
|
||||
if (open) focusAfterClose.current = "composer";
|
||||
else requestAnimationFrame(() => onRequestComposerFocus?.());
|
||||
setOpen(false);
|
||||
if (name !== activeName) onPresetChange?.(name);
|
||||
requestAnimationFrame(() => onRequestComposerFocus?.());
|
||||
};
|
||||
|
||||
const openModelSettings = () => {
|
||||
focusAfterClose.current = "management";
|
||||
setOpen(false);
|
||||
onManageModels?.();
|
||||
};
|
||||
@@ -306,13 +311,7 @@ export function ModelPresetBadge({
|
||||
</Container>
|
||||
</TooltipTrigger>
|
||||
) : (
|
||||
<Popover
|
||||
open={open}
|
||||
onOpenChange={(nextOpen) => {
|
||||
setOpen(nextOpen);
|
||||
if (!nextOpen) requestAnimationFrame(() => onRequestComposerFocus?.());
|
||||
}}
|
||||
>
|
||||
<Popover open={open} onOpenChange={setOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
<TooltipTrigger asChild>
|
||||
<button
|
||||
@@ -320,6 +319,7 @@ export function ModelPresetBadge({
|
||||
data-switching={motion ? "true" : undefined}
|
||||
aria-label={label}
|
||||
aria-expanded={open}
|
||||
{...escapeFocus.triggerProps}
|
||||
onPointerDown={handlePointerDown}
|
||||
onPointerMove={handlePointerMove}
|
||||
onPointerLeave={(event) => {
|
||||
@@ -404,6 +404,16 @@ export function ModelPresetBadge({
|
||||
collisionPadding={12}
|
||||
role="dialog"
|
||||
aria-label={switchModelLabel}
|
||||
onEscapeKeyDown={escapeFocus.contentProps.onEscapeKeyDown}
|
||||
onCloseAutoFocus={(event) => {
|
||||
if (focusAfterClose.current === "management") event.preventDefault();
|
||||
else if (focusAfterClose.current === "composer" && onRequestComposerFocus) {
|
||||
event.preventDefault();
|
||||
onRequestComposerFocus();
|
||||
}
|
||||
escapeFocus.contentProps.onCloseAutoFocus(event);
|
||||
focusAfterClose.current = null;
|
||||
}}
|
||||
onOpenAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
const content = event.currentTarget;
|
||||
|
||||
@@ -39,6 +39,7 @@ export function PromptNavigator({
|
||||
const [highlighted, setHighlighted] = useState(0);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||
const openerRef = useRef<HTMLElement | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const keyDown = (event: KeyboardEvent) => {
|
||||
@@ -93,8 +94,16 @@ export function PromptNavigator({
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
aria-describedby={undefined}
|
||||
onOpenAutoFocus={(event) => { event.preventDefault(); inputRef.current?.focus(); }}
|
||||
onCloseAutoFocus={(event) => { event.preventDefault(); triggerRef.current?.focus(); }}
|
||||
onOpenAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
openerRef.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
||||
inputRef.current?.focus();
|
||||
}}
|
||||
onCloseAutoFocus={(event) => {
|
||||
event.preventDefault();
|
||||
const target = openerRef.current?.isConnected ? openerRef.current : triggerRef.current;
|
||||
target?.focus({ preventScroll: true });
|
||||
}}
|
||||
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"
|
||||
>
|
||||
<DialogTitle className="sr-only">
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
PopoverContent,
|
||||
PopoverTrigger,
|
||||
} from "@/components/ui/popover";
|
||||
import { useOverlayEscapeFocus } from "@/hooks/useOverlayEscapeFocus";
|
||||
import { currentLocale } from "@/i18n";
|
||||
import { fmtDateTime } from "@/lib/format-time";
|
||||
import type {
|
||||
@@ -63,6 +64,7 @@ export function SessionInfoPopoverView({ jobs, loading, loadFailed, now, onActio
|
||||
}) {
|
||||
const { t } = useTranslation("common");
|
||||
const [open, setOpen] = useState(false);
|
||||
const escapeFocus = useOverlayEscapeFocus();
|
||||
const [inspectedJob, setInspectedJob] = useState<SessionAutomationJob | null>(null);
|
||||
// Keep requested dialogs mounted through their close and focus-restoration lifecycle.
|
||||
const [dialogsRequested, setDialogsRequested] = useState(false);
|
||||
@@ -179,6 +181,7 @@ export function SessionInfoPopoverView({ jobs, loading, loadFailed, now, onActio
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
ref={triggerRef}
|
||||
{...escapeFocus.triggerProps}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={t("thread.header.sessionInfo")}
|
||||
@@ -194,8 +197,10 @@ export function SessionInfoPopoverView({ jobs, loading, loadFailed, now, onActio
|
||||
align="end"
|
||||
sideOffset={8}
|
||||
className="w-[min(23rem,calc(100vw-1.5rem))] overflow-hidden p-0"
|
||||
onEscapeKeyDown={escapeFocus.contentProps.onEscapeKeyDown}
|
||||
onCloseAutoFocus={(event) => {
|
||||
if (detailOpen) event.preventDefault();
|
||||
escapeFocus.contentProps.onCloseAutoFocus(event);
|
||||
}}
|
||||
>
|
||||
<div className="flex max-h-[min(var(--radix-popover-content-available-height),32rem)] flex-col">
|
||||
|
||||
@@ -36,7 +36,6 @@ import {
|
||||
type Ref,
|
||||
} from "react";
|
||||
|
||||
import { MarkdownText, preloadMarkdownText } from "@/components/MarkdownText";
|
||||
import {
|
||||
CapabilityMentionToken,
|
||||
cliAppInitials,
|
||||
@@ -56,8 +55,6 @@ import {
|
||||
import { INLINE_REFERENCE_HIGHLIGHT_COLOR, INLINE_TOKEN_HIGHLIGHT_COLOR, InlineTokenHighlight } from "@/components/InlineTokenHighlight";
|
||||
import { SlashCommandText } from "@/components/SlashCommandText";
|
||||
import {
|
||||
ChevronDown,
|
||||
ChevronUp,
|
||||
CornerDownRight,
|
||||
Loader2,
|
||||
Quote,
|
||||
@@ -73,7 +70,6 @@ import { ComposerActionIcon, type ComposerActionState } from "@/components/threa
|
||||
import {
|
||||
floatingItemClassName,
|
||||
floatingItemFocusClassName,
|
||||
floatingSurfaceElevationClassName,
|
||||
floatingSurfaceVisualClassName,
|
||||
} from "@/components/ui/floating-surface";
|
||||
import {
|
||||
@@ -512,40 +508,6 @@ function getVisibleBounds(el: HTMLElement): { top: number; bottom: number } {
|
||||
return { top, bottom };
|
||||
}
|
||||
|
||||
function goalStateStripPreview(
|
||||
goal: GoalStateWsPayload | undefined,
|
||||
t: (key: string) => string,
|
||||
): string | null {
|
||||
if (!goal?.active) return null;
|
||||
const summary = goal.ui_summary?.trim();
|
||||
if (summary) return summary;
|
||||
const obj = goal.objective?.trim();
|
||||
if (obj) return obj.length > 72 ? `${obj.slice(0, 72)}…` : obj;
|
||||
return t("thread.composer.goalStateFallback");
|
||||
}
|
||||
|
||||
const GOAL_PANEL_VIEWPORT_TOP_PAD = 20;
|
||||
const GOAL_PANEL_GAP_ABOVE_STRIP_PX = 10;
|
||||
const GOAL_PANEL_MIN_HEIGHT_PX = 112;
|
||||
const GOAL_PANEL_MAX_VIEWPORT_RATIO = 0.62;
|
||||
|
||||
function measureGoalPanelMaxCssHeight(stripTopY: number): number {
|
||||
const viewport = visualViewportBounds();
|
||||
const spaceAboveStrip =
|
||||
stripTopY - viewport.top - GOAL_PANEL_VIEWPORT_TOP_PAD - GOAL_PANEL_GAP_ABOVE_STRIP_PX;
|
||||
return Math.min(
|
||||
Math.max(spaceAboveStrip, GOAL_PANEL_MIN_HEIGHT_PX),
|
||||
Math.floor(viewport.height * GOAL_PANEL_MAX_VIEWPORT_RATIO),
|
||||
);
|
||||
}
|
||||
|
||||
function buildGoalMarkdownBody(summary: string, objective: string): string {
|
||||
const s = summary.trim();
|
||||
const o = objective.trim();
|
||||
if (s && o) return `${s}\n\n---\n\n${o}`;
|
||||
return o || s;
|
||||
}
|
||||
|
||||
function cliAppMentionPayload(app: CliAppInfo): OutboundCliAppMention {
|
||||
return {
|
||||
name: app.name,
|
||||
@@ -570,193 +532,6 @@ function mcpPresetMentionPayload(preset: McpPresetInfo): OutboundMcpPresetMentio
|
||||
};
|
||||
}
|
||||
|
||||
function GoalStateStrip({
|
||||
goalState,
|
||||
}: {
|
||||
goalState?: GoalStateWsPayload;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [goalPanelOpen, setGoalPanelOpen] = useState(false);
|
||||
const stripLabel = goalStateStripPreview(goalState, t);
|
||||
const active = !!stripLabel?.trim();
|
||||
const [, setTick] = useState(0);
|
||||
const stripWrapperRef = useRef<HTMLDivElement>(null);
|
||||
const panelRef = useRef<HTMLDivElement>(null);
|
||||
const expandToggleRef = useRef<HTMLButtonElement>(null);
|
||||
const stripSnapshotRef = useRef<{
|
||||
goalState?: GoalStateWsPayload;
|
||||
stripLabel: string | null;
|
||||
} | null>(null);
|
||||
const [panelMaxPx, setPanelMaxPx] = useState(280);
|
||||
|
||||
if (active) {
|
||||
stripSnapshotRef.current = { goalState, stripLabel };
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!active) setGoalPanelOpen(false);
|
||||
}, [active]);
|
||||
|
||||
const display = active
|
||||
? { goalState, stripLabel }
|
||||
: stripSnapshotRef.current;
|
||||
const displayGoalState = display?.goalState;
|
||||
const displayStripLabel = display?.stripLabel ?? null;
|
||||
|
||||
const objectiveFull = displayGoalState?.objective?.trim() ?? "";
|
||||
const summaryFull = displayGoalState?.ui_summary?.trim() ?? "";
|
||||
const canExpandGoal = !!(active && displayGoalState?.active && (objectiveFull || summaryFull));
|
||||
|
||||
const markdownBody =
|
||||
objectiveFull || summaryFull
|
||||
? buildGoalMarkdownBody(summaryFull, objectiveFull)
|
||||
: "";
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!goalPanelOpen) return;
|
||||
|
||||
function relayout(): void {
|
||||
const el = stripWrapperRef.current;
|
||||
if (!el) return;
|
||||
const top = el.getBoundingClientRect().top;
|
||||
setPanelMaxPx(measureGoalPanelMaxCssHeight(top));
|
||||
}
|
||||
|
||||
relayout();
|
||||
|
||||
void preloadMarkdownText();
|
||||
const ro =
|
||||
typeof ResizeObserver !== "undefined"
|
||||
? new ResizeObserver(() => relayout())
|
||||
: null;
|
||||
if (stripWrapperRef.current && ro) {
|
||||
ro.observe(stripWrapperRef.current);
|
||||
}
|
||||
const viewport = window.visualViewport;
|
||||
viewport?.addEventListener("resize", relayout);
|
||||
viewport?.addEventListener("scroll", relayout);
|
||||
window.addEventListener("resize", relayout);
|
||||
window.addEventListener("scroll", relayout, true);
|
||||
return () => {
|
||||
ro?.disconnect();
|
||||
viewport?.removeEventListener("resize", relayout);
|
||||
viewport?.removeEventListener("scroll", relayout);
|
||||
window.removeEventListener("resize", relayout);
|
||||
window.removeEventListener("scroll", relayout, true);
|
||||
};
|
||||
}, [goalPanelOpen]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!goalPanelOpen) return;
|
||||
|
||||
function onPointerDown(ev: MouseEvent): void {
|
||||
const target = ev.target as Node | null;
|
||||
if (!target) return;
|
||||
if (panelRef.current?.contains(target)) return;
|
||||
if (expandToggleRef.current?.contains(target)) return;
|
||||
setGoalPanelOpen(false);
|
||||
}
|
||||
|
||||
function onKey(ev: KeyboardEvent): void {
|
||||
if (ev.key === "Escape") setGoalPanelOpen(false);
|
||||
}
|
||||
|
||||
window.addEventListener("mousedown", onPointerDown);
|
||||
window.addEventListener("keydown", onKey);
|
||||
return () => {
|
||||
window.removeEventListener("mousedown", onPointerDown);
|
||||
window.removeEventListener("keydown", onKey);
|
||||
};
|
||||
}, [goalPanelOpen]);
|
||||
|
||||
if (!display) return null;
|
||||
|
||||
const ariaLabel = displayStripLabel
|
||||
? t("thread.composer.goalStateStrip", { label: displayStripLabel })
|
||||
: t("thread.composer.goalStateFallback");
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={stripWrapperRef}
|
||||
className="composer-status-drawer relative z-30"
|
||||
data-composer-status-drawer=""
|
||||
data-state={active ? "open" : "closed"}
|
||||
aria-hidden={active ? undefined : true}
|
||||
onTransitionEnd={(event) => {
|
||||
if (active || event.target !== event.currentTarget) return;
|
||||
stripSnapshotRef.current = null;
|
||||
setTick((n) => n + 1);
|
||||
}}
|
||||
>
|
||||
{goalPanelOpen && canExpandGoal && markdownBody ? (
|
||||
<div
|
||||
ref={panelRef}
|
||||
id="nanobot-goal-panel-root"
|
||||
role="dialog"
|
||||
aria-modal="false"
|
||||
aria-label={t("thread.composer.goalStateSheetTitle")}
|
||||
tabIndex={-1}
|
||||
className={cn(
|
||||
"absolute bottom-[calc(100%+8px)] left-3 right-3 z-[50] flex max-w-none flex-col overflow-hidden",
|
||||
"rounded-2xl",
|
||||
floatingSurfaceElevationClassName,
|
||||
)}
|
||||
style={{ maxHeight: `${Math.round(panelMaxPx)}px` }}
|
||||
>
|
||||
<div
|
||||
id="nanobot-goal-panel-scroll"
|
||||
className="min-h-0 flex-1 overflow-y-auto scrollbar-thin p-3"
|
||||
>
|
||||
<MarkdownText className="max-w-none text-foreground/90">
|
||||
{markdownBody}
|
||||
</MarkdownText>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="composer-status-drawer-clip">
|
||||
{display ? (
|
||||
<div
|
||||
className="composer-status-drawer-content flex min-h-[36px] items-center gap-2 px-3 py-2"
|
||||
role="status"
|
||||
aria-label={ariaLabel}
|
||||
>
|
||||
<GoalIcon className="h-4 w-4 shrink-0 text-primary/75" aria-hidden />
|
||||
<span className="flex min-w-0 flex-1 items-center gap-1.5 text-[12px] font-medium text-foreground/75">
|
||||
{displayStripLabel ? (
|
||||
<span className="truncate">
|
||||
{t("thread.composer.goalStateStrip", { label: displayStripLabel })}
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
{canExpandGoal ? (
|
||||
<button
|
||||
ref={expandToggleRef}
|
||||
type="button"
|
||||
className={cn(
|
||||
"inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-full",
|
||||
"text-muted-foreground transition-colors hover:text-foreground",
|
||||
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
||||
)}
|
||||
aria-expanded={goalPanelOpen}
|
||||
aria-controls={goalPanelOpen ? "nanobot-goal-panel-root" : undefined}
|
||||
aria-label={t("thread.composer.goalStateExpandAria")}
|
||||
title={t("thread.composer.goalStateExpandAria")}
|
||||
onClick={() => setGoalPanelOpen((o) => !o)}
|
||||
>
|
||||
{goalPanelOpen ? (
|
||||
<ChevronDown className="h-4 w-4" aria-hidden />
|
||||
) : (
|
||||
<ChevronUp className="h-4 w-4" aria-hidden />
|
||||
)}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function autosizeTextarea(input: HTMLTextAreaElement) {
|
||||
const container = input.parentElement!;
|
||||
const previousMinHeight = container.style.minHeight;
|
||||
@@ -2163,7 +1938,7 @@ export function ThreadComposer({
|
||||
const relaxedHeroInput = isHero && images.length === 0 && !isStreaming;
|
||||
const compactIdle = compactWhenIdle && !compactControls && !isHero && !composerFocused
|
||||
&& value.length === 0 && images.length === 0 && !inlineError
|
||||
&& !normalizedQuotedContext && !queuedPrompt && !goalState?.active
|
||||
&& !normalizedQuotedContext && !queuedPrompt
|
||||
&& !isDragging && !sessionDragPreview && !voiceRecorder.isRecording && !showProjectPicker;
|
||||
useLayoutEffect(() => {
|
||||
if (!compactWhenIdle || compactControls) return;
|
||||
@@ -2328,8 +2103,6 @@ export function ThreadComposer({
|
||||
interactionDisabled && "opacity-60",
|
||||
sessionDragPreview && "ring-1 ring-primary/25",
|
||||
isDragging && "ring-2 ring-primary/40 motion-reduce:ring-0 motion-reduce:border-primary",
|
||||
goalState?.active &&
|
||||
"ring-1 ring-sky-400/35 motion-reduce:ring-sky-400/25 dark:ring-sky-400/45",
|
||||
)}
|
||||
>
|
||||
{queuedPrompt ? (
|
||||
@@ -2398,7 +2171,6 @@ export function ThreadComposer({
|
||||
</button>
|
||||
</div>
|
||||
) : null}
|
||||
<GoalStateStrip goalState={goalState} />
|
||||
<div className="thread-composer-input relative min-w-0">
|
||||
{placeholder === undefined ? (
|
||||
<span className="pointer-events-none invisible absolute h-0 w-0 overflow-hidden">
|
||||
|
||||
@@ -38,6 +38,7 @@ interface ThreadHeaderProps {
|
||||
minimal?: boolean;
|
||||
promptNavigatorAction?: ReactNode;
|
||||
sessionInfoAction?: ReactNode;
|
||||
goal?: ReactNode;
|
||||
temporaryChatEnabled?: boolean;
|
||||
temporaryChatDisabled?: boolean;
|
||||
onTemporaryChatEnabledChange?: (enabled: boolean) => void;
|
||||
@@ -58,6 +59,7 @@ export function ThreadHeader({
|
||||
minimal = false,
|
||||
promptNavigatorAction,
|
||||
sessionInfoAction,
|
||||
goal,
|
||||
temporaryChatEnabled = false,
|
||||
temporaryChatDisabled = false,
|
||||
onTemporaryChatEnabledChange,
|
||||
@@ -68,7 +70,8 @@ export function ThreadHeader({
|
||||
<div
|
||||
data-testid="thread-header"
|
||||
className={cn(
|
||||
"pointer-events-none inset-x-0 top-0 z-30 flex shrink-0 items-center justify-between gap-3 px-3 py-1",
|
||||
"thread-header-container pointer-events-none inset-x-0 top-0 z-30 flex shrink-0 items-center justify-between gap-3 px-3 py-1",
|
||||
goal && "thread-header-with-goal",
|
||||
"[position:var(--thread-header-position,absolute)]",
|
||||
minimal && "h-11",
|
||||
className,
|
||||
@@ -76,6 +79,7 @@ export function ThreadHeader({
|
||||
>
|
||||
<div
|
||||
data-theme-surface
|
||||
data-header-controls="start"
|
||||
className={cn(
|
||||
controlsClassName,
|
||||
"relative min-w-0",
|
||||
@@ -103,6 +107,7 @@ export function ThreadHeader({
|
||||
) : null}
|
||||
{handle ? (
|
||||
<span
|
||||
data-header-handle
|
||||
className="flex shrink-0 items-center rounded-md px-1.5 py-1 text-[12px] font-medium"
|
||||
>
|
||||
<SessionHandleLabel id={handle.id}>
|
||||
@@ -112,7 +117,8 @@ export function ThreadHeader({
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div data-theme-surface className={cn(controlsClassName, "ml-auto shrink-0")}>
|
||||
{goal}
|
||||
<div data-theme-surface data-header-controls="end" className={cn(controlsClassName, "ml-auto shrink-0")}>
|
||||
{sessionInfoAction}
|
||||
{promptNavigatorAction}
|
||||
{actions}
|
||||
|
||||
@@ -34,6 +34,7 @@ import {
|
||||
toModelBadgeInfo,
|
||||
} from "@/components/thread/model-preset";
|
||||
import { ThreadHeader } from "@/components/thread/ThreadHeader";
|
||||
import { GoalIsland } from "@/components/thread/GoalIsland";
|
||||
import { ThreadLoadingSkeleton } from "@/components/thread/ThreadLoadingSkeleton";
|
||||
import { StreamErrorNotice } from "@/components/thread/StreamErrorNotice";
|
||||
import { ThreadViewport, type ThreadViewportHandle } from "@/components/thread/ThreadViewport";
|
||||
@@ -1427,6 +1428,8 @@ export function ThreadShell({
|
||||
<ThreadHeader
|
||||
className={previewOpen ? "h-10" : undefined}
|
||||
title={title}
|
||||
goal={currentGoalState && (currentGoalState.active || currentGoalState.status === "blocked")
|
||||
? <GoalIsland key={historyKey} goal={currentGoalState} /> : undefined}
|
||||
onToggleSidebar={onToggleSidebar}
|
||||
theme={theme}
|
||||
onToggleTheme={onToggleTheme}
|
||||
|
||||
@@ -1334,6 +1334,7 @@ export const ThreadViewport = forwardRef<ThreadViewportHandle, ThreadViewportPro
|
||||
initialLoading
|
||||
? "overflow-hidden"
|
||||
: cn("flex items-center justify-center", hasComposer && "sm:items-end sm:pb-8"),
|
||||
"thread-empty-region",
|
||||
)}
|
||||
>
|
||||
{emptyState}
|
||||
|
||||
@@ -15,6 +15,7 @@ import { SidebarSelectionHighlight, SIDEBAR_SELECTION_ITEM_CLASS } from "@/compo
|
||||
import type { WorkspaceScopePayload, ProjectDirectory, WorkspaceDirectoriesPayload, WorkspacesPayload } from "@/lib/types";
|
||||
import { createWorkspaceDirectoryCache } from "@/lib/workspace-directory-cache";
|
||||
import { useMediaQuery } from "@/hooks/useMediaQuery";
|
||||
import { useOverlayEscapeFocus } from "@/hooks/useOverlayEscapeFocus";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { isAbsoluteWorkspacePath, projectNameFromPath, sameWorkspacePath, scopeWithAccessMode, workspaceBreadcrumbs, workspacePathCompletionQuery, workspaceDirectoryPrefix, selectedProjectScope, type BrowseWorkspaceDirectories } from "@/lib/workspace";
|
||||
|
||||
@@ -211,6 +212,7 @@ export function WorkspaceProjectPicker({ disabled, scope, defaultScope, controls
|
||||
const triggerRef = useRef<HTMLButtonElement>(null);
|
||||
const [keyboardInteraction, setKeyboardInteraction] = useState(false);
|
||||
const openedWithKeyboard = useRef(false);
|
||||
const escapeFocus = useOverlayEscapeFocus();
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const confirmRef = useRef<HTMLButtonElement>(null);
|
||||
const optionsId = useId();
|
||||
@@ -556,7 +558,7 @@ export function WorkspaceProjectPicker({ disabled, scope, defaultScope, controls
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<HoverHint content={`${t("workspace.picker.switchDirectory")}\n${displayedScope?.project_path ?? ""}`}>
|
||||
<DialogTrigger asChild>
|
||||
<button ref={triggerRef} onClick={event => { openedWithKeyboard.current = event.detail === 0; }} onPointerDown={() => setKeyboardInteraction(false)} onKeyDown={() => setKeyboardInteraction(true)} type="button" disabled={disabled} aria-label={t("workspace.picker.switchDirectory")} className="thread-composer-workspace touch-target inline-flex h-7 min-w-0 max-w-full items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55">
|
||||
<button ref={triggerRef} {...escapeFocus.triggerProps} onClick={event => { openedWithKeyboard.current = event.detail === 0; }} onPointerDown={() => setKeyboardInteraction(false)} onKeyDown={() => setKeyboardInteraction(true)} type="button" disabled={disabled} aria-label={t("workspace.picker.switchDirectory")} className="thread-composer-workspace touch-target inline-flex h-7 min-w-0 max-w-full items-center gap-1.5 rounded-md px-2 text-[12px] font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-55">
|
||||
<WorkspaceIcon className="h-3.5 w-3.5 shrink-0" />
|
||||
<span className="min-w-0 truncate">{projectLabel}</span>
|
||||
<ChevronDown className="h-3 w-3 shrink-0" aria-hidden />
|
||||
@@ -571,8 +573,14 @@ export function WorkspaceProjectPicker({ disabled, scope, defaultScope, controls
|
||||
if (!canBrowse || pickingFolder || event.nativeEvent.isComposing) return;
|
||||
if ((event.metaKey || event.ctrlKey) && event.shiftKey && event.key.toLowerCase() === "g") { event.preventDefault(); editPath(); }
|
||||
}}
|
||||
onEscapeKeyDown={event => { if (editingPath) { event.preventDefault(); cancelPathEditing(); } }}
|
||||
onCloseAutoFocus={event => { if (!openedWithKeyboard.current) event.preventDefault(); }}>
|
||||
onEscapeKeyDown={event => {
|
||||
if (editingPath) { event.preventDefault(); cancelPathEditing(); }
|
||||
else escapeFocus.contentProps.onEscapeKeyDown();
|
||||
}}
|
||||
onCloseAutoFocus={event => {
|
||||
escapeFocus.contentProps.onCloseAutoFocus(event);
|
||||
if (!openedWithKeyboard.current) event.preventDefault();
|
||||
}}>
|
||||
<DialogTitle className="sr-only">{t("workspace.picker.title")}</DialogTitle>
|
||||
<DialogDescription className="sr-only">{t("workspace.picker.description")}</DialogDescription>
|
||||
<div className="flex shrink-0 items-center gap-1 bg-muted px-[var(--picker-toolbar-inset)] pt-[var(--picker-toolbar-inset)] pb-3">
|
||||
|
||||
@@ -0,0 +1,284 @@
|
||||
@property --goal-island-width {
|
||||
syntax: "<length-percentage>";
|
||||
inherits: true;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --goal-island-height {
|
||||
syntax: "<length-percentage>";
|
||||
inherits: true;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --goal-island-radius {
|
||||
syntax: "<length>";
|
||||
inherits: true;
|
||||
initial-value: 16px;
|
||||
}
|
||||
|
||||
.thread-header-container {
|
||||
container-type: inline-size;
|
||||
}
|
||||
.thread-header-with-goal > [data-header-controls="start"] {
|
||||
max-width: calc(50% - min(18cqw, 10rem) - 24px);
|
||||
}
|
||||
.thread-header-with-goal [data-header-handle] {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.goal-island-position {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
width: min(36cqw, 20rem);
|
||||
transform: translateX(-50%);
|
||||
pointer-events: auto;
|
||||
}
|
||||
.goal-island,
|
||||
.goal-island-panel {
|
||||
--goal-surface: hsl(var(--sidebar) / 94%);
|
||||
--goal-highlight: rgb(255 255 255 / 80%);
|
||||
--goal-shadow: rgb(20 20 24 / 10%);
|
||||
--goal-blocked-color: hsl(0 42% 48%);
|
||||
color: hsl(var(--sidebar-foreground));
|
||||
}
|
||||
:where(.dark) .goal-island,
|
||||
:where(.dark) .goal-island-panel {
|
||||
--goal-highlight: rgb(255 255 255 / 12%);
|
||||
--goal-shadow: rgb(0 0 0 / 26%);
|
||||
--goal-blocked-color: hsl(0 42% 70%);
|
||||
}
|
||||
.goal-island-trigger {
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
padding: 0 16px;
|
||||
border-radius: 0 0 16px 16px;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
.goal-island[data-detail-mounted="true"] .goal-island-trigger {
|
||||
opacity: 0;
|
||||
}
|
||||
.goal-island-trigger:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
.goal-island-trigger:focus-visible > span:last-child {
|
||||
text-decoration: underline;
|
||||
text-decoration-thickness: 2px;
|
||||
text-underline-offset: 4px;
|
||||
}
|
||||
.goal-island-panel {
|
||||
--goal-island-radius: 28px;
|
||||
isolation: isolate;
|
||||
width: min(36rem, calc(100vw - 64px));
|
||||
outline: none;
|
||||
}
|
||||
.goal-island-surface {
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
top: 0;
|
||||
left: 50%;
|
||||
width: var(--goal-island-width);
|
||||
height: var(--goal-island-height);
|
||||
transform: translateX(-50%);
|
||||
filter: drop-shadow(0 1px 0 var(--goal-highlight)) drop-shadow(0 7px 12px var(--goal-shadow));
|
||||
pointer-events: none;
|
||||
}
|
||||
.goal-island-panel > .goal-island-surface {
|
||||
filter: drop-shadow(0 1px 0 var(--goal-highlight)) drop-shadow(0 4px 5px hsl(240 10% 16% / 0.12));
|
||||
}
|
||||
:where(.dark) .goal-island-panel > .goal-island-surface {
|
||||
filter: drop-shadow(0 1px 0 var(--goal-highlight)) drop-shadow(0 4px 5px hsl(240 12% 3% / 0.12));
|
||||
}
|
||||
.goal-island-surface::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 -24px;
|
||||
background: var(--goal-surface);
|
||||
backdrop-filter: blur(20px) saturate(1.2);
|
||||
-webkit-backdrop-filter: blur(20px) saturate(1.2);
|
||||
clip-path: shape(
|
||||
from 0 0,
|
||||
hline to 100%,
|
||||
curve to calc(100% - 24px) 24px with calc(100% - 13.255px) 0 / calc(100% - 24px) 10.745px,
|
||||
vline to calc(100% - var(--goal-island-radius)),
|
||||
arc to calc(100% - 24px - var(--goal-island-radius)) 100% of var(--goal-island-radius) cw,
|
||||
hline to calc(24px + var(--goal-island-radius)),
|
||||
arc to 24px calc(100% - var(--goal-island-radius)) of var(--goal-island-radius) cw,
|
||||
vline to 24px,
|
||||
curve to 0 0 with 24px 10.745px / 13.255px 0,
|
||||
close
|
||||
);
|
||||
}
|
||||
.goal-island-panel-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: inherit;
|
||||
}
|
||||
.goal-island-summary {
|
||||
flex-shrink: 0;
|
||||
margin: 0;
|
||||
padding: 22px 24px 12px;
|
||||
color: hsl(var(--foreground));
|
||||
}
|
||||
.goal-island-summary h2 {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.goal-island-body {
|
||||
--goal-fade-top: 0px;
|
||||
--goal-fade-bottom: 0px;
|
||||
min-height: 0;
|
||||
overflow: auto;
|
||||
overscroll-behavior: contain;
|
||||
scrollbar-width: none;
|
||||
overflow-wrap: anywhere;
|
||||
mask-image: linear-gradient(to bottom, transparent, #000 var(--goal-fade-top), #000 calc(100% - var(--goal-fade-bottom)), transparent);
|
||||
}
|
||||
.goal-island-body::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
.goal-island-body[data-overflow-top] {
|
||||
--goal-fade-top: min(28px, 25%);
|
||||
}
|
||||
.goal-island-body[data-overflow-bottom] {
|
||||
--goal-fade-bottom: min(36px, 25%);
|
||||
}
|
||||
.goal-island-document {
|
||||
padding: 0 24px 24px;
|
||||
}
|
||||
.goal-island-body:first-child .goal-island-document {
|
||||
padding-top: 24px;
|
||||
}
|
||||
.goal-island-body .markdown-content {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.goal-island-blocked {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding-bottom: 12px;
|
||||
border-bottom: 1px solid hsl(var(--foreground) / 0.08);
|
||||
color: hsl(var(--foreground));
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.goal-island-blocked .markdown-content.goal-island-reason {
|
||||
--tw-prose-body: var(--goal-blocked-color);
|
||||
--tw-prose-headings: var(--goal-blocked-color);
|
||||
--tw-prose-bold: var(--goal-blocked-color);
|
||||
--tw-prose-lead: var(--goal-blocked-color);
|
||||
min-width: 0;
|
||||
color: var(--goal-blocked-color);
|
||||
font-size: 14px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
.goal-island-panel[data-goal-status="blocked"] .goal-island-body[data-overflow-bottom] {
|
||||
--goal-fade-bottom: 16px;
|
||||
}
|
||||
.goal-island-status-icon {
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
flex: none;
|
||||
color: var(--goal-blocked-color);
|
||||
}
|
||||
.goal-island-reason {
|
||||
color: var(--goal-blocked-color);
|
||||
}
|
||||
.goal-island-blocked .goal-island-status-icon {
|
||||
margin-top: 0.225em;
|
||||
}
|
||||
.goal-island-panel[data-state="open"] {
|
||||
animation: goal-island-expand 400ms cubic-bezier(0.2, 0.9, 0.1, 1) both;
|
||||
}
|
||||
.goal-island-panel[data-state="open"] .goal-island-panel-content {
|
||||
animation: goal-island-content-in 200ms ease-out 100ms both;
|
||||
}
|
||||
.goal-island-panel[data-state="closed"] {
|
||||
animation: goal-island-collapse 240ms cubic-bezier(0.4, 0, 0.2, 1) both;
|
||||
pointer-events: none;
|
||||
}
|
||||
[data-radix-popper-content-wrapper]:has(> .goal-island-panel[data-state="closed"]) {
|
||||
pointer-events: none;
|
||||
}
|
||||
.goal-island-panel[data-state="closed"] .goal-island-panel-content {
|
||||
animation: goal-island-content-out 80ms ease-in both;
|
||||
}
|
||||
@keyframes goal-island-expand {
|
||||
from {
|
||||
--goal-island-width: var(--goal-from-width, var(--radix-popover-trigger-width));
|
||||
--goal-island-height: var(--goal-from-height, 40px);
|
||||
--goal-island-radius: var(--goal-from-radius, 16px);
|
||||
}
|
||||
to { --goal-island-width: 100%; --goal-island-height: 100%; --goal-island-radius: 28px; }
|
||||
}
|
||||
@keyframes goal-island-collapse {
|
||||
from {
|
||||
--goal-island-width: var(--goal-from-width);
|
||||
--goal-island-height: var(--goal-from-height);
|
||||
--goal-island-radius: var(--goal-from-radius);
|
||||
}
|
||||
to { --goal-island-width: var(--radix-popover-trigger-width); --goal-island-height: 40px; --goal-island-radius: 16px; }
|
||||
}
|
||||
@keyframes goal-island-content-in {
|
||||
from { opacity: var(--goal-from-opacity, 0); transform: var(--goal-from-transform, translateY(-8px)); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
@keyframes goal-island-content-out {
|
||||
from { opacity: var(--goal-from-opacity); transform: var(--goal-from-transform); }
|
||||
to { opacity: 0; transform: translateY(-8px); }
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.thread-header-with-goal:has(.goal-island[data-detail-mounted="true"]) {
|
||||
z-index: 60;
|
||||
}
|
||||
.goal-island-summary {
|
||||
padding-top: 44px;
|
||||
}
|
||||
.goal-island-body:first-child .goal-island-document {
|
||||
padding-top: 44px;
|
||||
}
|
||||
}
|
||||
@media (max-height: 600px) {
|
||||
.goal-island-summary h2 {
|
||||
-webkit-line-clamp: 1;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.goal-island-panel[data-state],
|
||||
.goal-island-panel[data-state] .goal-island-panel-content {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
|
||||
.goal-island,
|
||||
.goal-island-panel {
|
||||
--goal-surface: hsl(var(--sidebar));
|
||||
}
|
||||
.goal-island-surface::before {
|
||||
backdrop-filter: none;
|
||||
-webkit-backdrop-filter: none;
|
||||
}
|
||||
}
|
||||
@media (forced-colors: active) {
|
||||
.goal-island,
|
||||
.goal-island-panel {
|
||||
--goal-surface: Canvas;
|
||||
}
|
||||
.goal-island-surface {
|
||||
outline: 1px solid CanvasText;
|
||||
}
|
||||
.goal-island,
|
||||
.goal-island-panel {
|
||||
color: CanvasText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
:root[data-session-transition] {
|
||||
view-transition-name: none;
|
||||
}
|
||||
|
||||
:root[data-session-transition] :is(.thread-message-viewport, .thread-empty-region) {
|
||||
view-transition-name: var(--session-thread-name, session-thread-0);
|
||||
view-transition-class: session-thread;
|
||||
}
|
||||
|
||||
:root[data-session-transition] [data-active-composer] .thread-composer-surface {
|
||||
view-transition-name: session-composer;
|
||||
}
|
||||
:root[data-session-transition] [data-active-composer] .thread-composer-input {
|
||||
view-transition-name: session-input;
|
||||
}
|
||||
:root[data-session-transition] [data-active-composer] .thread-composer-footer {
|
||||
view-transition-name: session-toolbar;
|
||||
}
|
||||
:root[data-session-transition] [data-active-composer] .thread-composer-meta {
|
||||
view-transition-name: session-meta;
|
||||
}
|
||||
:root[data-session-transition] .goal-island {
|
||||
view-transition-name: session-goal;
|
||||
}
|
||||
:root[data-session-transition] [data-active-composer] .subagent-task-dock {
|
||||
view-transition-name: session-tasks;
|
||||
}
|
||||
|
||||
:root[data-session-transition]::view-transition {
|
||||
pointer-events: none;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-group(*) {
|
||||
animation-duration: 200ms;
|
||||
animation-timing-function: cubic-bezier(0.2, 0, 0, 1);
|
||||
}
|
||||
|
||||
/* The frame may change size; keep text at its original raster size and bottom anchor. */
|
||||
:root[data-session-transition]::view-transition-old(*),
|
||||
:root[data-session-transition]::view-transition-new(*) {
|
||||
object-fit: none;
|
||||
object-position: bottom left;
|
||||
mix-blend-mode: normal;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-old(session-composer),
|
||||
:root[data-session-transition]::view-transition-old(session-input),
|
||||
:root[data-session-transition]::view-transition-old(session-toolbar),
|
||||
:root[data-session-transition]::view-transition-old(session-meta) {
|
||||
display: none;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-new(session-composer),
|
||||
:root[data-session-transition]::view-transition-new(session-input),
|
||||
:root[data-session-transition]::view-transition-new(session-toolbar),
|
||||
:root[data-session-transition]::view-transition-new(session-meta) {
|
||||
animation: none;
|
||||
}
|
||||
|
||||
:root[data-session-transition]::view-transition-group(.session-thread) {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-old(.session-thread),
|
||||
:root[data-session-transition]::view-transition-new(.session-thread) {
|
||||
object-position: top left;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-old(.session-thread) {
|
||||
animation: session-thread-out 80ms ease-in both;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-new(.session-thread) {
|
||||
animation: session-thread-in 120ms ease-out 60ms both;
|
||||
}
|
||||
|
||||
@keyframes session-thread-out {
|
||||
to { opacity: 0; }
|
||||
}
|
||||
@keyframes session-thread-in {
|
||||
from { opacity: 0; }
|
||||
to { opacity: 1; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
:root[data-session-transition]::view-transition-group(*),
|
||||
:root[data-session-transition]::view-transition-new(*) {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-session-transition]::view-transition-old(*) {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { flushSync } from "react-dom";
|
||||
|
||||
import "./session-transition.css";
|
||||
|
||||
let active: ViewTransition | null = null;
|
||||
let pending: (() => void) | null = null;
|
||||
|
||||
export function finishSessionTransition(): void {
|
||||
const update = pending;
|
||||
pending = null;
|
||||
active?.skipTransition();
|
||||
active = null;
|
||||
delete document.documentElement.dataset.sessionTransition;
|
||||
if (update) flushSync(update);
|
||||
}
|
||||
|
||||
export function transitionSession(update: () => void, animate = true): void {
|
||||
pending = update;
|
||||
active?.skipTransition();
|
||||
const root = document.documentElement;
|
||||
if (!animate || !document.startViewTransition
|
||||
|| window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
||||
|| root.hasAttribute("data-theme-snapshot")) {
|
||||
active = null;
|
||||
pending = null;
|
||||
delete root.dataset.sessionTransition;
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
root.dataset.sessionTransition = "";
|
||||
const transition = document.startViewTransition(() => {
|
||||
if (pending !== update) return;
|
||||
pending = null;
|
||||
flushSync(update);
|
||||
});
|
||||
active = transition;
|
||||
// Skipped captures still run their update; only the latest navigation may commit.
|
||||
void transition.ready.catch(() => {});
|
||||
const release = () => {
|
||||
if (active !== transition) return;
|
||||
active = null;
|
||||
delete root.dataset.sessionTransition;
|
||||
};
|
||||
void transition.finished.then(release, release);
|
||||
}
|
||||
Reference in new issue
Block a user