Merge pull request #6819 from uinstinct/staging-distinction

feat: show a yellow border when staging is active
This commit is contained in:
Ting-Wai 2025-07-29 09:30:38 -07:00 • committed by GitHub
commit 35de16f4f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 6 deletions

View file

@ -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();
});

View file

@ -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 },

View file

@ -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

View file

@ -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 = () => {
<LocalStorageProvider>
<AuthProvider>
<LayoutTopDiv>
{showStagingIndicator && (
<span
title="Staging environment"
className="absolute right-0 mx-1.5 h-1.5 w-1.5 rounded-full"
style={{
backgroundColor: "var(--vscode-list-warningForeground)",
}}
/>
)}
<LumpProvider>
<OSRContextMenu />
<div
@ -257,7 +277,7 @@ const Layout = () => {
message={dialogMessage}
/>
<GridDiv className="">
<GridDiv>
<PostHogPageView />
<Outlet />
<FatalErrorIndicator />