Skip to content

Commit 6aa0eb4

Browse files
fix: minor UX issues for Chat (opensearch-project#11408)
* fix: minor UX issues for Chat Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * Changeset file for PR opensearch-project#11408 created/updated * fix: UT Signed-off-by: SuZhou-Joe <suzhou@amazon.com> * feat: address comment Signed-off-by: SuZhou-Joe <suzhou@amazon.com> --------- Signed-off-by: SuZhou-Joe <suzhou@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent cb739df commit 6aa0eb4

7 files changed

Lines changed: 74 additions & 20 deletions

File tree

changelogs/fragments/11408.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fix:
2+
- Minor UX issues for Chat ([#11408](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/11408))

src/plugins/chat/public/components/chat_container.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717
margin: 0 auto;
1818
}
1919
}
20+
21+
.chat-sidecar {
22+
border-left: 1px solid $euiBorderColor;
23+
}

src/plugins/chat/public/components/error_row.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const ErrorRow: React.FC<ErrorRowProps> = ({ error }) => {
2121
<div className="errorRow__content">
2222
<div className="errorRow__info">
2323
<EuiText size="s" style={{ fontWeight: 600, color: '#BD271E' }}>
24-
System Error
24+
Something went wrong
2525
</EuiText>
2626
</div>
2727
<div className="errorRow__message">

src/plugins/chat/public/services/ag_ui_agent.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ describe('AgUiAgent', () => {
8787
const mockResponse = {
8888
ok: false,
8989
status: 500,
90+
text: jest.fn().mockResolvedValue(''),
9091
};
9192

9293
mockFetch.mockResolvedValue(mockResponse as any);
@@ -96,10 +97,10 @@ describe('AgUiAgent', () => {
9697
observable.subscribe({
9798
next: (event) => {
9899
expect(event.type).toBe(EventType.RUN_ERROR);
99-
expect(event.message).toBe('HTTP error! status: 500');
100+
expect(event.message).toBe('Request failed with status 500');
100101
},
101102
error: (error) => {
102-
expect(error.message).toBe('HTTP error! status: 500');
103+
expect(error.message).toBe('Request failed with status 500');
103104
done();
104105
},
105106
});

src/plugins/chat/public/services/ag_ui_agent.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,18 @@ export class AgUiAgent {
6262
})
6363
.then(async (response) => {
6464
if (!response.ok) {
65-
throw new Error(`HTTP error! status: ${response.status}`);
65+
const errorText = await response.text();
66+
let errorMessage = `Request failed with status ${response.status}`;
67+
68+
try {
69+
const errorBody = JSON.parse(errorText);
70+
const reason = errorBody.error?.reason || errorBody.message || errorText;
71+
errorMessage = reason ? `${reason} (Status: ${response.status})` : errorMessage;
72+
} catch {
73+
errorMessage = errorText ? `${errorText} (Status: ${response.status})` : errorMessage;
74+
}
75+
76+
throw new Error(errorMessage);
6677
}
6778

6879
const reader = response.body?.getReader();

src/plugins/data/public/ui/query_string_input/_query_bar.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
flex-grow: 0 !important;
8585
flex-basis: auto !important;
8686

87+
> div {
88+
width: auto;
89+
}
90+
8791
&.osdQueryBar__datePickerWrapper-isHidden {
8892
width: 0;
8993
overflow: hidden;

src/plugins/dev_tools/public/dev_tools_icon.tsx

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import React, { useRef, useCallback, useState, useEffect } from 'react';
6+
import React, { useRef, useCallback, useState, useEffect, useMemo } from 'react';
77
import {
88
EuiButtonIcon,
99
EuiFlexGroup,
@@ -37,6 +37,14 @@ export function DevToolsIcon({
3737
}) {
3838
const [modalVisible, setModalVisible] = useState(false);
3939
const [devToolTab, setDevToolTab] = useState('');
40+
const [sidecarPaddingRight, setSidecarPaddingRight] = useState('0px');
41+
42+
useEffect(() => {
43+
const subscription = core.overlays.sidecar.getSidecarConfig$().subscribe((config) => {
44+
setSidecarPaddingRight(config?.dockedMode === 'right' ? `${config.paddingSize}px` : '0px');
45+
});
46+
return () => subscription.unsubscribe();
47+
}, [core.overlays.sidecar]);
4048

4149
// Use refs to avoid closure issues
4250
const modalVisibleRef = useRef(modalVisible);
@@ -103,9 +111,36 @@ export function DevToolsIcon({
103111
};
104112
}, [modalVisible, core.keyboardShortcut, closeModal]);
105113

106-
const closeModalVisible = () => {
114+
const closeModalVisible = useCallback(() => {
107115
setModalVisible(false);
108-
};
116+
}, []);
117+
118+
const memoizedMainApp = useMemo(
119+
() => (
120+
<MainApp
121+
devTools={devTools}
122+
savedObjects={core.savedObjects}
123+
notifications={core.notifications}
124+
dataSourceEnabled={!!deps.dataSource}
125+
dataSourceManagement={deps.dataSourceManagement}
126+
useUpdatedUX
127+
setMenuMountPoint={setMountPoint}
128+
RouterComponent={MemoryRouter}
129+
defaultRoute={devToolTab}
130+
onManageDataSource={closeModalVisible}
131+
/>
132+
),
133+
[
134+
devTools,
135+
core.savedObjects,
136+
core.notifications,
137+
deps.dataSource,
138+
deps.dataSourceManagement,
139+
setMountPoint,
140+
devToolTab,
141+
closeModalVisible,
142+
]
143+
);
109144

110145
return (
111146
<>
@@ -130,7 +165,15 @@ export function DevToolsIcon({
130165
* but overlay mask has a default padding bottom that prevent the modal from covering the whole page.
131166
*/
132167
<EuiOverlayMask className="devToolsOverlayMask" headerZindexLocation="below">
133-
<div style={{ width: '100vw', height: '100vh', maxWidth: '100vw' }}>
168+
<div
169+
style={{
170+
width: '100vw',
171+
height: '100vh',
172+
maxWidth: '100vw',
173+
marginRight: sidecarPaddingRight,
174+
position: 'relative',
175+
}}
176+
>
134177
<EuiButtonIcon
135178
iconType="cross"
136179
onClick={() => setModalVisible(false)}
@@ -159,18 +202,7 @@ export function DevToolsIcon({
159202
</EuiFlexGroup>
160203
</EuiFlexItem>
161204
<EuiFlexItem className="devAppWrapper">
162-
<MainApp
163-
devTools={devTools}
164-
savedObjects={core.savedObjects}
165-
notifications={core.notifications}
166-
dataSourceEnabled={!!deps.dataSource}
167-
dataSourceManagement={deps.dataSourceManagement}
168-
useUpdatedUX
169-
setMenuMountPoint={setMountPoint}
170-
RouterComponent={MemoryRouter}
171-
defaultRoute={devToolTab}
172-
onManageDataSource={closeModalVisible}
173-
/>
205+
{memoizedMainApp}
174206
<EuiSpacer size="s" />
175207
<EuiSmallButton
176208
iconType="cross"

0 commit comments

Comments
 (0)