mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
27 lines
672 B
TypeScript
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: [] }),
|
|
}));
|