fix(ai-workspace): scroll API Keys into view from the Consume LLM Provider step - #3103
fix(ai-workspace): scroll API Keys into view from the Consume LLM Provider step#3103sanjulaonline wants to merge 2 commits into
Conversation
Focus the API Keys section when the consume step is selected from either the overview or deploy page. Carry the intent through router state and consume it once per location to prevent effect replays. Related to wso2#3099
📝 WalkthroughWalkthroughThe consume step now requests API-key focus through navigation state. The overview tracks the API Keys section, scrolls to it after mounting, highlights it temporarily, and removes consumed state flags. ChangesAPI key focus navigation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ConsumeStep
participant ServiceProviderOverview
participant ServiceProviderOverviewTab
ConsumeStep->>ServiceProviderOverview: Navigate with focusApiKeys
ServiceProviderOverview->>ServiceProviderOverviewTab: Pass apiKeysSectionRef
ServiceProviderOverviewTab-->>ServiceProviderOverview: Mount API Keys section
ServiceProviderOverview->>ServiceProviderOverview: Scroll and highlight API Keys
ServiceProviderOverview->>ServiceProviderOverview: Remove consumed navigation flag
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@portals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderDeploy.tsx`:
- Around line 80-83: Only pass the focusApiKeys navigation state from
ServiceProviderDeploy when the destination renders the API Keys section;
otherwise use the explicit project-level/non-admin fallback. In
ServiceProviderOverview, update the focus-state consumer to apply that same
fallback before clearing the request, so non-rendering layouts do not silently
discard the Consume-step intent. Affected sites:
portals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderDeploy.tsx
lines 80-83 requires the navigation guard;
portals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderOverview.tsx
lines 710-727 requires the matching consume-or-fallback behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: dc18c0fa-75a1-4f26-82c5-9f21f078b7a9
📒 Files selected for processing (3)
portals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderDeploy.tsxportals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderOverview.tsxportals/ai-workspace/src/pages/appShell/appShellPages/serviceProvider/ServiceProviderOverviewTab.tsx
Only pass the API Keys focus intent when the overview page can render its target. Otherwise, keep the user on the deploy page and show an informational message explaining why API key management is unavailable. Related to wso2#3099
Purpose
The "Consume LLM Provider" step in the LLM provider quick-start banner gave no
visible feedback, so it read as a dead button. Two causes, one per entry point:
setTabIndex(0)when tab 0 is alreadythe default (a no-op), then set
highlightApiKeySection, which only changes aborderColor/boxShadowon the API Keys section. That section sits below thefold and nothing ever scrolled it into view.
so the highlight intent was dropped across the navigation.
Related to #3099
Scoped to the first defect reported in that issue only. The second (LLM proxy
deployment failing when provider security is switched off) is already covered by
#2955, so the issue is intentionally left open.
Goals
Select the Overview tab, smoothly scroll the API Keys section into view, and
briefly highlight it — from both entry points.
Approach
apiKeysSectionRefprop toServiceProviderOverviewTab,attached to the
Boxalready wrapping the API Keys heading and panel.ServiceProviderOverviewscrolls it withscrollIntoView({ behavior: 'smooth', block: 'center' })and enables theexisting temporary highlight.
TabPanelunmountsinactive tabs, and the section sits inside an async
gateways.length > 0branch owned by the child. So a pending-intent flag is drained by a stable
callback ref the moment the node mounts — no timeout or polling in the focus
path.
focusApiKeysin the effect that already handlesproviderAdded, guarded onlocation.keyso a single history entry isconsumed exactly once. This matters because the clearing navigation is async:
without the guard a replayed effect sees the same state and would fire the
snackbar and the scroll twice. It then drops only the consumed flags, keeping
unrelated state as well as
search/hash, so a refresh or back-navigationcannot replay the scroll.
setTimeout(..., 3000)moved into an effect withclearTimeoutcleanup, fixing an uncancelled timer on unmount.(
hasPermission(SCOPES.LLM_PROVIDER_MANAGE) && !isProjectLevel, matchingisAdminOrgLevelon the overview page). When API Keys are unavailable it showsan informational snackbar without navigating and without creating a
focusApiKeysintent, so the step never lands on a page with no target.No changes to the deployment or security path, no new dependencies, no unrelated
refactoring.
User stories
As a user who has created and deployed an LLM provider, clicking "Consume LLM
Provider" takes me to the API Keys section and highlights it — from either the
overview or the deploy page.
Documentation
N/A — no documented behaviour changes; this restores the interaction the existing
quick-start banner already implies.
Automation tests
Verification performed:
npm run build— passed.npx tsc --noEmit— currently fails with the same 20 pre-existing errors onunchanged
main; this change introduces no additional TypeScript errors.Manual verification steps:
Consume LLM Provider — the page should scroll to API Keys and highlight it.
Overview and scroll to API Keys.
navigate to Overview and scroll to API Keys.
click the step on the Deploy page — you should stay on the Deploy page, see the
informational message, and no navigation state should be created.
Security checks
Samples
N/A
Related PRs
ServiceProviderOverview.tsx(LLM → AI terminology sweep);whichever merges second needs a small mechanical rebase.
Test environment
npm run buildandnpx tsc --noEmitonly.