feat(servers): switch the sidebar listing between local and linked servers

The Servers section becomes a Local/server switcher shared by the desktop sidebar, collapsed rail and mobile repo sheet. Selecting a linked server lists its projects and sessions with the same navigation as local repos, and a remote project page mirrors the local repo page.
This commit is contained in:
Chris Scott committed 2026-10-19 10:16:32 -04:00
1 parent cb9b7645e6
commit 36b8c1b200
29 files changed
+2080 -201

No files matched your search

+52
View File
@@ -20,6 +20,7 @@ import {
buildServerActivityIndex,
collectActiveRoots,
needsWorktreeLookup,
projectActivityFromIndex,
repoActivityFromIndex,
rootSessionID,
serverActivityFromIndex,
@@ -108,6 +109,57 @@ export function useServerActivityState(serverId: string): 'needs-input' | 'runni
)
}
/**
* Whether any local session is active, returned as a primitive so the local switcher row only
* re-renders when it changes. Reads only the session-status store and the pending queues.
*/
export function useLocalActivityState(): 'needs-input' | 'running' | null {
const pendingInputSessionIDs = usePendingInputSessionIDs()
return useSessionStatus((state) => {
const index = buildRepoActivityIndex({
statuses: state.statuses,
parents: state.parents,
runningShells: state.runningShells,
directories: state.directories,
pendingInputSessionIDs,
})
let running = false
for (const activity of index.values()) {
if (activity === 'needs-input') return 'needs-input'
running = true
}
return running ? 'running' : null
})
}
/**
* Whether a project on a linked server has any active session, returned as a primitive so rows
* only re-render when it changes.
*/
export function useProjectActivityState(
serverId: string,
directory: string,
): 'needs-input' | 'running' | null {
const pendingInputSessionIDs = usePendingInputSessionIDs()
return useSessionStatus((state) =>
projectActivityFromIndex(
serverId,
directory,
buildServerActivityIndex({
statuses: state.statuses,
parents: state.parents,
runningShells: state.runningShells,
directories: state.directories,
sessionServers: state.sessionServers,
pendingInputSessionIDs,
}),
),
)
}
interface SessionScope {
serverId: string
directory: string | undefined