-
-
Notifications
You must be signed in to change notification settings - Fork 5
Update AI SDK, Remove chatbot #212
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
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughRemoved the entire Chatbots feature: all dashboard pages, forms, actions, embed page, chat API routes, rag‑chat integration and related UI/DB models; switched AI usage to OpenRouter and updated dependencies; dropped ChatBot and ChatBotUserSession models and associated DB migration. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Browser as Browser/UI
participant Server as App Server (routes/pages)
participant DB as Database
participant AI as AI Provider
Note over Browser,Server: Previous chatbot flows removed
Browser->>Server: GET /chatbots or /chatbots/new or /chatbots/:id
Server-->>Browser: Route/file removed → 404 or missing page
Browser->>Server: POST /api/v1/chat/token or /api/v1/chat/:token/stream
Server-->>Browser: Endpoint removed → 404
Browser->>Server: GET/DELETE /api/v1/chat/:token/history
Server-->>Browser: Endpoint removed → 404
Note over Server,AI: Remaining AI utilities use OpenRouter provider instead of prior SDKs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@coderabbitai review |
✅ Actions performedReview triggered.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
components/core/streaming-text.tsx (1)
36-45
: Fix stuck loading and harden error handling
- loading remains true when response not OK or body is null; also unhandled errors can throw.
Apply this diff:
- const getData = useCallback(async () => { - setLoading(true); - const response = await fetch(url, { + const getData = useCallback(async () => { + try { + setLoading(true); + const response = await fetch(url, { method: "POST", headers: { "Content-Type": "application/json", }, body: body ? JSON.stringify(body) : null, - }); - - if (!response.ok) { - return null; - } + }); + if (!response.ok) { + setResult(fallbackText); + setLoading(false); + return; + } const data = response.body; if (!data) { setResult(fallbackText); - return; + setLoading(false); + return; } const reader = data.getReader(); const decoder = new TextDecoder(); let done = false; setLoading(false); while (!done) { const { value, done: doneReading } = await reader.read(); done = doneReading; - const chunkValue = decoder.decode(value); + const chunkValue = decoder.decode(value, { stream: true }); setResult((prev) => (prev ?? "") + chunkValue); } onCompleted?.(); - }, [url, fallbackText, body, onCompleted]); + } catch { + setResult(fallbackText); + setLoading(false); + } + }, [url, fallbackText, body, onCompleted]);Additionally consider an AbortController to cancel the fetch on unmount to avoid leaks.
Also applies to: 50-60
app/(dashboard)/workflows/actions.ts (3)
31-33
: Prevent NaN for cacheControlTtlNumber(undefined) yields NaN and ?? won’t catch it. Use a safe parse.
- const cacheControlTtl = Number(formData.get("cacheControlTtl")) ?? 0; + const ttlRaw = formData.get("cacheControlTtl"); + const cacheControlTtl = Number.isFinite(Number(ttlRaw)) ? Number(ttlRaw) : 0;
91-92
: Same NaN risk in updateWorkflowMirror the safe parse here.
- const cacheControlTtl = Number(formData.get("cacheControlTtl")) ?? 0; + const ttlRaw = formData.get("cacheControlTtl"); + const cacheControlTtl = Number.isFinite(Number(ttlRaw)) ? Number(ttlRaw) : 0;
364-368
: Guard missing user and align with other actions’ patternowner() can return null userId; connecting with undefined will throw.
-export async function runTests(formData: FormData) { - const { userId } = await owner(); +export async function runTests(formData: FormData) { + const { userId } = await owner(); + if (!userId) { + return { error: "User is missing" }; + }
🧹 Nitpick comments (9)
package.json (1)
19-21
: Align Prisma adapter with client 6.17.0
@prisma/client
andprisma
now target 6.17.0, but@prisma/adapter-pg
remains on 6.16.2. Mixing minors has bitten us before (engine feature mismatches at runtime). Please bump the adapter to the same version.- "@prisma/adapter-pg": "^6.16.2", + "@prisma/adapter-pg": "^6.17.0",components/core/streaming-text.tsx (1)
24-25
: Revisit hasStarted guard to allow subsequent runs per URL changeUsing a single hasStarted ref can prevent starting when url changes without unmount. Track last URL instead or rely on mount/unmount.
Example:
-const hasStarted = useRef(false); +const lastUrl = useRef<string | null>(null); ... -useEffect(() => { - if (url && !hasStarted.current) { - hasStarted.current = true; - getData(); - } -}, [url, getData]); +useEffect(() => { + if (url && lastUrl.current !== url) { + lastUrl.current = url; + getData(); + } +}, [url, getData]);Also applies to: 62-68
app/(dashboard)/workflows/actions.ts (3)
319-319
: Remove stray console.logLeftover debug log in server action.
- console.log({ id, input, output, condition });
419-427
: Harden test input parsing to avoid crashing the loopJSON.parse on test.input can throw and abort all tests. Wrap in try/catch; mark test as fail or skip with status/error.
Minimal change:
- inputValues: JSON.parse(test.input as unknown as string) as Record< - string, - string - >, + inputValues: (() => { + try { + return JSON.parse(test.input as string) as Record<string, string>; + } catch { + return {}; + } + })(),Optionally, detect parse failure and update the test status to "fail" with a reason before continue.
499-500
: Avoid revalidating on every test iterationrevalidatePath inside the loop causes N revalidations. Trigger once after the loop (and maybe once when setting "running").
- revalidatePath(`/workflows/${id}/tests`); + // defer revalidate until after loopAfter the loop:
+ revalidatePath(`/workflows/${id}/tests`);
Also applies to: 413-414
app/api/v1/run/[workflowId]/stream/route.ts (2)
151-160
: Ensure CORS parity for live stream responseCached path sets CORS headers; live path relies on getStreamingCompletion. If consumed cross-origin, align headers.
- const response = await getStreamingCompletion( + const response = await getStreamingCompletion( model, content, JSON.parse(JSON.stringify(workflow.modelSettings)), workflow.organization.UserKeys, onFinish, ); - - return response; + const headers = new Headers(response.headers); + headers.set("Access-Control-Allow-Origin", "*"); + headers.set("Access-Control-Allow-Methods", "POST, OPTIONS"); + headers.set("Access-Control-Allow-Headers", "*"); + return new Response(response.body, { status: response.status, headers });
76-98
: Cached stream: minor improvementText splitting by " " drops original spacing and punctuation grouping. If fidelity matters, stream the cachedResult as-is in chunks.
- const chunks = cachedResult.split(" "); + const chunks = cachedResult.match(/.{1,1024}/gs) ?? [cachedResult]; ... - controller.enqueue(encoder.encode(`${chunk} `)); + controller.enqueue(encoder.encode(chunk));components/console/workflow/workflow-composer.tsx (2)
20-27
: Remove unused prop from Propsbranch is no longer used; trim Props to avoid confusion.
interface Props { workflow: Workflow; apiSecretKey?: string; - branch?: string; } -export function WorkflowComposer({ workflow, apiSecretKey }: Props) { +export function WorkflowComposer({ workflow, apiSecretKey }: Props) {
41-49
: Replace all placeholder occurrences, not just the firstString.replace replaces only the first match. Use a global regex to fill all instances.
- Object.keys(inputValues).forEach((key) => { - result = result.replace(`{{${key}}}`, inputValues[key]); - }); + Object.keys(inputValues).forEach((key) => { + const pattern = new RegExp(`{{${key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}}}`, "g"); + result = result.replace(pattern, String(inputValues[key] ?? "")); + });Apply similarly to instruction.
Also applies to: 51-59
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
bun.lock
is excluded by!**/*.lock
📒 Files selected for processing (5)
app/(dashboard)/workflows/actions.ts
(2 hunks)app/api/v1/run/[workflowId]/stream/route.ts
(2 hunks)components/console/workflow/workflow-composer.tsx
(8 hunks)components/core/streaming-text.tsx
(3 hunks)package.json
(4 hunks)
🔇 Additional comments (2)
components/console/workflow/workflow-composer.tsx (1)
61-92
: New streaming run flow looks solidToken fetch, guarded run, and StreamingText integration are clean and cohesive. UX states and resets behave as expected.
Also applies to: 156-170, 187-201, 243-261
app/api/v1/run/[workflowId]/stream/route.ts (1)
119-137
: Verify workflowRun.user connection: validateToken.ownerId may reference an organization, not a user. Confirm that you’re connecting a valid User.id (e.g., include userId in the token or fall back to workflow.userId) to avoid mis-attribution or runtime errors.
Summary by CodeRabbit
Revert
Chores
Breaking Changes