From b0d2b09a2e0517da5ab3b2f8f8a1feeb5e970839 Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Wed, 28 Jan 2026 16:03:38 -0800 Subject: [PATCH] AIX: Fix show injector --- .../aix/client/debugger/AixDebuggerDialog.tsx | 105 ++++++++++++------ .../aix/client/debugger/AixDebuggerFrame.tsx | 8 +- .../client/debugger/DebugPayloadOverride.tsx | 4 +- 3 files changed, 77 insertions(+), 40 deletions(-) diff --git a/src/modules/aix/client/debugger/AixDebuggerDialog.tsx b/src/modules/aix/client/debugger/AixDebuggerDialog.tsx index fc51855fa..99816c11f 100644 --- a/src/modules/aix/client/debugger/AixDebuggerDialog.tsx +++ b/src/modules/aix/client/debugger/AixDebuggerDialog.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; -import { Box, Button, Divider, FormControl, FormLabel, Link, Option, Select, Switch, Typography } from '@mui/joy'; +import { Box, Button, Chip, Divider, FormControl, FormLabel, Link, Option, Select, Switch, Typography } from '@mui/joy'; import ClearAllIcon from '@mui/icons-material/ClearAll'; +import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown'; import { GoodModal } from '~/common/components/modals/GoodModal'; import { KeyStroke } from '~/common/components/KeyStroke'; @@ -10,13 +11,38 @@ import { useUIPreferencesStore } from '~/common/stores/store-ui'; import { AixDebuggerFrame } from './AixDebuggerFrame'; import { DebugPayloadOverride } from './DebugPayloadOverride'; -import { GoodTooltip } from '~/common/components/GoodTooltip'; -import { aixClientDebuggerActions, aixClientDebuggerSetRBO, useAixClientDebuggerStore } from './memstore-aix-client-debugger'; +import { aixClientDebuggerActions, useAixClientDebuggerStore } from './memstore-aix-client-debugger'; // configuration const DEBUGGER_DEBOUNCE_MS = 1000 / 5; // 5Hz +const _styles = { + zeroState: { + minHeight: '228px', // take up some space even when empty + + // backgroundColor: 'background.level1', + borderBottom: '1px solid', + borderBottomColor: 'divider', + + margin: 'calc(-1 * var(--Card-padding, 1rem))', mb: 0, padding: 'var(--Card-padding, 1rem)', // fill card + + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + justifyContent: 'center', + }, + frameViewer: { + overflow: 'auto', // scroll this part of the dialog, i.e. the full debugging frame + + // backgroundColor: 'background.level1', + borderBottom: '1px solid', + borderBottomColor: 'divider', + + margin: 'calc(-1 * var(--Card-padding, 1rem))', mb: 0, padding: 'var(--Card-padding, 1rem)', // fill card + }, +} as const; + function _getStoreSnapshot() { const state = useAixClientDebuggerStore.getState(); @@ -75,7 +101,7 @@ export function AixDebuggerDialog(props: { // external state const isMobile = useIsMobile(); - const aixInspector = useUIPreferencesStore(state => state.aixInspector); + const hasInspector = useUIPreferencesStore(state => state.aixInspector); const hasInjectorJson = useAixClientDebuggerStore(state => !!state.requestBodyOverrideJson); const { frames, activeFrameId, maxFrames } = useDebouncedAixDebuggerStore(); @@ -83,8 +109,8 @@ export function AixDebuggerDialog(props: { const [showInjector, setShowInjector] = React.useState(hasInjectorJson); // derived state - const isInjector = aixInspector && (showInjector || hasInjectorJson); const activeFrame = frames.find(f => f.id === activeFrameId) ?? null; + const willInjectJson = hasInspector && hasInjectorJson; // handlers @@ -97,40 +123,52 @@ export function AixDebuggerDialog(props: { aixClientDebuggerActions().setActiveFrame(value); }, []); + const handleToggleInjector = React.useCallback(() => { + setShowInjector(on => !on); + // NOTE: we don't clear injection on close anymore, as we have a good 'active' tag to show injection + // if (showInjector || hasInjectorJson) { + // // aixClientDebuggerSetRBO(''); // turning off - clear the RBO + // setShowInjector(false); + // } else { + // setShowInjector(true); + // } + }, []); + return ( - {aixInspector && ( - - { - if (!target.checked) aixClientDebuggerSetRBO(''); - setShowInjector(target.checked); - }} - /> - - )} - AI Request {isInjector ? 'Injector' : 'Inspector'} - - - } + unfilterBackdrop + autoOverflow + fullscreen={isMobile || 'button'} titleStartDecorator={ } - autoOverflow - fullscreen={isMobile || 'button'} + title={isMobile ? 'AI Inspector' : + + AI Request {(willInjectJson || showInjector) ? 'Injector' : 'Inspector'} + + + } + startButton={ + + } sx={{ maxWidth: undefined }} > @@ -194,13 +232,13 @@ export function AixDebuggerDialog(props: { {/* Zero State */} {(!frames.length || !activeFrame) && ( - + {!frames.length && <> - {aixInspector ? 'Ready to capture' : 'AI Request Inspector'} + {hasInspector ? 'Ready to capture' : 'AI Request Inspector'} - {aixInspector + {hasInspector ? 'Your next AI request will be captured here.' : <> + )} {/* Debug Payload Override */} - {isInjector && } - {isInjector && } + {showInjector && } ); diff --git a/src/modules/aix/client/debugger/AixDebuggerFrame.tsx b/src/modules/aix/client/debugger/AixDebuggerFrame.tsx index 22e063b06..12e642c45 100644 --- a/src/modules/aix/client/debugger/AixDebuggerFrame.tsx +++ b/src/modules/aix/client/debugger/AixDebuggerFrame.tsx @@ -66,7 +66,7 @@ export function AixDebuggerFrame(props: { const isConversation = contextName === 'conversation'; return ( - + {/* Frame Header */} @@ -78,13 +78,13 @@ export function AixDebuggerFrame(props: { {frame.isComplete ? 'Done' : 'In Progress'}
Date
- {new Date(frame.timestamp).toLocaleString()} +
{new Date(frame.timestamp).toLocaleString()}
-> URL:
- {frame.url || 'No URL data available'} +
{frame.url || 'No URL data available'}
Context:
{contextName}
Reference:
- {frame.context.contextRef} +
{frame.context.contextRef}
{/* Headers */} diff --git a/src/modules/aix/client/debugger/DebugPayloadOverride.tsx b/src/modules/aix/client/debugger/DebugPayloadOverride.tsx index 8130f2d76..f15f743e7 100644 --- a/src/modules/aix/client/debugger/DebugPayloadOverride.tsx +++ b/src/modules/aix/client/debugger/DebugPayloadOverride.tsx @@ -88,8 +88,8 @@ export function DebugPayloadOverride() {