Undo chat history (#74)
This commit is contained in:
@@ -31,6 +31,7 @@ export function ChatList({ show }: { show?: boolean }) {
|
||||
if (isChatRoute) {
|
||||
const id = routerState.location.search.id;
|
||||
if (id) {
|
||||
console.log("Setting selected chat id to", id);
|
||||
setSelectedChatId(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { PanelRightOpen, History, PlusCircle } from "lucide-react";
|
||||
import { PanelRightClose } from "lucide-react";
|
||||
import { useAtomValue, useSetAtom } from "jotai";
|
||||
import { selectedAppIdAtom } from "@/atoms/appAtoms";
|
||||
import { useLoadVersions } from "@/hooks/useLoadVersions";
|
||||
import { useVersions } from "@/hooks/useVersions";
|
||||
import { Button } from "../ui/button";
|
||||
import { IpcClient } from "@/ipc/ipc_client";
|
||||
import { useRouter } from "@tanstack/react-router";
|
||||
@@ -22,7 +22,7 @@ export function ChatHeader({
|
||||
onVersionClick,
|
||||
}: ChatHeaderProps) {
|
||||
const appId = useAtomValue(selectedAppIdAtom);
|
||||
const { versions, loading } = useLoadVersions(appId);
|
||||
const { versions, loading } = useVersions(appId);
|
||||
const { navigate } = useRouter();
|
||||
const setSelectedChatId = useSetAtom(selectedChatIdAtom);
|
||||
const { refreshChats } = useChats(appId);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useAtom, useAtomValue } from "jotai";
|
||||
import { selectedAppIdAtom, selectedVersionIdAtom } from "@/atoms/appAtoms";
|
||||
import { useLoadVersions } from "@/hooks/useLoadVersions";
|
||||
import { useVersions } from "@/hooks/useVersions";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import { RotateCcw, X } from "lucide-react";
|
||||
import type { Version } from "@/ipc/ipc_types";
|
||||
@@ -15,7 +15,8 @@ interface VersionPaneProps {
|
||||
|
||||
export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
|
||||
const appId = useAtomValue(selectedAppIdAtom);
|
||||
const { versions, loading, refreshVersions } = useLoadVersions(appId);
|
||||
const { versions, loading, refreshVersions, revertVersion } =
|
||||
useVersions(appId);
|
||||
const [selectedVersionId, setSelectedVersionId] = useAtom(
|
||||
selectedVersionIdAtom
|
||||
);
|
||||
@@ -108,11 +109,9 @@ export function VersionPane({ isVisible, onClose }: VersionPaneProps) {
|
||||
onClick={async (e) => {
|
||||
e.stopPropagation();
|
||||
setSelectedVersionId(null);
|
||||
await IpcClient.getInstance().revertVersion({
|
||||
appId: appId!,
|
||||
previousVersionId: version.oid,
|
||||
await revertVersion({
|
||||
versionId: version.oid,
|
||||
});
|
||||
refreshVersions();
|
||||
}}
|
||||
className={cn(
|
||||
"invisible mt-1 flex items-center gap-1 px-2 py-0.5 text-sm font-medium bg-(--primary) text-(--primary-foreground) hover:bg-background-lightest rounded-md transition-colors",
|
||||
|
||||
Reference in New Issue
Block a user