OpenHands/frontend/src/stores/command-store.ts

27 lines
672 B
TypeScript

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: [] }),
}));