Skip to content

feat(intelligent-assistant): gate UI by consolidated RBAC permissions - #4651

Open
rohitratannagar wants to merge 13 commits into
redhat-developer:mainfrom
rohitratannagar:feat/UI-permissions-gating
Open

feat(intelligent-assistant): gate UI by consolidated RBAC permissions#4651
rohitratannagar wants to merge 13 commits into
redhat-developer:mainfrom
rohitratannagar:feat/UI-permissions-gating

Conversation

@rohitratannagar

@rohitratannagar rohitratannagar commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR consolidates Intelligent Assistant frontend permission checks around four RBAC permissions and treats them as binary feature gates rather than partial/read-only access modes.

Permission model

Permission Purpose
intelligent-assistant.chat Chat conversations, models, welcome prompts, and chat API hooks
intelligent-assistant.notebooks Notebooks tab, notebook sessions, and document workflows
intelligent-assistant.mcp.tools MCP server settings menu and configuration UI
intelligent-assistant.skills Skills-related capabilities (hook wired for future use)

UI gating behavior

  • Entry (FAB + chat container): Shown when the user has chat OR notebooks permission. Hidden entirely when neither is granted.
  • Chat / Notebooks tabs: Shown only when the user has both permissions. Single-permission users land directly on their allowed surface without tab chrome.
  • Header divider: Always rendered below header actions (independent of tab visibility).
  • MCP settings: Shown only with intelligent-assistant.mcp.tools. Read-only MCP mode and permission-denied screens are removed — no access means the UI is hidden.
  • Chat API hooks: Gated with enabled flags (e.g. useAllModels, useConversations, useWelcomePrompts) so notebooks-only users do not trigger chat backend calls.

Hook refactor

Legacy hooks renamed and aligned to the new permission names:

  • useLightspeedUpdatePermissionuseIaChatPermission
  • useLightspeedViewPermissionuseIaMcpToolsPermission
  • useLightspeedNotebooksPermissionuseIaNotebooksPermission
  • useLightspeedDeletePermissionuseIaSkillsPermission

Each hook returns { loading, allowed } only.

Cleanup

  • Removed PermissionRequiredState and PermissionRequiredIcon components.
  • Removed unused translation keys for permission-denied screens and MCP read-only messaging across all locales.
  • Updated unit tests for chat, FAB, and page components to cover the new gating matrix.

Fixed

  • RHIDP-15932 — Gate chat UI by intelligent-assistant.chat
  • RHIDP-15933 — Gate notebooks UI by intelligent-assistant.notebooks
  • RHIDP-15934 — Gate MCP settings by intelligent-assistant.mcp.tools

Test Plan

  • Sign in as a user with chat only — FAB and chat surface visible; no Notebooks tab; no MCP menu without MCP permission.
  • Sign in as a user with notebooks only — FAB and notebooks surface visible; no Chat tab; chat API calls not fired (verify network tab).
  • Sign in as a user with both chat and notebooks — both tabs visible; can switch between surfaces.
  • Sign in as a user with neither chat nor notebooks — FAB and chat container hidden.
  • Sign in as a user with intelligent-assistant.mcp.tools — MCP settings menu and server configuration accessible.
  • Sign in as a user without MCP permission — MCP menu hidden; no read-only fallback.
  • Run yarn test --watchAll=false in workspaces/intelligent-assistant — all tests pass.

Checklist

  • A changeset describing the change and affected packages. (more info)
  • Added or Updated documentation
  • Tests for new functionality and regression tests for bug fixes
  • Screenshots attached (for UI changes)

Made with Cursor

Replace legacy Lightspeed permission hooks with four feature-level RBAC
permissions and hide UI elements when access is denied instead of showing
permission-denied screens or read-only MCP mode.

Signed-off-by: rohitratannagar <rohitratannagar2003@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@rhdh-gh-app

rhdh-gh-app Bot commented Sep 9, 2026

Copy link
Copy Markdown

Important

This PR includes changes that affect public-facing API. Please ensure you are adding/updating documentation for new features or behavior.

Changed Packages

Package Name Package Path Changeset Bump Current Version
@red-hat-developer-hub/backstage-plugin-intelligent-assistant workspaces/intelligent-assistant/plugins/intelligent-assistant minor v5.0.1

