Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion gui/src/hooks/ParallelListeners.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import { setTTSActive } from "../redux/slices/uiSlice";
import { modelSupportsReasoning } from "core/llm/autodetect";
import { cancelStream } from "../redux/thunks/cancelStream";
import { handleApplyStateUpdate } from "../redux/thunks/handleApplyStateUpdate";
import { refreshSessionMetadata } from "../redux/thunks/session";
import {
loadLastSession,
refreshSessionMetadata,
} from "../redux/thunks/session";
import { updateFileSymbolsFromHistory } from "../redux/thunks/updateFileSymbols";
import {
setDocumentStylesFromLocalStorage,
Expand Down Expand Up @@ -104,6 +107,7 @@ function ParallelListeners() {
await handleConfigUpdate(true, result.content);
}
dispatch(setConfigLoading(false));
await dispatch(loadLastSession());
}
void initialLoadConfig();
const interval = setInterval(() => {
Expand Down
7 changes: 2 additions & 5 deletions gui/src/pages/gui/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { ToolCallDiv } from "./ToolCallDiv";

import { useStore } from "react-redux";
import { CliInstallBanner } from "../../components/CliInstallBanner";

import { FatalErrorIndicator } from "../../components/config/FatalErrorNotice";
import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage";
import { RootState } from "../../redux/store";
Expand Down Expand Up @@ -441,11 +442,7 @@ export function Chat() {
{history.length === 0 && lastSessionId && !isInEdit && (
<NewSessionButton
onClick={async () => {
await dispatch(
loadLastSession({
saveCurrentSession: true,
}),
);
await dispatch(loadLastSession());
}}
className="flex items-center gap-2"
>
Expand Down
2 changes: 0 additions & 2 deletions gui/src/redux/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const rootReducer = combineReducers({

const saveSubsetFilters = [
createFilter("session", [
"history",
"id",
"lastSessionId",
"title",
Expand Down Expand Up @@ -73,7 +72,6 @@ const migrations: MigrationManifest = {
defaultModelTitle: oldState?.state?.defaultModelTitle ?? undefined,
},
session: {
history: oldState?.state?.history ?? [],
id: oldState?.state?.sessionId ?? "",
},
tabs: {
Expand Down
6 changes: 1 addition & 5 deletions gui/src/redux/thunks/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,7 @@ export const exitEdit = createAsyncThunk<
if (openNewSession || state.editModeState.lastNonEditSessionWasEmpty) {
dispatch(newSession());
} else {
await dispatch(
loadLastSession({
saveCurrentSession: false,
}),
);
await dispatch(loadLastSession());
}

dispatch(setMode(state.editModeState.returnToMode));
Expand Down
36 changes: 18 additions & 18 deletions gui/src/redux/thunks/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ export const deleteSession = createAsyncThunk<void, string, ThunkApiType>(
dispatch(deleteSessionMetadata(id)); // optimistic
const state = getState();
if (id === state.session.id) {
await dispatch(
loadLastSession({
saveCurrentSession: false,
}),
);
await dispatch(loadLastSession());
}
const result = await extra.ideMessenger.request("history/delete", { id });
if (result.status === "error") {
Expand Down Expand Up @@ -146,27 +142,31 @@ export const loadRemoteSession = createAsyncThunk<
},
);

export const loadLastSession = createAsyncThunk<
void,
{
saveCurrentSession: boolean;
},
ThunkApiType
>(
export const loadLastSession = createAsyncThunk<void, void, ThunkApiType>(
"session/loadLast",
async ({ saveCurrentSession }, { extra, dispatch, getState }) => {
const state = getState();
async (_, { extra, dispatch, getState }) => {
let lastSessionId = getState().session.lastSessionId;

if (state.session.id && saveCurrentSession) {
}
const lastSessionId = getState().session.lastSessionId;
// const lastSessionResult = await extra.ideMessenger.request("history/list", {
// limit: 1,
// });
// if (lastSessionResult.status === "success") {
// lastSessionId = lastSessionResult.content.at(0)?.sessionId;
// }

if (!lastSessionId) {
dispatch(newSession());
return;
}

const session = await getSession(extra.ideMessenger, lastSessionId);
let session: Session;
try {
session = await getSession(extra.ideMessenger, lastSessionId);
} catch {
// retry again after 1 sec
await new Promise((resolve) => setTimeout(resolve, 1000));
session = await getSession(extra.ideMessenger, lastSessionId);
}
dispatch(newSession(session));
},
);
Expand Down
Loading