Skip to content

Conversation

arjunkomath
Copy link
Member

@arjunkomath arjunkomath commented Sep 30, 2025

Summary by CodeRabbit

  • Revert

    • Removed the Chatbots feature from the dashboard (list, create, edit, detail) and related embed/view components.
    • Disabled chat APIs (token issuance, streaming, history) and chat UI components.
  • Chores

    • Removed Chatbots links from navigation and footer.
    • Embed chatbot route is no longer public.
    • Updated dependencies to a new AI provider and removed previous AI SDKs.
  • Breaking Changes

    • Chatbot data, sessions, and histories have been deleted via schema/migration.

Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
manage-prompt Ready Ready Preview Oct 10, 2025 8:32am

Copy link

coderabbitai bot commented Sep 30, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Removed 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

Cohort / File(s) Summary
Dashboard: Chatbots pages & actions
app/(dashboard)/chatbots/page.tsx, app/(dashboard)/chatbots/new/page.tsx, app/(dashboard)/chatbots/[id]/page.tsx, app/(dashboard)/chatbots/[id]/edit/page.tsx, app/(dashboard)/chatbots/actions.ts, app/(dashboard)/chatbots/loading.tsx
Removed listing, create, detail, edit pages, server actions (create/update/delete), and loading re-export for Chatbots.
Embed page
app/embed/chatbot/[token]/page.tsx
Removed embed page that rendered ChatView with token.
Chat API routes
app/api/v1/chat/[token]/history/route.ts, app/api/v1/chat/[token]/stream/route.ts, app/api/v1/chat/token/route.ts
Deleted token issuance, streaming chat, history retrieval/deletion endpoints and associated handlers/exports (OPTIONS/GET/POST/DELETE).
Console chatbot components
components/console/chatbot/chat-view.tsx, components/console/chatbot/chat-deploy.tsx, components/console/chatbot/chatbot-form.tsx
Removed ChatView, ChatDeploy, and ChatbotForm components and their exports.
Navigation & footer
components/console/navbar.tsx, components/layout/footer.tsx
Removed “Chatbots” navigation tab and footer entry.
AI & RAG utilities
lib/utils/ai.ts, lib/utils/rag-chat.ts, lib/utils/api.ts
Switched AI utils from OpenAI SDK to OpenRouter provider; removed rag‑chat and vector index exports; removed ErrorCodes.ChatbotNotFound.
Middleware
middleware.ts
Removed /embed/chatbot from publicAppPaths (now treated as non-public).
Database schema & migrations
prisma/schema.prisma, prisma/migrations/20251010065557_remove_chatbot/migration.sql, prisma/migrations/migration_lock.toml
Dropped ChatBot and ChatBotUserSession models and related fields on User/Organization; added migration to drop tables and FKs; lock file effectively unchanged.
Workflows & streaming
app/(dashboard)/workflows/actions.ts, app/api/v1/run/[workflowId]/stream/route.ts, components/console/workflow/workflow-composer.tsx, components/core/streaming-text.tsx
Removed runWorkflow implementation; replaced ai-stream helper with native ReadableStream; added client-side streaming flow and UI changes in workflow composer; adjusted streaming-text to guard fetch.
Dependencies
package.json
Removed previous AI SDKs and Upstash rag/vector packages; added @openrouter/ai-sdk-provider; bumped ai and zod versions.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

Hop hop, I tidy the burrow tight,
Old chatbot tunnels fade from sight.
I swap my maps for OpenRouter skies,
Prune rag‑old vines where data lies.
Lighter paws, new paths to try—🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly captures the two primary changes in the pull request—updating the AI SDK and removing all chatbot functionality—and aligns directly with the extensive code removals and SDK migration in the changeset. It is concise, clear, and specific enough to inform a reviewer of the main intent without unnecessary detail.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@arjunkomath arjunkomath changed the title Update AI SDK Update AI SDK, Remove chatbot Oct 10, 2025
@arjunkomath
Copy link
Member Author

@coderabbitai review

Copy link

coderabbitai bot commented Oct 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@arjunkomath
Copy link
Member Author

arjunkomath commented Oct 10, 2025

@coderabbitai review

Copy link

coderabbitai bot commented Oct 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a 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 cacheControlTtl

Number(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 updateWorkflow

Mirror 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’ pattern

owner() 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 and prisma 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 change

Using 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.log

Leftover debug log in server action.

-  console.log({ id, input, output, condition });

419-427: Harden test input parsing to avoid crashing the loop

JSON.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 iteration

revalidatePath 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 loop

After 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 response

Cached 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 improvement

Text 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 Props

branch 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 first

String.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

📥 Commits

Reviewing files that changed from the base of the PR and between 44ac4c2 and efae0c8.

⛔ 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 solid

Token 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.

@arjunkomath arjunkomath merged commit a331c07 into main Oct 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant