add stream error state and component

This commit is contained in:
Dallin Romney 2024-12-10 23:09:50 -08:00
parent d7ef0a3b1b
commit 04df03d86f
3 changed files with 29 additions and 1 deletions

View file

@ -75,6 +75,7 @@ import {
loadLastSession,
saveCurrentSession,
} from "../../redux/thunks/session";
import StreamError from "./StreamError";
const StopButton = styled.div`
background-color: ${vscBackground};
@ -551,6 +552,9 @@ export function Chat() {
)}
</div>
</div>
<div className="flex flex-col">
<StreamError />
</div>
<div
className={`${history.length === 0 ? "h-full" : ""} flex flex-col justify-end`}
>

View file

@ -0,0 +1,12 @@
import { useAppSelector } from "../../redux/hooks";
const StreamError = () => {
const streamError = useAppSelector((state) => state.session.streamError);
if (streamError) {
return null;
}
return <div className="flex flex-col px-3">Hello</div>;
};
export default StreamError;

View file

@ -53,6 +53,10 @@ type SessionState = {
states: ApplyState[];
curIndex: number;
};
streamError?: {
statusCode: number;
message: string;
};
};
function isCodeToEditEqual(a: CodeToEdit, b: CodeToEdit) {
@ -348,6 +352,15 @@ export const sessionSlice = createSlice({
}
}
},
setStreamError: (
state,
{ payload }: PayloadAction<{ statusCode: number; message: string }>,
) => {
state.streamError = payload;
},
clearStreamError: (state) => {
state.streamError = undefined;
},
newSession: (state, { payload }: PayloadAction<Session | undefined>) => {
state.lastSessionId = state.id;
@ -369,7 +382,6 @@ export const sessionSlice = createSlice({
state.curCheckpointIndex = 0;
}
},
updateSessionTitle: (state, { payload }: PayloadAction<string>) => {
state.title = payload;
},