remove unnecessary type assertions and clean up session loading logic

This commit is contained in:
ferenci84 2025-11-10 22:42:23 +01:00
parent a3b5ee840f
commit ea6e871db5
2 changed files with 7 additions and 19 deletions

View file

@ -1,7 +1,6 @@
import { XMarkIcon } from "@heroicons/react/24/outline";
import React, { useCallback, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useAppSelector } from "../../redux/hooks";
import styled from "styled-components";
import { defaultBorderRadius } from "..";
import { newSession } from "../../redux/slices/sessionSlice";
@ -15,8 +14,6 @@ import {
import { AppDispatch, RootState } from "../../redux/store";
import { loadSession, saveCurrentSession } from "../../redux/thunks/session";
import { varWithFallback } from "../../styles/theme";
import { useAuth } from "../../context/Auth";
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
// Haven't set up theme colors for tabs yet
// Will keep it simple and choose from existing ones. Comments show vars we could use

View file

@ -120,10 +120,7 @@ export const loadSession = createAsyncThunk<
dispatch(newSession(session));
// Restore selected chat model from session, if present
const chatModelTitle = (session as any).chatModelTitle as
| string
| null
| undefined;
const chatModelTitle = session.chatModelTitle;
if (chatModelTitle) {
const state = getState();
const org = state.profiles.organizations.find(
@ -140,7 +137,7 @@ export const loadSession = createAsyncThunk<
role: "chat",
modelTitle: chatModelTitle,
selectedProfile,
}) as any,
}),
);
}
}
@ -173,10 +170,7 @@ export const loadRemoteSession = createAsyncThunk<
dispatch(newSession(session));
// Restore selected chat model from session, if present
const chatModelTitle = (session as any).chatModelTitle as
| string
| null
| undefined;
const chatModelTitle = session.chatModelTitle;
if (chatModelTitle) {
const state = getState();
const org = state.profiles.organizations.find(
@ -193,7 +187,7 @@ export const loadRemoteSession = createAsyncThunk<
role: "chat",
modelTitle: chatModelTitle,
selectedProfile,
}) as any,
}),
);
}
}
@ -228,10 +222,7 @@ export const loadLastSession = createAsyncThunk<void, void, ThunkApiType>(
dispatch(newSession(session));
// Restore selected chat model from session, if present
const chatModelTitle = (session as any).chatModelTitle as
| string
| null
| undefined;
const chatModelTitle = session.chatModelTitle;
if (chatModelTitle) {
const state = getState();
const org = state.profiles.organizations.find(
@ -248,7 +239,7 @@ export const loadLastSession = createAsyncThunk<void, void, ThunkApiType>(
role: "chat",
modelTitle: chatModelTitle,
selectedProfile,
}) as any,
}),
);
}
}
@ -339,7 +330,7 @@ export const saveCurrentSession = createAsyncThunk<
history: state.session.history,
mode: state.session.mode,
chatModelTitle: selectedChatModel?.title ?? null,
} as Session;
};
const result = await dispatch(updateSession(session));
unwrapResult(result);