diff --git a/common/types/config.ts b/common/types/config.ts
index 698f00bf..920a9521 100644
--- a/common/types/config.ts
+++ b/common/types/config.ts
@@ -10,6 +10,7 @@ export const configSchema = schema.object({
chat: schema.object({
enabled: schema.boolean({ defaultValue: false }),
trace: schema.boolean({ defaultValue: true }),
+ feedback: schema.boolean({ defaultValue: true }),
}),
incontextInsight: schema.object({
enabled: schema.boolean({ defaultValue: true }),
diff --git a/public/tabs/chat/messages/message_bubble.test.tsx b/public/tabs/chat/messages/message_bubble.test.tsx
index 8fca94ef..c189d035 100644
--- a/public/tabs/chat/messages/message_bubble.test.tsx
+++ b/public/tabs/chat/messages/message_bubble.test.tsx
@@ -19,7 +19,9 @@ describe('', () => {
const reportUiStatsMock = jest.fn();
beforeEach(() => {
- jest.spyOn(services, 'getConfigSchema').mockReturnValue({ chat: { trace: true } });
+ jest
+ .spyOn(services, 'getConfigSchema')
+ .mockReturnValue({ chat: { trace: true, feedback: true } });
jest
.spyOn(useFeedbackHookExports, 'useFeedback')
.mockReturnValue({ feedbackResult: undefined, sendFeedback: sendFeedbackMock });
@@ -336,4 +338,33 @@ describe('', () => {
);
expect(screen.queryByTestId('trace-icon-bar2')).toBeNull();
});
+
+ it('should control feedback buttons through config flag', () => {
+ const { rerender } = render(
+
+ );
+ expect(screen.queryByLabelText('feedback thumbs down')).toBeVisible();
+ expect(screen.queryByLabelText('feedback thumbs up')).toBeVisible();
+
+ jest.spyOn(services, 'getConfigSchema').mockReturnValue({ chat: { feedback: false } });
+ rerender(
+
+ );
+ expect(screen.queryByLabelText('feedback thumbs down')).toBeNull();
+ expect(screen.queryByLabelText('feedback thumbs up')).toBeNull();
+ });
});
diff --git a/public/tabs/chat/messages/message_bubble.tsx b/public/tabs/chat/messages/message_bubble.tsx
index 7764325e..708e5a5c 100644
--- a/public/tabs/chat/messages/message_bubble.tsx
+++ b/public/tabs/chat/messages/message_bubble.tsx
@@ -47,8 +47,11 @@ type MessageBubbleProps = {
export const MessageBubble: React.FC = React.memo((props) => {
const { executeAction } = useChatActions();
const core = useCore();
+ const configSchema = getConfigSchema();
+
// According to the design of the feedback, only markdown type output is supported.
const showFeedback =
+ configSchema.chat.feedback &&
'message' in props &&
props.message.type === 'output' &&
props.message.contentType === 'markdown';
@@ -124,7 +127,6 @@ export const MessageBubble: React.FC = React.memo((props) =>
}
const fullWidth = props.message.fullWidth;
- const configSchema = getConfigSchema();
return (