Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 1 addition & 9 deletions components/VercelChat/tools/CreateArtistToolResult.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useEffect } from "react";
import { CreateArtistResult } from "@/types/createArtistResult";
import useCreateArtistTool from "@/hooks/useCreateArtistTool";
import GenericSuccess from "./GenericSuccess";
import { useArtistProvider } from "@/providers/ArtistProvider";

Expand All @@ -19,7 +18,6 @@ export function CreateArtistToolResult({
result,
}: CreateArtistToolResultProps) {
const { getArtists } = useArtistProvider();
const { isProcessing, error: processingError } = useCreateArtistTool(result);

useEffect(() => {
getArtists(result.artistAccountId);
Expand All @@ -46,13 +44,7 @@ export function CreateArtistToolResult({
<GenericSuccess
image={result.artist.image}
name={result.artist.name}
message={
isProcessing
? "Setting up artist conversation..."
: processingError
? `Created successfully but: ${processingError}`
: "Artist created successfully"
}
message="Artist created successfully"
/>
);
}
Expand Down
91 changes: 0 additions & 91 deletions hooks/useCreateArtistTool.ts

This file was deleted.

17 changes: 17 additions & 0 deletions hooks/useVercelChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { usePrivy } from "@privy-io/react-auth";
import { TextAttachment } from "@/types/textAttachment";
import { formatTextAttachments } from "@/lib/chat/formatTextAttachments";
import { useDeleteTrailingMessages } from "./useDeleteTrailingMessages";
import { z } from "zod";

// 30 days in seconds for Supabase signed URL expiry
const SIGNED_URL_EXPIRES_SECONDS = 60 * 60 * 24 * 30;
Expand Down Expand Up @@ -61,6 +62,7 @@ export function useVercelChat({
const { refetchCredits } = usePaymentProvider();
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: Flag AI Slop and Fabricated Changes

This behavior change (tool-triggered redirect via onToolCall/onFinish) ships without a regression test, which Rule 3 explicitly flags for bug-fix/behavior-change PRs.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useVercelChat.ts, line 64:

<comment>This behavior change (tool-triggered redirect via `onToolCall`/`onFinish`) ships without a regression test, which Rule 3 explicitly flags for bug-fix/behavior-change PRs.</comment>

<file context>
@@ -61,6 +61,7 @@ export function useVercelChat({
   const { refetchCredits } = usePaymentProvider();
   const { transport, getHeaders } = useChatTransport();
   const { authenticated } = usePrivy();
+  const pendingRedirectPathRef = useRef<string | null>(null);
 
   // Load artist files for mentions (from Supabase)
</file context>
Fix with Cubic

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Custom agent: Code Structure and Size Limits for Readability and Single Responsibility

This adds more behavior to an already far-over-limit hook file instead of splitting responsibilities; Rule 1 requires files to stay under 100 LOC.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useVercelChat.ts, line 189:

<comment>This adds more behavior to an already far-over-limit hook file instead of splitting responsibilities; Rule 1 requires files to stay under 100 LOC.</comment>

<file context>
@@ -181,12 +182,27 @@ export function useVercelChat({
         console.error("An error occurred, please try again!", e);
         toast.error("An error occurred, please try again!");
       },
+      onToolCall: async ({ toolCall }) => {
+        if ("toolName" in toolCall && toolCall.toolName === "redirect") {
+          const path = (toolCall.input as { path?: string } | undefined)?.path;
</file context>
Fix with Cubic

const { transport, getHeaders } = useChatTransport();
const { authenticated } = usePrivy();
const redirectPathRef = useRef<string | null>(null);

// Load artist files for mentions (from Supabase)
const { files: allArtistFiles = [] } = useArtistFilesForMentions();
Expand Down Expand Up @@ -180,13 +182,28 @@ export function useVercelChat({
transport,
experimental_throttle: 100,
generateId: generateUUID,
dataPartSchemas: {
redirect: z.object({ path: z.string() }),
},
onError: (e) => {
redirectPathRef.current = null;
console.error("An error occurred, please try again!", e);
toast.error("An error occurred, please try again!");
},
onData: (part) => {
if (part.type === "data-redirect" && part.data.path.startsWith("/")) {
redirectPathRef.current = part.data.path;
}
},
onFinish: async () => {
// Update credits after AI response completes
await refetchCredits();

if (redirectPathRef.current) {
const redirectPath = redirectPathRef.current;
redirectPathRef.current = null;
window.history.replaceState({}, "", redirectPath);
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: history.replaceState only changes the address bar, so the redirect tool won’t navigate to the new route and the chat will keep using the old id. Use a real navigation call (e.g., window.location.replace or the Next router) so the redirect actually takes effect.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At hooks/useVercelChat.ts, line 204:

<comment>`history.replaceState` only changes the address bar, so the redirect tool won’t navigate to the new route and the chat will keep using the old `id`. Use a real navigation call (e.g., `window.location.replace` or the Next router) so the redirect actually takes effect.</comment>

<file context>
@@ -181,12 +182,27 @@ export function useVercelChat({
+        if (pendingRedirectPathRef.current) {
+          const redirectPath = pendingRedirectPathRef.current;
+          pendingRedirectPathRef.current = null;
+          window.history.replaceState({}, "", redirectPath);
+        }
       },
</file context>
Fix with Cubic

}
},
});

Expand Down
58 changes: 0 additions & 58 deletions lib/messages/copyMessages.ts

This file was deleted.

1 change: 0 additions & 1 deletion types/createArtistResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ export interface CreateArtistResult {
artistAccountId?: string;
message: string;
error?: string;
newRoomId?: string | null;
}
Loading