Skip to content

Commit c68e2d4

Browse files
Merge pull request microsoft#86 from Roopan-Microsoft/revert-84-PSL_BUG_7819
Revert "fix: Psl bug 7819"
2 parents 4e543b8 + a38554c commit c68e2d4

File tree

5 files changed

+10
-34
lines changed

5 files changed

+10
-34
lines changed

frontend/src/components/Sidebar/Sidebar.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
align-items: center;
4545
border-radius: 8px;
4646
margin: 8px;
47-
cursor: not-allowed;
47+
4848
padding: 8px, 8px, 8px, 8px;
4949
background: var(--Colors-Alpha-Black-5, #0000000D);
5050

frontend/src/components/Sidebar/Sidebar.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ const NavigationButton = ({ text, buttonState, onClick }: NavigationButtonProps)
2828
}[buttonState]
2929

3030
const iconElements: { [key: string]: JSX.Element } = {
31-
'Browse': <News28Regular color={fontColor} cursor={ buttonState === NavigationButtonStates.Disabled ? 'not-allowed': 'pointer'}/>,
32-
'Generate': <Book28Regular color={fontColor} cursor={ buttonState === NavigationButtonStates.Disabled ? 'not-allowed': 'pointer'}/>,
33-
'Draft': <Notepad28Regular color={fontColor} cursor={ buttonState === NavigationButtonStates.Disabled ? 'not-allowed': 'pointer'}/>
31+
'Browse': <News28Regular color={fontColor}/>,
32+
'Generate': <Book28Regular color={fontColor}/>,
33+
'Draft': <Notepad28Regular color={fontColor}/>
3434
}
3535

