Conversation
Users can paste a ((block-uid)) in the personal settings "Add section" field to create a query section. Query sections auto-create settings (Alias, Folded, Truncate-result, Result-limit) and render query results as clickable children in the sidebar view. Settings panel: inline alias input, block ref display, settings/trash buttons. Settings dialog: Result-limit panel for all sections. Sidebar view: QuerySectionItem with lazy query execution on first expand, refresh via inline menu, go-to-query-block navigation, and proper loading/error/empty states.
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThis PR extends the left sidebar to support query sections—personal sections containing Roam query syntax in double parentheses. Users can execute queries on-demand, set result limits, and alias sections; query results are rendered as clickable child items with optional truncation. ChangesQuery Sections: Type Definitions, Settings Persistence, and Rendering
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/roam/src/components/LeftSidebarView.tsx`:
- Around line 320-342: The runQuery function calls parseQuery(queryUid)
synchronously so any thrown parse errors bypass the promise .catch; update
runQuery to handle sync failures by either wrapping parseQuery in a try/catch
that sets setError("Query failed to run"), setIsLoading(false) and
setHasLoaded(true) on error, or convert to a promise chain (e.g.,
Promise.resolve().then(() => parseQuery(queryUid)).then(args =>
fireQuery(args)...)) so parse errors flow into the existing .catch; ensure you
reference runQuery, parseQuery, fireQuery, setError, setIsLoading and
setHasLoaded when applying the fix.
In `@apps/roam/src/components/settings/LeftSidebarPersonalSettings.tsx`:
- Line 944: Rename the setter callback parameter named `_keys` to a camelCase
identifier (e.g., `keys` or `selectedKeys`) in the setter prop passed in
LeftSidebarPersonalSettings (the arrow function `setter={(_keys, value) => { ...
}}`) to satisfy ESLint camelCase rules; update all references inside that
function body to the new name and ensure the function signature remains `(keys,
value) => { ... }` (or `(selectedKeys, value) => { ... }`) so no other behavior
changes.
- Around line 339-380: handleAliasChange is calling
syncAllSectionsToBlockProps(sectionsRef.current) while sections are not updated,
causing stale alias writes; fix by computing an updatedSections array (map over
previous sections and set the new alias.value and valueUid as appropriate) for
both the updateBlock and createBlock branches, immediately assign it to
sectionsRef.current and call setSections(updatedSections), then call
syncAllSectionsToBlockProps(updatedSections) (instead of sectionsRef.current)
before refreshAndNotify so the serialized settings reflect the new alias state;
reference handleAliasChange, alias.valueUid, updateBlock, createBlock,
setSections, sectionsRef, and syncAllSectionsToBlockProps.
In `@apps/roam/src/utils/getLeftSidebarSettings.ts`:
- Around line 22-23: isQuerySection currently treats any string wrapped in
((...)) as a query ref, allowing malformed refs like (()) or ((not-a-uid)) to
reach QuerySectionItem and parseQuery; update isQuerySection to extract the
inner text (e.g., const inner = text.slice(2, -2).trim()) and return true only
if inner is non-empty and passes a UID validation (prefer reusing an existing
isValidUid/isUid utility if available, otherwise validate against the Roam UID
pattern such as /^[A-Za-z0-9]{9}$/); this prevents invalid refs from being
classified as query sections and stops bad input from reaching
QuerySectionItem/parseQuery.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9e3dab95-2fb3-4fea-9821-e85e93b2b71d
📒 Files selected for processing (3)
apps/roam/src/components/LeftSidebarView.tsxapps/roam/src/components/settings/LeftSidebarPersonalSettings.tsxapps/roam/src/utils/getLeftSidebarSettings.ts
- Reuse existing runQuery utility instead of inline parseQuery + fireQuery - Apply resultLimit at render so limit changes take effect without refetch - Validate block ref format in isQuerySection to reject malformed refs - Wrap query call in try/catch so sync parseQuery throws don't bypass error state - Persist alias edits to section state before syncing block props
https://www.loom.com/share/4981b1b58cfc4db1b70b766029858903
Summary by CodeRabbit