Skip to content

Commit 6cea32d

Browse files
committed
chore(site): hide chat behind ExperimentAgenticChat
1 parent 370796f commit 6cea32d

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

site/src/contexts/useAgenticChat.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { experiments } from "api/queries/experiments";
2+
3+
import { useEmbeddedMetadata } from "hooks/useEmbeddedMetadata";
4+
import { useEffect, useState } from "react";
5+
import { useQuery } from "react-query";
6+
7+
interface AgenticChat {
8+
readonly enabled: boolean;
9+
}
10+
11+
export const useAgenticChat = (): AgenticChat => {
12+
const { metadata } = useEmbeddedMetadata();
13+
const enabledExperimentsQuery = useQuery(experiments(metadata.experiments));
14+
15+
const [enabled, setEnabled] = useState<boolean>(false);
16+
useEffect(() => {
17+
if (enabledExperimentsQuery.data?.includes("agentic-chat")) {
18+
setEnabled(true);
19+
}
20+
});
21+
22+
return { enabled };
23+
};

site/src/modules/dashboard/Navbar/NavbarView.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Button } from "components/Button/Button";
44
import { ExternalImage } from "components/ExternalImage/ExternalImage";
55
import { CoderIcon } from "components/Icons/CoderIcon";
66
import type { ProxyContextValue } from "contexts/ProxyContext";
7+
import { useAgenticChat } from "contexts/useAgenticChat";
78
import { useWebpushNotifications } from "contexts/useWebpushNotifications";
89
import { NotificationsInbox } from "modules/notifications/NotificationsInbox/NotificationsInbox";
910
import type { FC } from "react";
@@ -45,8 +46,7 @@ export const NavbarView: FC<NavbarViewProps> = ({
4546
canViewAuditLog,
4647
proxyContextValue,
4748
}) => {
48-
const { subscribed, enabled, loading, subscribe, unsubscribe } =
49-
useWebpushNotifications();
49+
const webPush = useWebpushNotifications();
5050

5151
return (
5252
<div className="border-0 border-b border-solid h-[72px] flex items-center leading-none px-6">
@@ -76,13 +76,21 @@ export const NavbarView: FC<NavbarViewProps> = ({
7676
/>
7777
</div>
7878

79-
{enabled ? (
80-
subscribed ? (
81-
<Button variant="outline" disabled={loading} onClick={unsubscribe}>
79+
{webPush.enabled ? (
80+
webPush.subscribed ? (
81+
<Button
82+
variant="outline"
83+
disabled={webPush.loading}
84+
onClick={webPush.unsubscribe}
85+
>
8286
Disable WebPush
8387
</Button>
8488
) : (
85-
<Button variant="outline" disabled={loading} onClick={subscribe}>
89+
<Button
90+
variant="outline"
91+
disabled={webPush.loading}
92+
onClick={webPush.subscribe}
93+
>
8694
Enable WebPush
8795
</Button>
8896
)
@@ -132,6 +140,7 @@ interface NavItemsProps {
132140

133141
const NavItems: FC<NavItemsProps> = ({ className }) => {
134142
const location = useLocation();
143+
const agenticChat = useAgenticChat();
135144

136145
return (
137146
<nav className={cn("flex items-center gap-4 h-full", className)}>
@@ -154,14 +163,16 @@ const NavItems: FC<NavItemsProps> = ({ className }) => {
154163
>
155164
Templates
156165
</NavLink>
157-
<NavLink
158-
className={({ isActive }) => {
159-
return cn(linkStyles.default, isActive ? linkStyles.active : "");
160-
}}
161-
to="/chat"
162-
>
163-
Chat
164-
</NavLink>
166+
{agenticChat.enabled ? (
167+
<NavLink
168+
className={({ isActive }) => {
169+
return cn(linkStyles.default, isActive ? linkStyles.active : "");
170+
}}
171+
to="/chat"
172+
>
173+
Chat
174+
</NavLink>
175+
) : null}
165176
</nav>
166177
);
167178
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy