Skip to content
Merged
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
612 changes: 56 additions & 556 deletions e2e/tests/console/aiAssistant.spec.js

Large diffs are not rendered by default.

1,126 changes: 1,126 additions & 0 deletions e2e/tests/console/aiProviderSetup.spec.js

Large diffs are not rendered by default.

54 changes: 48 additions & 6 deletions e2e/utils/aiAssistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ const CUSTOM_PROVIDER_DEFAULTS = {
function getOpenAIConfiguredSettings(schemaAccess = true) {
return {
"ai.assistant.settings": JSON.stringify({
selectedModel: "gpt-5-mini",
modelValueFormat: 2,
selectedModel: "openai:gpt-5-mini",
providers: {
openai: {
apiKey: "test-openai-key",
enabledModels: ["gpt-5-mini", "gpt-5"],
enabledModels: ["openai:gpt-5-mini", "openai:gpt-5"],
grantSchemaAccess: schemaAccess,
},
},
Expand All @@ -48,11 +49,12 @@ function getOpenAIPermissionedSettings({
}) {
return {
"ai.assistant.settings": JSON.stringify({
selectedModel: "gpt-5-mini",
modelValueFormat: 2,
selectedModel: "openai:gpt-5-mini",
providers: {
openai: {
apiKey: "test-openai-key",
enabledModels: ["gpt-5-mini", "gpt-5"],
enabledModels: ["openai:gpt-5-mini", "openai:gpt-5"],
grantSchemaAccess,
read,
write,
Expand All @@ -65,11 +67,15 @@ function getOpenAIPermissionedSettings({
function getAnthropicConfiguredSettings(schemaAccess = true) {
return {
"ai.assistant.settings": JSON.stringify({
selectedModel: "claude-sonnet-4-5",
modelValueFormat: 2,
selectedModel: "anthropic:claude-sonnet-4-5",
providers: {
anthropic: {
apiKey: "test-anthropic-key",
enabledModels: ["claude-sonnet-4-5", "claude-opus-4-5"],
enabledModels: [
"anthropic:claude-sonnet-4-5",
"anthropic:claude-opus-4-5",
],
grantSchemaAccess: schemaAccess,
},
},
Expand Down Expand Up @@ -101,6 +107,7 @@ function getCustomProviderConfiguredSettings(config = {}, mergeWith = null) {

const settings = {
...baseSettings,
modelValueFormat: 2,
selectedModel: enabledModels[0],
customProviders: {
...(baseSettings.customProviders || {}),
Expand Down Expand Up @@ -1163,7 +1170,42 @@ function createMultiTurnFlow(config) {
}
}

/**
* Intercepts AI chat requests with a default test response.
*
* @param {"anthropic" | "openai"} provider - The AI provider to intercept
* @param {string} [alias] - Optional custom alias for the intercept
* @param {number} [delay=200] - Delay in milliseconds
* @param {Object} [options] - Options
* @param {boolean} [options.streaming=true] - Whether to use streaming response
*/
function interceptAIChatRequest(
provider,
alias,
delay = 200,
options = { streaming: true },
) {
const aliasName = alias || `${provider}ChatRequest`
const endpoint = PROVIDERS[provider].endpoint
const { streaming = true } = options

const responseData = createFinalResponseData(
provider,
"Test response explanation",
)

cy.intercept("POST", endpoint, (req) => {
if (isTitleRequest(provider, req.body)) {
req.reply(createChatTitleResponse(provider, "Test Chat"))
return
}
req.alias = aliasName
req.reply(createResponse(provider, responseData, { streaming, delay }))
})
}

module.exports = {
interceptAIChatRequest,
PROVIDERS,
CUSTOM_PROVIDER_DEFAULTS,
getOpenAIConfiguredSettings,
Expand Down
56 changes: 2 additions & 54 deletions src/components/AIStatusIndicator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import { color } from "../../utils"
import { slideAnimation } from "../Animation"
import { AISparkle } from "../AISparkle"
import { assistantLinearGradientHorizontal } from "../../theme"
import { getAllModelOptions } from "../../utils/ai"
import { useAIConversation } from "../../providers/AIConversationProvider"
import { Button } from "../../components/Button"
import { AIStopButton } from "../AIStopButton"
import { BrainIcon } from "../SetupAIAssistant/BrainIcon"
import { AssistantModes, buildOperationSections } from "./AssistantModes"
import { CircleNotchSpinner } from "../../scenes/Editor/Monaco/icons"
import { useSelector } from "react-redux"
Expand Down Expand Up @@ -220,34 +218,6 @@ const ChevronButton = styled(Button).attrs({ variant: "ghost" })`
margin-right: 1rem;
`

const ExtendedThinkingLabel = styled.div`
display: flex;
gap: 0.8rem;
align-items: center;
justify-content: center;
width: 100%;
flex-shrink: 0;
`

const BrainIconWrapper = styled.div`
width: 1.6rem;
height: 1.6rem;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
`

const ExtendedThinkingText = styled.p`
flex: 1 0 0;
font-weight: 400;
font-size: 1.1rem;
color: ${color("contentSecondary")};
min-height: 0;
min-width: 0;
margin: 0;
`

const AssistantModesContainer = styled.div`
display: flex;
flex-direction: column;
Expand All @@ -264,14 +234,8 @@ const AssistantModesContainer = styled.div`
`

export const AIStatusIndicator: React.FC = () => {
const {
status,
currentOperation,
currentModel,
abortOperation,
clearOperation,
aiAssistantSettings,
} = useAIStatus()
const { status, currentOperation, abortOperation, clearOperation } =
useAIStatus()
const { chatWindowState, openChatWindow } = useAIConversation()
const [expanded, setExpanded] = useState(false)
const [isClosed, setIsClosed] = useState(false)
Expand All @@ -280,11 +244,6 @@ export const AIStatusIndicator: React.FC = () => {
const assistantModesRef = useRef<HTMLDivElement | null>(null)
const activeSidebar = useSelector(selectors.console.getActiveSidebar)
const statusRef = useRef<AIOperationStatus | null>(null)
const hasExtendedThinking = useMemo(() => {
return getAllModelOptions(aiAssistantSettings).find(
(model) => model.value === currentModel,
)?.isSlow
}, [currentModel, aiAssistantSettings])

const operationSections = useMemo(
() => buildOperationSections(currentOperation, status, true),
Expand Down Expand Up @@ -416,17 +375,6 @@ export const AIStatusIndicator: React.FC = () => {
)}
</Header>

{hasExtendedThinking && (
<ExtendedThinkingLabel>
<BrainIconWrapper>
<BrainIcon />
</BrainIconWrapper>
<ExtendedThinkingText>
Extended thinking model enabled. Responses may be slow.
</ExtendedThinkingText>
</ExtendedThinkingLabel>
)}

{expanded && (
<AssistantModesContainer ref={assistantModesRef}>
<AssistantModes
Expand Down
10 changes: 9 additions & 1 deletion src/components/AlertDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from "react"
import * as RadixAlertDialog from "@radix-ui/react-alert-dialog"
import styled, { css } from "styled-components"
import { modalSurfaceStyles } from "../overlayStyles"
import { ModalLayer } from "../ModalLayer"

const dialogShow = css`
@keyframes dialogShow {
Expand All @@ -24,8 +26,14 @@ const dialogHide = css`
}
`

const Root = (props: React.ComponentProps<typeof RadixAlertDialog.Root>) => (
<ModalLayer modal>
<RadixAlertDialog.Root {...props} />
</ModalLayer>
)

export const AlertDialog = {
Root: RadixAlertDialog.Root,
Root,
Overlay: RadixAlertDialog.Overlay,
Trigger: RadixAlertDialog.Trigger,
Portal: RadixAlertDialog.Portal,
Expand Down
13 changes: 12 additions & 1 deletion src/components/Dialog/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react"
import * as RadixDialog from "@radix-ui/react-dialog"
import styled, { css } from "styled-components"
import { Button } from "../Button"
import { modalSurfaceStyles } from "../overlayStyles"
import { ModalLayer } from "../ModalLayer"

const dialogShow = css`
@keyframes dialogShow {
Expand All @@ -25,8 +27,17 @@ const dialogHide = css`
}
`

const Root = ({
modal = true,
...props
}: React.ComponentProps<typeof RadixDialog.Root>) => (
<ModalLayer modal={modal}>
<RadixDialog.Root modal={modal} {...props} />
</ModalLayer>
)

export const Dialog = {
Root: RadixDialog.Root,
Root,
Overlay: RadixDialog.Overlay,
Trigger: RadixDialog.Trigger,
Portal: RadixDialog.Portal,
Expand Down
5 changes: 3 additions & 2 deletions src/components/Drawer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from "react"
import * as RadixDialog from "@radix-ui/react-dialog"
import { Dialog } from "../Dialog"
import styled, { css } from "styled-components"
import { useSelector, useDispatch } from "react-redux"
import { selectors, actions } from "../../store"
Expand Down Expand Up @@ -219,7 +220,7 @@ export const Drawer = ({
)

return (
<RadixDialog.Root
<Dialog.Root
onOpenChange={onOpenChange}
open={open}
modal={mode === "modal"}
Expand Down Expand Up @@ -275,7 +276,7 @@ export const Drawer = ({
{children}
</DrawerContent>
</RadixDialog.Portal>
</RadixDialog.Root>
</Dialog.Root>
)
}

Expand Down
16 changes: 16 additions & 0 deletions src/components/ModalLayer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { createContext, useContext } from "react"

const ModalLayerContext = createContext(false)

type ModalLayerProps = {
modal: boolean
children: React.ReactNode
}

export const ModalLayer = ({ modal, children }: ModalLayerProps) => (
<ModalLayerContext.Provider value={modal}>
{children}
</ModalLayerContext.Provider>
)

export const useIsInModalLayer = () => useContext(ModalLayerContext)
Loading
Loading