Skip to content
TypeScript

feat(web): add opt-in panel animations (#8830)

maria91c8d4771ccb
diff --git a/apps/desktop/src/settings/DesktopClientSettings.test.ts b/apps/desktop/src/settings/DesktopClientSettings.test.ts
index 4766b7a3439..1c02a45026b 100644
--- a/apps/desktop/src/settings/DesktopClientSettings.test.ts
+++ b/apps/desktop/src/settings/DesktopClientSettings.test.ts
@@ -41,6 +41,7 @@ const clientSettings: ClientSettings = {
fontSizeTerminal: 12,
fontSmoothing: true,
glassOpacity: 80,
+ panelAnimationDurationMs: 0,
planModeEnabled: false,
showSkillsInSlashMenu: false,
providerModelPreferences: {},
diff --git a/apps/web/src/components/AppSidebarLayout.tsx b/apps/web/src/components/AppSidebarLayout.tsx
index 3d9e0e82e51..1780c8b9acb 100644
--- a/apps/web/src/components/AppSidebarLayout.tsx
+++ b/apps/web/src/components/AppSidebarLayout.tsx
@@ -17,6 +17,7 @@ import { resolveShortcutCommand, shortcutLabelForCommand } from "../keybindings"
import { cn, isMacPlatform } from "../lib/utils";
import { primaryServerKeybindingsAtom } from "../state/server";
import { useEnvironmentIdentificationMode, useLegacySidebarEnabled } from "../hooks/useSettings";
+import { usePanelAnimationSettings } from "../panelAnimations";
import LegacyThreadSidebar from "./LegacySidebar";
import ThreadSidebar from "./Sidebar";
import { SidebarChromeHeader } from "./sidebar/SidebarChrome";
@@ -148,6 +149,8 @@ function ProjectProjectionRetention() {
export function AppSidebarLayout({ children }: { children: ReactNode }) {
const navigate = useNavigate();
const legacySidebarEnabled = useLegacySidebarEnabled();
+ const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
+ usePanelAnimationSettings();
// Settings routes show the settings nav in place of whichever thread
// sidebar is active.
const pathname = useLocation({ select: (location) => location.pathname });
@@ -175,6 +178,7 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
});
const sidebarProviderStyle = {
"--sidebar-width": `${sidebarWidth}px`,
+ "--panel-animation-duration": `${panelAnimationDurationMs}ms`,
...(isMacosDesktop && !isWindowFullscreen
? { "--workspace-controls-left": MACOS_TRAFFIC_LIGHTS_LEFT_INSET }
: {}),
@@ -218,7 +222,12 @@ export function AppSidebarLayout({ children }: { children: ReactNode }) {
}, [navigate, pathname]);
return (
- <SidebarProvider className="h-dvh! min-h-0!" defaultOpen style={sidebarProviderStyle}>
+ <SidebarProvider
+ className="h-dvh! min-h-0!"
+ data-panel-animations={panelAnimationsActive ? "true" : "false"}
+ defaultOpen
+ style={sidebarProviderStyle}
+ >
<ProjectProjectionRetention />
<Sidebar
side="left"
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index bee12b52294..faa24584e72 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -217,6 +217,7 @@ import {
useEnvironmentSettings,
} from "../hooks/useSettings";
import { useNowMinute } from "../hooks/useNowMinute";
+import { usePanelAnimationSettings, usePanelPresence } from "../panelAnimations";
import { useNewThreadHandler } from "../hooks/useHandleNewThread";
import { useThreadActions } from "../hooks/useThreadActions";
import { resolveAppModelSelectionForInstance } from "../modelSelection";
@@ -741,7 +742,7 @@ function serverTerminalIdsStrictSubsetOfClient(
interface PersistentThreadTerminalDrawerProps {
threadRef: { environmentId: EnvironmentId; threadId: ThreadId };
threadId: ThreadId;
- visible: boolean;
+ active: boolean;
launchContext: PersistentTerminalLaunchContext | null;
focusRequestId: number;
splitShortcutLabel: string | undefined;
@@ -755,7 +756,7 @@ interface PersistentThreadTerminalDrawerProps {
const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDrawer({
threadRef,
threadId,
- visible,
+ active,
launchContext,
focusRequestId,
splitShortcutLabel,
@@ -779,6 +780,7 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
const terminalUiState = useTerminalUiStateStore((state) =>
selectThreadTerminalUiState(state.terminalUiStateByThreadKey, threadRef),
);
+ const visible = active && terminalUiState.terminalOpen;
const knownTerminalSessions = useKnownTerminalSessions({
environmentId: threadRef.environmentId,
threadId,
@@ -1063,41 +1065,51 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
[onAddTerminalContext, visible],
);
- if (!project || !terminalUiState.terminalOpen || !cwd) {
+ if (!project || (!terminalUiState.terminalOpen && !active) || !cwd) {
return null;
}
return (
- <div className={visible ? undefined : "hidden"}>
- <ThreadTerminalDrawer
- threadRef={threadRef}
- threadId={threadId}
- cwd={cwd}
- worktreePath={effectiveWorktreePath}
- runtimeEnv={runtimeEnv}
- visible={visible}
- height={terminalUiState.terminalHeight}
- // Known-session order is MRU and changes on focus; persisted store order keeps sidebar labels stable.
- terminalIds={terminalUiState.terminalIds}
- activeTerminalId={terminalUiState.activeTerminalId}
- terminalGroups={terminalUiState.terminalGroups}
- activeTerminalGroupId={terminalUiState.activeTerminalGroupId}
- focusRequestId={focusRequestId + localFocusRequestId + (visible ? 1 : 0)}
- onSplitTerminal={splitTerminal}
- onSplitTerminalVertical={splitTerminalVertical}
- onNewTerminal={createNewTerminal}
- splitShortcutLabel={visible ? splitShortcutLabel : undefined}
- splitVerticalShortcutLabel={visible ? splitVerticalShortcutLabel : undefined}
- newShortcutLabel={visible ? newShortcutLabel : undefined}
- closeShortcutLabel={visible ? closeShortcutLabel : undefined}
- keybindings={keybindings}
- onActiveTerminalChange={activateTerminal}
- onCloseTerminal={closeTerminal}
- onHeightChange={setTerminalHeight}
- onAddTerminalContext={handleAddTerminalContext}
- terminalLabelsById={terminalLabelsById}
- terminalLaunchLocationsById={terminalLaunchLocationsById}
- />
+ <div
+ className={cn(
+ "grid shrink-0 overflow-clip",
+ active ? (visible ? "grid-rows-[1fr]" : "grid-rows-[0fr]") : "hidden",
+ active &&
+ "[[data-panel-animations=true]_&]:transition-[grid-template-rows] [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
+ active && visible && "[[data-panel-animations=true]_&]:starting:grid-rows-[0fr]!",
+ )}
+ >
+ <div className="min-h-0 overflow-clip">
+ <ThreadTerminalDrawer
+ threadRef={threadRef}
+ threadId={threadId}
+ cwd={cwd}
+ worktreePath={effectiveWorktreePath}
+ runtimeEnv={runtimeEnv}
+ visible={visible}
+ height={terminalUiState.terminalHeight}
+ // Known-session order is MRU and changes on focus; persisted store order keeps sidebar labels stable.
+ terminalIds={terminalUiState.terminalIds}
+ activeTerminalId={terminalUiState.activeTerminalId}
+ terminalGroups={terminalUiState.terminalGroups}
+ activeTerminalGroupId={terminalUiState.activeTerminalGroupId}
+ focusRequestId={focusRequestId + localFocusRequestId + (visible ? 1 : 0)}
+ onSplitTerminal={splitTerminal}
+ onSplitTerminalVertical={splitTerminalVertical}
+ onNewTerminal={createNewTerminal}
+ splitShortcutLabel={visible ? splitShortcutLabel : undefined}
+ splitVerticalShortcutLabel={visible ? splitVerticalShortcutLabel : undefined}
+ newShortcutLabel={visible ? newShortcutLabel : undefined}
+ closeShortcutLabel={visible ? closeShortcutLabel : undefined}
+ keybindings={keybindings}
+ onActiveTerminalChange={activateTerminal}
+ onCloseTerminal={closeTerminal}
+ onHeightChange={setTerminalHeight}
+ onAddTerminalContext={handleAddTerminalContext}
+ terminalLabelsById={terminalLabelsById}
+ terminalLaunchLocationsById={terminalLaunchLocationsById}
+ />
+ </div>
</div>
);
});
@@ -1791,8 +1803,6 @@ function ChatViewContent(props: ChatViewProps) {
);
const refreshVcsStatus = useAtomCommand(vcsEnvironment.refreshStatus, { reportFailure: false });
const sidebarPrRefreshKeyRef = useRef<string | null>(null);
- const activeFileSurface =
- activeRightPanelSurface?.kind === "file" ? activeRightPanelSurface : null;
const activePreviewState = useThreadPreviewState(activeThreadRef);
const activePreviewServerEpoch = activePreviewState.serverEpoch;
const resolvePreviewRuntimeTabId = useMemo(
@@ -1820,6 +1830,34 @@ function ChatViewContent(props: ChatViewProps) {
);
const previewPanelOpen = activeRightPanelKind === "preview" && isPreviewSupportedInRuntime();
const rightPanelOpen = rightPanelState.isOpen;
+ const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
+ usePanelAnimationSettings();
+ const activeTerminalDrawerPresence = usePanelPresence(
+ Boolean(activeThreadKey && terminalUiState.terminalOpen),
+ true,
+ panelAnimationsActive,
+ activeThreadKey,
+ panelAnimationDurationMs,
+ );
+ const rightPanelPresenceValue = useMemo(
+ () => ({
+ activeSurface: activeRightPanelSurface,
+ surfaces: rightPanelState.surfaces,
+ }),
+ [activeRightPanelSurface, rightPanelState.surfaces],
+ );
+ const rightPanelPresence = usePanelPresence(
+ rightPanelOpen && activeThreadRef !== null,
+ rightPanelPresenceValue,
+ panelAnimationsActive,
+ activeThreadKey,
+ panelAnimationDurationMs,
+ );
+ const rightPanelPresent = rightPanelPresence.present;
+ const rightPanelControlsInPanel =
+ rightPanelPresent && (!shouldUseRightPanelSheet || rightPanelOpen);
+ const renderedRightPanelSurface = rightPanelPresence.value?.activeSurface ?? null;
+ const renderedRightPanelSurfaces = rightPanelPresence.value?.surfaces ?? [];
const canMaximizeRightPanel = rightPanelOpen && !shouldUseRightPanelSheet;
const rightPanelMaximized =
canMaximizeRightPanel && maximizedRightPanelThreadKey === routeThreadKey;
@@ -1882,7 +1920,7 @@ function ChatViewContent(props: ChatViewProps) {
currentThreadIds,
openThreadIds: existingOpenTerminalThreadKeys,
activeThreadId: activeThreadKey,
- activeThreadTerminalOpen: Boolean(activeThreadKey && terminalUiState.terminalOpen),
+ activeThreadTerminalOpen: activeTerminalDrawerPresence.present,
maxHiddenThreadCount: MAX_HIDDEN_MOUNTED_TERMINAL_THREADS,
});
return currentThreadIds.length === nextThreadIds.length &&
@@ -1890,7 +1928,7 @@ function ChatViewContent(props: ChatViewProps) {
? currentThreadIds
: nextThreadIds;
});
- }, [activeThreadKey, existingOpenTerminalThreadKeys, terminalUiState.terminalOpen]);
+ }, [activeTerminalDrawerPresence.present, activeThreadKey, existingOpenTerminalThreadKeys]);
const latestTurnSettled = isLatestTurnSettled(activeLatestTurn, activeThread?.session ?? null);
const activeProjectRef = useMemo(
() =>
@@ -7095,29 +7133,39 @@ function ChatViewContent(props: ChatViewProps) {
const panelLayoutControls = (
<div
className={cn(
- // One inset in both states: the controls move between containers when
- // the right panel opens, and a different right offset made them jump
- // sideways on every toggle.
- "absolute top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
+ // Keep one viewport anchor inside the header's no-drag region. The
+ // header can shrink behind the right panel without moving the controls.
+ "pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
)}
data-workspace-titlebar-controls
>
- {rightPanelOpen && !shouldUseRightPanelSheet ? (
- <RightPanelMaximizeControl
- maximized={rightPanelMaximized}
- onToggle={toggleRightPanelMaximized}
- />
+ {!shouldUseRightPanelSheet ? (
+ <span
+ aria-hidden={!rightPanelOpen}
+ className={cn(
+ "flex shrink-0",
+ panelAnimationsActive &&
+ "motion-safe:transition-opacity motion-safe:[transition-duration:var(--panel-animation-duration)] motion-safe:ease-out",
+ rightPanelOpen ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0",
+ )}
+ inert={!rightPanelOpen}
+ >
+ <RightPanelMaximizeControl
+ maximized={rightPanelMaximized}
+ onToggle={toggleRightPanelMaximized}
+ />
+ </span>
) : null}
- {panelToggleControls}
+ <div className="pointer-events-auto flex h-full items-center">{panelToggleControls}</div>
</div>
);
const rightPanelContent = activeThreadRef ? (
- activeRightPanelSurface?.kind === "preview" ? (
+ renderedRightPanelSurface?.kind === "preview" ? (
<Suspense fallback={null}>
<PreviewPanel
mode="embedded"
threadRef={activeThreadRef}
- tabId={activeRightPanelSurface.resourceId}
+ tabId={renderedRightPanelSurface.resourceId}
configuredUrls={configuredPreviewUrls}
visible
onSendAnnotation={(annotation, image) => {
@@ -7125,10 +7173,10 @@ function ChatViewContent(props: ChatViewProps) {
}}
/>
</Suspense>
- ) : activeRightPanelSurface?.kind === "terminal" ? (
+ ) : renderedRightPanelSurface?.kind === "terminal" ? (
<PersistentThreadTerminalPanel
threadRef={activeThreadRef}
- surface={activeRightPanelSurface}
+ surface={renderedRightPanelSurface}
launchContext={activeTerminalLaunchContext ?? null}
focusRequestId={terminalFocusRequestId}
keybindings={keybindings}
@@ -7143,7 +7191,7 @@ function ChatViewContent(props: ChatViewProps) {
newShortcutLabel={newTerminalShortcutLabel ?? undefined}
closeShortcutLabel={closeTerminalShortcutLabel ?? undefined}
/>
- ) : activeRightPanelSurface?.kind === "diff" ? (
+ ) : renderedRightPanelSurface?.kind === "diff" ? (
<Suspense fallback={null}>
<DiffPanel
key={`${activeThreadKey}:${diffPanelGitStatusResolutionKey}`}
@@ -7153,26 +7201,26 @@ function ChatViewContent(props: ChatViewProps) {
workspaceMutationId={workspaceMutationId}
/>
</Suspense>
- ) : activeRightPanelSurface?.kind === "pull-request" && !pullRequestsCapabilityKnown ? (
+ ) : renderedRightPanelSurface?.kind === "pull-request" && !pullRequestsCapabilityKnown ? (
<PullRequestDetailGhost />
- ) : activeRightPanelSurface?.kind === "pull-request" && !supportsPullRequests ? (
+ ) : renderedRightPanelSurface?.kind === "pull-request" && !supportsPullRequests ? (
<PullRequestsUnavailableState
title="Pull requests unavailable"
error="Update this environment's T3 Code server to browse pull requests."
/>
- ) : activeRightPanelSurface?.kind === "pull-request" ? (
+ ) : renderedRightPanelSurface?.kind === "pull-request" ? (
// No onClose: the surface tab's own X owns closing here, and a second X in the header
// would be the same action twice. The thread context also drops the checkout button, so it
// is only right for the thread's own pull request, whose branch is already under the
// reader's feet. A link the agent wrote can open any other one here, and that one has to be
// checkable out like it is anywhere else.
<PullRequestDetailPanel
- key={`${activeRightPanelSurface.repository}#${activeRightPanelSurface.number}`}
+ key={`${renderedRightPanelSurface.repository}#${renderedRightPanelSurface.number}`}
environmentId={activeThread.environmentId}
reference={{
- projectId: activeRightPanelSurface.projectId as ProjectId,
- repository: activeRightPanelSurface.repository,
- number: activeRightPanelSurface.number,
+ projectId: renderedRightPanelSurface.projectId as ProjectId,
+ repository: renderedRightPanelSurface.repository,
+ number: renderedRightPanelSurface.number,
}}
context={
isThreadOwnPullRequest(
@@ -7182,9 +7230,9 @@ function ChatViewContent(props: ChatViewProps) {
number: activeThreadPr?.number ?? null,
},
{
- projectId: activeRightPanelSurface.projectId,
- repository: activeRightPanelSurface.repository,
- number: activeRightPanelSurface.number,
+ projectId: renderedRightPanelSurface.projectId,
+ repository: renderedRightPanelSurface.repository,
+ number: renderedRightPanelSurface.number,
},
)
? "thread"
@@ -7193,13 +7241,14 @@ function ChatViewContent(props: ChatViewProps) {
composerDraftTarget={composerDraftTarget}
onStateChange={handlePullRequestTabStatusChange}
/>
- ) : activeRightPanelSurface?.kind === "agents" ? (
+ ) : renderedRightPanelSurface?.kind === "agents" ? (
<AgentsPanel
model={agentPanelModel}
environmentId={activeThreadRef?.environmentId ?? null}
threadId={activeThreadRef?.threadId ?? null}
/>
- ) : (activeRightPanelSurface?.kind === "files" || activeRightPanelSurface?.kind === "file") &&
+ ) : (renderedRightPanelSurface?.kind === "files" ||
+ renderedRightPanelSurface?.kind === "file") &&
activeProject &&
activeWorkspaceRoot ? (
<Suspense fallback={null}>
@@ -7213,14 +7262,25 @@ function ChatViewContent(props: ChatViewProps) {
keybindings={keybindings}
availableEditors={availableEditors}
relativePath={
- activeRightPanelSurface.kind === "file" ? activeRightPanelSurface.relativePath : null
+ renderedRightPanelSurface.kind === "file"
+ ? renderedRightPanelSurface.relativePath
+ : null
+ }
+ revealLine={
+ renderedRightPanelSurface.kind === "file"
+ ? (renderedRightPanelSurface.revealLine ?? null)
+ : null
+ }
+ revealRequestId={
+ renderedRightPanelSurface.kind === "file"
+ ? renderedRightPanelSurface.revealRequestId
+ : 0
}
- revealLine={activeFileSurface?.revealLine ?? null}
- revealRequestId={activeFileSurface?.revealRequestId ?? 0}
onOpenFile={openFileSurface}
onPendingChange={handleFilePendingChange}
selectedFilePending={
- activeFileSurface !== null && pendingFileSurfaceIds.has(activeFileSurface.id)
+ renderedRightPanelSurface.kind === "file" &&
+ pendingFileSurfaceIds.has(renderedRightPanelSurface.id)
}
workspaceMutationId={workspaceMutationId}
/>
@@ -7235,7 +7295,6 @@ function ChatViewContent(props: ChatViewProps) {
return (
<div className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background">
- {rightPanelOpen && !shouldUseRightPanelSheet ? panelLayoutControls : null}
<div
className={cn(
"flex min-h-0 min-w-0 flex-col overflow-x-hidden",
@@ -7250,7 +7309,7 @@ function ChatViewContent(props: ChatViewProps) {
reserveNativeControls={reserveTitleBarControlInset && !inlineRightPanelOwnsTitleBar}
className="relative bg-background"
>
- {!rightPanelOpen ? panelLayoutControls : null}
+ {!shouldUseRightPanelSheet || !rightPanelControlsInPanel ? panelLayoutControls : null}
<ChatHeader
{...(!supportsPullRequests || activeProjectRepository === null
? {}
@@ -7639,7 +7698,7 @@ function ChatViewContent(props: ChatViewProps) {
key={mountedThreadKey}
threadRef={mountedThreadRef}
threadId={mountedThreadRef.threadId}
- visible={mountedThreadKey === activeThreadKey && terminalUiState.terminalOpen}
+ active={mountedThreadKey === activeThreadKey}
launchContext={
mountedThreadKey === activeThreadKey ? (activeTerminalLaunchContext ?? null) : null
}
@@ -7654,12 +7713,13 @@ function ChatViewContent(props: ChatViewProps) {
))}
</div>
- {!shouldUseRightPanelSheet && rightPanelOpen && activeThreadRef ? (
+ {rightPanelPresent && !shouldUseRightPanelSheet && activeThreadRef ? (
<RightPanelTabs
mode="inline"
+ open={rightPanelOpen}
maximized={rightPanelMaximized}
- surfaces={rightPanelState.surfaces}
- activeSurfaceId={activeRightPanelSurface?.id ?? null}
+ surfaces={renderedRightPanelSurfaces}
+ activeSurfaceId={renderedRightPanelSurface?.id ?? null}
pendingSurfaceIds={pendingFileSurfaceIds}
previewSessions={activePreviewState.sessions}
desktopByTabId={activePreviewState.desktopByTabId}
@@ -7690,17 +7750,25 @@ function ChatViewContent(props: ChatViewProps) {
{rightPanelContent}
</RightPanelTabs>
) : null}
- {shouldUseRightPanelSheet && rightPanelOpen && activeThreadRef ? (
- <RightPanelSheet open onClose={closePreviewPanel}>
+ {rightPanelPresent && shouldUseRightPanelSheet && activeThreadRef ? (
+ <RightPanelSheet
+ animationDurationMs={panelAnimationsActive ? panelAnimationDurationMs : 0}
+ open={rightPanelOpen}
+ onClose={closePreviewPanel}
+ >
<RightPanelTabs
mode="sheet"
// Same effective inset as the closed-state titlebar controls
// (pr-3 in the tab bar plus this pixel equals the absolute
// right inset plus mr-px), so the cluster does not creep when
// the sheet opens.
- layoutControls={<div className="mr-px flex items-center">{panelToggleControls}</div>}
- surfaces={rightPanelState.surfaces}
- activeSurfaceId={activeRightPanelSurface?.id ?? null}
+ layoutControls={
+ rightPanelOpen ? (
+ <div className="mr-px flex items-center">{panelToggleControls}</div>
+ ) : null
+ }
+ surfaces={renderedRightPanelSurfaces}
+ activeSurfaceId={renderedRightPanelSurface?.id ?? null}
pendingSurfaceIds={pendingFileSurfaceIds}
previewSessions={activePreviewState.sessions}
desktopByTabId={activePreviewState.desktopByTabId}
diff --git a/apps/web/src/components/RightPanelSheet.tsx b/apps/web/src/components/RightPanelSheet.tsx
index ebc4aa0a698..e3468034396 100644
--- a/apps/web/src/components/RightPanelSheet.tsx
+++ b/apps/web/src/components/RightPanelSheet.tsx
@@ -4,6 +4,7 @@ import { RIGHT_PANEL_SHEET_CLASS_NAME } from "../rightPanelLayout";
import { Sheet, SheetPopup } from "./ui/sheet";
export function RightPanelSheet(props: {
+ animationDurationMs: number;
children: ReactNode;
open: boolean;
onClose: () => void;
@@ -18,6 +19,7 @@ export function RightPanelSheet(props: {
}}
>
<SheetPopup
+ transitionDurationMs={props.animationDurationMs}
side="right"
showCloseButton={false}
keepMounted
diff --git a/apps/web/src/components/RightPanelTabs.tsx b/apps/web/src/components/RightPanelTabs.tsx
index c48dceb048a..5f6983c3c1f 100644
--- a/apps/web/src/components/RightPanelTabs.tsx
+++ b/apps/web/src/components/RightPanelTabs.tsx
@@ -55,6 +55,7 @@ import { PierreEntryIcon } from "./chat/PierreEntryIcon";
interface RightPanelTabsProps {
mode: PreviewPanelMode;
maximized?: boolean;
+ open?: boolean;
/** Forwarded to PreviewPanelShell so this surface persists its own width. */
widthStorageKey?: string;
/** Forwarded to PreviewPanelShell as the initial width before a user resize. */
@@ -798,6 +799,7 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
<PreviewPanelShell
mode={props.mode}
{...(props.maximized !== undefined ? { maximized: props.maximized } : {})}
+ {...(props.open !== undefined ? { open: props.open } : {})}
{...(props.widthStorageKey !== undefined ? { widthStorageKey: props.widthStorageKey } : {})}
{...(props.defaultWidth !== undefined ? { defaultWidth: props.defaultWidth } : {})}
>
diff --git a/apps/web/src/components/WorkspacePageHeader.tsx b/apps/web/src/components/WorkspacePageHeader.tsx
index cd8a96273c0..5d98b80760a 100644
--- a/apps/web/src/components/WorkspacePageHeader.tsx
+++ b/apps/web/src/components/WorkspacePageHeader.tsx
@@ -16,7 +16,7 @@ export function WorkspacePageHeader({
return (
<header
className={cn(
- "flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center gap-3 pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] transition-[padding-left] duration-200 ease-linear motion-reduce:transition-none sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]",
+ "flex h-[var(--workspace-topbar-height)] min-h-[var(--workspace-topbar-height)] shrink-0 items-center gap-3 pl-[calc(env(safe-area-inset-left)+0.75rem)] pr-[calc(env(safe-area-inset-right)+0.75rem)] [[data-panel-animations=true]_&]:motion-safe:transition-[padding-left,padding-right] [[data-panel-animations=true]_&]:motion-safe:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:motion-safe:ease-out sm:pl-[calc(env(safe-area-inset-left)+1.25rem)] sm:pr-[calc(env(safe-area-inset-right)+1.25rem)]",
electron && "drag-region",
reserveNativeControls && "wco:pr-[var(--workspace-native-controls-inset)]",
COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index d043900841e..672d4c80c6c 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -135,9 +135,12 @@ import { ComposerPendingElementContexts } from "./ComposerPendingElementContexts
import { ComposerPendingReviewComments } from "./ComposerPendingReviewComments";
import { ComposerPreviewAnnotationCards } from "./ComposerPreviewAnnotationCards";
import {
+ COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX,
+ COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX,
shouldUseCompactComposerPrimaryActions,
shouldUseCompactComposerFooter,
} from "../composerFooterLayout";
+import { observeResponsiveBreakpointFade, usePanelAnimationSettings } from "../../panelAnimations";
import { type ComposerPromptEditorHandle, ComposerPromptEditor } from "../ComposerPromptEditor";
import { ProviderModelPicker } from "./ProviderModelPicker";
import { type ComposerCommandItem, ComposerCommandMenu } from "./ComposerCommandMenu";
@@ -1283,6 +1286,8 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
active: false,
});
const isMobileViewport = useMediaQuery("max-sm");
+ const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
+ usePanelAnimationSettings();
const isComposerCollapsedMobile =
isMobileViewport && !forceExpandedOnMobile && !isComposerFocused;
@@ -1292,6 +1297,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
const composerEditorRef = useRef<ComposerPromptEditorHandle>(null);
const attachmentInputRef = useRef<HTMLInputElement>(null);
const composerFormRef = useRef<HTMLFormElement>(null);
+ const composerFooterControlsRef = useRef<HTMLDivElement>(null);
const composerSurfaceRef = useRef<HTMLDivElement>(null);
const providerInputRejectedRef = useRef(false);
const composerSelectLockRef = useRef(false);
@@ -1829,6 +1835,21 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
setIsComposerPrimaryActionsCompact(initialCompactness.primaryActionsCompact);
setIsComposerFooterCompact(initialCompactness.footerCompact);
if (typeof ResizeObserver === "undefined") return;
+ const footerControls = composerFooterControlsRef.current;
+ const stopFooterControlsFade = footerControls
+ ? observeResponsiveBreakpointFade({
+ target: footerControls,
+ container: composerForm,
+ active: panelAnimationsActive,
+ durationMs: panelAnimationDurationMs,
+ breakpoint: {
+ value: composerFooterHasWideActions
+ ? COMPOSER_FOOTER_WIDE_ACTIONS_COMPACT_BREAKPOINT_PX
+ : COMPOSER_FOOTER_COMPACT_BREAKPOINT_PX,
+ unit: "px",
+ },
+ })
+ : undefined;
const observer = new ResizeObserver(() => {
const nextCompactness = measureFooterCompactness();
@@ -1845,8 +1866,17 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
observer.observe(composerForm);
return () => {
observer.disconnect();
+ stopFooterControlsFade?.();
};
- }, [activeThreadId, composerFooterActionLayoutKey, composerFooterHasWideActions]);
+ }, [
+ activeThreadId,
+ composerFooterActionLayoutKey,
+ composerFooterHasWideActions,
+ isComposerApprovalState,
+ isComposerCollapsedMobile,
+ panelAnimationDurationMs,
+ panelAnimationsActive,
+ ]);
// ------------------------------------------------------------------
// Image persist effect
@@ -4223,7 +4253,11 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
showMobilePendingAnswerActions && "hidden sm:flex",
)}
>
- <div className="-m-1 -ms-3.5 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 ps-3.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
+ <div
+ ref={composerFooterControlsRef}
+ data-chat-composer-footer-controls="true"
+ className="-m-1 -ms-3.5 flex min-w-0 flex-1 items-center gap-1 overflow-x-auto p-1 ps-3.5 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
+ >
{noProviderAvailable ? (
<Button
type="button"
diff --git a/apps/web/src/components/chat/ChatHeader.tsx b/apps/web/src/components/chat/ChatHeader.tsx
index 6964702726e..dde6fd0dade 100644
--- a/apps/web/src/components/chat/ChatHeader.tsx
+++ b/apps/web/src/components/chat/ChatHeader.tsx
@@ -37,6 +37,7 @@ import { useT3ProjectFileScripts } from "~/hooks/useT3ProjectFileScripts";
import { useThreadActionMenu } from "~/hooks/useThreadActionMenu";
import { threadEnvironment } from "../../state/threads";
import { useAtomCommand } from "../../state/use-atom-command";
+import { observeResponsiveBreakpointFade, usePanelAnimationSettings } from "../../panelAnimations";
import { ProjectFavicon } from "../ProjectFavicon";
import {
WorkspaceBreadcrumb,
@@ -94,6 +95,8 @@ export function resolveRenameCommit(input: {
// events (the second click dismisses it and dblclick still fires), so it
// opens immediately.
const TITLE_MENU_OPEN_DELAY_MS = 500;
+// Matches the @3xl/header-actions container breakpoint owned by this header.
+const HEADER_ACTIONS_EXPANDED_BREAKPOINT_REM = 48;
export function shouldShowOpenInPicker(input: {
readonly activeProjectName: string | undefined;
@@ -137,6 +140,21 @@ export const ChatHeader = memo(function ChatHeader({
onUpdateProjectScript,
onDeleteProjectScript,
}: ChatHeaderProps) {
+ const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
+ usePanelAnimationSettings();
+ const headerActionsRef = useRef<HTMLDivElement | null>(null);
+ useEffect(() => {
+ const actions = headerActionsRef.current;
+ const container = actions?.parentElement;
+ if (!actions || !container) return;
+ return observeResponsiveBreakpointFade({
+ target: actions,
+ container,
+ active: panelAnimationsActive,
+ durationMs: panelAnimationDurationMs,
+ breakpoint: { value: HEADER_ACTIONS_EXPANDED_BREAKPOINT_REM, unit: "rem" },
+ });
+ }, [panelAnimationDurationMs, panelAnimationsActive]);
const primaryEnvironmentId = usePrimaryEnvironmentId();
const fileScripts = useT3ProjectFileScripts(
activeThreadEnvironmentId,
@@ -372,10 +390,12 @@ export const ChatHeader = memo(function ChatHeader({
</WorkspaceBreadcrumbItem>
</WorkspaceBreadcrumb>
<div
+ ref={headerActionsRef}
data-chat-header-actions
className={cn(
"flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3",
rightPanelOpen ? "pr-0" : "pr-16",
+ "[[data-panel-animations=true]_&]:motion-safe:transition-[padding-right] [[data-panel-animations=true]_&]:motion-safe:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:motion-safe:ease-out",
)}
>
{activeProjectScripts && (
diff --git a/apps/web/src/components/preview/PreviewPanelShell.tsx b/apps/web/src/components/preview/PreviewPanelShell.tsx
index 7a20c2eaaa0..4b95f974044 100644
--- a/apps/web/src/components/preview/PreviewPanelShell.tsx
+++ b/apps/web/src/components/preview/PreviewPanelShell.tsx
@@ -52,6 +52,7 @@ export function getPreviewPanelMaxWidth(viewportWidth: number, containerWidth?:
export function PreviewPanelShell(props: {
mode: PreviewPanelMode;
maximized?: boolean;
+ open?: boolean;
/**
* Overrides the localStorage key used to persist the panel width. Callers
* embedding this shell for a different surface (e.g. the pull requests
@@ -65,6 +66,8 @@ export function PreviewPanelShell(props: {
}) {
const useDragRegion = isElectron && props.mode !== "sheet" && props.mode !== "embedded";
const isInline = props.mode === "inline";
+ const collapsible = isInline && props.open !== undefined;
+ const open = props.open ?? true;
const hostRef = useRef<HTMLDivElement | null>(null);
// Only inline non-maximized mode applies `width`/`maxWidth`; skip the
// container measurement (and its re-renders) everywhere else.
@@ -76,7 +79,26 @@ export function PreviewPanelShell(props: {
maxWidth,
edge: "left",
});
-
+ const previousLayoutRef = useRef({ open, width });
+ useLayoutEffect(() => {
+ const previous = previousLayoutRef.current;
+ previousLayoutRef.current = { open, width };
+ if (!collapsible || previous.open !== open || previous.width === width) return;
+ const host = hostRef.current;
+ if (!host?.closest("[data-panel-animations=true]")) return;
+ host.style.setProperty("transition-duration", "0ms");
+ let restoreFrame = 0;
+ const paintFrame = window.requestAnimationFrame(() => {
+ restoreFrame = window.requestAnimationFrame(() => {
+ host.style.removeProperty("transition-duration");
+ });
+ });
+ return () => {
+ window.cancelAnimationFrame(paintFrame);
+ window.cancelAnimationFrame(restoreFrame);
+ host.style.removeProperty("transition-duration");
+ };
+ }, [collapsible, open, width]);
return (
<div
ref={hostRef}
@@ -87,14 +109,29 @@ export function PreviewPanelShell(props: {
? "flex-1 border-l border-border"
: "shrink-0 border-l border-border"
: "w-full",
+ collapsible &&
+ "[[data-panel-animations=true]_&]:transition-[width] [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
+ collapsible && open && "[[data-panel-animations=true]_&]:starting:w-0!",
+ collapsible && !open && "pointer-events-none",
)}
- style={isInline && !props.maximized ? { width: `${width}px` } : undefined}
+ style={
+ isInline
+ ? { width: props.maximized ? "100%" : collapsible && !open ? "0px" : `${width}px` }
+ : undefined
+ }
data-preview-panel-mode={props.mode}
data-preview-panel-maximized={props.maximized ? "true" : "false"}
>
{isInline && !props.maximized ? <RightPanelResizeHandle handlers={handlers} /> : null}
- {useDragRegion ? <div className="electron-drag-region h-0 w-full" aria-hidden /> : null}
- {props.children}
+ <div className={cn("h-full min-h-0 w-full", collapsible && "overflow-clip")}>
+ <div
+ className="flex h-full min-h-0 min-w-0 flex-col"
+ style={collapsible && !props.maximized ? { width: `calc(${width}px - 1px)` } : undefined}
+ >
+ {useDragRegion ? <div className="electron-drag-region h-0 w-full" aria-hidden /> : null}
+ {props.children}
+ </div>
+ </div>
</div>
);
}
diff --git a/apps/web/src/components/settings/PanelAnimationsPreview.tsx b/apps/web/src/components/settings/PanelAnimationsPreview.tsx
new file mode 100644
index 00000000000..a56504479c4
--- /dev/null
+++ b/apps/web/src/components/settings/PanelAnimationsPreview.tsx
@@ -0,0 +1,52 @@
+import { type CSSProperties, useState } from "react";
+
+import { cn } from "~/lib/utils";
+
+export function PanelAnimationsPreview({ durationMs }: { durationMs: number }) {
+ const [panelsOpen, setPanelsOpen] = useState(true);
+ const transitionClass =
+ "transition-[width,height,border-width] [transition-duration:var(--preview-duration)] ease-out motion-reduce:transition-none";
+
+ return (
+ <button
+ type="button"
+ aria-label="Replay panel animation preview"
+ className="flex h-10 w-full cursor-pointer overflow-hidden rounded-lg border border-border bg-background p-1 shadow-xs/5 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background"
+ onClick={() => setPanelsOpen((open) => !open)}
+ style={{ "--preview-duration": `${durationMs}ms` } as CSSProperties}
+ >
+ <span
+ aria-hidden
+ className={cn(
+ "h-full shrink-0 overflow-hidden rounded-md bg-sidebar",
+ transitionClass,
+ panelsOpen ? "w-4" : "w-0",
+ )}
+ />
+ <span aria-hidden className="flex min-w-0 flex-1 flex-col px-1">
+ <span className="flex min-h-0 flex-1 flex-col gap-1 pt-1">
+ <span className="h-0.5 w-full rounded-full bg-muted-foreground/25" />
+ <span className="h-0.5 w-4/5 rounded-full bg-muted-foreground/20" />
+ <span className="h-0.5 w-3/5 rounded-full bg-muted-foreground/15" />
+ </span>
+ <span
+ className={cn(
+ "flex shrink-0 items-center overflow-hidden bg-foreground/5 px-2",
+ transitionClass,
+ panelsOpen ? "h-2 border-t border-border/70" : "h-0 border-t-0",
+ )}
+ >
+ <span className="h-px w-2/3 rounded-full bg-muted-foreground/25" />
+ </span>
+ </span>
+ <span
+ aria-hidden
+ className={cn(
+ "h-full shrink-0 overflow-hidden rounded-md bg-muted",
+ transitionClass,
+ panelsOpen ? "w-5" : "w-0",
+ )}
+ />
+ </button>
+ );
+}
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index 8137114dcd9..51423cf996e 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -24,6 +24,7 @@ import {
MAX_CODE_FONT_SIZE,
MAX_GLASS_OPACITY,
MAX_INTERFACE_FONT_SIZE,
+ MAX_PANEL_ANIMATION_DURATION_MS,
MAX_PROMPT_FONT_SIZE,
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MAX_TERMINAL_FONT_SIZE,
@@ -31,6 +32,7 @@ import {
MIN_APPEARANCE_CONTRAST,
MIN_GLASS_OPACITY,
MIN_INTERFACE_FONT_SIZE,
+ MIN_PANEL_ANIMATION_DURATION_MS,
MIN_PROMPT_FONT_SIZE,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_TERMINAL_FONT_SIZE,
@@ -152,6 +154,7 @@ import {
} from "./settingsLayout";
import { searchableSetting } from "./settingsSearch";
import { ProjectFavicon } from "../ProjectFavicon";
+import { PanelAnimationsPreview } from "./PanelAnimationsPreview";
const ENVIRONMENT_IDENTIFICATION_LABELS: Record<EnvironmentIdentificationMode, string> = {
artwork: "Artwork",
@@ -493,6 +496,9 @@ export function useSettingsRestore(onRestored?: () => void) {
? ["Contrast"]
: []),
...(settings.glassOpacity !== DEFAULT_UNIFIED_SETTINGS.glassOpacity ? ["Glass opacity"] : []),
+ ...(settings.panelAnimationDurationMs !== DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs
+ ? ["Panel animations"]
+ : []),
...(settings.environmentIdentificationMode !==
DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode
? ["Environment identification"]
@@ -593,6 +599,7 @@ export function useSettingsRestore(onRestored?: () => void) {
settings.fontSizePrompt,
settings.fontSizeTerminal,
settings.glassOpacity,
+ settings.panelAnimationDurationMs,
settings.enableLegacyTokenStreaming,
settings.enableProviderUpdateChecks,
settings.continueThreadsAfterServerUpdate,
@@ -680,6 +687,7 @@ export function useSettingsRestore(onRestored?: () => void) {
contextWindowMeterEnabled: DEFAULT_UNIFIED_SETTINGS.contextWindowMeterEnabled,
environmentIdentificationMode: DEFAULT_UNIFIED_SETTINGS.environmentIdentificationMode,
glassOpacity: DEFAULT_UNIFIED_SETTINGS.glassOpacity,
+ panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
sidebarThreadPreviewCount: DEFAULT_UNIFIED_SETTINGS.sidebarThreadPreviewCount,
sidebarProjectGroupingMode: DEFAULT_UNIFIED_SETTINGS.sidebarProjectGroupingMode,
sidebarAutoSettleAfterDays: DEFAULT_UNIFIED_SETTINGS.sidebarAutoSettleAfterDays,
@@ -1035,6 +1043,13 @@ export function AppearanceSettingsPanel() {
"--settings-slider-progress": `${appearanceContrastRatio * 100}%`,
"--settings-slider-fill-offset": `${0.5 - appearanceContrastRatio}rem`,
} as CSSProperties;
+ const panelAnimationDurationRatio =
+ (settings.panelAnimationDurationMs - MIN_PANEL_ANIMATION_DURATION_MS) /
+ (MAX_PANEL_ANIMATION_DURATION_MS - MIN_PANEL_ANIMATION_DURATION_MS);
+ const panelAnimationDurationSliderStyle = {
+ "--settings-slider-progress": `${panelAnimationDurationRatio * 100}%`,
+ "--settings-slider-fill-offset": `${0.5 - panelAnimationDurationRatio}rem`,
+ } as CSSProperties;
return (
<SettingsPageContainer>
@@ -1192,6 +1207,60 @@ export function AppearanceSettingsPanel() {
) : null}
</SettingsSection>
+ <SettingsSection id="motion" title="Motion">
+ <SettingsRow
+ {...searchableSetting("panel-animations")}
+ description="Set how fast panels open and close."
+ control={
+ <div className="grid w-full grid-cols-[5rem_minmax(0,1fr)] items-center gap-3 sm:w-auto sm:grid-cols-[7rem_13rem] sm:gap-4">
+ <PanelAnimationsPreview durationMs={settings.panelAnimationDurationMs} />
+ <div className="flex w-full items-center gap-3">
+ <output
+ className="min-w-16 rounded-md bg-muted px-2 py-1 text-center font-mono text-xs font-medium tabular-nums text-foreground"
+ htmlFor="panel-animation-duration"
+ >
+ {settings.panelAnimationDurationMs} ms
+ </output>
+ <input
+ aria-label="Panel animation duration"
+ className="settings-slider min-w-0 flex-1"
+ id="panel-animation-duration"
+ max={MAX_PANEL_ANIMATION_DURATION_MS}
+ min={MIN_PANEL_ANIMATION_DURATION_MS}
+ onChange={(event) => {
+ const panelAnimationDurationMs = Number(event.currentTarget.value);
+ if (
+ Number.isInteger(panelAnimationDurationMs) &&
+ panelAnimationDurationMs >= MIN_PANEL_ANIMATION_DURATION_MS &&
+ panelAnimationDurationMs <= MAX_PANEL_ANIMATION_DURATION_MS
+ ) {
+ updateSettings({ panelAnimationDurationMs });
+ }
+ }}
+ step={25}
+ style={panelAnimationDurationSliderStyle}
+ type="range"
+ value={settings.panelAnimationDurationMs}
+ />
+ </div>
+ </div>
+ }
+ resetAction={
+ settings.panelAnimationDurationMs !==
+ DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs ? (
+ <SettingResetButton
+ label="panel animations"
+ onClick={() =>
+ updateSettings({
+ panelAnimationDurationMs: DEFAULT_UNIFIED_SETTINGS.panelAnimationDurationMs,
+ })
+ }
+ />
+ ) : null
+ }
+ />
+ </SettingsSection>
+
<TypographySection />
</SettingsPageContainer>
);
diff --git a/apps/web/src/components/settings/settingsSearch.test.ts b/apps/web/src/components/settings/settingsSearch.test.ts
index a84a2e925b4..362fe52738e 100644
--- a/apps/web/src/components/settings/settingsSearch.test.ts
+++ b/apps/web/src/components/settings/settingsSearch.test.ts
@@ -51,6 +51,7 @@ describe("searchSettings", () => {
it("matches normalized title substrings", () => {
expect(searchSettings(" WORD WRAP ", ITEMS).map((item) => item.id)).toEqual(["word-wrap"]);
expect(searchSettings("glass").map((item) => item.id)).toEqual(["setting-glass-opacity"]);
+ expect(searchSettings("panel animations").map((item) => item.id)).toEqual(["panel-animations"]);
expect(searchSettings("thè\u{1ab0}mes")[0]?.id).toBe("theme");
const localeLowerCase = vi.spyOn(String.prototype, "toLocaleLowerCase").mockReturnValue("gıt");
try {
diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts
index 20aea7d3f77..f6bba760d1c 100644
--- a/apps/web/src/components/settings/settingsSearch.ts
+++ b/apps/web/src/components/settings/settingsSearch.ts
@@ -94,6 +94,11 @@ export const SETTINGS_SEARCH_ITEMS = [
to: "/settings/appearance",
searchTerms: ["transparent transparency solid menus dialogs composer"],
},
+ {
+ id: "panel-animations",
+ title: "Panel animations",
+ to: "/settings/appearance",
+ },
{
id: "environment-identification",
title: "Environment identification",
diff --git a/apps/web/src/components/ui/sheet.tsx b/apps/web/src/components/ui/sheet.tsx
index 9d0436b661d..2e3cb060df0 100644
--- a/apps/web/src/components/ui/sheet.tsx
+++ b/apps/web/src/components/ui/sheet.tsx
@@ -2,6 +2,7 @@
import { Dialog as SheetPrimitive } from "@base-ui/react/dialog";
import { XIcon } from "lucide-react";
+import type { CSSProperties } from "react";
import { cn } from "~/lib/utils";
import { Button } from "~/components/ui/button";
import { ScrollArea } from "~/components/ui/scroll-area";
@@ -62,18 +63,34 @@ function SheetPopup({
children,
showCloseButton = true,
keepMounted = false,
+ transitionDurationMs,
side = "right",
variant = "default",
+ style,
...props
}: SheetPrimitive.Popup.Props & {
showCloseButton?: boolean;
keepMounted?: boolean;
+ transitionDurationMs?: number;
side?: "right" | "left" | "top" | "bottom";
variant?: "default" | "inset";
}) {
+ const transitionStyle =
+ transitionDurationMs === undefined
+ ? undefined
+ : ({ transitionDuration: `${transitionDurationMs}ms` } satisfies CSSProperties);
+ const instant = transitionDurationMs === 0;
+
return (
<SheetPortal keepMounted={keepMounted}>
- <SheetBackdrop />
+ <SheetBackdrop
+ className={
+ instant
+ ? "transition-none! data-ending-style:opacity-100! data-starting-style:opacity-100!"
+ : undefined
+ }
+ style={transitionStyle}
+ />
<SheetViewport side={side} variant={variant}>
<SheetPrimitive.Popup
className={cn(
@@ -88,9 +105,12 @@ function SheetPopup({
"col-start-2 w-[calc(100%-(--spacing(12)))] max-w-md border-s data-ending-style:translate-x-8 data-starting-style:translate-x-8",
variant === "inset" &&
"before:hidden sm:rounded-2xl sm:border sm:before:rounded-[calc(var(--radius-2xl)-1px)] sm:**:data-[slot=sheet-footer]:rounded-b-[calc(var(--radius-2xl)-1px)]",
+ instant &&
+ "transition-none! will-change-auto! data-ending-style:translate-x-0! data-starting-style:translate-x-0! data-ending-style:translate-y-0! data-starting-style:translate-y-0! data-ending-style:opacity-100! data-starting-style:opacity-100!",
className,
)}
data-slot="sheet-popup"
+ style={{ ...transitionStyle, ...style }}
{...props}
>
{children}
diff --git a/apps/web/src/components/ui/sidebar.tsx b/apps/web/src/components/ui/sidebar.tsx
index ce6e4cc78ca..624798e19f5 100644
--- a/apps/web/src/components/ui/sidebar.tsx
+++ b/apps/web/src/components/ui/sidebar.tsx
@@ -281,7 +281,8 @@ function Sidebar({
{/* This is what handles the sidebar gap on desktop */}
<div
className={cn(
- "relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
+ "relative w-(--sidebar-width) bg-transparent",
+ "[[data-panel-animations=true]_&]:transition-[width] [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
"group-data-[collapsible=offcanvas]:w-0",
"group-data-[side=right]:rotate-180",
variant === "floating" || variant === "inset"
@@ -292,7 +293,8 @@ function Sidebar({
/>
<div
className={cn(
- "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex",
+ "fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) md:flex",
+ "[[data-panel-animations=true]_&]:transition-[left,right,width] [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
side === "left"
? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"
: "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
@@ -601,7 +603,8 @@ function SidebarRail({
aria-label={railLabel}
className={cn(
/* disable pointer events only when offcanvas sidebar is collapsed, that's when the rail sits over the native scrollbar on windows and linux. icon mode stays fully clickable. */
- "-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex [[data-collapsible=offcanvas][data-state=collapsed]_&]:pointer-events-none",
+ "-translate-x-1/2 group-data-[side=left]:-right-4 absolute inset-y-0 z-20 hidden w-4 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=right]:left-0 sm:flex [[data-collapsible=offcanvas][data-state=collapsed]_&]:pointer-events-none",
+ "[[data-panel-animations=true]_&]:transition-all [[data-panel-animations=true]_&]:[transition-duration:var(--panel-animation-duration)] [[data-panel-animations=true]_&]:ease-out",
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
"group-data-[collapsible=offcanvas]:translate-x-0 hover:group-data-[collapsible=offcanvas]:bg-sidebar group-data-[collapsible=offcanvas]:after:left-full",
diff --git a/apps/web/src/panelAnimations.ts b/apps/web/src/panelAnimations.ts
new file mode 100644
index 00000000000..f606a3f930d
--- /dev/null
+++ b/apps/web/src/panelAnimations.ts
@@ -0,0 +1,88 @@
+import { useEffect, useRef, useState } from "react";
+import { type PanelAnimationDurationMs } from "@t3tools/contracts/settings";
+
+import { useMediaQuery } from "./hooks/useMediaQuery";
+import { useClientSettings } from "./hooks/useSettings";
+
+export function observeResponsiveBreakpointFade(options: {
+ target: HTMLElement;
+ container: HTMLElement;
+ active: boolean;
+ durationMs: PanelAnimationDurationMs;
+ breakpoint: { value: number; unit: "px" | "rem" };
+}): () => void {
+ const { target, container, active, durationMs, breakpoint } = options;
+ if (!active || typeof ResizeObserver === "undefined") return () => {};
+
+ const rootFontSize = Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
+ const breakpointPx =
+ breakpoint.unit === "px"
+ ? breakpoint.value
+ : breakpoint.value * (Number.isFinite(rootFontSize) ? rootFontSize : 16);
+ let expanded = container.getBoundingClientRect().width >= breakpointPx;
+ let animation: Animation | null = null;
+
+ const observer = new ResizeObserver(([entry]) => {
+ if (!entry) return;
+ const nextExpanded = entry.contentRect.width >= breakpointPx;
+ if (nextExpanded === expanded) return;
+ expanded = nextExpanded;
+ animation?.cancel();
+ animation = target.animate([{ opacity: 0 }, { opacity: 1 }], {
+ duration: Math.min(100, durationMs),
+ easing: "ease-out",
+ });
+ });
+
+ observer.observe(container);
+ return () => {
+ observer.disconnect();
+ animation?.cancel();
+ };
+}
+
+export function usePanelAnimationSettings(): {
+ active: boolean;
+ durationMs: PanelAnimationDurationMs;
+} {
+ const durationMs = useClientSettings((settings) => settings.panelAnimationDurationMs);
+ const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
+ return { active: durationMs > 0 && !prefersReducedMotion, durationMs };
+}
+
+/** Keeps closing panel content mounted until its opt-in transition ends. */
+export function usePanelPresence<T>(
+ open: boolean,
+ value: T | null,
+ animated: boolean,
+ scopeKey: string | null,
+ durationMs: PanelAnimationDurationMs,
+): { present: boolean; value: T | null } {
+ const [present, setPresent] = useState(open);
+ const retainedRef = useRef<{ scopeKey: string | null; value: T | null } | null>(
+ open ? { scopeKey, value } : null,
+ );
+
+ useEffect(() => {
+ if (open) retainedRef.current = { scopeKey, value };
+ }, [open, scopeKey, value]);
+
+ useEffect(() => {
+ if (open) {
+ setPresent(true);
+ return;
+ }
+ if (!animated) {
+ setPresent(false);
+ return;
+ }
+
+ const timeout = window.setTimeout(() => setPresent(false), durationMs);
+ return () => window.clearTimeout(timeout);
+ }, [animated, durationMs, open]);
+
+ const retainedValue =
+ retainedRef.current?.scopeKey === scopeKey ? retainedRef.current.value : null;
+ const visible = open || (animated && present && retainedRef.current?.scopeKey === scopeKey);
+ return { present: visible, value: open ? value : visible ? retainedValue : null };
+}
diff --git a/apps/web/src/routes/_chat.pull-requests.tsx b/apps/web/src/routes/_chat.pull-requests.tsx
index 2864eb4ced9..593d39fad1a 100644
--- a/apps/web/src/routes/_chat.pull-requests.tsx
+++ b/apps/web/src/routes/_chat.pull-requests.tsx
@@ -106,6 +106,7 @@ import { Menu, MenuPopup, MenuRadioGroup, MenuRadioItem, MenuTrigger } from "../
import { SidebarInset } from "../components/ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../components/ui/tooltip";
import { useLiveRefresh } from "../hooks/useLiveRefresh";
+import { usePanelAnimationSettings, usePanelPresence } from "../panelAnimations";
import { toSortableTimestamp } from "../lib/threadSort";
import {
selectActiveRightPanelSurface,
@@ -449,10 +450,29 @@ function PullRequestsRouteView() {
const selectedPullRequestSurface =
selectedRightPanelSurface?.kind === "pull-request" ? selectedRightPanelSurface : null;
const activePullRequestSurface = rightPanelState.isOpen ? selectedPullRequestSurface : null;
+ const { active: panelAnimationsActive, durationMs: panelAnimationDurationMs } =
+ usePanelAnimationSettings();
+ const rightPanelPresenceValue = useMemo(
+ () => ({
+ activeSurface: selectedPullRequestSurface,
+ surfaces: rightPanelState.surfaces,
+ }),
+ [rightPanelState.surfaces, selectedPullRequestSurface],
+ );
+ const rightPanelPresence = usePanelPresence(
+ rightPanelState.isOpen && selectedPullRequestSurface !== null,
+ rightPanelPresenceValue,
+ panelAnimationsActive,
+ rightPanelRef === null ? null : PULL_REQUESTS_PANEL_ID,
+ panelAnimationDurationMs,
+ );
+ const rightPanelPresent = rightPanelPresence.present;
+ const renderedPullRequestSurface = rightPanelPresence.value?.activeSurface ?? null;
+ const renderedRightPanelSurfaces = rightPanelPresence.value?.surfaces ?? [];
// The open tab names its own server; a link that arrived before any tab was opened names it
// through the project it selected.
const panelEnvironmentId =
- (activePullRequestSurface?.environmentId as EnvironmentId | undefined) ??
+ (renderedPullRequestSurface?.environmentId as EnvironmentId | undefined) ??
selectedProject?.environmentId ??
null;
const [pullRequestTabStatuses, setPullRequestTabStatuses] = useState<
@@ -1783,16 +1803,37 @@ function PullRequestsRouteView() {
// mounted at the fixed titlebar inset in both states so it cannot move
// on toggle, and this spacer keeps refresh from sliding underneath it
// (sized per header padding so refresh ends a normal gap short of it).
- !pullRequestsSupported || rightPanelState.isOpen ? null : (
- <span aria-hidden className="w-7 shrink-0 sm:w-5" />
+ !pullRequestsSupported ? null : (
+ <span
+ aria-hidden
+ className={cn(
+ "shrink-0",
+ rightPanelState.isOpen ? "-ml-3 w-0" : "w-7 sm:w-5",
+ panelAnimationsActive && "transition-[width,margin] ease-out",
+ )}
+ style={
+ panelAnimationsActive
+ ? { transitionDuration: `${panelAnimationDurationMs}ms` }
+ : undefined
+ }
+ />
),
titlebarControls:
// While the panel is closed the strip lives inside the header: a no-drag
// descendant beats the header's desktop drag-region, where a floating
- // sibling loses (app-region hit-testing ignores z-index). Open, it moves
- // back out to the route container, which spans the panel too, so the
- // toggle keeps one fixed top-right anchor and never jumps sideways.
- pullRequestsSupported && !rightPanelState.isOpen ? openPanelControls : null,
+ // sibling loses (app-region hit-testing ignores z-index). While the
+ // floating strip crosses the header during motion, the narrow extension
+ // keeps that overlap non-draggable without moving the toggle.
+ pullRequestsSupported ? (
+ rightPanelPresent ? (
+ <span
+ aria-hidden
+ className="pointer-events-none absolute inset-y-0 left-full w-7 [-webkit-app-region:no-drag]"
+ />
+ ) : (
+ openPanelControls
+ )
+ ) : null,
rightPanelOpen: rightPanelState.isOpen,
listBody,
scrollRef,
@@ -1835,19 +1876,20 @@ function PullRequestsRouteView() {
return (
<SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground">
<div className="relative flex min-h-0 flex-1">
- {pullRequestsSupported && rightPanelState.isOpen ? openPanelControls : null}
+ {pullRequestsSupported && rightPanelPresent ? openPanelControls : null}
<PullRequestsColumn {...columnProps} />
- {rightPanelState.isOpen && activePullRequestSurface && panelEnvironmentId !== null ? (
+ {rightPanelPresent && renderedPullRequestSurface && panelEnvironmentId !== null ? (
<RightPanelTabs
mode="inline"
+ open={rightPanelState.isOpen}
widthStorageKey="t3code:pull-request-panel-width"
// Default to roughly half the viewport: the PR list needs more
// room than a chat, so the 540px chat-preview default squashes
// it. SSR has no window, so fall back to a reasonable width.
defaultWidth={typeof window === "undefined" ? 640 : Math.floor(window.innerWidth / 2)}
- surfaces={rightPanelState.surfaces}
- activeSurfaceId={activePullRequestSurface.id}
+ surfaces={renderedRightPanelSurfaces}
+ activeSurfaceId={renderedPullRequestSurface.id}
pendingSurfaceIds={EMPTY_PENDING_SURFACES}
previewSessions={EMPTY_PREVIEW_SESSIONS}
desktopByTabId={EMPTY_PREVIEW_DESKTOP_STATE}
@@ -1883,12 +1925,12 @@ function PullRequestsRouteView() {
pullRequestStatuses={pullRequestTabStatuses}
>
<PullRequestDetailPanel
- key={activePullRequestSurface.id}
+ key={renderedPullRequestSurface.id}
environmentId={panelEnvironmentId}
reference={{
- projectId: activePullRequestSurface.projectId as ProjectId,
- repository: activePullRequestSurface.repository,
- number: activePullRequestSurface.number,
+ projectId: renderedPullRequestSurface.projectId as ProjectId,
+ repository: renderedPullRequestSurface.repository,
+ number: renderedPullRequestSurface.number,
}}
refreshToken={detailRefreshToken}
// Merging, closing or reopening changes the row this panel was opened from, so
diff --git a/docs/user/thread-sidebar.md b/docs/user/thread-sidebar.md
index be2c1559b1a..2f24e22b3b9 100644
--- a/docs/user/thread-sidebar.md
+++ b/docs/user/thread-sidebar.md
@@ -42,6 +42,13 @@ If reordering is unavailable for one environment, update the T3 Code server runn
environment. Older servers can still pin and unpin threads, but do not understand synced ordering;
their pinned threads keep the default newest-first order below the ones you have arranged.
+## Panel motion
+
+The main sidebar, right panel, and terminal drawer open and close immediately by default. Under
+**Settings → Appearance → Motion**, move the **Panel animations** slider above 0 ms to add motion.
+The duration can be set up to 400 ms. Clicking the preview replays all three panel transitions; at
+0 ms, it snaps between the same open and closed states.
+
## Environment artwork
Dev and Nightly environments can identify themselves with artwork at the top of the sidebar and in
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index 43781429fa0..c5fcf81bd95 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -144,6 +144,22 @@ describe("ClientSettings appearance contrast", () => {
});
});
+describe("ClientSettings panel animations", () => {
+ it("defaults to instant changes", () => {
+ expect(decodeClientSettings({}).panelAnimationDurationMs).toBe(0);
+ });
+
+ it.each([0, 400])("accepts a panel animation duration: %s", (value) => {
+ expect(decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toEqual({
+ panelAnimationDurationMs: value,
+ });
+ });
+
+ it.each([-1, 401, 150.5])("rejects an invalid panel animation duration: %s", (value) => {
+ expect(() => decodeClientSettingsPatch({ panelAnimationDurationMs: value })).toThrow();
+ });
+});
+
describe("ClientSettings environment identification", () => {
it("defaults to artwork and accepts each presentation mode", () => {
expect(decodeClientSettings({}).environmentIdentificationMode).toBe("artwork");
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 7c867c212d4..9eeabba67b7 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -84,6 +84,16 @@ export const AppearanceContrast = Schema.Int.check(
);
export type AppearanceContrast = typeof AppearanceContrast.Type;
export const DEFAULT_APPEARANCE_CONTRAST: AppearanceContrast = 100;
+export const MIN_PANEL_ANIMATION_DURATION_MS = 0;
+export const MAX_PANEL_ANIMATION_DURATION_MS = 400;
+export const PanelAnimationDurationMs = Schema.Int.check(
+ Schema.isBetween({
+ minimum: MIN_PANEL_ANIMATION_DURATION_MS,
+ maximum: MAX_PANEL_ANIMATION_DURATION_MS,
+ }),
+);
+export type PanelAnimationDurationMs = typeof PanelAnimationDurationMs.Type;
+export const DEFAULT_PANEL_ANIMATION_DURATION_MS: PanelAnimationDurationMs = 0;
/**
* Font size preferences, in CSS pixels. The ranges are deliberately narrow:
* the interface size scales every rem-based dimension in the app, so the
@@ -179,6 +189,11 @@ export const ClientSettingsSchema = Schema.Struct({
appearanceContrast: AppearanceContrast.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_APPEARANCE_CONTRAST)),
),
+ // Panel motion defaults to zero because width and height transitions cause
+ // layout work on every frame, which is noticeable on lower-power clients.
+ panelAnimationDurationMs: PanelAnimationDurationMs.pipe(
+ Schema.withDecodingDefault(Effect.succeed(DEFAULT_PANEL_ANIMATION_DURATION_MS)),
+ ),
browserDefaultViewport: PreviewViewportSetting.pipe(
Schema.withDecodingDefault(Effect.succeed(DEFAULT_BROWSER_VIEWPORT)),
),
@@ -966,6 +981,7 @@ export type ServerSettingsPatch = typeof ServerSettingsPatch.Type;
export const ClientSettingsPatch = Schema.Struct({
appearanceContrast: Schema.optionalKey(AppearanceContrast),
+ panelAnimationDurationMs: Schema.optionalKey(PanelAnimationDurationMs),
browserDefaultViewport: Schema.optionalKey(PreviewViewportSetting),
browserDefaultZoomFactor: Schema.optionalKey(PreviewZoomFactor),
browserDefaultAppearance: Schema.optionalKey(PreviewAppearancePreference),