@codecov

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.71910% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.41%. Comparing base (726c1de) to head (1e64738).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4651      +/-   ##
==========================================
- Coverage   62.72%   62.41%   -0.31%     
==========================================
  Files        2636     2623      -13     
  Lines      105422   105270     -152     
  Branches    29521    29577      +56     
==========================================
- Hits        66125    65709     -416     
- Misses      38762    38992     +230     
- Partials      535      569      +34     
Flag Coverage Δ *Carryforward flag
adoption-insights 84.77% <ø> (ø) Carriedforward from 7e95c70
ai-integrations 78.80% <ø> (ø) Carriedforward from 7e95c70
app-defaults 53.07% <ø> (ø) Carriedforward from 7e95c70
augment 46.67% <ø> (ø) Carriedforward from 7e95c70
boost 80.50% <ø> (-2.96%) ⬇️ Carriedforward from 7e95c70
bulk-import 73.12% <ø> (ø) Carriedforward from 7e95c70
cost-management 13.35% <ø> (ø) Carriedforward from 7e95c70
dcm 73.47% <ø> (ø) Carriedforward from 7e95c70
e2e-adoption-insights 60.00% <ø> (ø) Carriedforward from 7e95c70
e2e-extensions 62.31% <ø> (ø) Carriedforward from 7e95c70
e2e-global-header 49.71% <ø> (ø) Carriedforward from 7e95c70
e2e-homepage 61.11% <ø> (ø) Carriedforward from 7e95c70
e2e-intelligent-assistant 46.68% <ø> (+0.58%) ⬆️ Carriedforward from 7e95c70
e2e-orchestrator 49.52% <ø> (ø) Carriedforward from 7e95c70
e2e-orchestrator-plugin 49.51% <ø> (ø) Carriedforward from 7e95c70
e2e-quickstart 55.21% <ø> (ø) Carriedforward from 7e95c70
e2e-scorecard 50.10% <ø> (+0.05%) ⬆️ Carriedforward from 7e95c70
e2e-theme 16.36% <ø> (ø) Carriedforward from 7e95c70
extensions 57.37% <ø> (ø) Carriedforward from 7e95c70
global-floating-action-button 71.18% <ø> (ø) Carriedforward from 7e95c70
global-header 67.86% <ø> (-0.03%) ⬇️ Carriedforward from 7e95c70
homepage 48.39% <ø> (ø) Carriedforward from 7e95c70
install-dynamic-plugins 71.31% <ø> (-0.64%) ⬇️ Carriedforward from 7e95c70
intelligent-assistant 77.07% <74.71%> (-0.20%) ⬇️
konflux 91.98% <ø> (ø) Carriedforward from 7e95c70
lightspeed 69.02% <ø> (ø) Carriedforward from 7e95c70
mcp-integrations 84.46% <ø> (ø) Carriedforward from 7e95c70
orchestrator 71.13% <ø> (-0.89%) ⬇️ Carriedforward from 7e95c70
quickstart 63.74% <ø> (ø) Carriedforward from 7e95c70
sandbox 79.56% <ø> (ø) Carriedforward from 7e95c70
scorecard 87.94% <ø> (-0.27%) ⬇️ Carriedforward from 7e95c70
theme 87.91% <ø> (ø) Carriedforward from 7e95c70
translations 5.12% <ø> (ø) Carriedforward from 7e95c70
x2a 77.18% <ø> (ø) Carriedforward from 7e95c70

*This pull request uses carry forward flags. Click here to find out more.


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 726c1de...1e64738. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rohitratannagar

Copy link
Copy Markdown
Contributor Author

Both chats and notebooks permissions

p, role:default/intelligent-assistant-guest, intelligent-assistant.chat, use, allow
p, role:default/intelligent-assistant-guest, intelligent-assistant.notebooks, use, allow
Screen.Recording.2026-09-09.at.7.14.21.PM.mov

Only chat permission

p, role:default/intelligent-assistant-guest, intelligent-assistant.chat, use, allow
p, role:default/intelligent-assistant-guest, intelligent-assistant.notebooks, use, deny
Screen.Recording.2026-09-09.at.7.14.52.PM.mov

Only notebook permission

