feat: command palette, PSA ticket context, session-to-flow converter #108

Merged
chihlasm merged 27 commits from feat/command-palette-session-flow-psa-context into main 2026-03-16 17:39:17 +00:00
Showing only changes of commit 3fc04ee8d5 - Show all commits

View File

@@ -0,0 +1,40 @@
import { useState, useEffect, useCallback } from 'react'
import { psaContextApi, type TicketContext } from '@/api/psaContext'
interface UseTicketContextResult {
context: TicketContext | null
loading: boolean
error: string | null
refresh: () => void
}
export function useTicketContext(
psaTicketId: string | null | undefined,
psaConnectionId: string | null | undefined
): UseTicketContextResult {
const [context, setContext] = useState<TicketContext | null>(null)
const [loading, setLoading] = useState(false)
const [error, setError] = useState<string | null>(null)
const fetchContext = useCallback(async () => {
if (!psaTicketId || !psaConnectionId) return
setLoading(true)
setError(null)
try {
const data = await psaContextApi.getTicketContext(psaTicketId)
setContext(data)
} catch (err) {
const message = err instanceof Error ? err.message : 'Failed to load ticket context'
setError(message)
} finally {
setLoading(false)
}
}, [psaTicketId, psaConnectionId])
useEffect(() => {
fetchContext()
}, [fetchContext])
return { context, loading, error, refresh: fetchContext }
}