chore(apps): consolidate accessor implementation to runtime (1/4) - #41376
Conversation
|
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
WalkthroughThe PR documents accessor consolidation, adds ChangesAccessor consolidation
Estimated code review effort: 3 (Moderate) | ~30 minutes Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant Accessor
participant RemoteBridges
participant Messenger
participant HostBridge
Accessor->>RemoteBridges: invoke do* operation
RemoteBridges->>Messenger: send bridges:<bridge>:<doMethod>
Messenger->>HostBridge: dispatch request
HostBridge-->>Messenger: return JSON-RPC result
Messenger-->>RemoteBridges: return response
RemoteBridges-->>Accessor: return unwrapped result
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41376 +/- ##
===========================================
- Coverage 68.47% 68.46% -0.01%
===========================================
Files 4092 4092
Lines 158285 158285
Branches 28622 28667 +45
===========================================
- Hits 108379 108373 -6
- Misses 44874 44877 +3
- Partials 5032 5035 +3
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
06c7719 to
477d50c
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (2)
docs/proposals/apps-accessor-consolidation/README.md (1)
261-261: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSpecify a language for the fenced code block.
Static analysis tool
markdownlint-cli2flagged that this fenced code block lacks a specified language. Consider addingtextorplaintextfor better formatting.📝 Proposed fix
-``` +```text AppResourceBridge (host-side, internal — not part of the app-facing definition surface)🤖 Prompt for 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. In `@docs/proposals/apps-accessor-consolidation/README.md` at line 261, Specify an explicit language for the fenced code block containing the AppResourceBridge text, using text or plaintext as appropriate, while preserving the block’s existing content.Source: Linters/SAST tools
packages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.ts (1)
24-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the repeated implementation comments.
The late-bound callback is already concise and self-explanatory.
packages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.ts#L24-L25: remove the constructor comment.packages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.ts#L31-L32: remove the duplicate comment.packages/apps/base-runtime/src/lib/accessors/notifier.ts#L19-L20: remove the duplicate comment.As per coding guidelines, “Avoid code comments in the implementation.” <coding_guidelines>
🤖 Prompt for 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. In `@packages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.ts` around lines 24 - 25, Remove the repeated late-bound callback implementation comments from the constructors in ModifyExtender.ts (lines 24-25), ModifyUpdater.ts (lines 31-32), and notifier.ts (lines 19-20). Leave the callback implementations unchanged.Source: Coding guidelines
🤖 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 `@packages/apps/base-runtime/src/lib/accessors/notifier.ts`:
- Around line 63-64: Update getAppUser to return Promise<IUser>, validate the
result of doGetAppUser, and reject or throw when no app user is returned instead
of propagating undefined. Then remove the downstream as IUser casts and optional
chaining that are no longer needed, preserving the required sender and typing
username behavior.
In
`@packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.ts`:
- Around line 46-59: Update the parity assertion in the
ModifyExtender.extendMessage/finish test to validate the recorded calls’
parameters as well as their method names. Use emitted() or equivalent call
inspection to assert the expected ordered arguments, including APP_ID
normalization, while preserving the existing bridge-method ordering check.
In `@packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.ts`:
- Line 6: Update the documentation reference in the parityHarness comment to
point to docs/proposals/apps-accessor-consolidation/README.md, replacing the
outdated docs/base-runtime-accessor-consolidation.md path.
- Around line 64-67: Update the sender callback that builds each RecordedCall to
snapshot requestDescriptor.params, including nested objects and arrays, before
pushing it into calls. Preserve the existing normalization of non-array params
while ensuring later accessor mutations cannot change previously recorded calls.
---
Nitpick comments:
In `@docs/proposals/apps-accessor-consolidation/README.md`:
- Line 261: Specify an explicit language for the fenced code block containing
the AppResourceBridge text, using text or plaintext as appropriate, while
preserving the block’s existing content.
In `@packages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.ts`:
- Around line 24-25: Remove the repeated late-bound callback implementation
comments from the constructors in ModifyExtender.ts (lines 24-25),
ModifyUpdater.ts (lines 31-32), and notifier.ts (lines 19-20). Leave the
callback implementations unchanged.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bb9acd44-1e1a-4550-b712-91c0c2d66aad
📒 Files selected for processing (16)
docs/proposals/apps-accessor-consolidation/README.mddocs/proposals/apps-accessor-consolidation/base-runtime-app-id-exceptions.mdpackages/apps/base-runtime/src/lib/UIHelper.tspackages/apps/base-runtime/src/lib/accessors/http.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyCreator.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.tspackages/apps/base-runtime/src/lib/accessors/notifier.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.tspackages/apps/base-runtime/src/lib/bridges/RemoteBridges.tspackages/apps/base-runtime/src/lib/bridges/tests/RemoteBridges.test.tspackages/apps/base-runtime/src/lib/roomFactory.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
- GitHub Check: 📦 Build Packages
- GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation
Files:
packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.tspackages/apps/base-runtime/src/lib/bridges/tests/RemoteBridges.test.tspackages/apps/base-runtime/src/lib/UIHelper.tspackages/apps/base-runtime/src/lib/roomFactory.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.tspackages/apps/base-runtime/src/lib/accessors/notifier.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.tspackages/apps/base-runtime/src/lib/accessors/http.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.tspackages/apps/base-runtime/src/lib/bridges/RemoteBridges.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyCreator.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.
Applied to files:
packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.tspackages/apps/base-runtime/src/lib/bridges/tests/RemoteBridges.test.tspackages/apps/base-runtime/src/lib/UIHelper.tspackages/apps/base-runtime/src/lib/roomFactory.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.tspackages/apps/base-runtime/src/lib/accessors/notifier.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.tspackages/apps/base-runtime/src/lib/accessors/http.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.tspackages/apps/base-runtime/src/lib/bridges/RemoteBridges.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyCreator.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.
Applied to files:
packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.tspackages/apps/base-runtime/src/lib/bridges/tests/RemoteBridges.test.tspackages/apps/base-runtime/src/lib/UIHelper.tspackages/apps/base-runtime/src/lib/roomFactory.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.tspackages/apps/base-runtime/src/lib/accessors/notifier.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.tspackages/apps/base-runtime/src/lib/accessors/http.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.tspackages/apps/base-runtime/src/lib/bridges/RemoteBridges.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyCreator.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.
Applied to files:
packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.tspackages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.tspackages/apps/base-runtime/src/lib/bridges/tests/RemoteBridges.test.tspackages/apps/base-runtime/src/lib/UIHelper.tspackages/apps/base-runtime/src/lib/roomFactory.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.tspackages/apps/base-runtime/src/lib/accessors/notifier.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.tspackages/apps/base-runtime/src/lib/accessors/http.tspackages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.tspackages/apps/base-runtime/src/lib/bridges/RemoteBridges.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.tspackages/apps/base-runtime/src/lib/accessors/modify/ModifyCreator.ts
🪛 LanguageTool
docs/proposals/apps-accessor-consolidation/README.md
[style] ~203-~203: ‘exactly the same’ might be wordy. Consider a shorter alternative.
Context: ...gistry`. The new bridge methods receive exactly the same serialized shapes, so **the wire semant...
(EN_WORDINESS_PREMIUM_EXACTLY_THE_SAME)
🪛 markdownlint-cli2 (0.23.0)
docs/proposals/apps-accessor-consolidation/README.md
[warning] 261-261: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (8)
packages/apps/base-runtime/src/lib/accessors/modify/ModifyExtender.ts (1)
11-23: LGTM!Also applies to: 26-30, 39-47, 57-65
packages/apps/base-runtime/src/lib/accessors/modify/ModifyUpdater.ts (1)
14-30: LGTM!Also applies to: 33-33, 75-87, 118-118, 148-148
packages/apps/base-runtime/src/lib/accessors/notifier.ts (1)
9-18: LGTM!Also applies to: 21-22, 59-61
packages/apps/base-runtime/src/lib/accessors/tests/ModifyCreator.test.ts (1)
59-59: LGTM!packages/apps/base-runtime/src/lib/accessors/tests/ModifyExtender.test.ts (1)
40-40: LGTM!Also applies to: 51-51, 66-66, 77-77, 92-92, 103-103
packages/apps/base-runtime/src/lib/accessors/tests/ModifyUpdater.test.ts (1)
45-45: LGTM!Also applies to: 64-64, 79-79, 101-101
packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.test.ts (1)
1-44: LGTM!packages/apps/base-runtime/src/lib/accessors/tests/helpers/parityHarness.ts (1)
23-53: LGTM!Also applies to: 61-63, 69-80
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
8df5c8d to
6a9ed9d
Compare
Analyzes every accessor in packages/apps/src/server/accessors and lays out a phased plan to make the base-runtime the single source of truth for accessor behavior and to eliminate handleAccessorMessage (the accessor:* JSON-RPC category) from BaseRuntimeSubprocessController, leaving bridges:* as the only app-originated RPC channel. Key findings and decisions documented: - Permission enforcement lives in host bridge do* wrappers with APP_ID substitution, so moving accessor logic into the subprocess loses nothing security-wise. - The registration/configuration family (slash commands, APIs, scheduler, UI buttons, providers, app settings) writes into host-only manager registries; a new internal AppResourceBridge fronts those managers over the existing bridges:* channel instead of keeping a residual accessor channel. - Behavioral drift between the duplicated implementations (diff vs full-object updates, editor tracking, typing await semantics, APP_ID placeholder inconsistency) is resolved in favor of the runtime, which is the behavior production apps already experience. - Only one genuine host-side accessor consumer exists outside the RPC path (AppListenerManager's getAppUser lookup), replaceable with a direct bridge call, enabling full deletion of src/server/accessors and AppAccessorManager. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018FbxFGJWHiroxrdNPJRL3P move docs to proper place grilling session on the plan rename proposal doc
…dation Lays the groundwork for moving accessor behavior into the base-runtime and eventually removing handleAccessorMessage, without changing observable behavior: - Add RemoteBridges, a typed facade over the host bridge surface that centralizes bridges:<bridge>:do* message construction, result unwrapping, and error formatting. It deliberately does NOT auto-inject the 'APP_ID' sentinel and gates access to do* methods only (mirrors the host gate, failing fast in the subprocess). - Refactor the existing local runtime accessors (Http, Notifier, ModifyCreator, ModifyUpdater, ModifyExtender, roomFactory) onto the facade. Caller-identity params are normalized to the 'APP_ID' sentinel so the host substitutes the real id (closing the prior inconsistency where the sandbox sent its own id); app-supplied argument-appIds and nested payload appIds are left raw per the exception list. Each accessor builds its facade from a thunk reading this.senderFn so instance-level senderFn test stubs keep working; ModifyCreator/ModifyUpdater retain senderFn for their remaining accessor:* sub-proxies until their Phase 2 port. - Duplicate UIHelper into base-runtime/src/lib so the runtime no longer imports the host's apps/dist output (avoids a build cycle); the host copy stays until teardown. - Add a transitional parity harness (recording sendRequest) to pin the ordered host-bound traffic a ported accessor emits, gating MOVE-accessor deletions in later phases. - Document the APP_ID normalization exception list and record Phase 0 status and the changeset decision in the migration plan. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018FbxFGJWHiroxrdNPJRL3P
…arness - parityHarness: deep-snapshot recorded params at emit time so a later accessor mutation of a shared object cannot rewrite an already-recorded call; fix the stale migration-doc reference. - parityHarness test: assert the emitted params (id + APP_ID sentinel on lookup, mutated message + APP_ID sentinel on write), not just the ordered method names. - docs: give the AppResourceBridge fenced block an explicit language. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
6a9ed9d to
5b74754
Compare
Proposed changes (including videos or screenshots)
This PR adds a comprehensive design document (
base-runtime-accessor-consolidation.md) that outlines a phased plan to consolidate accessor logic frompackages/apps/src/server/accessors/into the base-runtime, eliminating the need for theaccessor:*JSON-RPC message category and making the base-runtime the single source of truth for accessor behavior.Current state: Accessor calls from apps take three paths:
accessor:*messages (forwarded to host)Target state: Consolidate all accessor logic into the base-runtime, with side effects flowing through the existing
bridges:*RPC channel.This document represents significant architectural work to improve code organization and eliminate technical debt. It includes:
AppResourceBridgeto close gapsIssue(s)
Related Jira task: ARCH-2185: reunite duplicated accessor implementations into a shared location
Steps to test or reproduce
Further comments
Summary by CodeRabbit