Conversation
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@CodeRabbit ai full review |
|
@sid597: I'll perform a full review of this PR now. 🧠 Learnings used✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughAdds a new Roam settings accessors module with typed, nested get/set utilities, schema validation, caching and invalidation; converts Relations from arrays to record objects in schemas and defaults; and wires the new accessors into init with stub calls for Left Sidebar personal sections. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Accessors as Accessors Module
participant Zod as Zod Schema
participant Roam as Roam Blocks DB
participant Cache as Local Cache
Client->>Accessors: getGlobalSetting(keys)
Accessors->>Cache: check cache for page/block props
alt cache hit
Cache-->>Accessors: cached value
else cache miss
Accessors->>Roam: read block by page/title/uid
Roam-->>Accessors: block props (raw)
Accessors->>Zod: validate/parse props
Zod-->>Accessors: parsed/typed settings
Accessors->>Cache: store parsed value
end
Accessors-->>Client: return typed setting
Client->>Accessors: setGlobalSetting(keys, value)
Accessors->>Zod: validate value against schema
Zod-->>Accessors: validated payload
Accessors->>Roam: write/update nested block props
Roam-->>Accessors: write confirmation
Accessors->>Cache: invalidate/update cache
Accessors-->>Client: success
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
1ebeb69 to
22de4b1
Compare
e30930e to
0ca99fc
Compare
22de4b1 to
9464473
Compare
0ca99fc to
7ea650f
Compare
9464473 to
3d7e4c7
Compare
3d7e4c7 to
fb87a45
Compare
fb87a45 to
3fbeb9f
Compare
0365026 to
76d487b
Compare
76d487b to
3c7d025
Compare
3fbeb9f to
6cf85ea
Compare
c43eb11 to
67cb84e
Compare
mdroidian
left a comment
There was a problem hiding this comment.
Good start.
Main items to address:
-
Key-path semantics: Several functions accept
keys: string[], but the meaning ofkeysdiffers by function (sometimes it’s a traversal path, sometimes the first element is treated as a lookup key, etc.). Please make this explicit at the call site—either by splitting functions (e.g.,setAtPathvssetRoot/getFromSettingsBlockvsgetByUid) or by renaming parameters (pathvssettingsKeys) and adding docstrings/examples. -
Type safety for keys: Callers currently have to manually know the valid keys for each schema. Can we make this more Zod/TypeScript-safe (e.g., typed path helpers, exported key constants, or a small set of typed getters/setters per settings domain) to avoid stringly-typed access?
-
Type assertions: There are a number of
as ...assertions. Please reduce these where possible by tightening types and/or adding type guards. If an assertion is truly necessary, add a short comment explaining why it is required, and why it is safe. -
Export surface: It’s unclear which exports are intended as public API vs internal helpers. Please audit exports and keep only the functions intended for callers outside
accessors.ts(or move internal helpers to non-exported scope). -
Error reporting: Any
console.warnthat indicates a user-impacting or unexpected state should go throughinternalError()so we can track it and surface appropriate messaging.
apps/roam/src/components/settings/data/defaultRelationsBlockProps.ts
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/data/defaultRelationsBlockProps.ts
Outdated
Show resolved
Hide resolved
| }, settings) as T | undefined; | ||
| }; | ||
|
|
||
| let discourseNodesCache: DiscourseNodeSettings[] | null = null; |
There was a problem hiding this comment.
What is the thought behind having a cache just for discourse node settings?
There was a problem hiding this comment.
you mean we should have the caching for other settings as well? Its for discourse node because we have to run a query and thats expensive so we cache it
There was a problem hiding this comment.
Which query are you referring to?
There was a problem hiding this comment.
line 466 in function getAllDiscourseNodes()
There was a problem hiding this comment.
getAllDiscourseNodes() (just a handlefull of pages based on a simple string match) shouldn't be a heavy query, let's not cache it
|
@sid597 Also make sure you format with prettier |
|
Did the following changes:
|
8a707cf to
c0ca4ef
Compare
67cb84e to
177a47d
Compare
177a47d to
b40fcdc
Compare
apps/roam/src/components/settings/data/defaultRelationsBlockProps.ts
Outdated
Show resolved
Hide resolved
b40fcdc to
e11e431
Compare
0cf76d1 to
c95a994
Compare
c95a994 to
132d1c5
Compare
mdroidian
left a comment
There was a problem hiding this comment.
Let's just remove the caches for now (shouldn't need them, so let's not make it more complex than we need to). We'll add them back in if we find a need for them.
Then there's a few more comments to address.
apps/roam/src/components/settings/data/defaultRelationsBlockProps.ts
Outdated
Show resolved
Hide resolved
apps/roam/src/components/settings/data/defaultRelationsBlockProps.ts
Outdated
Show resolved
Hide resolved
| }, settings) as T | undefined; | ||
| }; | ||
|
|
||
| let discourseNodesCache: DiscourseNodeSettings[] | null = null; |
There was a problem hiding this comment.
getAllDiscourseNodes() (just a handlefull of pages based on a simple string match) shouldn't be a heavy query, let's not cache it
mdroidian
left a comment
There was a problem hiding this comment.
Actually I'll approve this, but tag me before merging if there are any issues with implementing the requests.

https://www.loom.com/share/3c07a184d5d740a59410ee49d1fead0c
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.