Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(control-ui): hide "Shared with me" tab when grant-listing is unavailable

Jose Ramirez96644ac94606
diff --git a/control-ui/components/PublisherView/GrantedToMe.tsx b/control-ui/components/PublisherView/GrantedToMe.tsx
index 41f064502..6c4817b7e 100644
--- a/control-ui/components/PublisherView/GrantedToMe.tsx
+++ b/control-ui/components/PublisherView/GrantedToMe.tsx
@@ -1,7 +1,8 @@
'use client'
-import { useCallback, useEffect, useState } from 'react'
-import { type GrantedToMeItem, listGrantedToMe } from '../../lib/api'
+import { CONTROL_ROUTES } from '@constants/routes'
+import type { GrantedToMeItem } from '../../lib/api'
+import type { InboundGrantsStatus } from '../../lib/hooks/useInboundGrants'
import { TableHeaderRow } from '../TableHeaderRow'
import type { TableHeaderColumn } from '../TableHeaderRow/types'
import { RetryBanner } from './RetryBanner'
@@ -16,31 +17,34 @@ function fmt(v?: string): string {
return v ? new Date(v).toLocaleDateString() : '—'
}
-export function GrantedToMe() {
- const [grants, setGrants] = useState<GrantedToMeItem[]>([])
- const [loading, setLoading] = useState(true)
- const [error, setError] = useState(false)
-
- const load = useCallback(async () => {
- setLoading(true)
- setError(false)
- try {
- const { grants: rows } = await listGrantedToMe()
- setGrants(rows)
- } catch {
- setError(true)
- } finally {
- setLoading(false)
- }
- }, [])
-
- useEffect(() => {
- void load()
- }, [load])
-
- if (loading) return <p>Loading…</p>
- if (error) {
- return <RetryBanner message="Could not load inbound grants." onRetry={() => void load()} />
+/**
+ * Presentational — the fetch lives in `useInboundGrants` (owned by PublisherView,
+ * which also uses its status to hide this tab when `unavailable`). On a deep-link
+ * to the hidden route we still render, so `unavailable` shows an accurate
+ * signpost rather than an error: shared plugins are installable from the
+ * Marketplace even though this convenience list isn't served for the deployment.
+ */
+export function GrantedToMe({
+ status,
+ grants,
+ reload,
+}: {
+ status: InboundGrantsStatus
+ grants: GrantedToMeItem[]
+ reload: () => void
+}) {
+ if (status === 'loading') return <p>Loading…</p>
+ if (status === 'unavailable') {
+ return (
+ <p className="cu-banner cu-banner--warn">
+ Plugins shared with your org appear in your{' '}
+ <a href={CONTROL_ROUTES.marketplace.root}>Marketplace catalog</a> and can be installed from
+ there.
+ </p>
+ )
+ }
+ if (status === 'error') {
+ return <RetryBanner message="Could not load inbound grants." onRetry={reload} />
}
if (grants.length === 0) {
return <p>No plugins have been shared with your org yet.</p>
diff --git a/control-ui/components/PublisherView/index.tsx b/control-ui/components/PublisherView/index.tsx
index 03ce4caf0..3b62521e2 100644
--- a/control-ui/components/PublisherView/index.tsx
+++ b/control-ui/components/PublisherView/index.tsx
@@ -1,6 +1,7 @@
'use client'
import { CONTROL_ROUTES } from '@constants/routes'
+import { useInboundGrants } from '../../lib/hooks/useInboundGrants'
import { isPublisherEnabled, usePublishScope } from '../../lib/hooks/usePublishScope'
import { TabBar } from '../TabBar'
import { TablePanelHeader } from '../TablePanelHeader'
@@ -17,6 +18,7 @@ const TABS: { value: PublisherTab; href: string; label: string }[] = [
export function PublisherView({ activeTab }: { activeTab: PublisherTab }) {
const { scope, loading } = usePublishScope()
+ const inbound = useInboundGrants()
if (loading) {
return (
@@ -41,6 +43,16 @@ export function PublisherView({ activeTab }: { activeTab: PublisherTab }) {
const orgScope = scope.scope
+ // Grant *listing* is a hosted/curator surface. A self-hosted deploy's registry
+ // client lacks `registry:grant`, so `granted-to-me` 403s (`unavailable`) — hide
+ // the "Shared with me" tab (plugins shared with the org still install from the
+ // Marketplace). Transient errors keep the tab (the feature exists); it stays
+ // hidden only while probing or on a 403.
+ const tabs =
+ inbound.status === 'available' || inbound.status === 'error'
+ ? TABS
+ : TABS.filter(t => t.value !== 'shared')
+
return (
<section>
<div className="cu-card cu-card--viewport-fill">
@@ -51,10 +63,12 @@ export function PublisherView({ activeTab }: { activeTab: PublisherTab }) {
ariaLabel="Publisher sections"
activeValue={activeTab}
className="cu-tabs--flush-top"
- options={TABS}
+ options={tabs}
/>
{activeTab === 'entries' ? <OwnedEntries orgScope={orgScope} /> : null}
- {activeTab === 'shared' ? <GrantedToMe /> : null}
+ {activeTab === 'shared' ? (
+ <GrantedToMe status={inbound.status} grants={inbound.grants} reload={inbound.reload} />
+ ) : null}
{activeTab === 'credentials' ? <DockerCredentialsPanel orgScope={orgScope} /> : null}
</div>
</div>
diff --git a/control-ui/components/__tests__/GrantedToMe.test.tsx b/control-ui/components/__tests__/GrantedToMe.test.tsx
index 7bdf6e01b..3ae46bbdb 100644
--- a/control-ui/components/__tests__/GrantedToMe.test.tsx
+++ b/control-ui/components/__tests__/GrantedToMe.test.tsx
@@ -1,35 +1,42 @@
-import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, describe, expect, it, vi } from 'vitest'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import * as api from '../../lib/api'
import { GrantedToMe } from '../PublisherView/GrantedToMe'
-vi.mock('../../lib/api', () => ({ listGrantedToMe: vi.fn() }))
afterEach(cleanup)
-beforeEach(() => vi.clearAllMocks())
-describe('GrantedToMe', () => {
- it('renders inbound grants read-only (no revoke)', async () => {
- vi.mocked(api.listGrantedToMe).mockResolvedValue({
- grants: [{ pluginName: '@beta/tool', ownerOrg: 'beta', createdAt: '2026-06-01T00:00:00Z' }],
- })
- render(<GrantedToMe />)
- expect(await screen.findByText('@beta/tool')).toBeInTheDocument()
+describe('GrantedToMe (presentational)', () => {
+ it('renders inbound grants read-only (no revoke)', () => {
+ render(
+ <GrantedToMe
+ status="available"
+ grants={[{ pluginName: '@beta/tool', ownerOrg: 'beta', createdAt: '2026-06-01T00:00:00Z' }]}
+ reload={vi.fn()}
+ />
+ )
+ expect(screen.getByText('@beta/tool')).toBeInTheDocument()
expect(screen.getByText('beta')).toBeInTheDocument()
expect(screen.queryByRole('button', { name: /revoke/i })).toBeNull()
})
- it('empty state', async () => {
- vi.mocked(api.listGrantedToMe).mockResolvedValue({ grants: [] })
- render(<GrantedToMe />)
- expect(await screen.findByText(/no plugins.*shared with/i)).toBeInTheDocument()
+ it('empty state', () => {
+ render(<GrantedToMe status="available" grants={[]} reload={vi.fn()} />)
+ expect(screen.getByText(/no plugins.*shared with/i)).toBeInTheDocument()
})
- it('error + Retry', async () => {
- vi.mocked(api.listGrantedToMe)
- .mockRejectedValueOnce(Object.assign(new Error('boom'), { status: 500 }))
- .mockResolvedValueOnce({ grants: [] })
- render(<GrantedToMe />)
- fireEvent.click(await screen.findByRole('button', { name: /retry/i }))
- expect(await screen.findByText(/no plugins.*shared with/i)).toBeInTheDocument()
+ it('error → Retry calls reload', () => {
+ const reload = vi.fn()
+ render(<GrantedToMe status="error" grants={[]} reload={reload} />)
+ fireEvent.click(screen.getByRole('button', { name: /retry/i }))
+ expect(reload).toHaveBeenCalledTimes(1)
+ })
+
+ it('unavailable (403) → Marketplace signpost, no error/retry', () => {
+ // The deep-link case: the tab is hidden, but a direct nav still renders. It
+ // must reassure (shared plugins install from the Marketplace), not error.
+ render(<GrantedToMe status="unavailable" grants={[]} reload={vi.fn()} />)
+ const link = screen.getByRole('link', { name: /marketplace catalog/i })
+ expect(link).toHaveAttribute('href', '/marketplace')
+ expect(screen.queryByRole('button', { name: /retry/i })).toBeNull()
+ expect(screen.queryByText(/could not load/i)).toBeNull()
})
})
diff --git a/control-ui/components/__tests__/PublisherView.test.tsx b/control-ui/components/__tests__/PublisherView.test.tsx
index 7c56d5354..f5f8b114d 100644
--- a/control-ui/components/__tests__/PublisherView.test.tsx
+++ b/control-ui/components/__tests__/PublisherView.test.tsx
@@ -1,5 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { cleanup, render, screen } from '@testing-library/react'
+import * as inboundHook from '../../lib/hooks/useInboundGrants'
import * as hook from '../../lib/hooks/usePublishScope'
import { PublisherView } from '../PublisherView'
@@ -17,9 +18,19 @@ vi.mock('../../lib/hooks/usePublishScope', async orig => {
const actual = await orig<typeof import('../../lib/hooks/usePublishScope')>()
return { ...actual, usePublishScope: vi.fn() }
})
+vi.mock('../../lib/hooks/useInboundGrants', () => ({ useInboundGrants: vi.fn() }))
afterEach(cleanup)
-beforeEach(() => vi.clearAllMocks())
+beforeEach(() => {
+ vi.clearAllMocks()
+ // Default: grant listing available → the "Shared with me" tab shows. The
+ // tab-visibility tests below override this per-case.
+ vi.mocked(inboundHook.useInboundGrants).mockReturnValue({
+ status: 'available',
+ grants: [],
+ reload: vi.fn(),
+ })
+})
describe('PublisherView', () => {
it('renders a loading state while publish-scope resolves', () => {
@@ -102,4 +113,36 @@ describe('PublisherView', () => {
const shared = screen.getByRole('tab', { name: /shared with me/i })
expect(shared).toHaveAttribute('href', '/publisher/shared-with-me')
})
+
+ it('hides the "Shared with me" tab when inbound grants are unavailable (403)', () => {
+ vi.mocked(inboundHook.useInboundGrants).mockReturnValue({
+ status: 'unavailable',
+ grants: [],
+ reload: vi.fn(),
+ })
+ vi.mocked(hook.usePublishScope).mockReturnValue({
+ scope: { scope: '@acme', curator: false, orgName: 'Acme' },
+ loading: false,
+ error: false,
+ })
+ render(<PublisherView activeTab="entries" />)
+ expect(screen.queryByRole('tab', { name: /shared with me/i })).toBeNull()
+ expect(screen.getByRole('tab', { name: /published entries/i })).toBeInTheDocument()
+ expect(screen.getByRole('tab', { name: /docker credentials/i })).toBeInTheDocument()
+ })
+
+ it('shows the "Shared with me" tab when inbound grants are available', () => {
+ vi.mocked(inboundHook.useInboundGrants).mockReturnValue({
+ status: 'available',
+ grants: [],
+ reload: vi.fn(),
+ })
+ vi.mocked(hook.usePublishScope).mockReturnValue({
+ scope: { scope: '@acme', curator: false, orgName: 'Acme' },
+ loading: false,
+ error: false,
+ })
+ render(<PublisherView activeTab="entries" />)
+ expect(screen.getByRole('tab', { name: /shared with me/i })).toBeInTheDocument()
+ })
})
diff --git a/control-ui/lib/hooks/useInboundGrants.ts b/control-ui/lib/hooks/useInboundGrants.ts
new file mode 100644
index 000000000..7ece71078
--- /dev/null
+++ b/control-ui/lib/hooks/useInboundGrants.ts
@@ -0,0 +1,51 @@
+'use client'
+
+import { useCallback, useEffect, useState } from 'react'
+import { type GrantedToMeItem, isSilentApiError, listGrantedToMe } from '../api'
+
+export type InboundGrantsStatus = 'loading' | 'available' | 'unavailable' | 'error'
+
+export type InboundGrantsState = {
+ status: InboundGrantsStatus
+ grants: GrantedToMeItem[]
+ reload: () => void
+}
+
+/**
+ * Fetch the org's inbound cross-org grants once on mount.
+ *
+ * `unavailable` is a 403: the deployment's registry client is not provisioned to
+ * list grants (self-hosted connect tenants get read/publish scopes but not
+ * `registry:grant`). Grant *listing* is a hosted/curator surface — but plugins
+ * shared with the org still appear in the Marketplace catalog and install
+ * normally, so this is a missing convenience list, not a broken feature. The
+ * Publisher hides the "Shared with me" tab in that case (see PublisherView).
+ * `error` is a transient failure (retryable via `reload`). A silent 401
+ * (session expiry) is left to the global auth handler.
+ */
+export function useInboundGrants(): InboundGrantsState {
+ const [status, setStatus] = useState<InboundGrantsStatus>('loading')
+ const [grants, setGrants] = useState<GrantedToMeItem[]>([])
+ const [nonce, setNonce] = useState(0)
+ const reload = useCallback(() => setNonce(n => n + 1), [])
+
+ useEffect(() => {
+ let cancelled = false
+ setStatus('loading')
+ listGrantedToMe()
+ .then(({ grants: rows }) => {
+ if (cancelled) return
+ setGrants(rows)
+ setStatus('available')
+ })
+ .catch(err => {
+ if (cancelled || isSilentApiError(err)) return
+ setStatus((err as { status?: number }).status === 403 ? 'unavailable' : 'error')
+ })
+ return () => {
+ cancelled = true
+ }
+ }, [nonce])
+
+ return { status, grants, reload }
+}
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 2cb64779c..ab6c0d8a9 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.332",
+ "version": "0.1.333",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.332",
+ "version": "0.1.333",
"dependencies": {
"@clerum/llm-providers": "file:../packages/llm-providers",
"@clerum/workflow-recipe-capability-policy": "file:../packages/workflow-recipe-capability-policy",
diff --git a/control-ui/package.json b/control-ui/package.json
index 0f5bed389..187c35ed7 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.332",
+ "version": "0.1.333",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",