Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion hooks/useCreateArtistTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useConversationsProvider } from "@/providers/ConversationsProvider";
import { CreateArtistResult } from "@/types/createArtistResult";
import copyMessages from "@/lib/messages/copyMessages";
import { usePrivy } from "@privy-io/react-auth";
import { useRouter } from "next/navigation";

/**
* Hook for managing the create artist tool result
Expand All @@ -13,6 +14,7 @@ export function useCreateArtistTool(result: CreateArtistResult) {
const { status, id } = useVercelChatContext();
const { refetchConversations } = useConversationsProvider();
const { getAccessToken } = usePrivy();
const router = useRouter();
const [isProcessing, setIsProcessing] = useState(false);
const [isSuccess, setIsSuccess] = useState(false);
const [error, setError] = useState<string | null>(null);
Expand Down Expand Up @@ -54,7 +56,7 @@ export function useCreateArtistTool(result: CreateArtistResult) {

if (success) {
// Update the URL to point to the new conversation
window.history.replaceState({}, "", `/chat/${result.newRoomId}`);
router.replace(`/chat/${result.newRoomId}`);
setIsSuccess(true);
} else {
console.error("Failed to copy messages");
Expand All @@ -79,6 +81,7 @@ export function useCreateArtistTool(result: CreateArtistResult) {
isProcessing,
refetchConversations,
getAccessToken,
router,
]);

return {
Expand Down
Loading