Skip to content

Commit

Permalink
Merge pull request #717 from openchatai/new-default-handoff-component
Browse files Browse the repository at this point in the history
Fix JSON parsing error, new default handoff component
  • Loading branch information
faltawy authored Mar 19, 2024
2 parents 45e2ef8 + a03159d commit 2fab2cc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
11 changes: 8 additions & 3 deletions copilot-widget/lib/@components/Handoff.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@ type Props = ComponentProps<HandoffPayloadType>;

export function Handoff(props: Props) {
return (
<div className="w-full">
<span>{props.data.sentiment}</span>
<span>{props.data.summary}</span>
<div className="w-full p-3">
<button className="text-sm font-medium py-2 px-3 rounded-lg bg-primary text-white max-w-sm w-full">
open an issue ticket
</button>
<p className="text-xs mt-1">
this is the default handoff component.{" "}
<a className='text-primary' href="https://docs.opencopilot.so/resources/human-handoff">Read docs</a>
</p>
</div>
);
}
4 changes: 3 additions & 1 deletion copilot-widget/lib/contexts/componentRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export class ComponentRegistry {
}

private get(key: string) {
const c = this.components.find((c) => c.key === key);
const c = this.components.find(
(c) => c.key.toUpperCase() === key.toUpperCase()
);
if (c) return c;
return null;
}
Expand Down
5 changes: 3 additions & 2 deletions copilot-widget/lib/contexts/messageHandler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,9 @@ export class ChatController {
return;
}

const handle = (msg: string) => {
const parsedResponse = JSON.parse(msg) as HandoffPayloadType;
const handle = (msg: string | object) => {
const parsedResponse: HandoffPayloadType =
typeof msg === "object" ? msg : JSON.parse(msg);
externalCallback?.(parsedResponse);
this.internalHandleHandoff(parsedResponse);
};
Expand Down
2 changes: 1 addition & 1 deletion copilot-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openchatai/copilot-widget",
"private": false,
"version": "2.8.10",
"version": "2.8.11",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@hookform/resolvers": "^3.3.1",
"@kbox-labs/react-echarts": "^1.0.3",
"@openchatai/copilot-widget": "^2.8.10",
"@openchatai/copilot-widget": "^2.8.11",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-avatar": "^1.0.4",
Expand Down
8 changes: 4 additions & 4 deletions dashboard/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2fab2cc

Please sign in to comment.