Skip to content

Commit e9e83b8

Browse files
fix: citation remains open even after deleting complete chat history
fix: citation remains open even after deleting complete chat history
2 parents 83950cf + e310d0d commit e9e83b8

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

src/App/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ const Dashboard: React.FC = () => {
203203
type: actionConstants.UPDATE_APP_SPINNER_STATUS,
204204
payload: true,
205205
});
206+
dispatch({ type: actionConstants.UPDATE_CITATION,payload: { activeCitation: null, showCitation: false }})
206207
setClearing(true);
207208
const response = await historyDeleteAll();
208209
if (!response.ok) {
@@ -355,7 +356,7 @@ const Dashboard: React.FC = () => {
355356
/>
356357
</div>
357358
)}
358-
{state.citation.showCitation && (
359+
{state.citation.showCitation && state.citation.currentConversationIdForCitation !== "" && (
359360
<div
360361
style={{
361362
// width: `${panelWidths[panels.DASHBOARD]}%`,

src/App/src/components/ChatHistoryListItemCell/ChatHistoryListItemCell.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export const ChatHistoryListItemCell: React.FC<
7373
type: actionConstants.UPDATE_APP_SPINNER_STATUS,
7474
payload: true,
7575
});
76+
if(state.citation.currentConversationIdForCitation === item.id) {
77+
dispatch({ type: actionConstants.UPDATE_CITATION,payload: { activeCitation: null, showCitation: false, currentConversationIdForCitation: "" } });
78+
}else{
79+
dispatch({ type: actionConstants.UPDATE_CITATION,payload: { showCitation: true } });
80+
}
7681
const response = await historyDelete(item.id);
7782
if (!response.ok) {
7883
setErrorDelete(true);

src/App/src/components/Citations/Citations.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const Citations = ({ answer, index }: Props) => {
3232
) => {
3333
dispatch({
3434
type: actionConstants.UPDATE_CITATION,
35-
payload: { showCitation: true, activeCitation: citation },
35+
payload: { showCitation: true, activeCitation: citation, currentConversationIdForCitation: state?.selectedConversationId},
3636
});
3737
};
3838

src/App/src/state/AppProvider.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ export type AppState = {
3333
citations: string |null;
3434
};
3535
citation: {
36-
activeCitation: any;
36+
activeCitation?: any;
3737
showCitation: boolean;
38+
currentConversationIdForCitation?: string;
3839
};
3940
chatHistory: {
4041
list: Conversation[];
@@ -77,6 +78,7 @@ const initialState: AppState = {
7778
citation: {
7879
activeCitation: null,
7980
showCitation: false,
81+
currentConversationIdForCitation: '',
8082
},
8183
chatHistory: {
8284
list: [],
@@ -207,7 +209,7 @@ export type Action =
207209
}
208210
| {
209211
type: typeof actionConstants.UPDATE_CITATION;
210-
payload: {activeCitation: any, showCitation: boolean};
212+
payload: {activeCitation?: any, showCitation: boolean, currentConversationIdForCitation?: string};
211213
};
212214

213215
export const AppContext = createContext<{

src/App/src/state/AppReducer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,9 @@ const appReducer = (state: AppState, action: Action): AppState => {
257257
...state,
258258
citation: {
259259
...state.citation,
260-
activeCitation: action.payload.activeCitation,
261-
showCitation: action.payload.showCitation
260+
activeCitation: action.payload.activeCitation || state.citation.activeCitation,
261+
showCitation: action.payload.showCitation,
262+
currentConversationIdForCitation: action.payload?.currentConversationIdForCitation || state.citation.currentConversationIdForCitation,
262263
},
263264
};
264265
default:

0 commit comments

Comments
 (0)