openhands / src /stores /command-store.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
5f40163 verified
Raw
History Blame Contribute Delete
672 Bytes
import { create } from "zustand";
export type Command = {
content: string;
type: "input" | "output";
};
interface CommandState {
commands: Command[];
appendInput: (content: string) => void;
appendOutput: (content: string) => void;
clearTerminal: () => void;
}
export const useCommandStore = create<CommandState>((set) => ({
commands: [],
appendInput: (content: string) =>
set((state) => ({
commands: [...state.commands, { content, type: "input" }],
})),
appendOutput: (content: string) =>
set((state) => ({
commands: [...state.commands, { content, type: "output" }],
})),
clearTerminal: () => set({ commands: [] }),
}));