fix: 6 integration audit fixes — ticket filter, admin nav, FK scope, debounce, error messages
- Fix AISession.ticket_id → psa_ticket_id in list_sessions filter query - Add Gallery nav item (LayoutGrid icon) to AdminSidebar navItems array - Remove ForeignKey from FileUpload.session_id (Python model) + migration b8d2f4a6c091 to drop DB constraint, allowing column to reference either session type - Add 400ms debounce on AI session search input in SessionHistoryPage (aiSearchInput state + useRef timeout pattern) - Show friendly 503 error message in RichTextInput upload error handler (both initial upload and retry paths) - Add overflow-x-auto to FlowPilotAnalyticsPage tab bar container Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
FolderTree,
|
||||
ClipboardList,
|
||||
MessageSquareText,
|
||||
LayoutGrid,
|
||||
ArrowLeft,
|
||||
} from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
@@ -25,6 +26,7 @@ const navItems = [
|
||||
{ path: '/admin/categories', label: 'Categories', icon: FolderTree },
|
||||
{ path: '/admin/survey-invites', label: 'Survey Invites', icon: ClipboardList },
|
||||
{ path: '/admin/survey-responses', label: 'Survey Responses', icon: MessageSquareText },
|
||||
{ path: '/admin/gallery', label: 'Gallery', icon: LayoutGrid },
|
||||
]
|
||||
|
||||
interface AdminSidebarProps {
|
||||
|
||||
@@ -73,10 +73,13 @@ export function RichTextInput({
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
const errorMsg = err?.response?.status === 503
|
||||
? 'File uploads not available — contact your administrator'
|
||||
: err?.message || 'Upload failed'
|
||||
setPendingUploads((prev) =>
|
||||
prev.map((u) =>
|
||||
u.id === upload.id
|
||||
? { ...u, status: 'error' as const, error: err?.message || 'Upload failed' }
|
||||
? { ...u, status: 'error' as const, error: errorMsg }
|
||||
: u
|
||||
)
|
||||
)
|
||||
@@ -196,10 +199,13 @@ export function RichTextInput({
|
||||
})
|
||||
})
|
||||
.catch((err) => {
|
||||
const errorMsg = err?.response?.status === 503
|
||||
? 'File uploads not available — contact your administrator'
|
||||
: err?.message || 'Upload failed'
|
||||
setPendingUploads((prev) =>
|
||||
prev.map((u) =>
|
||||
u.id === uploadId
|
||||
? { ...u, status: 'error' as const, error: err?.message || 'Upload failed' }
|
||||
? { ...u, status: 'error' as const, error: errorMsg }
|
||||
: u
|
||||
)
|
||||
)
|
||||
|
||||
@@ -189,7 +189,7 @@ export default function FlowPilotAnalyticsPage() {
|
||||
</div>
|
||||
|
||||
{/* Tab bar */}
|
||||
<div className="flex gap-1 border-b border-border">
|
||||
<div className="flex gap-1 border-b border-border overflow-x-auto">
|
||||
{TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
|
||||
@@ -25,6 +25,8 @@ export function SessionHistoryPage() {
|
||||
const [sessionType, setSessionType] = useState<'flow' | 'ai'>('flow')
|
||||
const [aiSessions, setAiSessions] = useState<AISessionSummary[]>([])
|
||||
const [aiLoading, setAiLoading] = useState(false)
|
||||
const [aiSearchInput, setAiSearchInput] = useState('')
|
||||
const aiSearchTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
|
||||
const [aiFilters, setAiFilters] = useState({
|
||||
q: '',
|
||||
problem_domain: '',
|
||||
@@ -67,6 +69,15 @@ export function SessionHistoryPage() {
|
||||
}
|
||||
})
|
||||
|
||||
// Debounce AI search input → aiFilters.q
|
||||
useEffect(() => {
|
||||
if (aiSearchTimeout.current) clearTimeout(aiSearchTimeout.current)
|
||||
aiSearchTimeout.current = setTimeout(() => {
|
||||
setAiFilters(prev => ({ ...prev, q: aiSearchInput }))
|
||||
}, 400)
|
||||
return () => { if (aiSearchTimeout.current) clearTimeout(aiSearchTimeout.current) }
|
||||
}, [aiSearchInput])
|
||||
|
||||
// Load trees for filter dropdown
|
||||
useEffect(() => {
|
||||
const loadTrees = async () => {
|
||||
@@ -324,8 +335,8 @@ export function SessionHistoryPage() {
|
||||
<Search className="absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground pointer-events-none" />
|
||||
<input
|
||||
type="text"
|
||||
value={aiFilters.q}
|
||||
onChange={(e) => setAiFilters((f) => ({ ...f, q: e.target.value }))}
|
||||
value={aiSearchInput}
|
||||
onChange={(e) => setAiSearchInput(e.target.value)}
|
||||
placeholder="Search sessions..."
|
||||
className="w-full rounded-lg border border-border bg-card pl-8 pr-3 py-1.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-[rgba(6,182,212,0.3)] focus:outline-none"
|
||||
/>
|
||||
@@ -389,9 +400,12 @@ export function SessionHistoryPage() {
|
||||
</div>
|
||||
|
||||
{/* Clear filters */}
|
||||
{(aiFilters.q || aiFilters.problem_domain || aiFilters.confidence_tier || aiFilters.date_from || aiFilters.date_to) && (
|
||||
{(aiSearchInput || aiFilters.q || aiFilters.problem_domain || aiFilters.confidence_tier || aiFilters.date_from || aiFilters.date_to) && (
|
||||
<button
|
||||
onClick={() => setAiFilters({ q: '', problem_domain: '', confidence_tier: '', date_from: '', date_to: '' })}
|
||||
onClick={() => {
|
||||
setAiSearchInput('')
|
||||
setAiFilters({ q: '', problem_domain: '', confidence_tier: '', date_from: '', date_to: '' })
|
||||
}}
|
||||
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
Clear
|
||||
@@ -405,13 +419,16 @@ export function SessionHistoryPage() {
|
||||
<Spinner />
|
||||
</div>
|
||||
) : aiSessions.length === 0 ? (
|
||||
(aiFilters.q || aiFilters.problem_domain || aiFilters.confidence_tier || aiFilters.date_from || aiFilters.date_to) ? (
|
||||
(aiSearchInput || aiFilters.q || aiFilters.problem_domain || aiFilters.confidence_tier || aiFilters.date_from || aiFilters.date_to) ? (
|
||||
<EmptyState
|
||||
title="No sessions match your filters"
|
||||
description="Try adjusting your search or filters."
|
||||
action={
|
||||
<button
|
||||
onClick={() => setAiFilters({ q: '', problem_domain: '', confidence_tier: '', date_from: '', date_to: '' })}
|
||||
onClick={() => {
|
||||
setAiSearchInput('')
|
||||
setAiFilters({ q: '', problem_domain: '', confidence_tier: '', date_from: '', date_to: '' })
|
||||
}}
|
||||
className="text-foreground hover:underline text-sm"
|
||||
>
|
||||
Clear all filters
|
||||
|
||||
Reference in New Issue
Block a user