feat(web): hide browse affordances unless a machine reports workspace roots

This commit is contained in:
weishu
2026-08-01 11:36:12 +08:00
parent b6897ee736
commit b1b0d590a7
+9 -1
View File
@@ -175,6 +175,12 @@ function SessionsPage() {
}
return byId
}, [machines])
// Workspace browsing is opt-in per runner (`--workspace-root`); only show
// browse affordances when at least one machine reported roots.
const canBrowse = useMemo(
() => machines.some(m => (m.metadata?.workspaceRoots?.length ?? 0) > 0),
[machines]
)
const sessionMatch = matchRoute({ to: '/sessions/$sessionId', fuzzy: true })
const selectedSessionId = sessionMatch && sessionMatch.sessionId !== 'new' ? sessionMatch.sessionId : null
const selectedSession = useMemo(
@@ -220,12 +226,13 @@ function SessionsPage() {
})}
onNewSession={() => navigate({ to: '/sessions/new' })}
onNewSessionInDirectory={handleNewSessionInDirectory}
onBrowse={() => navigate({ to: '/browse' })}
onBrowse={canBrowse ? () => navigate({ to: '/browse' }) : undefined}
onRefresh={handleRefresh}
isLoading={isLoading}
renderHeader={false}
headerActions={(
<div className="flex items-center gap-2">
{canBrowse && (
<button
type="button"
onClick={() => navigate({ to: '/browse' })}
@@ -234,6 +241,7 @@ function SessionsPage() {
>
<FolderOpenIcon className="h-5 w-5" />
</button>
)}
<button
type="button"
onClick={() => navigate({ to: '/settings' })}