Clear console only clears from current console

This commit is contained in:
Emir Karabeg
2025-01-31 14:46:31 -08:00
parent 5a5450f19e
commit d84f53d721
3 changed files with 7 additions and 3 deletions

View File

@@ -85,7 +85,7 @@ export function Console() {
<Button
variant="ghost"
size="sm"
onClick={clearConsole}
onClick={() => clearConsole(activeWorkflowId)}
className="text-muted-foreground hover:text-foreground"
>
Clear

View File

@@ -25,7 +25,11 @@ export const useConsoleStore = create<ConsoleStore>()(
})
},
clearConsole: () => set({ entries: [] }),
clearConsole: (workflowId: string | null) => {
set((state) => ({
entries: state.entries.filter(entry => !workflowId || entry.workflowId !== workflowId)
}))
},
getWorkflowEntries: (workflowId) => {
return get().entries.filter((entry) => entry.workflowId === workflowId)

View File

@@ -13,6 +13,6 @@ export interface ConsoleEntry {
export interface ConsoleStore {
entries: ConsoleEntry[]
addConsole: (entry: Omit<ConsoleEntry, 'id'>) => void
clearConsole: () => void
clearConsole: (workflowId: string | null) => void
getWorkflowEntries: (workflowId: string) => ConsoleEntry[]
}