TypeScript
fix(web): thread undo notice sits above the bottom shelves instead of pushing the list (#25270)
maria1549046fd2c4
diff --git a/apps/web/src/components/LegacySidebar.tsx b/apps/web/src/components/LegacySidebar.tsxindex 4d1f6f8ef5d..10ff6ef6bef 100644--- a/apps/web/src/components/LegacySidebar.tsx+++ b/apps/web/src/components/LegacySidebar.tsx@@ -3674,7 +3674,7 @@ export default function LegacySidebar({ routeReveal }: { routeReveal: SidebarRouattachProjectListAutoAnimateRef={attachProjectListAutoAnimateRef}projectsLength={projectsLength}/>- <SidebarChromeFooter />+ <SidebarChromeFooter showUndoNotice /></RevealActiveRowContext>);}diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsxindex 4a3d41bf556..72f90e27a8e 100644--- a/apps/web/src/components/Sidebar.tsx+++ b/apps/web/src/components/Sidebar.tsx@@ -3124,6 +3124,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReveclassName="mt-auto"label="Working"count={workingThreads.length}+ hostsUndoNoticetoggle={{expanded: workingShelfExpanded,onToggle: toggleWorkingShelf,@@ -3139,6 +3140,7 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReveclassName={cn(workingThreads.length === 0 && "mt-auto")}label="Snoozed"count={snoozedThreads.length}+ hostsUndoNotice={workingThreads.length === 0}toggle={{expanded: snoozedShelfExpanded,onToggle: toggleSnoozedShelf,@@ -3156,6 +3158,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve)}label="Settled"count={settledCount}+ hostsUndoNotice={+ workingThreads.length + snoozedThreads.length === 0+ }dragging={from !== null}isDropTarget={dragTargetSection === "settled"}toggle={{@@ -3247,7 +3252,9 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve) : null}</SidebarGroup></SidebarContent>- <SidebarChromeFooter />+ <SidebarChromeFooter+ showUndoNotice={isSearchingThreads || sidebarListItemsFresh.length === 0}+ /></>);}diff --git a/apps/web/src/components/sidebar/SidebarChrome.tsx b/apps/web/src/components/sidebar/SidebarChrome.tsxindex d507689a03f..d7207e3e376 100644--- a/apps/web/src/components/sidebar/SidebarChrome.tsx+++ b/apps/web/src/components/sidebar/SidebarChrome.tsx@@ -228,10 +228,14 @@ const SidebarUtilityMenu = memo(function SidebarUtilityMenu() {);});-export const SidebarChromeFooter = memo(function SidebarChromeFooter() {+export const SidebarChromeFooter = memo(function SidebarChromeFooter({+ showUndoNotice = false,+}: {+ showUndoNotice?: boolean;+}) {return (<SidebarFooter>- <SidebarThreadUndoNotice />+ {showUndoNotice ? <SidebarThreadUndoNotice /> : null}<SidebarProviderUpdatePill /><SidebarUpdateArchitectureWarning /><SidebarUtilityMenu />diff --git a/apps/web/src/components/sidebar/SidebarListMarkers.tsx b/apps/web/src/components/sidebar/SidebarListMarkers.tsxindex 5cefee4452e..4c45b5829fb 100644--- a/apps/web/src/components/sidebar/SidebarListMarkers.tsx+++ b/apps/web/src/components/sidebar/SidebarListMarkers.tsx@@ -10,6 +10,7 @@ import {type SidebarListMarker,} from "../Sidebar.logic";import { SIDEBAR_SORTABLE_DRAG_DISABLED } from "./SidebarThreadRow";+import { SidebarThreadUndoNotice } from "./SidebarThreadUndoNotice";function SortableSidebarMarker(props: {marker: SidebarListMarker;@@ -109,6 +110,8 @@ export function SidebarSectionHeader(props: {dragging?: boolean;isDropTarget?: boolean;toggle: { expanded: boolean; onToggle: () => void };+ /** The first shelf at the bottom of the list hosts the undo notice just above itself. */+ hostsUndoNotice?: boolean;}) {const shelf =props.marker === "working-header"@@ -123,8 +126,11 @@ export function SidebarSectionHeader(props: {<SortableSidebarMarkermarker={props.marker}data-testid={`sidebar-${props.marker}`}- className={cn("mx-0.5 h-8", props.className)}+ className={cn("relative mx-0.5 h-8", props.className)}>+ {props.hostsUndoNotice ? (+ <SidebarThreadUndoNotice className="absolute inset-x-0 bottom-full bg-sidebar surface-grain" />+ ) : null}<CollapsibleSectionHeaderonClick={props.toggle.onToggle}expanded={props.toggle.expanded}diff --git a/apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx b/apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsxindex 7cfa4bdb703..72b5754a193 100644--- a/apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx+++ b/apps/web/src/components/sidebar/SidebarThreadUndoNotice.tsx@@ -1,4 +1,5 @@import { useAtomValue } from "@effect/atom-react";+import { useState } from "react";import {threadUndoLabel,@@ -6,22 +7,37 @@ import {undoLatestThreadAction,useThreadUndoNotice,} from "../../hooks/showThreadUndoNotice";+import { cn } from "../../lib/utils";import { primaryServerKeybindingsAtom } from "../../state/server";-import { Alert, AlertDescription } from "../ui/alert";import { InlineButton } from "../ui/button";-export function SidebarThreadUndoNotice() {+export function SidebarThreadUndoNotice({ className }: { className?: string }) {const notice = useThreadUndoNotice((state) => state.notice);const keybindings = useAtomValue(primaryServerKeybindingsAtom);+ const summary = notice ? threadUndoNoticeSummary(notice) : null;- if (!notice) return null;+ // Keeps the last text on screen while it fades out, then unmounts on transitionend.+ const [shownSummary, setShownSummary] = useState(summary);+ if (summary && summary !== shownSummary) setShownSummary(summary);+ const text = summary ?? shownSummary;+ if (!text) return null;return (- <Alert role="group" variant="sidebar">- <AlertDescription>- {threadUndoNoticeSummary(notice)},{" "}- <InlineButton onClick={undoLatestThreadAction}>{threadUndoLabel(keybindings)}</InlineButton>- </AlertDescription>- </Alert>+ <div+ role="group"+ aria-hidden={!summary}+ inert={!summary}+ onTransitionEnd={(event) => {+ if (!summary && event.target === event.currentTarget) setShownSummary(null);+ }}+ className={cn(+ "flex gap-1 px-2 text-2xs leading-6 text-sidebar-muted-foreground transition-opacity duration-200 ease-out starting:opacity-0",+ !summary && "opacity-0",+ className,+ )}+ >+ <span className="min-w-0 truncate">{text},</span>+ <InlineButton onClick={undoLatestThreadAction}>{threadUndoLabel(keybindings)}</InlineButton>+ </div>);}