Repository navigation
fix(web): thread undo notice sits above the bottom shelves instead of pushing the list #25270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d8dddf1
15d3290
b541d9c
5c36b3e
b60fe8b
6c2d9f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,43 @@ | ||
| import { useAtomValue } from "@effect/atom-react"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { | ||
| threadUndoLabel, | ||
| threadUndoNoticeSummary, | ||
| 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, | ||
|
Comment on lines
+19
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔎 Supported by static analysis
Keep the retained summary state above the conditional shelf hosts.
Move the retained summary and transition cleanup to the shared notice owner, or keep one notice instance mounted across host changes. Do not add separate fixes to the shelf callers.
|
||
| )} | ||
| > | ||
| <span className="min-w-0 truncate">{text},</span> | ||
| <InlineButton onClick={undoLatestThreadAction}>{threadUndoLabel(keybindings)}</InlineButton> | ||
| </div> | ||
| ); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.