OpenHands / frontend /src /state /command-slice.ts
Backup-bdg's picture
Upload 565 files
b59aa07 verified
raw
history blame
725 Bytes
import { createSlice } from "@reduxjs/toolkit";
export type Command = {
content: string;
type: "input" | "output";
};
const initialCommands: Command[] = [];
export const commandSlice = createSlice({
name: "command",
initialState: {
commands: initialCommands,
},
reducers: {
appendInput: (state, action) => {
state.commands.push({ content: action.payload, type: "input" });
},
appendOutput: (state, action) => {
state.commands.push({ content: action.payload, type: "output" });
},
clearTerminal: (state) => {
state.commands = [];
},
},
});
export const { appendInput, appendOutput, clearTerminal } =
commandSlice.actions;
export default commandSlice.reducer;