p, role:default/intelligent-assistant-guest, intelligent-assistant.chat, use, deny
p, role:default/intelligent-assistant-guest, intelligent-assistant.notebooks, use, allow
Screen.Recording.2026-09-09.at.7.15.22.PM.mov

no permission (FAB disappear)

p, role:default/intelligent-assistant-guest, intelligent-assistant.chat, use, deny
p, role:default/intelligent-assistant-guest, intelligent-assistant.notebooks, use, deny
Screen.Recording.2026-09-09.at.7.15.52.PM.mov

MCP setting page

Screen.Recording.2026-09-09.at.7.17.00.PM.mov

@its-mitesh-kumar

Copy link
Copy Markdown
Member

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 10, 2026

Copy link
Copy Markdown

🤖 Finished Review · ❌ Failure (validation failed after 2 iteration(s)) · Started 3:03 AM UTC · Completed 3:06 AM UTC

Commit: 60546ee · View workflow run →

Runtime: claude · Model: opus → claude-opus-5

@its-mitesh-kumar

Copy link
Copy Markdown
Member

@rohitratannagar Could you please see in Agenticview why fs-review is failing.

Add component, hook, and Playwright coverage for the consolidated IA
permission matrix introduced in redhat-developer#4651, including permission API mocks and
page-object based e2e scenarios with post-test MCP permission restore.

Signed-off-by: HusneShabbir <husneshabbir447@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

@HusneShabbir HusneShabbir left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few observations I noticed:

No Chat/Notebooks access: When a user without Chat or Notebooks access navigates to /intelligent-assistant, they are presented with an empty screen, which leaves them unclear about what to do next.

Screen.Recording.2026-09-10.at.11.49.32.AM.mov

Notebooks UI flicker: When a user has only Notebooks access and already has a notebook, refreshing/reloading /notebooks briefly shows the “No notebooks” state before displaying the existing notebook. This results in a noticeable UI flicker.

Screen.Recording.2026-09-10.at.11.48.29.AM.mov

HusneShabbir and others added 8 commits September 10, 2026 13:15
Use untyped jest.Mock for useAllModels and useConversations mocks to
match existing component tests and satisfy CI type checking.

Signed-off-by: HusneShabbir <husneshabbir447@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Use isolated browser sessions per permission scenario, scope tab
assertions to the chatbot region, and run the suite in English only to
avoid parallel locale bootstrap races.

Signed-off-by: HusneShabbir <husneshabbir447@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Use per-page permission matrix updates without route races, isolate each
scenario in its own browser context, and assert single-permission layouts
via tab visibility instead of brittle tab counts and API tracking.

Co-authored-by: Cursor <cursoragent@cursor.com>
Bootstrap a fresh browser context per test, register permission mocks on
the context, and exclude the permissions suite from non-English locale
projects to avoid CI login races.

Co-authored-by: Cursor <cursoragent@cursor.com>
Browser-level permission mocking is unreliable in the full CI Playwright
suite. Keep component and hook tests that cover all six RBAC scenarios
and revert the shared e2e bootstrap permission intercept.

Co-authored-by: Cursor <cursoragent@cursor.com>
Run permission gating e2e in an isolated Playwright config that enables
the permission framework, applies per-scenario authorize mocks before
navigation, and keeps the main e2e suite on the default app config.

Co-authored-by: Cursor <cursoragent@cursor.com>
…ks access

Return Backstage ErrorPage on /intelligent-assistant when neither
intelligent-assistant.chat nor intelligent-assistant.notebooks is granted,
instead of rendering an empty page.

Co-authored-by: Cursor <cursoragent@cursor.com>
…rmission-gating-automation

test(intelligent-assistant): add RBAC permission gating automation
@rohitratannagar

Copy link
Copy Markdown
Contributor Author

Permissions in RBAC cc: @its-mitesh-kumar
Screenshot 2026-09-10 at 5 46 57 PM

@michael-valdron

Copy link
Copy Markdown
Member

/fs-review

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 10, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 11:34 PM UTC · Completed 11:56 PM UTC

Commit: e761566 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Cost: $11.87

@fullsend-ai-review

fullsend-ai-review Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review

Reason: stale-head

The review agent reviewed commit 7e95c70b7c78dcc01fefeac6f430dcd51081c16c but the PR HEAD is now 1e64738b82703f4625abf6d216d24054f833ae31. This review was discarded to avoid approving unreviewed code.

