Skip to content

Commit 7ac7c79

Browse files
authored
feat(ui): expand AI interpret result panel (#851)
## What type of PR is this? /kind feature ## What this PR does / why we need it: Expands the AI Interpret Result panel so longer AI responses are easier to read. The panel now opens in an expanded reading mode when interpretation starts, and includes a header control to collapse or expand the result panel. ## Which issue(s) this PR fixes: Fixes #796 ## Validation - `npm run lint` - `npm run build` compiles, with existing CSS order warnings from #784 on upstream `main` - Local browser smoke test at `http://localhost:8000`
1 parent 9404ca9 commit 7ac7c79

3 files changed

Lines changed: 65 additions & 9 deletions

File tree

ui/src/components/yaml/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ import styles from './styles.module.less'
2828
hljs.registerLanguage('yaml', require('highlight.js/lib/languages/yaml'))
2929

3030
type InterpretStatus =
31-
| 'idle'
32-
| 'init'
33-
| 'streaming'
34-
| 'complete'
35-
| 'error'
36-
| 'loading'
31+
'idle' | 'init' | 'streaming' | 'complete' | 'error' | 'loading'
3732

3833
type IProps = {
3934
data: any

ui/src/pages/insightDetail/components/exceptionList/index.tsx

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
PoweroffOutlined,
99
CloseOutlined,
1010
RedoOutlined,
11+
FullscreenOutlined,
12+
FullscreenExitOutlined,
1113
} from '@ant-design/icons'
1214
import Loading from '@/components/loading'
1315
import { SEVERITY_MAP } from '@/utils/constants'
@@ -42,6 +44,7 @@ const ExceptionList = ({
4244
const [currentKey, setCurrentKey] = useState('All')
4345
const { t, i18n } = useTranslation()
4446
const [isShowList, setIsShowList] = useState(true)
47+
const [isInterpretExpanded, setInterpretExpanded] = useState(false)
4548

4649
// AI interpret states
4750
const [interpret, setInterpret] = useState('')
@@ -91,6 +94,7 @@ const ExceptionList = ({
9194
// Reset interpret state
9295
setInterpret('')
9396
setInterpretStatus('loading')
97+
setInterpretExpanded(true)
9498
setStreaming(true)
9599

96100
// Cancel any existing SSE connection
@@ -237,6 +241,10 @@ const ExceptionList = ({
237241

238242
const contentToTopHeight = contentRef.current?.getBoundingClientRect()?.top
239243
const dotToTopHeight = interpretEndRef.current?.getBoundingClientRect()?.top
244+
const interpretPanelHeight =
245+
interpretBodyRef.current?.offsetHeight ||
246+
exceptionRef.current?.offsetHeight ||
247+
0
240248

241249
const renderInterpretWindow = () => {
242250
if (interpretStatus === 'idle') {
@@ -245,8 +253,14 @@ const ExceptionList = ({
245253

246254
return (
247255
<div
248-
className={styles.interpret_panel}
249-
style={{ height: exceptionRef?.current?.offsetHeight }}
256+
className={classNames(styles.interpret_panel, {
257+
[styles.interpret_panel_expanded]: isInterpretExpanded,
258+
})}
259+
style={{
260+
height: isInterpretExpanded
261+
? undefined
262+
: exceptionRef?.current?.offsetHeight,
263+
}}
250264
>
251265
<div className={styles.interpret_header}>
252266
<Space>
@@ -256,6 +270,26 @@ const ExceptionList = ({
256270
{t('ExceptionList.InterpretResult')}
257271
</Space>
258272
<Space>
273+
<Tooltip
274+
title={
275+
isInterpretExpanded
276+
? t('ExceptionList.Collapse')
277+
: t('ExceptionList.Expand')
278+
}
279+
placement="bottom"
280+
>
281+
<Button
282+
type="text"
283+
icon={
284+
isInterpretExpanded ? (
285+
<FullscreenExitOutlined />
286+
) : (
287+
<FullscreenOutlined />
288+
)
289+
}
290+
onClick={() => setInterpretExpanded(prev => !prev)}
291+
/>
292+
</Tooltip>
259293
{isStreaming && (
260294
<Tooltip
261295
title={t('ExceptionList.StopInterpret')}
@@ -284,6 +318,7 @@ const ExceptionList = ({
284318
}
285319
setInterpretStatus('idle')
286320
setInterpret('')
321+
setInterpretExpanded(false)
287322
setStreaming(false)
288323
}}
289324
/>
@@ -312,7 +347,7 @@ const ExceptionList = ({
312347
</div>
313348
{interpretStatus === 'streaming' && interpret && (
314349
<div
315-
className={`${styles.streaming_indicator} ${dotToTopHeight - contentToTopHeight + 57 - exceptionRef.current?.offsetHeight >= 0 ? styles.streaming_indicatorFixed : ''}`}
350+
className={`${styles.streaming_indicator} ${dotToTopHeight - contentToTopHeight + 57 - interpretPanelHeight >= 0 ? styles.streaming_indicatorFixed : ''}`}
316351
>
317352
<span className={styles.dot}></span>
318353
<span className={styles.dot}></span>

ui/src/pages/insightDetail/components/exceptionList/style.module.less

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366

367367
.interpret_panel {
368368
width: 400px;
369+
flex: 0 0 400px;
369370
border-radius: 12px;
370371
box-shadow:
371372
0 8px 24px rgba(149, 128, 247, 0.08),
@@ -851,6 +852,31 @@
851852
}
852853
}
853854
}
855+
856+
.interpret_panel_expanded {
857+
width: min(720px, 48vw);
858+
height: min(720px, calc(100vh - 160px));
859+
max-height: calc(100vh - 160px);
860+
min-width: 520px;
861+
flex-basis: min(720px, 48vw);
862+
}
863+
}
864+
865+
@media (width <= 1200px) {
866+
.exceptionContainer {
867+
flex-direction: column;
868+
869+
.interpret_panel,
870+
.interpret_panel_expanded {
871+
width: 100%;
872+
min-width: 0;
873+
flex-basis: auto;
874+
}
875+
876+
.interpret_panel_expanded {
877+
height: min(640px, calc(100vh - 160px));
878+
}
879+
}
854880
}
855881

856882
@keyframes dotPulse {

0 commit comments

Comments
 (0)