-
Notifications
You must be signed in to change notification settings - Fork 15
fix: move artist redirect to live client tool handling #1642
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
base: test
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -61,6 +62,7 @@ export function useVercelChat({ | |
| const { refetchCredits } = usePaymentProvider(); | ||
|
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. 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 |
||
| const { transport, getHeaders } = useChatTransport(); | ||
| const { authenticated } = usePrivy(); | ||
| const redirectPathRef = useRef<string | null>(null); | ||
|
|
||
| // Load artist files for mentions (from Supabase) | ||
| const { files: allArtistFiles = [] } = useArtistFilesForMentions(); | ||
|
|
@@ -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); | ||
|
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. P2: Prompt for AI agents |
||
| } | ||
| }, | ||
| }); | ||
|
|
||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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