routes refuse at the route, and a new home is empty

Three things, from a member sitting on /music with no music capability on a server with
no music sidecar: an empty library, and 403s in the console.

PERMISSIONS AT THE ROUTE. `canVisit` filtered the dock and nothing else, so the tile was
hidden and the route was wide open — typing the path, following an old link or restoring
a tab rendered the screen anyway. RouteGate now wraps every screen in one place, inside
the error boundary.

It does not redirect. Sending someone to `/` erases what they asked for and reads as a
bug: they clicked Music and landed on Home. It says why instead, and the URL stays put so
a reload after installing the thing just works.

And it says which of the two reasons applies, because they need different screens and send
the reader to different places. `not-installed` is a fact about the SERVER — the owner gets
a link to the app store. `not-granted` is a fact about the ACCOUNT, and only the owner can
change it. Presenting either as the other sends you looking in the wrong place.

ROUTES FOLLOW THE SIDECAR. Free, once the above exists: `deniedRoutes` already covers
"held but its sidecar is not installed", so an uninstalled feature has no tile AND no
screen. The dock, the Permissions list and the routes now agree because they read one
answer.

NO MORE SEEDING. Downloads/Documents/Music/Videos/Pictures are gone from both places that
made them — the member's provisioning and, older and worse, `/ls`, which created folders in
somebody's home as a side effect of LOOKING at it. A listing that invents its own contents
is a listing you cannot trust, and the platform has no standing to choose a person's folder
layout. A new home is empty.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 18:42:39 +00:00
co-authored by Claude Opus 5
parent 4b058a6703
commit b4f88ec161
6 changed files with 106 additions and 34 deletions
@@ -9,6 +9,7 @@ import { Header } from './Header';
import { Dock, CORE_DOCK_ITEMS, dockItemsFromPlugins, DEFAULT_DOCK_PATHS } from './Dock';
import { useIsTouch } from './useIsTouch';
import { usePageTitleSync } from '@/state/usePageTitle';
import { RouteGate } from './RouteGate';
type DashboardLayoutProps = {
children?: React.ReactNode;
@@ -55,7 +56,10 @@ export function DashboardLayout({ children }: DashboardLayoutProps) {
resetKeys={[pathname]}
fallback={({ error, reset }) => <ScreenErrorFallback error={error} reset={reset} />}
>
{children}
{/* Inside the boundary and around every screen, so one place decides whether a route exists for
this account on this server. Filtering the dock was never enough: the tile was hidden and the
route still rendered for anyone who typed it, followed an old link or restored a tab. */}
<RouteGate>{children}</RouteGate>
</ErrorBoundary>
</div>
</section>
@@ -0,0 +1,61 @@
import { useLocation, Link } from 'react-router';
import { PackageOpen, Lock } from 'lucide-react';
import { useCapabilities } from 'hooks/useCapabilities';
// A screen only exists if this account can reach it AND this server has the thing behind it.
//
// Until this existed, `canVisit` filtered the dock and nothing else — so the icon was hidden and the ROUTE
// was wide open. Typing /music, following an old link or restoring a tab rendered the Music screen for an
// account with no music capability on a server with no music sidecar: an empty library, a spinner, and a
// handful of 403s in the console. The refusal has to be at the route, because that is where the reader
// arrives.
//
// Deliberately NOT a redirect. Sending someone to `/` erases what they asked for and reads as a bug — they
// clicked Music and landed on Home. Saying "Music is not installed" answers the question they actually have,
// and the URL stays put so a reload after installing it just works.
//
// This is a courtesy, not the lock. Every route here is refused server-side as well; hiding the screen only
// stops the app promising something it will then refuse.
export function RouteGate({ children }: { children?: React.ReactNode }) {
const { pathname } = useLocation();
const { denialReason, isOwner } = useCapabilities();
const reason = denialReason(pathname);
if (!reason) return <>{children}</>;
const name = pathname.split('/').filter(Boolean)[0] ?? 'This';
const label = name.charAt(0).toUpperCase() + name.slice(1);
return (
<div className="flex h-full items-center justify-center p-6">
<div className="flex max-w-md flex-col items-center gap-3 text-center">
{reason === 'not-installed' ? (
<>
<PackageOpen className="h-8 w-8 text-muted-foreground" />
<div className="text-lg font-medium">{label} is not installed</div>
<p className="text-sm text-muted-foreground">
Nothing on this server provides it yet.
{isOwner ? ' Install it and this page starts working.' : ' Ask the server owner to install it.'}
</p>
{/* Only offered to the owner: the app store is owner-only, so a member following this link would
meet a second refusal. */}
{isOwner && (
<Link to="/app-store" className="rounded-md border px-3 py-1.5 text-sm transition-colors hover:bg-accent">
Open the app store
</Link>
)}
</>
) : (
<>
<Lock className="h-8 w-8 text-muted-foreground" />
<div className="text-lg font-medium">{label} is not available to you</div>
<p className="text-sm text-muted-foreground">
Your role does not include it. The server owner decides this under Settings User management.
</p>
</>
)}
</div>
</div>
);
}