-
Notifications
You must be signed in to change notification settings - Fork 4
ENG-1188: add pull watch for top level blocks #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: eng-1189-init-schema
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| import { TOP_LEVEL_BLOCK_PROP_KEYS } from "~/data/blockPropsSettingsConfig"; | ||
|
|
||
| export const setupPullWatchBlockPropsBasedSettings = ( | ||
| blockUids: Record<string, string>, | ||
| ) => { | ||
| const featureFlagsBlockUid = | ||
| blockUids[TOP_LEVEL_BLOCK_PROP_KEYS.featureFlags]; | ||
|
|
||
| if (featureFlagsBlockUid) { | ||
| window.roamAlphaAPI.data.addPullWatch( | ||
| "[:block/props]", | ||
| `[:block/uid "${featureFlagsBlockUid}"]`, | ||
| (before, after) => { | ||
| console.log("feature flags changed", before, after); | ||
| }, | ||
| ); | ||
| } | ||
|
Comment on lines
+9
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find and read the pullWatchBlockPropsBasedSettings file
find . -name "*pullWatchBlockPropsBasedSettings*" -type fRepository: DiscourseGraphs/discourse-graph Length of output: 132 🏁 Script executed: #!/bin/bash
# Read the file in question and context
fd "pullWatchBlockPropsBasedSettings" --exec cat -n {} \;Repository: DiscourseGraphs/discourse-graph Length of output: 720 🏁 Script executed: #!/bin/bash
# Search for setupPullWatchBlockPropsBasedSettings usage in the codebase
rg -n "setupPullWatchBlockPropsBasedSettings" -A 3 -B 3 --type ts --type tsxRepository: DiscourseGraphs/discourse-graph Length of output: 102 🏁 Script executed: #!/bin/bash
# Search for how setupPullWatchBlockPropsBasedSettings is called
rg -n "setupPullWatchBlockPropsBasedSettings" -A 5 -B 2Repository: DiscourseGraphs/discourse-graph Length of output: 802 🏁 Script executed: #!/bin/bash
# Search for other addPullWatch usage in codebase to see cleanup patterns
rg -n "addPullWatch" -A 5 -B 2Repository: DiscourseGraphs/discourse-graph Length of output: 1402 🏁 Script executed: #!/bin/bash
# Search for callers of setupPullWatchBlockPropsBasedSettings - where is it invoked?
rg -n "setupPullWatchBlockPropsBasedSettings\(" -B 5 -A 5Repository: DiscourseGraphs/discourse-graph Length of output: 57 🏁 Script executed: #!/bin/bash
# Get more context around the useRoamStore usage to understand the cleanup pattern
cat -n apps/roam/src/components/canvas/useRoamStore.ts | sed -n '410,430p'Repository: DiscourseGraphs/discourse-graph Length of output: 880 🏁 Script executed: #!/bin/bash
# Search for imports and actual usage of setupPullWatchBlockPropsBasedSettings
rg -n "setupPullWatchBlockPropsBasedSettings" --type tsRepository: DiscourseGraphs/discourse-graph Length of output: 187 🏁 Script executed: #!/bin/bash
# Look for where this function might be called - check if it's exported and used
git grep -n "setupPullWatchBlockPropsBasedSettings"Repository: DiscourseGraphs/discourse-graph Length of output: 187 🏁 Script executed: #!/bin/bash
# Check the full context of useRoamStore to see the pullWatchProps definition
cat -n apps/roam/src/components/canvas/useRoamStore.ts | sed -n '400,430p'Repository: DiscourseGraphs/discourse-graph Length of output: 1479 🏁 Script executed: #!/bin/bash
# Search more broadly - check all files including .tsx for any reference
rg "setupPullWatchBlockPropsBasedSettings" --type-list
rg "setupPullWatchBlockPropsBasedSettings" .Repository: DiscourseGraphs/discourse-graph Length of output: 594 🏁 Script executed: #!/bin/bash
# Check the context around line 400-430 to understand the full picture
cat -n apps/roam/src/components/canvas/useRoamStore.ts | sed -n '395,435p'Repository: DiscourseGraphs/discourse-graph Length of output: 1615 🏁 Script executed: #!/bin/bash
# Check if setupPullWatchBlockPropsBasedSettings is actually called anywhere
rg "setupPullWatchBlockPropsBasedSettings\(" --type ts -B 3 -A 3Repository: DiscourseGraphs/discourse-graph Length of output: 57 🏁 Script executed: #!/bin/bash
# Look for imports of setupPullWatchBlockPropsBasedSettings
rg "import.*setupPullWatchBlockPropsBasedSettings"Repository: DiscourseGraphs/discourse-graph Length of output: 57 🏁 Script executed: #!/bin/bash
# Check the type definition for AddPullWatch to understand return value
rg -n "type AddPullWatch|interface AddPullWatch" -A 5Repository: DiscourseGraphs/discourse-graph Length of output: 57 🏁 Script executed: #!/bin/bash
# Check if setupPullWatchBlockPropsBasedSettings might be called dynamically or exported in a barrel export
cat apps/roam/src/utils/pullWatchBlockPropsBasedSettings.tsRepository: DiscourseGraphs/discourse-graph Length of output: 594 🏁 Script executed: #!/bin/bash
# Check index files that might re-export this
find apps/roam/src -name "index.ts" -o -name "index.tsx" | xargs grep -l "setupPullWatchBlockPropsBasedSettings" 2>/dev/nullRepository: DiscourseGraphs/discourse-graph Length of output: 59 🏁 Script executed: #!/bin/bash
# Final check - search entire repo for any reference including comments
rg "setupPullWatchBlockPropsBasedSettings" --type ts -C 10Repository: DiscourseGraphs/discourse-graph Length of output: 1238 🏁 Script executed: #!/bin/bash
# Check if there are any newer commits or branches that might use this function
git log --oneline --all -S "setupPullWatchBlockPropsBasedSettings" 2>/dev/null | head -20Repository: DiscourseGraphs/discourse-graph Length of output: 118 🏁 Script executed: #!/bin/bash
# Check the git diff or status to see if this is a new file in this PR
git log --oneline --follow -- apps/roam/src/utils/pullWatchBlockPropsBasedSettings.ts 2>/dev/null | head -10Repository: DiscourseGraphs/discourse-graph Length of output: 118 🏁 Script executed: #!/bin/bash
# Check the commit details to understand this PR better
git show 8f17d89 --statRepository: DiscourseGraphs/discourse-graph Length of output: 40103 🏁 Script executed: #!/an/bin/bash
# Check if the function is used in that commit or any subsequent commits
git show 8f17d89 --name-onlyRepository: DiscourseGraphs/discourse-graph Length of output: 29331 🏁 Script executed: #!/bin/bash
# Check the full diff of that commit
git show 8f17d89Repository: DiscourseGraphs/discourse-graph Length of output: 50391 Critical: Add cleanup mechanism to prevent memory leaks when pull watch is registered. The return () => {
window.roamAlphaAPI.data.removePullWatch(
"[:block/props]",
`[:block/uid "${featureFlagsBlockUid}"]`,
callback
);
};Additionally, the callback only logs to console—implement the actual settings update logic to complete this feature. |
||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add explicit return type per coding guidelines.
The function is missing an explicit return type. Per the coding guidelines, all functions should have explicit return types.
🔎 Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents