Skip to content

Commit b09cbf3

Browse files
feat(content-sidebar): added support for feedback tooltip in Box AI (#4059)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent db6c93e commit b09cbf3

File tree

6 files changed

+31
-10
lines changed

6 files changed

+31
-10
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
"@box/blueprint-web": "^9.18.11",
126126
"@box/blueprint-web-assets": "4.36.0",
127127
"@box/box-ai-agent-selector": "^0.31.0",
128-
"@box/box-ai-content-answers": "^0.113.0",
128+
"@box/box-ai-content-answers": "^0.120.0",
129129
"@box/cldr-data": "^34.2.0",
130130
"@box/combobox-with-api": "^0.28.4",
131131
"@box/frontend": "^11.0.0",
@@ -300,7 +300,7 @@
300300
"@box/blueprint-web": "^9.18.11",
301301
"@box/blueprint-web-assets": "^4.36.0",
302302
"@box/box-ai-agent-selector": "^0.31.0",
303-
"@box/box-ai-content-answers": "^0.113.0",
303+
"@box/box-ai-content-answers": "^0.120.0",
304304
"@box/cldr-data": ">=34.2.0",
305305
"@box/combobox-with-api": "^0.28.4",
306306
"@box/item-icon": "^0.9.83",

src/elements/content-sidebar/BoxAISidebar.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import * as React from 'react';
66
import { useIntl } from 'react-intl';
7-
import {type ItemType, SuggestedQuestionType} from '@box/box-ai-content-answers';
7+
import { type FeedbackFormData, type ItemType, SuggestedQuestionType } from '@box/box-ai-content-answers';
88
import { AgentsProvider, RecordActionType } from '@box/box-ai-agent-selector';
99
import BoxAISidebarContent from './BoxAISidebarContent';
1010
import { BoxAISidebarContext } from './context/BoxAISidebarContext';
@@ -43,6 +43,7 @@ export interface BoxAISidebarProps {
4343
isCitationsEnabled: boolean;
4444
isDebugModeEnabled: boolean;
4545
isFeedbackEnabled: boolean;
46+
isFeedbackFormEnabled: boolean;
4647
isIntelligentQueryMode: boolean;
4748
isMarkdownEnabled: boolean;
4849
isResetChatEnabled: boolean;
@@ -51,6 +52,7 @@ export interface BoxAISidebarProps {
5152
items: Array<ItemType>;
5253
itemSize?: string;
5354
localizedQuestions: Array<{ id: string; label: string; prompt: string }>;
55+
onFeedbackFormSubmit?: (data: FeedbackFormData, onSuccess: () => void) => void;
5456
onUserInteraction?: () => void;
5557
recordAction: (params: RecordActionType) => void;
5658
setCacheValue: BoxAISidebarCacheSetter;
@@ -68,10 +70,12 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
6870
getSuggestedQuestions,
6971
isIntelligentQueryMode,
7072
isFeedbackEnabled,
73+
isFeedbackFormEnabled,
7174
isStopResponseEnabled,
7275
items,
7376
itemSize,
7477
localizedQuestions,
78+
onFeedbackFormSubmit,
7579
onUserInteraction,
7680
recordAction,
7781
setCacheValue,
@@ -88,9 +92,11 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
8892
elementId,
8993
fileExtension,
9094
isFeedbackEnabled,
95+
isFeedbackFormEnabled,
9196
isStopResponseEnabled,
9297
items,
9398
itemSize,
99+
onFeedbackFormSubmit,
94100
onUserInteraction,
95101
recordAction,
96102
setCacheValue,
@@ -102,9 +108,11 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
102108
elementId,
103109
fileExtension,
104110
isFeedbackEnabled,
111+
isFeedbackFormEnabled,
105112
isStopResponseEnabled,
106113
items,
107114
itemSize,
115+
onFeedbackFormSubmit,
108116
onUserInteraction,
109117
recordAction,
110118
setCacheValue,
@@ -156,7 +164,9 @@ const BoxAISidebar = (props: BoxAISidebarProps) => {
156164
restoredSession={cache.encodedSession}
157165
restoredShouldShowLandingPage={cache.shouldShowLandingPage}
158166
shouldPreinitSession={shouldPreinitSession}
159-
suggestedQuestions={cache.suggestedQuestions.length > 0 ? cache.suggestedQuestions : suggestedQuestions}
167+
suggestedQuestions={
168+
cache.suggestedQuestions.length > 0 ? cache.suggestedQuestions : suggestedQuestions
169+
}
160170
warningNotice={spreadsheetNotice}
161171
warningNoticeAriaLabel={formatMessage(messages.welcomeMessageSpreadsheetNoticeAriaLabel)}
162172
{...rest}

src/elements/content-sidebar/BoxAISidebarContent.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ function BoxAISidebarContent(props: ApiWrapperWithInjectedProps & { shouldShowLa
6161
elementId,
6262
fileExtension,
6363
isFeedbackEnabled,
64+
isFeedbackFormEnabled,
6465
isStopResponseEnabled,
6566
items,
6667
itemSize,
68+
onFeedbackFormSubmit,
6769
onUserInteraction,
6870
recordAction,
6971
setCacheValue,
@@ -207,9 +209,11 @@ function BoxAISidebarContent(props: ApiWrapperWithInjectedProps & { shouldShowLa
207209
hostAppName={hostAppName}
208210
isAIStudioAgentSelectorEnabled={isAIStudioAgentSelectorEnabled}
209211
isFeedbackEnabled={isFeedbackEnabled}
212+
isFeedbackFormEnabled={isFeedbackFormEnabled}
210213
isStopResponseEnabled={isStopResponseEnabled}
211214
items={items}
212215
questions={questions}
216+
onFeedbackFormSubmit={onFeedbackFormSubmit}
213217
onUserIntentToUseAI={handleUserIntentToUseAI}
214218
shouldShowLandingPage={cache.shouldShowLandingPage}
215219
showLoadingIndicator={isLoading && shouldPreinitSession}
@@ -230,11 +234,13 @@ function BoxAISidebarContent(props: ApiWrapperWithInjectedProps & { shouldShowLa
230234
hostAppName={hostAppName}
231235
isAIStudioAgentSelectorEnabled={isAIStudioAgentSelectorEnabled}
232236
isFeedbackEnabled={isFeedbackEnabled}
237+
isFeedbackFormEnabled={isFeedbackFormEnabled}
233238
isResetChatEnabled={isResetChatEnabled}
234239
isStopResponseEnabled={isStopResponseEnabled}
235240
items={items}
236241
itemSize={itemSize}
237242
onClearAction={onClearAction}
243+
onFeedbackFormSubmit={onFeedbackFormSubmit}
238244
onOpenChange={handleModalClose}
239245
onSelectAgent={onSelectAgent}
240246
onUserIntentToUseAI={handleUserIntentToUseAI}

src/elements/content-sidebar/__tests__/BoxAISidebar.test.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,13 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
112112
isCitationsEnabled: true,
113113
isDebugModeEnabled: true,
114114
isFeedbackEnabled: true,
115+
isFeedbackFormEnabled: true,
115116
isIntelligentQueryMode: true,
116117
isMarkdownEnabled: true,
117118
isResetChatEnabled: true,
118119
isStopResponseEnabled: true,
119120
isStreamingEnabled: true,
121+
onFeedbackFormSubmit: jest.fn(),
120122
onUserInteraction: jest.fn(),
121123
recordAction: jest.fn(),
122124
sendQuestion: jest.fn(),
@@ -246,7 +248,7 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
246248
});
247249

248250
test('should render cached custom suggested questions', async () => {
249-
await renderComponent( {
251+
await renderComponent({
250252
cache: {
251253
encodedSession: '1234',
252254
questions: [],

src/elements/content-sidebar/context/BoxAISidebarContext.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import noop from 'lodash/noop';
33
import { RecordActionType as AgentSelectorRecordActionType } from '@box/box-ai-agent-selector';
44
import { RecordActionType as ContentAnswersRecordActionType } from '@box/box-ai-content-answers';
5-
import type { ItemType } from '@box/box-ai-content-answers';
5+
import type { FeedbackFormData, ItemType } from '@box/box-ai-content-answers';
66
import type { BoxAISidebarCache, BoxAISidebarCacheSetter } from '../types/BoxAISidebarTypes';
77

88
type BoxAISidebarRecordActionType =
@@ -20,9 +20,11 @@ export interface BoxAISidebarContextValues {
2020
elementId: string;
2121
fileExtension: string;
2222
isFeedbackEnabled: boolean;
23+
isFeedbackFormEnabled: boolean;
2324
isStopResponseEnabled: boolean;
2425
items: Array<ItemType>;
2526
itemSize?: string;
27+
onFeedbackFormSubmit?: (data: FeedbackFormData, onSuccess: () => void) => void;
2628
onUserInteraction?: () => void;
2729
recordAction: (params: BoxAISidebarRecordActionType) => void;
2830
setCacheValue: BoxAISidebarCacheSetter;
@@ -35,6 +37,7 @@ export const BoxAISidebarContext = React.createContext<BoxAISidebarContextValues
3537
elementId: '',
3638
fileExtension: '',
3739
isFeedbackEnabled: false,
40+
isFeedbackFormEnabled: false,
3841
isStopResponseEnabled: false,
3942
items: [],
4043
recordAction: noop,

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1512,10 +1512,10 @@
15121512
resolved "https://registry.yarnpkg.com/@box/box-ai-agent-selector/-/box-ai-agent-selector-0.31.0.tgz#a2ef6c3c7284529ae268b609d04b6000348bb294"
15131513
integrity sha512-4+M/4g8LHJfZkP+7ISBKveQs2q5HeGvXv8B6/N8yFb9cpYuOjpKFxRvHyILdQWjwictHZbgY2XrNrpxbYGEXRQ==
15141514

1515-
"@box/box-ai-content-answers@^0.113.0":
1516-
version "0.113.0"
1517-
resolved "https://registry.yarnpkg.com/@box/box-ai-content-answers/-/box-ai-content-answers-0.113.0.tgz#6bd92abac22e06ea067983b7f42cd91d8ea35f8b"
1518-
integrity sha512-vY70YANv2RAwkSEEsIbhJBlEOTKxo3hP5SZ71fgpVb+7jMKLjDBranUN/18uu3orri6q998E2vOhN0BwRO2GfA==
1515+
"@box/box-ai-content-answers@^0.120.0":
1516+
version "0.120.0"
1517+
resolved "https://registry.yarnpkg.com/@box/box-ai-content-answers/-/box-ai-content-answers-0.120.0.tgz#67f09757a90010be045bd00423a1416656a027cd"
1518+
integrity sha512-cgd6zf/8owgVQYE4eO/XPoPNF3iZQeJRsxKNsVRKAbQ/1UtaxIcBhDUMN5AhNu40qWGN1JdJ5YRjbvXZ15F8jw==
15191519

15201520
"@box/cldr-data@^34.2.0":
15211521
version "34.8.0"

0 commit comments

Comments
 (0)