fix(client): a developer's Sessions page no longer asks for remote sources (403)
/api/remote-sources is STAFF_ONLY; Sessions loaded its labels for every viewer, so each developer page load logged a 403.
This commit is contained in:
@@ -88,6 +88,7 @@ import { SessionRowMenu, workspaceHref } from "../components/SessionRowMenu";
|
|||||||
import { formatDateTime, formatDuration, truncate, fmtCost, isoOrUndefined } from "../lib/format";
|
import { formatDateTime, formatDuration, truncate, fmtCost, isoOrUndefined } from "../lib/format";
|
||||||
import { effectiveSessionStatus, sessionAwaitingReason } from "../lib/types";
|
import { effectiveSessionStatus, sessionAwaitingReason } from "../lib/types";
|
||||||
import type { Session, DashboardEvent } from "../lib/types";
|
import type { Session, DashboardEvent } from "../lib/types";
|
||||||
|
import { usePermissions } from "../components/AuthGate";
|
||||||
|
|
||||||
const PAGE_SIZE = 10;
|
const PAGE_SIZE = 10;
|
||||||
|
|
||||||
@@ -183,14 +184,17 @@ export function Sessions({ embedded = false }: { embedded?: boolean } = {}) {
|
|||||||
|
|
||||||
// Load remote-source labels so remote-origin rows can show a friendly badge
|
// Load remote-source labels so remote-origin rows can show a friendly badge
|
||||||
// instead of a raw `src_…` id. Refreshed when a source's status changes.
|
// instead of a raw `src_…` id. Refreshed when a source's status changes.
|
||||||
|
// Staff only: a developer's /api/remote-sources is a 403 (STAFF_ONLY_PREFIXES).
|
||||||
|
const { seesAll } = usePermissions();
|
||||||
const loadSourceLabels = useCallback(() => {
|
const loadSourceLabels = useCallback(() => {
|
||||||
|
if (!seesAll) return;
|
||||||
api.remoteSources
|
api.remoteSources
|
||||||
.list()
|
.list()
|
||||||
.then((res: { sources: RemoteSource[] }) => {
|
.then((res: { sources: RemoteSource[] }) => {
|
||||||
setSourceLabels(new Map(res.sources.map((s) => [s.id, s.label])));
|
setSourceLabels(new Map(res.sources.map((s) => [s.id, s.label])));
|
||||||
})
|
})
|
||||||
.catch(() => undefined);
|
.catch(() => undefined);
|
||||||
}, []);
|
}, [seesAll]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadSourceLabels();
|
loadSourceLabels();
|
||||||
|
|||||||
Reference in New Issue
Block a user