Skip to content
Merged
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
3 changes: 3 additions & 0 deletions web/ce/helpers/pi-chat.helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const hideFloatingBot = () => {};

export const showFloatingBot = () => {};
Comment on lines +1 to +3
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Implementation required for hideFloatingBot and showFloatingBot functions

The functions are currently empty, which could lead to runtime issues. Consider implementing the actual functionality to control the floating bot visibility.

Consider adding TypeScript types and documentation:

-export const hideFloatingBot = () => {};
-
-export const showFloatingBot = () => {};
+/**
+ * Hides the floating chat bot interface
+ * @returns void
+ */
+export const hideFloatingBot = (): void => {
+  const botElement = document.querySelector<HTMLElement>('.floating-bot');
+  if (botElement) botElement.style.display = 'none';
+};
+
+/**
+ * Shows the floating chat bot interface
+ * @returns void
+ */
+export const showFloatingBot = (): void => {
+  const botElement = document.querySelector<HTMLElement>('.floating-bot');
+  if (botElement) botElement.style.display = 'block';
+};

Committable suggestion skipped: line range outside the PR's diff.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect } from "react";
import { observer } from "mobx-react";
import { useParams } from "next/navigation";
import { useForm } from "react-hook-form";
Expand All @@ -11,6 +12,7 @@ import { CustomAnalyticsSelectBar, CustomAnalyticsMainContent, CustomAnalyticsSi
import { ANALYTICS } from "@/constants/fetch-keys";
import { cn } from "@/helpers/common.helper";
import { useAppTheme } from "@/hooks/store";
import { hideFloatingBot, showFloatingBot } from "@/plane-web/helpers/pi-chat.helper";
import { AnalyticsService } from "@/services/analytics.service";

type Props = {
Expand Down Expand Up @@ -51,6 +53,13 @@ export const CustomAnalytics: React.FC<Props> = observer((props) => {

const isProjectLevel = projectId ? true : false;

useEffect(() => {
hideFloatingBot();
return () => {
showFloatingBot();
};
}, []);
Comment on lines +56 to +61
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Review the useEffect dependencies and error handling

The useEffect hook might run unnecessarily without dependencies. Also, consider adding error handling for the bot visibility functions.

Consider this improvement:

  useEffect(() => {
-   hideFloatingBot();
+   try {
+     hideFloatingBot();
+   } catch (error) {
+     console.error('Failed to hide floating bot:', error);
+   }
    return () => {
-     showFloatingBot();
+     try {
+       showFloatingBot();
+     } catch (error) {
+       console.error('Failed to show floating bot:', error);
+     }
    };
-  }, []);
+  }, []); // Empty deps array is fine as we only want this to run once
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
useEffect(() => {
hideFloatingBot();
return () => {
showFloatingBot();
};
}, []);
useEffect(() => {
try {
hideFloatingBot();
} catch (error) {
console.error('Failed to hide floating bot:', error);
}
return () => {
try {
showFloatingBot();
} catch (error) {
console.error('Failed to show floating bot:', error);
}
};
}, []); // Empty deps array is fine as we only want this to run once


return (
<div className={cn("relative flex h-full w-full overflow-hidden", isProjectLevel ? "flex-col-reverse" : "")}>
<div className="flex h-full w-full flex-col overflow-hidden">
Expand Down