diff --git a/core/core.ts b/core/core.ts index ea3e678dc..9b7e80cde 100644 --- a/core/core.ts +++ b/core/core.ts @@ -410,6 +410,10 @@ export class Core { await this.messenger.request("openUrl", url); }); + on("controlPlane/getEnvironment", async (msg) => { + return await getControlPlaneEnv(this.ide.getIdeSettings()); + }); + on("controlPlane/getFreeTrialStatus", async (msg) => { return this.configHandler.controlPlaneClient.getFreeTrialStatus(); }); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 743556d15..1a6e4dc20 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -43,7 +43,10 @@ import { AutocompleteCodeSnippet } from "../autocomplete/snippets/types"; import { GetLspDefinitionsFunction } from "../autocomplete/types"; import { ConfigHandler } from "../config/ConfigHandler"; import { SerializedOrgWithProfiles } from "../config/ProfileLifecycleManager"; -import { ControlPlaneSessionInfo } from "../control-plane/AuthTypes"; +import { + ControlPlaneEnv, + ControlPlaneSessionInfo, +} from "../control-plane/AuthTypes"; import { FreeTrialStatus } from "../control-plane/client"; export enum OnboardingModes { @@ -248,6 +251,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { ]; "clipboardCache/add": [{ content: string }, void]; "controlPlane/openUrl": [{ path: string; orgSlug?: string }, void]; + "controlPlane/getEnvironment": [undefined, ControlPlaneEnv]; "controlPlane/getFreeTrialStatus": [undefined, FreeTrialStatus | null]; "controlPlane/getModelsAddOnUpgradeUrl": [ { vsCodeUriScheme?: string }, diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index 6e25e5f54..967e0262e 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -66,12 +66,13 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "didChangeSelectedProfile", "didChangeSelectedOrg", "tools/call", - "controlPlane/openUrl", + "controlPlane/getEnvironment", + "controlPlane/getFreeTrialStatus", "controlPlane/getModelsAddOnUpgradeUrl", + "controlPlane/openUrl", "isItemTooBig", "process/markAsBackgrounded", "process/isBackgrounded", - "controlPlane/getFreeTrialStatus", ]; // Message types to pass through from core to webview diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index d41da483f..503fd2fb4 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -1,5 +1,5 @@ import { OnboardingModes } from "core/protocol/core"; -import { useContext, useEffect } from "react"; +import { useContext, useEffect, useState } from "react"; import { Outlet, useLocation, useNavigate } from "react-router-dom"; import styled from "styled-components"; import { CustomScrollbarDiv } from "."; @@ -42,12 +42,12 @@ const GridDiv = styled.div` `; const Layout = () => { + const [showStagingIndicator, setShowStagingIndicator] = useState(false); const navigate = useNavigate(); const location = useLocation(); const dispatch = useAppDispatch(); const onboardingCard = useOnboardingCard(); const ideMessenger = useContext(IdeMessengerContext); - const currentSessionId = useAppSelector((state) => state.session.id); const { mainEditor } = useMainEditor(); const dialogMessage = useAppSelector((state) => state.ui.dialogMessage); @@ -55,6 +55,17 @@ const Layout = () => { const showDialog = useAppSelector((state) => state.ui.showDialog); const isInEdit = useAppSelector((store) => store.session.isInEdit); + useEffect(() => { + (async () => { + const response = await ideMessenger.request( + "controlPlane/getEnvironment", + undefined, + ); + response.status === "success" && + setShowStagingIndicator(response.content.AUTH_TYPE.includes("staging")); + })(); + }, []); + useWebviewListener( "newSession", async () => { @@ -236,6 +247,15 @@ const Layout = () => { + {showStagingIndicator && ( + + )}
{ message={dialogMessage} /> - +