feat: task lane persistence + sidebar cleanup #121

Merged
chihlasm merged 49 commits from feat/task-lane-persistence into main 2026-03-29 16:59:41 +00:00
Showing only changes of commit 1e78977e4f - Show all commits

View File

@@ -31,7 +31,10 @@ export default function AssistantChatPage() {
const navigate = useNavigate()
const { sessionId: urlSessionId } = useParams<{ sessionId?: string }>()
const [chats, setChats] = useState<ChatListItem[]>([])
const [activeChatId, setActiveChatId] = useState<string | null>(urlSessionId || null)
const [activeChatId, setActiveChatId] = useState<string | null>(() => {
if (urlSessionId) return urlSessionId
try { return sessionStorage.getItem('rf-active-chat-id') } catch { return null }
})
const [messages, setMessages] = useState<MessageWithMeta[]>([])
const [input, setInput] = useState('')
const [loading, setLoading] = useState(false)
@@ -77,6 +80,14 @@ export default function AssistantChatPage() {
const dragCounterRef = useRef(0)
const prefillHandledRef = useRef(false)
// Persist active chat ID to sessionStorage
useEffect(() => {
try {
if (activeChatId) sessionStorage.setItem('rf-active-chat-id', activeChatId)
else sessionStorage.removeItem('rf-active-chat-id')
} catch { /* ignore */ }
}, [activeChatId])
// Load chat list from ai_sessions
useEffect(() => {
loadChats()
@@ -89,6 +100,13 @@ export default function AssistantChatPage() {
}
}, [urlSessionId]) // eslint-disable-line react-hooks/exhaustive-deps
// Restore session from sessionStorage on mount (when URL has no session ID)
useEffect(() => {
if (!urlSessionId && activeChatId) {
selectChat(activeChatId)
}
}, []) // eslint-disable-line react-hooks/exhaustive-deps
// Handle prefill from command palette / dashboard handoff
useEffect(() => {
const state = location.state as { prefill?: string; uploadIds?: string[] } | null