Skip to content
Closed
Show file tree
Hide file tree
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
45 changes: 1 addition & 44 deletions src/components/layout/AiModelQuickSelect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { AiModelQuickSelect } from "./AiModelQuickSelect";

const STORAGE_KEY = "tangle.aiProvider.config";
const FLAGS_STORAGE_KEY = "betaFlags";

function enableFlags(flags: Record<string, boolean>) {
window.localStorage.setItem(FLAGS_STORAGE_KEY, JSON.stringify(flags));
}

describe("AiModelQuickSelect", () => {
beforeEach(() => {
window.localStorage.clear();
Expand All @@ -22,31 +16,12 @@ describe("AiModelQuickSelect", () => {
});

it("does not render until AI provider settings are configured", () => {
enableFlags({ "ai-assistant": true });

render(<AiModelQuickSelect />);

expect(screen.queryByRole("combobox", { name: "AI model" })).toBeNull();
});

it("does not render when both AI features are disabled", () => {
enableFlags({ "ai-assistant": false, "component-search-v2": false });
window.localStorage.setItem(
STORAGE_KEY,
JSON.stringify({
apiBase: "https://api.example.com/v1",
apiKey: "",
model: "gpt-4.1-mini",
}),
);

render(<AiModelQuickSelect />);

expect(screen.queryByRole("combobox", { name: "AI model" })).toBeNull();
});

it("shows configured model choices when component search is enabled", () => {
enableFlags({ "component-search-v2": true });
it("shows configured model choices", () => {
window.localStorage.setItem(
STORAGE_KEY,
JSON.stringify({
Expand All @@ -68,22 +43,4 @@ describe("AiModelQuickSelect", () => {
screen.getByRole("option", { name: "GPT-4.1 mini" }),
).toBeInTheDocument();
});

it("shows configured model choices when the AI assistant is enabled", () => {
enableFlags({ "ai-assistant": true });
window.localStorage.setItem(
STORAGE_KEY,
JSON.stringify({
apiBase: "https://api.example.com/v1",
apiKey: "",
model: "gpt-4.1-mini",
}),
);

render(<AiModelQuickSelect />);

expect(
screen.getByRole("combobox", { name: "AI model" }),
).toBeInTheDocument();
});
});
7 changes: 1 addition & 6 deletions src/components/layout/AiModelQuickSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useFlagValue } from "@/components/shared/Settings/useFlags";
import {
Select,
SelectContent,
Expand All @@ -16,8 +15,6 @@ import {
import { useAiProviderSettings } from "@/hooks/useAiProviderSettings";

export function AiModelQuickSelect() {
const componentSearchEnabled = useFlagValue("component-search-v2");
const aiAssistantEnabled = useFlagValue("ai-assistant");
const { config, update, isConfigured } = useAiProviderSettings();
const configuredModel = config.model.trim();
const options = getAiModelOptions();
Expand All @@ -28,9 +25,7 @@ export function AiModelQuickSelect() {
update({ model: value });
};

if ((!componentSearchEnabled && !aiAssistantEnabled) || !isConfigured) {
return null;
}
if (!isConfigured) return null;

return (
<Select value={selectedValue} onValueChange={handleValueChange}>
Expand Down
8 changes: 0 additions & 8 deletions src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ export const ExistingFlags: ConfigFlags = {
category: "beta",
},

["ai-assistant"]: {
name: "AI Assistant",
description:
"Enable the AI Assistant panel in the V2 editor. Lets you chat with an assistant about your pipeline.",
default: false,
category: "beta",
},

["component-search-v2"]: {
name: "Component Search",
description:
Expand Down
22 changes: 7 additions & 15 deletions src/routes/Settings/SettingsLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Link, Outlet, useRouter } from "@tanstack/react-router";

import { useFlagValue } from "@/components/shared/Settings/useFlags";
import { Button } from "@/components/ui/button";
import { Icon, type IconName } from "@/components/ui/icon";
import { BlockStack, InlineStack } from "@/components/ui/layout";
Expand Down Expand Up @@ -41,23 +40,16 @@ const SIDEBAR_ITEMS: SidebarItem[] = [
icon: "Lock",
testId: "settings-nav-secrets",
},
{
to: "/settings/agent",
label: "AI Configuration",
icon: "Bot",
testId: "settings-nav-agent",
},
];

const AGENT_ITEM: SidebarItem = {
to: "/settings/agent",
label: "AI Configuration",
icon: "Bot",
testId: "settings-nav-agent",
};

export function SettingsLayout() {
const router = useRouter();
const componentSearchEnabled = useFlagValue("component-search-v2");
const aiAssistantEnabled = useFlagValue("ai-assistant");
const sidebarItems =
componentSearchEnabled || aiAssistantEnabled
? [...SIDEBAR_ITEMS, AGENT_ITEM]
: SIDEBAR_ITEMS;

const handleGoBack = () => {
router.history.back();
Expand Down Expand Up @@ -90,7 +82,7 @@ export function SettingsLayout() {
gap="1"
className="w-48 shrink-0 border-r border-border pr-4"
>
{sidebarItems.map((item) => (
{SIDEBAR_ITEMS.map((item) => (
<Link
key={item.to}
to={item.to}
Expand Down
8 changes: 0 additions & 8 deletions src/routes/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,6 @@ const settingsAgentRoute = createRoute({
getParentRoute: () => settingsLayoutRoute,
path: "/agent",
component: AgentSettings,
beforeLoad: () => {
if (
!isFlagEnabled("component-search-v2") &&
!isFlagEnabled("ai-assistant")
) {
throw redirect({ to: APP_ROUTES.SETTINGS_BACKEND });
}
},
});

const settingsSecretsRoute = createRoute({
Expand Down
3 changes: 1 addition & 2 deletions src/routes/v2/pages/Editor/EditorV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ const PipelineEditor = withSuspenseWrapper(
useDebugPanelWindow();
useTipOfTheDayWindow();

const aiEnabled = useFlagValue("ai-assistant");
useAiChatWindow(aiEnabled);
useAiChatWindow();

useComponentSearchV2Window(componentSearchV2Enabled);
useSeedInitialDockLayoutFromPreset(componentSearchV2Enabled);
Expand Down
8 changes: 2 additions & 6 deletions src/routes/v2/pages/Editor/hooks/useAiChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,11 @@ const SUGGESTED_PROMPTS_EDITOR: SuggestedPrompt[] = [
},
];

export function useAiChatWindow(enabled: boolean) {
export function useAiChatWindow() {
const { windows } = useSharedStores();
const editorSession = useEditorSession();

useEffect(() => {
if (!enabled) {
windows.closeWindow(AI_CHAT_WINDOW_ID);
return;
}
if (windows.getWindowById(AI_CHAT_WINDOW_ID)) return;

windows.openWindow(
Expand Down Expand Up @@ -55,5 +51,5 @@ export function useAiChatWindow(enabled: boolean) {
),
},
);
}, [enabled, windows, editorSession]);
}, [windows, editorSession]);
}
4 changes: 1 addition & 3 deletions src/routes/v2/pages/RunView/RunViewV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { useEffect, useRef } from "react";
import { InfoBox } from "@/components/shared/InfoBox";
import { LoadingScreen } from "@/components/shared/LoadingScreen";
import { RemoteAuthErrorView } from "@/components/shared/RemoteAuthErrorView";
import { useFlagValue } from "@/components/shared/Settings/useFlags";
import { BlockStack, InlineStack } from "@/components/ui/layout";
import { Paragraph } from "@/components/ui/typography";
import { useTrackRecentlyViewedRun } from "@/hooks/useTrackRecentlyViewedRun";
Expand Down Expand Up @@ -176,8 +175,7 @@ const RunViewLayout = observer(function RunViewLayout({
useFocusTaskFromUrl(spec);
useCanvasControlsWindow("v2.run_view");

const aiEnabled = useFlagValue("ai-assistant");
useAiChatWindow(aiEnabled);
useAiChatWindow();

const { navigation } = useSharedStores();
const activeSpec = navigation.activeSpec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const RUN_WINDOW_IDS = [
function renderRunWindowHooks() {
return renderHook(() => {
useRunViewWindows();
useAiChatWindow(true);
useAiChatWindow();
});
}

Expand Down
8 changes: 2 additions & 6 deletions src/routes/v2/pages/RunView/hooks/useAiChatWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,10 @@ const RunAiChatContent = observer(function RunAiChatContent() {
);
});

export function useAiChatWindow(enabled: boolean) {
export function useAiChatWindow() {
const { windows } = useSharedStores();

useEffect(() => {
if (!enabled) {
windows.closeWindow(RUN_AI_ASSISTANT_WINDOW_ID);
return;
}
if (windows.getWindowById(RUN_AI_ASSISTANT_WINDOW_ID)) return;

windows.openWindow(<RunAiChatContent />, {
Expand All @@ -101,5 +97,5 @@ export function useAiChatWindow(enabled: boolean) {
/>
),
});
}, [enabled, windows]);
}, [windows]);
}
Loading