mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-20 04:21:23 +00:00
* feat: custom node component * feat: create resizable panels for graph ui * feat: setup hono rpc on agent * feat: created getClient util * feat: created rpc client provider * chore: reafctor agent sdk * chore: created usechat hook * chore: graph create update endpoint return ai sdk stream * chore: graph create update endpoint return ai sdk stream * chore: graph create update endpoint return ai sdk stream * chore: graph create update endpoint return ai sdk stream * feat: graph chat component * feat: integrate input field * feat: make getActionForMessage optional * feat: integrate chat messages ui * feat: update graph canvas with latest message * feat: support editing graph with new message * feat: create chat test function * fix: created chat test api integration * chore: remove background window state * chore: improve agent ui stream * chore: print error * feat: create workflow storage * feat: created workflows screen on options page * feat: added error handling to workflows chat * chore: ignore graph code generation folder * fix: provide a better header title name * fix: buttons accessibility on graph canvas * feat: improve test and save workflow button state * chore: provide autofocus to the workflow header * feat: setup save and edit options on the workflow * feat: open the workflow in edit mode * fix: use sentry to capture server exception * feat: integrate run workflow using dialog box * feat: display errors in the run dialog box * fix: use rpc client to delete workflows * feat: fix panel sizes on graph creation * fix: provide suspense fallback boundary for the options page * feat: auto fitview on graph updates * fix: node colors in the graph * chore: make minimap movable * feat: provide styling to react flow controls * fix: missing imports * fix: pass personalization to workflow runs * feat: provide back button in workflow page * feat: added confirmation when leaving workflow page without saving * feat: provide animation to nodes * feat: autofit canvas to resizepanel size * feat: added workflows to newtab page * fix: typescript lint errors * feat: enforce bun version * fix: typecheck command --------- Co-authored-by: shivammittal274 <mittal.shivam103@gmail.com>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import { storage } from '@wxt-dev/storage'
|
|
import { useEffect, useState } from 'react'
|
|
|
|
export interface Workflow {
|
|
id: string
|
|
codeId: string
|
|
workflowName: string
|
|
}
|
|
|
|
export const workflowStorage = storage.defineItem<Workflow[]>(
|
|
'local:workflows',
|
|
{
|
|
fallback: [],
|
|
},
|
|
)
|
|
|
|
export function useWorkflows() {
|
|
const [workflows, setWorkflows] = useState<Workflow[]>([])
|
|
|
|
useEffect(() => {
|
|
workflowStorage.getValue().then(setWorkflows)
|
|
const unwatch = workflowStorage.watch((newValue) => {
|
|
setWorkflows(newValue ?? [])
|
|
})
|
|
return unwatch
|
|
}, [])
|
|
|
|
const addWorkflow = async (workflow: Omit<Workflow, 'id'>) => {
|
|
const newWorkflow: Workflow = {
|
|
id: crypto.randomUUID(),
|
|
...workflow,
|
|
}
|
|
const current = (await workflowStorage.getValue()) ?? []
|
|
await workflowStorage.setValue([...current, newWorkflow])
|
|
return newWorkflow
|
|
}
|
|
|
|
const removeWorkflow = async (id: string) => {
|
|
const current = (await workflowStorage.getValue()) ?? []
|
|
await workflowStorage.setValue(current.filter((w) => w.id !== id))
|
|
}
|
|
|
|
const editWorkflow = async (
|
|
id: string,
|
|
updates: Partial<Omit<Workflow, 'id'>>,
|
|
) => {
|
|
const current = (await workflowStorage.getValue()) ?? []
|
|
await workflowStorage.setValue(
|
|
current.map((w) => (w.id === id ? { ...w, ...updates } : w)),
|
|
)
|
|
}
|
|
|
|
return { workflows, addWorkflow, removeWorkflow, editWorkflow }
|
|
}
|