Initial commit: AI chat assistant with workflow chat, workspace, and profile tabs
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
43
composables/useWorkflow.uts
Normal file
43
composables/useWorkflow.uts
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* useWorkflow — Current workflow selection state
|
||||
*
|
||||
* Manages which workflow is active (general, code, document, data, creative).
|
||||
* The selection is persisted so it survives app restarts.
|
||||
*/
|
||||
|
||||
import type { WorkflowId, WorkflowDef } from '@/types/index'
|
||||
import { WORKFLOWS, STORAGE_KEYS } from '@/constants/index'
|
||||
import { useStorage } from './useStorage'
|
||||
|
||||
export function useWorkflow() {
|
||||
const { loadValue, saveValue } = useStorage()
|
||||
|
||||
// Initialize from storage, fallback to 'general'
|
||||
const activeWorkflowId = ref<WorkflowId>(
|
||||
loadValue<WorkflowId>(STORAGE_KEYS.ACTIVE_WORKFLOW_ID, 'general')
|
||||
)
|
||||
|
||||
// All available workflows (static)
|
||||
const workflows: WorkflowDef[] = WORKFLOWS
|
||||
|
||||
// Computed: the currently active workflow definition
|
||||
const activeWorkflow = computed<WorkflowDef>(() => {
|
||||
const found = workflows.find((w) => w.id === activeWorkflowId.value)
|
||||
return found ?? workflows[0]
|
||||
})
|
||||
|
||||
/**
|
||||
* Select a workflow and persist the choice.
|
||||
*/
|
||||
function selectWorkflow(id: WorkflowId): void {
|
||||
activeWorkflowId.value = id
|
||||
saveValue(STORAGE_KEYS.ACTIVE_WORKFLOW_ID, id)
|
||||
}
|
||||
|
||||
return {
|
||||
activeWorkflowId,
|
||||
workflows,
|
||||
activeWorkflow,
|
||||
selectWorkflow,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user