selfhost debugger support part 3 - frontend change (#3420)

This commit is contained in:
LawyZheng
2025-09-12 21:39:15 +08:00
committed by GitHub
parent f65bae5662
commit 3293230e63
4 changed files with 25 additions and 16 deletions

View File

@@ -296,6 +296,7 @@ export type DebugSessionApiResponse = {
workflow_permanent_id: string | null; workflow_permanent_id: string | null;
created_at: string; created_at: string;
modified_at: string; modified_at: string;
vnc_streaming_supported: boolean | null;
}; };
export type WorkflowRunApiResponse = { export type WorkflowRunApiResponse = {

View File

@@ -78,7 +78,6 @@ import {
layout, layout,
} from "./workflowEditorUtils"; } from "./workflowEditorUtils";
import { useAutoPan } from "./useAutoPan"; import { useAutoPan } from "./useAutoPan";
import { useUser } from "@/hooks/useUser";
const nextTick = () => new Promise((resolve) => setTimeout(resolve, 0)); const nextTick = () => new Promise((resolve) => setTimeout(resolve, 0));
@@ -256,14 +255,13 @@ function FlowRenderer({
}: Props) { }: Props) {
const reactFlowInstance = useReactFlow(); const reactFlowInstance = useReactFlow();
const debugStore = useDebugStore(); const debugStore = useDebugStore();
const user = useUser().get();
const { title, initializeTitle } = useWorkflowTitleStore(); const { title, initializeTitle } = useWorkflowTitleStore();
// const [parameters] = useState<ParametersState>(initialParameters); // const [parameters] = useState<ParametersState>(initialParameters);
const parameters = useWorkflowParametersStore((state) => state.parameters); const parameters = useWorkflowParametersStore((state) => state.parameters);
const nodesInitialized = useNodesInitialized(); const nodesInitialized = useNodesInitialized();
const [shouldConstrainPan, setShouldConstrainPan] = useState(false); const [shouldConstrainPan, setShouldConstrainPan] = useState(false);
const onNodesChangeTimeoutRef = useRef<NodeJS.Timeout | null>(null); const onNodesChangeTimeoutRef = useRef<NodeJS.Timeout | null>(null);
const flowIsConstrained = debugStore.isDebugMode && Boolean(user); const flowIsConstrained = debugStore.isDebugMode;
useEffect(() => { useEffect(() => {
if (nodesInitialized) { if (nodesInitialized) {
@@ -520,10 +518,6 @@ function FlowRenderer({
}; };
useOnChange(debugStore.isDebugMode, (newValue) => { useOnChange(debugStore.isDebugMode, (newValue) => {
if (!user) {
return;
}
const xLock = getXLock(); const xLock = getXLock();
if (newValue) { if (newValue) {

View File

@@ -1,5 +1,5 @@
import { AxiosError } from "axios"; import { AxiosError } from "axios";
import { useEffect, useRef, useState } from "react"; import { useEffect, useRef, useState, useMemo } from "react";
import { nanoid } from "nanoid"; import { nanoid } from "nanoid";
import { import {
ChevronRightIcon, ChevronRightIcon,
@@ -137,6 +137,12 @@ function Workspace({
const blockScriptStore = useBlockScriptStore(); const blockScriptStore = useBlockScriptStore();
const cacheKey = workflow?.cache_key ?? ""; const cacheKey = workflow?.cache_key ?? "";
const enableDebugBrowser = useMemo(() => {
return (
showBrowser || (activeDebugSession?.vnc_streaming_supported ?? false)
);
}, [showBrowser, activeDebugSession?.vnc_streaming_supported]);
const [cacheKeyValue, setCacheKeyValue] = useState( const [cacheKeyValue, setCacheKeyValue] = useState(
cacheKey === "" cacheKey === ""
? "" ? ""
@@ -699,7 +705,7 @@ function Workspace({
</div> </div>
{/* infinite canvas and sub panels when not in debug mode */} {/* infinite canvas and sub panels when not in debug mode */}
{!showBrowser && ( {!enableDebugBrowser && (
<div className="relative flex h-full w-full overflow-hidden overflow-x-hidden"> <div className="relative flex h-full w-full overflow-hidden overflow-x-hidden">
{/* infinite canvas */} {/* infinite canvas */}
<FlowRenderer <FlowRenderer
@@ -763,7 +769,7 @@ function Workspace({
)} )}
{/* infinite canvas, sub panels, browser, and timeline when in debug mode */} {/* infinite canvas, sub panels, browser, and timeline when in debug mode */}
{showBrowser && ( {enableDebugBrowser && (
<div className="relative flex h-full w-full overflow-hidden overflow-x-hidden"> <div className="relative flex h-full w-full overflow-hidden overflow-x-hidden">
<Splitter <Splitter
className="splittah" className="splittah"

View File

@@ -88,13 +88,21 @@ async def _authenticate_helper(authorization: str) -> Organization:
async def get_current_user_id( async def get_current_user_id(
authorization: Annotated[str | None, Header(include_in_schema=False)] = None, authorization: Annotated[str | None, Header(include_in_schema=False)] = None,
x_api_key: Annotated[str | None, Header(include_in_schema=False)] = None,
x_user_agent: Annotated[str | None, Header(include_in_schema=False)] = None,
) -> str: ) -> str:
if not authorization: if authorization:
raise HTTPException( return await _authenticate_user_helper(authorization)
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid credentials", if x_api_key and x_user_agent == "skyvern-ui":
) organization = await _get_current_org_cached(x_api_key, app.DATABASE)
return await _authenticate_user_helper(authorization) if organization:
return f"{organization.organization_id}_user"
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid credentials",
)
async def get_current_user_id_with_authentication( async def get_current_user_id_with_authentication(