diff --git a/.github/workflows/build-widget.yml b/.github/workflows/build-widget.yml
index b56b679ec..309b4c901 100644
--- a/.github/workflows/build-widget.yml
+++ b/.github/workflows/build-widget.yml
@@ -15,10 +15,10 @@ jobs:
node-version: 18
- name: Install dependencies
- run: cd copilot-widget/ && npm install
+ run: cd copilot-widget/ && pnpm install
- name: Build copilot-widget
- run: cd copilot-widget/ && npm run build
+ run: cd copilot-widget/ && pnpm build:embed
- name: Upload embed as artifact.
uses: actions/upload-artifact@v3
diff --git a/copilot-widget/.release-it.json b/copilot-widget/.release-it.json
new file mode 100644
index 000000000..bb1d4f52f
--- /dev/null
+++ b/copilot-widget/.release-it.json
@@ -0,0 +1,12 @@
+{
+ "github": {
+ "requireBranch": "main",
+ "release": true,
+ "commitMessage": "chore: release ${version}",
+ "hooks": {
+ "before:init": [
+ "pnpm lint"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/copilot-widget/src/lib/CopilotWidget.tsx b/copilot-widget/lib/CopilotWidget.tsx
similarity index 68%
rename from copilot-widget/src/lib/CopilotWidget.tsx
rename to copilot-widget/lib/CopilotWidget.tsx
index 6149c0b3b..1151123a8 100644
--- a/copilot-widget/src/lib/CopilotWidget.tsx
+++ b/copilot-widget/lib/CopilotWidget.tsx
@@ -1,7 +1,8 @@
import { useEffect } from "react";
-import { useWidgetStateContext } from "../contexts/WidgetState";
-import ChatScreenWithSfxs from "../screens/ChatScreen";
-import cn from "../utils/cn";
+import { useWidgetStateContext } from "./contexts/WidgetState";
+import cn from "./utils/cn";
+import ChatScreenWithSfxs from "./screens/ChatScreen";
+import { IS_SERVER } from "./utils/is_server";
export function CopilotWidget({
triggerSelector,
@@ -10,13 +11,11 @@ export function CopilotWidget({
}) {
const [open, toggle] = useWidgetStateContext();
useEffect(() => {
+ if (IS_SERVER) return;
const trigger = document.querySelector(triggerSelector);
- function handleClick() {
- toggle();
- }
if (trigger) {
- trigger.addEventListener("click", handleClick);
- return () => trigger.removeEventListener("click", handleClick);
+ trigger.addEventListener("click", toggle);
+ return () => trigger.removeEventListener("click", toggle);
} else {
console.warn(
"the trigger element can't be found,make sure it present in the DOM"
@@ -37,8 +36,10 @@ export function CopilotWidget({
className={cn(
"opencopilot-font-inter opencopilot-overflow-hidden opencopilot-h-full sm:opencopilot-rounded-xl opencopilot-bg-white",
"opencopilot-opacity-0 opencopilot-transition-opacity opencopilot-ease",
- open && "opencopilot-opacity-100 opencopilot-animate-in opencopilot-fade-in",
- !open && "opencopilot-hidden opencopilot-animate-out opencopilot-fade-out"
+ open &&
+ "opencopilot-opacity-100 opencopilot-animate-in opencopilot-fade-in",
+ !open &&
+ "opencopilot-hidden opencopilot-animate-out opencopilot-fade-out"
)}
>