From 7544cef8b967b3381b488b3353c0adfdd23461c0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 28 Jul 2025 14:23:08 +0530 Subject: [PATCH 1/5] show yellow border for staging env --- core/core.ts | 4 ++++ core/protocol/core.ts | 6 +++++- core/protocol/passThrough.ts | 3 ++- gui/src/components/Layout.tsx | 23 ++++++++++++++++++----- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/core/core.ts b/core/core.ts index d8275b8ff..69be1f484 100644 --- a/core/core.ts +++ b/core/core.ts @@ -407,6 +407,10 @@ export class Core { await this.messenger.request("openUrl", url); }); + on("controlPlane/getEnvironmentType", 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..abb6d40d2 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/getEnvironmentType": [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..69df93852 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -68,10 +68,11 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "tools/call", "controlPlane/openUrl", "controlPlane/getModelsAddOnUpgradeUrl", + "controlPlane/getEnvironmentType", + "controlPlane/getFreeTrialStatus", "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..0ace1cda2 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 "."; @@ -28,8 +28,9 @@ import { import OSRContextMenu from "./OSRContextMenu"; import PostHogPageView from "./PosthogPageView"; -const LayoutTopDiv = styled(CustomScrollbarDiv)` +const LayoutTopDiv = styled(CustomScrollbarDiv)<{ showBorder: boolean }>` height: 100%; + border-top: ${(props) => (props.showBorder ? "1px solid yellow" : "none")}; position: relative; overflow-x: hidden; `; @@ -42,12 +43,12 @@ const GridDiv = styled.div` `; const Layout = () => { + const [showBorder, setShowBorder] = 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 +56,18 @@ const Layout = () => { const showDialog = useAppSelector((state) => state.ui.showDialog); const isInEdit = useAppSelector((store) => store.session.isInEdit); + useEffect(() => { + (async () => { + const response = await ideMessenger.request( + "controlPlane/getEnvironmentType", + undefined, + ); + console.log("debug2 response was", response); + response.status === "success" && + setShowBorder(response.content.AUTH_TYPE.includes("staging")); + })(); + }, []); + useWebviewListener( "newSession", async () => { @@ -235,7 +248,7 @@ const Layout = () => { return ( - +
{ message={dialogMessage} /> - + From c84631678df08be1b0030539beaa8f70b124e098 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 28 Jul 2025 14:23:58 +0530 Subject: [PATCH 2/5] rename protocol to getEnvironment --- core/core.ts | 2 +- core/protocol/core.ts | 2 +- core/protocol/passThrough.ts | 2 +- gui/src/components/Layout.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/core.ts b/core/core.ts index 69be1f484..8df4992d4 100644 --- a/core/core.ts +++ b/core/core.ts @@ -407,7 +407,7 @@ export class Core { await this.messenger.request("openUrl", url); }); - on("controlPlane/getEnvironmentType", async (msg) => { + on("controlPlane/getEnvironment", async (msg) => { return await getControlPlaneEnv(this.ide.getIdeSettings()); }); diff --git a/core/protocol/core.ts b/core/protocol/core.ts index abb6d40d2..1a6e4dc20 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -251,7 +251,7 @@ export type ToCoreFromIdeOrWebviewProtocol = { ]; "clipboardCache/add": [{ content: string }, void]; "controlPlane/openUrl": [{ path: string; orgSlug?: string }, void]; - "controlPlane/getEnvironmentType": [undefined, ControlPlaneEnv]; + "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 69df93852..ba14d7594 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -68,7 +68,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "tools/call", "controlPlane/openUrl", "controlPlane/getModelsAddOnUpgradeUrl", - "controlPlane/getEnvironmentType", + "controlPlane/getEnvironment", "controlPlane/getFreeTrialStatus", "isItemTooBig", "process/markAsBackgrounded", diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 0ace1cda2..2ada98d9d 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -59,7 +59,7 @@ const Layout = () => { useEffect(() => { (async () => { const response = await ideMessenger.request( - "controlPlane/getEnvironmentType", + "controlPlane/getEnvironment", undefined, ); console.log("debug2 response was", response); From 745be48927ada907574ea5c54ca775c24a213d49 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 29 Jul 2025 09:27:32 +0530 Subject: [PATCH 3/5] resolve nits --- core/protocol/passThrough.ts | 4 ++-- gui/src/components/Layout.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index ba14d7594..967e0262e 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -66,10 +66,10 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] = "didChangeSelectedProfile", "didChangeSelectedOrg", "tools/call", - "controlPlane/openUrl", - "controlPlane/getModelsAddOnUpgradeUrl", "controlPlane/getEnvironment", "controlPlane/getFreeTrialStatus", + "controlPlane/getModelsAddOnUpgradeUrl", + "controlPlane/openUrl", "isItemTooBig", "process/markAsBackgrounded", "process/isBackgrounded", diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 2ada98d9d..0f5bb264c 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -62,7 +62,6 @@ const Layout = () => { "controlPlane/getEnvironment", undefined, ); - console.log("debug2 response was", response); response.status === "success" && setShowBorder(response.content.AUTH_TYPE.includes("staging")); })(); From 83b14343c21212c04dab40204608fd7337d33faf Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 29 Jul 2025 09:35:52 +0530 Subject: [PATCH 4/5] show a yellow dot --- gui/src/components/Layout.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 0f5bb264c..afc8ffc37 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -28,9 +28,8 @@ import { import OSRContextMenu from "./OSRContextMenu"; import PostHogPageView from "./PosthogPageView"; -const LayoutTopDiv = styled(CustomScrollbarDiv)<{ showBorder: boolean }>` +const LayoutTopDiv = styled(CustomScrollbarDiv)` height: 100%; - border-top: ${(props) => (props.showBorder ? "1px solid yellow" : "none")}; position: relative; overflow-x: hidden; `; @@ -43,7 +42,7 @@ const GridDiv = styled.div` `; const Layout = () => { - const [showBorder, setShowBorder] = useState(false); + const [showStagingIndicator, setShowStagingIndicator] = useState(false); const navigate = useNavigate(); const location = useLocation(); const dispatch = useAppDispatch(); @@ -63,7 +62,7 @@ const Layout = () => { undefined, ); response.status === "success" && - setShowBorder(response.content.AUTH_TYPE.includes("staging")); + setShowStagingIndicator(response.content.AUTH_TYPE.includes("staging")); })(); }, []); @@ -247,7 +246,16 @@ const Layout = () => { return ( - + + {showStagingIndicator && ( +
+ )}
Date: Tue, 29 Jul 2025 14:02:32 +0530 Subject: [PATCH 5/5] resolve comment --- gui/src/components/Layout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index afc8ffc37..503fd2fb4 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -248,8 +248,8 @@ const Layout = () => { {showStagingIndicator && ( -