diff --git a/frontend/src/components/features/conversation/conversation-main.tsx b/frontend/src/components/features/conversation/conversation-main.tsx index bc673e24b0..8b1f061e20 100644 --- a/frontend/src/components/features/conversation/conversation-main.tsx +++ b/frontend/src/components/features/conversation/conversation-main.tsx @@ -57,18 +57,13 @@ export function ConversationMain() { - + state.conversation, ); + // Persist selectedTab and isRightPanelShown in localStorage + const [persistedSelectedTab, setPersistedSelectedTab] = + useLocalStorage( + "conversation-selected-tab", + "editor", + ); + + const [persistedIsRightPanelShown, setPersistedIsRightPanelShown] = + useLocalStorage("conversation-right-panel-shown", true); + const onTabChange = (value: ConversationTab | null) => { dispatch(setSelectedTab(value)); + // Persist the selected tab to localStorage + setPersistedSelectedTab(value); }; + // Initialize Redux state from localStorage on component mount + useEffect(() => { + // Initialize selectedTab from localStorage if available + dispatch(setSelectedTab(persistedSelectedTab)); + dispatch(setIsRightPanelShown(persistedIsRightPanelShown)); + dispatch(setHasRightPanelToggled(persistedIsRightPanelShown)); + }, []); + useEffect(() => { const handlePanelVisibilityChange = () => { if (isRightPanelShown) { @@ -51,11 +73,13 @@ export function ConversationTabs() { if (selectedTab === tab && isRightPanelShown) { // If clicking the same active tab, close the drawer dispatch(setHasRightPanelToggled(false)); + setPersistedIsRightPanelShown(false); } else { // If clicking a different tab or drawer is closed, open drawer and select tab onTabChange(tab); if (!isRightPanelShown) { dispatch(setHasRightPanelToggled(true)); + setPersistedIsRightPanelShown(true); } } }; diff --git a/frontend/src/state/conversation-slice.tsx b/frontend/src/state/conversation-slice.tsx index d2044fbeec..e25d59cdc9 100644 --- a/frontend/src/state/conversation-slice.tsx +++ b/frontend/src/state/conversation-slice.tsx @@ -117,8 +117,6 @@ export const conversationSlice = createSlice({ }, // Reset conversation state (useful for cleanup) resetConversationState: (state) => { - state.selectedTab = "editor"; - state.isRightPanelShown = true; state.shouldHideSuggestions = false; }, setHasRightPanelToggled: (state, action) => {