Previous run

Review

Findings

Medium

  • [stale-reference] workspaces/intelligent-assistant/plugins/intelligent-assistant/src/translations/ref.ts:300 — The PR deletes PermissionRequiredIcon.tsx (the only consumer of icon.permissionRequired.alt) and correctly removes 6 other orphaned translation keys, but misses this one in ref.ts and all 5 locale files (de.ts, es.ts, fr.ts, it.ts, ja.ts).
    Remediation: Remove the icon.permissionRequired.alt entry from ref.ts and all five locale files, then regenerate report-alpha.api.md.

  • [stale-reference] workspaces/intelligent-assistant/plugins/intelligent-assistant/src/images/permission-required.svg — The SVG image file is orphaned after PermissionRequiredIcon.tsx deletion with no remaining consumer.
    Remediation: Delete the file.

Low

  • [authorization] McpServersSettings.tsx — Removed canManageMcp guards from mutation functions. Component-level gating and backend enforcement compensate, but defense-in-depth is reduced.

  • [code-organization] LightspeedFABContent.tsx — Permission-gating block duplicated verbatim across 3 components (FABContent, ChatContainer, Page). Consider extracting a useIaPluginAccess hook.

  • [backward-compatibility] report-alpha.api.md — Six translation keys removed from @alpha-exported type. Downstream overrides may see TypeScript errors, mitigated by the alpha stability tag.

  • [scope-creep] useIaSkillsPermission.ts — Hook created and exported but not consumed by any UI component. Pre-wired for future use per the changeset description.

  • [authorization] LightSpeedChat.tsx — Removed hasDeleteAccess/hasUpdateAccess disabled-state checks from dropdown items. Redundant since chat panel is now gated by the same permission.

  • [edge-case] LightspeedChatContainer.tsx — Notebooks-only users receive empty model/provider strings. Safe because the chat panel is hidden, but relies on implicit downstream guards.

  • [naming-convention] useAllModels.ts — New hooks omit explicit type annotation on enabled parameter (enabled = true vs existing convention enabled: boolean = true).


Labels: PR adds RBAC permission gating as a new feature to the intelligent-assistant workspace.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:

  • workspaces/intelligent-assistant/plugins/intelligent-assistant/src/translations/ref.ts (file-level): Line 300 · [medium] stale-reference

The PR deletes PermissionRequiredIcon.tsx (the only consumer of icon.permissionRequired.alt) and correctly removes 6 other orphaned translation keys, but misses this one in ref.ts and all 5 locale files (de.ts, es.ts, fr.ts, it.ts, ja.ts). The key also remains in report-alpha.api.md.

Suggested fix: Remove the icon.permissionRequired.alt entry from ref.ts and all five locale files, then regenerate report-alpha.api.md.

@fullsend-ai-review fullsend-ai-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the review comment for full details.

const { t } = useTranslation();
const { isChatbotActive, toggleChatbot, displayMode } =
useLightspeedDrawerContext();
const { allowed: hasChatAccess, loading: chatPermissionLoading } =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] code-organization

Permission-gating block (useIaChatPermission + useIaNotebooksPermission + permissionsLoading + hasPluginAccess) duplicated verbatim across 3 components: LightspeedFABContent.tsx, LightspeedChatContainer.tsx, and LightspeedPage.tsx.

Suggested fix: Extract the shared logic into a new useIaPluginAccess hook.

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment feature labels Sep 10, 2026
rohitratannagar and others added 2 commits September 11, 2026 12:53
Delete the unused permission-required SVG and drop the stale
icon.permissionRequired.alt translation key left behind after
removing PermissionRequiredIcon.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve merge conflicts by combining RBAC permission gating with the
intelligent-assistant MUI v5 styled-components migration from main.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Sep 11, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 12:06 PM UTC · Completed 12:27 PM UTC

Commit: 7e95c70 · View workflow run →

Runtime: claude · Model: opus → claude-opus-4-6 · Cost: $12.22

Restore boost catalog test files to match upstream/main. The React
import edits were unrelated to intelligent-assistant permission gating.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

Copy link
Copy Markdown

@fullsend-ai-review

Copy link
Copy Markdown

/fs-review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants