feat(renderer): add AppProviders and PermissionsProvider#1747
Conversation
Move the provider tree (ThemeProvider, PromptProvider, QueryClientProvider, TooltipProvider, ReactQueryDevtools) from renderer.tsx into a composable AppProviders component, enabling downstream builds to reuse the provider stack without duplication. Made-with: Cursor
Add a permissions context with canShow() helper, wired into AppProviders. All permissions default to true (OSS behavior unchanged). Downstream builds can pass partial overrides via AppProviders' permissions prop to selectively disable features. Made-with: Cursor
Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR refactors the renderer entrypoint by extracting the provider tree into a reusable AppProviders component and introduces a new permissions context intended to gate UI features behind typed permission keys (defaulting to “allowed” for OSS behavior parity).
Changes:
- Extract provider composition from
renderer.tsxintorenderer/src/app-providers.tsx. - Add a new permissions context (
PermissionsProvider,usePermissions(), andcanShow()helper) plus a centralpermission-keys.ts. - Add initial unit tests for the permissions provider behavior.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| renderer/src/renderer.tsx | Replaces inline provider tree with <AppProviders> wrapper. |
| renderer/src/app-providers.tsx | New composable provider stack, adds PermissionsProvider and permissions overrides prop. |
| renderer/src/common/contexts/permissions/index.ts | Defines permissions types, default permissions, context, and usePermissions() hook. |
| renderer/src/common/contexts/permissions/permissions-provider.tsx | Implements provider that merges overrides onto defaults. |
| renderer/src/common/contexts/permissions/permission-keys.ts | Introduces centralized permission key definitions (currently empty). |
| renderer/src/common/contexts/permissions/tests/permissions-provider.test.tsx | Adds tests for default allow + overrides (currently bypasses public API/types). |
renderer/src/common/contexts/permissions/__tests__/permissions-provider.test.tsx
Show resolved
Hide resolved
renderer/src/common/contexts/permissions/__tests__/permissions-provider.test.tsx
Show resolved
Hide resolved
Exports will be consumed when the first permission keys are defined. Made-with: Cursor
|
@claude succinct review |
|
Claude finished @peppescg's task in 41s —— View job Review
Permissions system — the scaffold is solid but has a few problems to address before or when keys are added: 1. Empty 2. Tests don't exercise the public API ( 3. 4. Overall the approach is good — the issues in 1–3 are acceptable as a scaffold if the intent is to fill in keys immediately in a follow-up, but they should be noted. Point 4 is a small omission worth fixing now. |
samuv
left a comment
There was a problem hiding this comment.
nice, let's just remember to add some tests
Summary
renderer.tsxinto a composableAppProviderscomponent (app-providers.tsx), reducing duplication and improving maintainabilityPermissionsProviderwith ausePermissions()hook andcanShow()helper to conditionally render UI features based on permission keystrue(no behavioral changes); individual keys can be overridden tofalsevia thepermissionsprop on<AppProviders>permission-keys.ts) with full TypeScript safety and IDE autocompletionHow it works
permission-keys.tscanShow(PERMISSION_KEYS.MY_FEATURE)in any component to gate visibility<AppProviders permissions={{ 'my-feature': false }}>to selectively disable featuresTest plan
Closes #1706
Closes #1708