Open History to see the last commit
1import { useAtomValue } from "@effect/atom-react";
2
3import { undoLatestThreadAction, useThreadUndoNotice } from "../../hooks/showThreadUndoNotice";
4import { shortcutLabelForCommand } from "../../keybindings";
5import { primaryServerKeybindingsAtom } from "../../state/server";
6import { Alert, AlertDescription } from "../ui/alert";
7import { InlineButton } from "../ui/button";
8
9export function SidebarThreadUndoNotice() {
10 const notice = useThreadUndoNotice((state) => state.notice);
11 const keybindings = useAtomValue(primaryServerKeybindingsAtom);
12
13 if (!notice) return null;
14 const shortcut = shortcutLabelForCommand(keybindings, "thread.undo");
15
16 return (
17 <Alert role="status" variant="sidebar">
18 <AlertDescription>
19 {notice.action} {notice.count} thread{notice.count === 1 ? "" : "s"},{" "}
20 <InlineButton onClick={undoLatestThreadAction}>
21 {shortcut ? `${shortcut} to undo` : "Undo"}
22 </InlineButton>
23 </AlertDescription>
24 </Alert>
25 );
26}