Skip to content

Commit ea6e871

Browse files
committed
remove unnecessary type assertions and clean up session loading logic
1 parent a3b5ee8 commit ea6e871

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

gui/src/components/TabBar/TabBar.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { XMarkIcon } from "@heroicons/react/24/outline";
22
import React, { useCallback, useEffect } from "react";
33
import { useDispatch, useSelector } from "react-redux";
4-
import { useAppSelector } from "../../redux/hooks";
54
import styled from "styled-components";
65
import { defaultBorderRadius } from "..";
76
import { newSession } from "../../redux/slices/sessionSlice";
@@ -15,8 +14,6 @@ import {
1514
import { AppDispatch, RootState } from "../../redux/store";
1615
import { loadSession, saveCurrentSession } from "../../redux/thunks/session";
1716
import { varWithFallback } from "../../styles/theme";
18-
import { useAuth } from "../../context/Auth";
19-
import { selectSelectedChatModel } from "../../redux/slices/configSlice";
2017

2118
// Haven't set up theme colors for tabs yet
2219
// Will keep it simple and choose from existing ones. Comments show vars we could use

gui/src/redux/thunks/session.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,7 @@ export const loadSession = createAsyncThunk<
120120
dispatch(newSession(session));
121121

122122
// Restore selected chat model from session, if present
123-
const chatModelTitle = (session as any).chatModelTitle as
124-
| string
125-
| null
126-
| undefined;
123+
const chatModelTitle = session.chatModelTitle;
127124
if (chatModelTitle) {
128125
const state = getState();
129126
const org = state.profiles.organizations.find(
@@ -140,7 +137,7 @@ export const loadSession = createAsyncThunk<
140137
role: "chat",
141138
modelTitle: chatModelTitle,
142139
selectedProfile,
143-
}) as any,
140+
}),
144141
);
145142
}
146143
}
@@ -173,10 +170,7 @@ export const loadRemoteSession = createAsyncThunk<
173170
dispatch(newSession(session));
174171

175172
// Restore selected chat model from session, if present
176-
const chatModelTitle = (session as any).chatModelTitle as
177-
| string
178-
| null
179-
| undefined;
173+
const chatModelTitle = session.chatModelTitle;
180174
if (chatModelTitle) {
181175
const state = getState();
182176
const org = state.profiles.organizations.find(
@@ -193,7 +187,7 @@ export const loadRemoteSession = createAsyncThunk<
193187
role: "chat",
194188
modelTitle: chatModelTitle,
195189
selectedProfile,
196-
}) as any,
190+
}),
197191
);
198192
}
199193
}
@@ -228,10 +222,7 @@ export const loadLastSession = createAsyncThunk<void, void, ThunkApiType>(
228222
dispatch(newSession(session));
229223

230224
// Restore selected chat model from session, if present
231-
const chatModelTitle = (session as any).chatModelTitle as
232-
| string
233-
| null
234-
| undefined;
225+
const chatModelTitle = session.chatModelTitle;
235226
if (chatModelTitle) {
236227
const state = getState();
237228
const org = state.profiles.organizations.find(
@@ -248,7 +239,7 @@ export const loadLastSession = createAsyncThunk<void, void, ThunkApiType>(
248239
role: "chat",
249240
modelTitle: chatModelTitle,
250241
selectedProfile,
251-
}) as any,
242+
}),
252243
);
253244
}
254245
}
@@ -339,7 +330,7 @@ export const saveCurrentSession = createAsyncThunk<
339330
history: state.session.history,
340331
mode: state.session.mode,
341332
chatModelTitle: selectedChatModel?.title ?? null,
342-
} as Session;
333+
};
343334

344335
const result = await dispatch(updateSession(session));
345336
unwrapResult(result);

0 commit comments

Comments
 (0)