feat(servers): show linked server projects on the home page and remove the server page

The home page follows the sidebar server selection and lists a linked server's projects with the same cards, search and row actions as local repositories. /servers/:id now selects that server and redirects home. Back from a remote session goes to its project page and back from a project goes home, and the selection follows the route app-wide so mobile keeps the linked server.
This commit is contained in:
Chris Scott committed 2026-10-19 15:01:48 -04:00
1 parent c1e09f34a5
commit c18c3584ef
32 files changed
+1576 -789

No files matched your search

@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { renderHook } from '@testing-library/react'
import { renderHook, act } from '@testing-library/react'
import { SwipeNavigationProvider, useSwipeNavigation } from './SwipeNavigationContext'
describe('SwipeNavigationContext', () => {
@@ -47,6 +47,24 @@ describe('SwipeNavigationContext', () => {
expect(current?.isSuspended()).toBe(false)
})
it('round-trips a page back target', () => {
const { result } = renderHook(() => useSwipeNavigation(), {
wrapper: SwipeNavigationProvider,
})
expect(result.current?.backTarget()).toBeNull()
act(() => {
result.current?.setBackTarget('/servers/srv_kitchen/projects?directory=%2Fhome%2Fme%2Fapp')
})
expect(result.current?.backTarget()).toBe('/servers/srv_kitchen/projects?directory=%2Fhome%2Fme%2Fapp')
act(() => {
result.current?.setBackTarget(null)
})
expect(result.current?.backTarget()).toBeNull()
})
it('clamps resume below zero to zero', () => {
let current: ReturnType<typeof useSwipeNavigation>
@@ -5,12 +5,17 @@ interface SwipeNavigationValue {
suspend: () => void
resume: () => void
isSuspended: () => boolean
/** Overrides the URL-derived swipe-back destination for the current page; pass null to clear it. */
setBackTarget: (path: string | null) => void
/** Returns the page-registered swipe-back destination, or null when the URL should decide. */
backTarget: () => string | null
}
export const SwipeNavigationContext = createContext<SwipeNavigationValue | null>(null)
function SwipeNavigationProvider({ children }: { children: ReactNode }) {
const countRef = useRef(0)
const backTargetRef = useRef<string | null>(null)
const value = useMemo<SwipeNavigationValue>(
() => ({
suspend: () => {
@@ -20,6 +25,10 @@ function SwipeNavigationProvider({ children }: { children: ReactNode }) {
countRef.current = Math.max(0, countRef.current - 1)
},
isSuspended: () => countRef.current > 0,
setBackTarget: (path) => {
backTargetRef.current = path
},
backTarget: () => backTargetRef.current,
}),
[]
)