add stream error state and component
This commit is contained in:
parent
d7ef0a3b1b
commit
04df03d86f
3 changed files with 29 additions and 1 deletions
|
|
@ -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`}
|
||||
>
|
||||
|
|
|
|||
12
gui/src/pages/gui/StreamError.tsx
Normal file
12
gui/src/pages/gui/StreamError.tsx
Normal 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;
|
||||
|
|
@ -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;
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue