fix: pre-landing and adversarial review fixes
- landing.css: hardcode --lp-btn to #60a5fa (lesson 104 — no var(--color-*) in landing.css) - ScriptBuilderInput: suggestion chips now correctly disabled during generation - ChatSidebar: wrapper onClick no longer fires onSelect while in confirming state - SessionHistoryPage: fix loadMoreAiSessions race condition with generation counter; flow session tab auto-activates when URL params target flow session filters Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,11 @@ type TabId = typeof TABS[number]['id']
|
||||
export default function SessionHistoryPage() {
|
||||
const navigate = useNavigate()
|
||||
const [searchParams, setSearchParams] = useSearchParams()
|
||||
const [activeTab, setActiveTab] = useState<TabId>('ai')
|
||||
const [activeTab, setActiveTab] = useState<TabId>(() => {
|
||||
// If URL params target flow session filters, start on flows tab
|
||||
const hasFlowParams = searchParams.get('ticket') || searchParams.get('client') || searchParams.get('tree')
|
||||
return hasFlowParams ? 'flows' : 'ai'
|
||||
})
|
||||
|
||||
// ── AI Session state ──
|
||||
const [aiSessions, setAiSessions] = useState<AISessionSummary[]>([])
|
||||
@@ -38,6 +42,7 @@ export default function SessionHistoryPage() {
|
||||
const [aiHasMore, setAiHasMore] = useState(false)
|
||||
const [aiSearchInput, setAiSearchInput] = useState('')
|
||||
const aiSearchTimeout = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)
|
||||
const aiFilterGenRef = useRef(0)
|
||||
const [aiFilters, setAiFilters] = useState({
|
||||
q: '',
|
||||
session_type: '',
|
||||
@@ -85,6 +90,9 @@ export default function SessionHistoryPage() {
|
||||
// ── AI Sessions: fetch ──
|
||||
useEffect(() => {
|
||||
let cancelled = false
|
||||
const gen = ++aiFilterGenRef.current
|
||||
setAiSessions([])
|
||||
setAiHasMore(false)
|
||||
const load = async () => {
|
||||
setAiLoading(true)
|
||||
try {
|
||||
@@ -97,7 +105,7 @@ export default function SessionHistoryPage() {
|
||||
date_from: aiFilters.date_from || undefined,
|
||||
date_to: aiFilters.date_to ? `${aiFilters.date_to}T23:59:59.999Z` : undefined,
|
||||
})
|
||||
if (!cancelled) {
|
||||
if (!cancelled && gen === aiFilterGenRef.current) {
|
||||
setAiSessions(data)
|
||||
setAiHasMore(data.length >= PAGE_SIZE)
|
||||
}
|
||||
@@ -112,6 +120,7 @@ export default function SessionHistoryPage() {
|
||||
}, [aiFilters])
|
||||
|
||||
const loadMoreAiSessions = async () => {
|
||||
const gen = aiFilterGenRef.current
|
||||
setAiLoadingMore(true)
|
||||
try {
|
||||
const data = await aiSessionsApi.listSessions({
|
||||
@@ -124,8 +133,10 @@ export default function SessionHistoryPage() {
|
||||
date_from: aiFilters.date_from || undefined,
|
||||
date_to: aiFilters.date_to ? `${aiFilters.date_to}T23:59:59.999Z` : undefined,
|
||||
})
|
||||
setAiSessions(prev => [...prev, ...data])
|
||||
setAiHasMore(data.length >= PAGE_SIZE)
|
||||
if (gen === aiFilterGenRef.current) {
|
||||
setAiSessions(prev => [...prev, ...data])
|
||||
setAiHasMore(data.length >= PAGE_SIZE)
|
||||
}
|
||||
} catch {
|
||||
toast.error('Failed to load more sessions')
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user