feat(frontend): consolidate session picker navigation and remote project loading

This commit is contained in:
Chris Scott committed 2026-10-23 22:35:10 -04:00
1 parent 81fb2d4033
commit 52aeb7780f
42 files changed
+1486 -769

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
import type { Repo, Session } from '@/api/types'
/**
* Builds a session fixture for picker tests.
*
* @param id Session id.
* @param title Session title.
* @param directory Session working directory.
* @param updated Session creation and update timestamp.
*/
export function makeSession(id: string, title: string, directory: string, updated = Date.now()): Session {
return {
id,
projectID: 'proj',
title,
time: { created: updated, updated },
location: { directory },
cost: 0,
tokens: {},
} as unknown as Session
}
/**
* Builds a ready repo fixture for picker tests.
*
* @param id Repo id.
* @param name Repo name.
* @param fullPath Repo working directory.
*/
export function makeRepo(id: number, name: string, fullPath: string): Repo {
return {
id,
name,
localPath: fullPath,
fullPath,
defaultBranch: 'main',
cloneStatus: 'ready',
clonedAt: 0,
}
}
+5 -1
View File
@@ -2,7 +2,7 @@
import { useEffect, type ReactNode } from 'react'
import { renderHook } from '@testing-library/react'
import { MemoryRouter, useLocation } from 'react-router-dom'
import { MemoryRouter, useLocation, useNavigationType } from 'react-router-dom'
import { vi } from 'vitest'
import type { useSettings } from '@/hooks/useSettings'
import type { VoiceConversationController } from '@/hooks/useVoiceConversation'
@@ -89,14 +89,18 @@ export function renderHookWithRouter<T>(renderFn: () => T, initialEntries?: stri
export function LocationCatcher({
capturedSearch,
capturedPathname,
capturedNavigationType,
}: {
capturedSearch: { current: string }
capturedPathname?: { current: string }
capturedNavigationType?: { current: string }
}) {
const location = useLocation()
const navigationType = useNavigationType()
useEffect(() => {
capturedSearch.current = location.search
if (capturedPathname) capturedPathname.current = location.pathname
if (capturedNavigationType) capturedNavigationType.current = navigationType
})
return null
}