mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
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:
1 parent
cb9b7645e6
commit
36b8c1b200
29 files changed
+2080
-201
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user