Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { cn, ResizableHandle, ResizablePanel } from '@openops/components/ui';
import { Permission } from '@openops/shared';
import { t } from 'i18next';
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { ImperativePanelHandle } from 'react-resizable-panels';

import { useAuthorization } from '@/app/common/hooks/authorization-hooks';
import { useResizablePanelGroup } from '@/app/common/hooks/use-resizable-panel-group';
import { RESIZABLE_PANEL_IDS } from '@/app/constants/layout';
import AssistantUiChat from '@/app/features/ai/assistant/assistant-ui-chat';
Expand Down Expand Up @@ -32,6 +34,11 @@ const SecondaryLeftSidePanelContainer = ({
setIsSidebarMinimized: s.setIsSidebarMinimized,
}));

const { checkAccess } = useAuthorization();
const hasBenchmarkAccess =
checkAccess(Permission.WRITE_FLOW) &&
checkAccess(Permission.READ_APP_CONNECTION);
Comment on lines +37 to +40
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hasBenchmarkAccess relies on checkAccess(...), but useAuthorization().checkAccess is currently implemented as return true (packages/react-ui/src/app/common/hooks/authorization-hooks.ts:9-11). As a result, this change does not actually add a permission check and the benchmark panel will still always be shown when isBenchmarkWizardOpen is true. Consider implementing real permission evaluation in useAuthorization (or using an existing authorization source) so this gating is effective.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The access check uses Permission.READ_APP_CONNECTION, but the Benchmark wizard can open CreateOrEditConnectionDialog (benchmark-wizard.tsx -> ProviderConnectionDialog) which performs connection upsert/patch calls. This flow typically requires Permission.WRITE_APP_CONNECTION (e.g., connection-select.tsx uses WRITE_APP_CONNECTION). Using only READ permission may still expose a wizard UI that cannot successfully complete for users who lack connection write access.

Suggested change
checkAccess(Permission.READ_APP_CONNECTION);
checkAccess(Permission.WRITE_APP_CONNECTION);

Copilot uses AI. Check for mistakes.

const { hasActiveAiSettings, isLoading } =
aiSettingsHooks.useHasActiveAiSettings();

Expand All @@ -43,22 +50,23 @@ const SecondaryLeftSidePanelContainer = ({
}, [hasActiveAiSettings, isAiChatOpened, isLoading]);

const prevVisibilityRef = useRef({
shouldShowBenchmark: isBenchmarkWizardOpen,
shouldShowBenchmark: hasBenchmarkAccess && isBenchmarkWizardOpen,
shouldShowAiChat,
});

const shouldShowPanelContent = isBenchmarkWizardOpen || shouldShowAiChat;
const shouldShowBenchmark = hasBenchmarkAccess && isBenchmarkWizardOpen;
const shouldShowPanelContent = shouldShowBenchmark || shouldShowAiChat;
Comment on lines +57 to +58
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When hasBenchmarkAccess is false but isBenchmarkWizardOpen is true, shouldShowBenchmark becomes false and the wizard is hidden, but the global store state remains "open". Since useOpenBenchmarkWizard can still set isBenchmarkWizardOpen(true) without checking permissions, this can leave the app in an inconsistent state where the benchmark wizard is logically open but invisible. Consider auto-closing (setIsBenchmarkWizardOpen(false)) when access is missing, or enforcing the permission check at the point where the wizard is opened.

Copilot uses AI. Check for mistakes.

const getDefaultPanelSize = useCallback(() => {
if (!shouldShowPanelContent) return 0;
return getPanelSize(RESIZABLE_PANEL_IDS.SECONDARY_LEFT_SIDEBAR) ?? 20;
}, [getPanelSize, shouldShowPanelContent]);

useEffect(() => {
if (isBenchmarkWizardOpen) {
if (shouldShowBenchmark) {
setIsSidebarMinimized(true);
}
}, [isBenchmarkWizardOpen, setIsSidebarMinimized]);
}, [shouldShowBenchmark, setIsSidebarMinimized]);

useEffect(() => {
if (!resizablePanelRef.current) {
Expand All @@ -67,7 +75,7 @@ const SecondaryLeftSidePanelContainer = ({

const shouldUpdatePanel = shouldUpdatePanelVisibility(
prevVisibilityRef.current,
isBenchmarkWizardOpen,
shouldShowBenchmark,
shouldShowAiChat,
);

Expand All @@ -82,20 +90,20 @@ const SecondaryLeftSidePanelContainer = ({
}

prevVisibilityRef.current = {
shouldShowBenchmark: isBenchmarkWizardOpen,
shouldShowBenchmark,
shouldShowAiChat,
};
}, [
shouldShowPanelContent,
getPanelSize,
isBenchmarkWizardOpen,
shouldShowBenchmark,
shouldShowAiChat,
]);

const size = getSize(
hasActiveAiSettings,
isAiChatOpened,
isBenchmarkWizardOpen,
shouldShowBenchmark,
);

return (
Expand All @@ -113,7 +121,7 @@ const SecondaryLeftSidePanelContainer = ({
collapsedSize={0}
defaultSize={getDefaultPanelSize()}
>
{isBenchmarkWizardOpen && (
{shouldShowBenchmark && (
<div className="w-full h-full dark:bg-background">
<BenchmarkWizard onClose={() => setIsBenchmarkWizardOpen(false)} />
</div>
Expand Down
Loading