3636
const buttonStyle = {
@@ -58,7 +58,6 @@ const Sidebar = (): JSX.Element => {
5858
const navigate = useNavigate()
5959
const location = useLocation();
6060
const [name, setName] = useState<string>("")
61-
const [isLoading, setIsLoading] = useState<boolean>()
6261

6362
useEffect(() => {
6463
if (!appStateContext) { throw new Error('useAppState must be used within a AppStateProvider') }
@@ -73,10 +72,6 @@ const Sidebar = (): JSX.Element => {
7372
}
7473
}, [])
7574

76-
useEffect(() => {
77-
setIsLoading(appStateContext?.state.isGenerating)
78-
}, [appStateContext?.state.isGenerating])
79-
8075
// determine url from react-router-dom
8176
const determineView = () => {
8277
const url = location.pathname
@@ -91,14 +86,15 @@ const Sidebar = (): JSX.Element => {
9186
// inactive, disabled, active
9287
var draftButtonState = NavigationButtonStates.Disabled
9388
if (appStateContext?.state.draftedDocument) { draftButtonState = currentView === 'draft' ? NavigationButtonStates.Active : NavigationButtonStates.Inactive }
89+
9490
return (
9591
<Stack className={styles.sidebarContainer}>
9692
<Stack horizontal className={styles.avatarContainer}>
97-
<Avatar color="colorful" name={name} />
93+
<Avatar color="colorful" name={name} />
9894
</Stack>
99-
<Stack className={styles.sidebarNavigationContainer}>
100-
<NavigationButton text={"Browse"} buttonState={currentView === 'chat' ? NavigationButtonStates.Active : (appStateContext?.state.isGenerating ? NavigationButtonStates.Disabled : NavigationButtonStates.Inactive)} onClick={() => { navigate("/chat") }} />
101-
<NavigationButton text={"Generate"} buttonState={currentView === 'generate' ? NavigationButtonStates.Active : (appStateContext?.state.isGenerating ? NavigationButtonStates.Disabled : NavigationButtonStates.Inactive)} onClick={() => { navigate("/generate") }} />
95+
<Stack className={styles.sidebarNavigationContainer}>
96+
<NavigationButton text={"Browse"} buttonState={currentView === 'chat' ? NavigationButtonStates.Active : NavigationButtonStates.Inactive} onClick={() => { navigate("/chat") }} />
97+
<NavigationButton text={"Generate"} buttonState={currentView === 'generate' ? NavigationButtonStates.Active : NavigationButtonStates.Inactive} onClick={() => { navigate("/generate") }} />
10298
<NavigationButton text={"Draft"} buttonState={draftButtonState} onClick={() => { navigate("/draft") }} />
10399
</Stack>
104100
</Stack>

frontend/src/pages/chat/Chat.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
155155
processTemplateResponse()
156156
}, [location])
157157

158-
useEffect(() => {
159-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: appStateContext?.state.isGenerating})
160-
}, [isLoading])
161-
162158
useEffect(() => {
163159
if (
164160
appStateContext?.state.isCosmosDBAvailable?.status !== CosmosDBStatus.Working &&
@@ -283,7 +279,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
283279

284280
const makeApiRequestWithoutCosmosDB = async (question: string, conversationId?: string) => {
285281
setIsLoading(true)
286-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: true })
287282
setShowLoadingMessage(true)
288283
const abortController = new AbortController()
289284
abortFuncs.current.unshift(abortController)
@@ -400,7 +395,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
400395
} finally {
401396
setIsLoading(false)
402397
setShowLoadingMessage(false)
403-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
404398
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
405399
setProcessMessages(messageStatus.Done)
406400
}
@@ -410,7 +404,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
410404

411405
const makeApiRequestWithCosmosDB = async (question: string, conversationId?: string) => {
412406
setIsLoading(true)
413-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: true })
414407
setShowLoadingMessage(true)
415408
const abortController = new AbortController()
416409
abortFuncs.current.unshift(abortController)
@@ -430,7 +423,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
430423
if (!conversation) {
431424
console.error('Conversation not found.')
432425
setIsLoading(false)
433-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
434426
setShowLoadingMessage(false)
435427
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
436428
return
@@ -476,7 +468,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
476468
} else {
477469
setMessages([...messages, userMessage, errorChatMsg])
478470
setIsLoading(false)
479-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
480471
setShowLoadingMessage(false)
481472
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
482473
return
@@ -538,7 +529,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
538529
if (!resultConversation) {
539530
console.error('Conversation not found.')
540531
setIsLoading(false)
541-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
542532
setShowLoadingMessage(false)
543533
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
544534
return
@@ -559,7 +549,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
559549
}
560550
if (!resultConversation) {
561551
setIsLoading(false)
562-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
563552
setShowLoadingMessage(false)
564553
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
565554
return
@@ -593,7 +582,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
593582
if (!resultConversation) {
594583
console.error('Conversation not found.')
595584
setIsLoading(false)
596-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
597585
setShowLoadingMessage(false)
598586
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
599587
return
@@ -610,7 +598,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
610598
}
611599
setMessages([...messages, userMessage, errorChatMsg])
612600
setIsLoading(false)
613-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
614601
setShowLoadingMessage(false)
615602
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
616603
return
@@ -625,7 +612,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
625612
}
626613
if (!resultConversation) {
627614
setIsLoading(false)
628-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
629615
setShowLoadingMessage(false)
630616
abortFuncs.current = abortFuncs.current.filter(a => a !== abortController)
631617
return
@@ -761,7 +747,6 @@ const Chat = ({ type = ChatType.Browse }: Props) => {
761747
abortFuncs.current.forEach(a => a.abort())
762748
setShowLoadingMessage(false)
763749
setIsLoading(false)
764-
appStateContext?.dispatch({ type: 'GENERATE_ISLODING', payload: false })
765750
}
766751

767752
useEffect(() => {

frontend/src/state/AppProvider.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export interface AppState {
2929
feedbackState: { [answerId: string]: Feedback.Neutral | Feedback.Positive | Feedback.Negative }
3030
draftedDocument: DraftedDocument | null
3131
draftedDocumentTitle: string
32-
isGenerating: boolean
3332
}
3433

3534
export type Action =
@@ -55,7 +54,6 @@ export type Action =
5554
| { type: 'UPDATE_BROWSE_CHAT'; payload: Conversation | null }
5655
| { type: 'UPDATE_GENERATE_CHAT'; payload: Conversation | null }
5756
| { type: 'UPDATE_DRAFTED_DOCUMENT_TITLE'; payload: string }
58-
| { type: 'GENERATE_ISLODING'; payload: boolean }
5957

6058
const initialState: AppState = {
6159
isChatHistoryOpen: false,
@@ -72,8 +70,7 @@ const initialState: AppState = {
7270
frontendSettings: null,
7371
feedbackState: {},
7472
draftedDocument: null,
75-
draftedDocumentTitle: '',
76-
isGenerating: false
73+
draftedDocumentTitle: ''
7774
}
7875

7976
export const AppStateContext = createContext<

frontend/src/state/AppReducer.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ export const appStateReducer = (state: AppState, action: Action): AppState => {
101101
return { ...state, generateChat: action.payload }
102102
case 'UPDATE_DRAFTED_DOCUMENT_TITLE':
103103
return { ...state, draftedDocumentTitle: action.payload }
104-
case 'GENERATE_ISLODING':
105-
return { ...state, isGenerating: action.payload }
106104
default:
107105
return state
108106
}

0 commit comments

Comments
 (0)