Skip to content

Conversation

@arthurdedeus
Copy link
Contributor

@arthurdedeus arthurdedeus commented Nov 27, 2025

Problem

When viewing a person's feed in a notebook, we need to automatically apply filters to show only events related to that person. Currently, this filtering is not applied automatically, requiring users to manually set up filters.

Changes

  • Added canvasFiltersOverride to the Notebook component and notebookLogic to allow passing filters from parent components
  • Modified NotebookNodeQuery to apply canvas filters to queries when they are first created
  • Added person ID filter in PersonFeedCanvas to automatically filter events by the current person
  • Added tracking for whether default filters have been applied to prevent duplicate application
  • Enhanced query type checking with utility functions like isDataTableNode, isEventsQuery, etc.

How did you test this code?

  • Tested creating a new insight for each kind in a person's feed canvas and verified that the current person filters were correctly applied
  • Verified that filters are correctly applied to different query types (DataTableNode, InsightVizNode)
  • Confirmed that filters are only applied once to prevent duplicate filters
  • Tested insights in normal canvas to ensure it still works when no overrides are passed down

Changelog: Yes

Copy link
Contributor Author

arthurdedeus commented Nov 27, 2025

@github-actions
Copy link
Contributor

github-actions bot commented Nov 27, 2025

Size Change: 0 B

Total Size: 3.41 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 3.41 MB

compressed-size-action

@arthurdedeus arthurdedeus force-pushed the feat/filter-canvas-content-per-entity branch from 42868dc to 512e8c9 Compare November 27, 2025 20:42
@arthurdedeus arthurdedeus marked this pull request as ready for review November 27, 2025 20:55
@arthurdedeus arthurdedeus self-assigned this Nov 27, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +184 to +196
if (
isInsightVizNode(modifiedQuery) &&
!isHogQLQuery(modifiedQuery.source) &&
!isActorsQuery(modifiedQuery.source) &&
!isDefaultFilterApplied
) {
modifiedQuery.source.properties = canvasFiltersOverride
updateAttributes({ ...attributes, isDefaultFilterApplied: true })
}

if (isDataTableNode(modifiedQuery) && isEventsQuery(modifiedQuery.source) && !isDefaultFilterApplied) {
modifiedQuery.source.fixedProperties = canvasFiltersOverride
updateAttributes({ ...attributes, isDefaultFilterApplied: true })
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: updateAttributes is called inside useMemo, which violates React rules - useMemo should be pure and not have side effects. This can cause unexpected behavior and infinite render loops.

Move the filter application logic to a useEffect hook instead:

useEffect(() => {
    if (
        isInsightVizNode(modifiedQuery) &&
        !isHogQLQuery(modifiedQuery.source) &&
        !isActorsQuery(modifiedQuery.source) &&
        !isDefaultFilterApplied &&
        canvasFiltersOverride
    ) {
        updateAttributes({ ...attributes, isDefaultFilterApplied: true })
    }
    
    if (isDataTableNode(modifiedQuery) && isEventsQuery(modifiedQuery.source) && !isDefaultFilterApplied && canvasFiltersOverride) {
        updateAttributes({ ...attributes, isDefaultFilterApplied: true })
    }
}, [isDefaultFilterApplied, canvasFiltersOverride, query.kind, query.source?.kind])
Prompt To Fix With AI
This is a comment left during a code review.
Path: frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx
Line: 184:197

Comment:
**logic:** `updateAttributes` is called inside `useMemo`, which violates React rules - `useMemo` should be pure and not have side effects. This can cause unexpected behavior and infinite render loops.

Move the filter application logic to a `useEffect` hook instead:

```
useEffect(() => {
    if (
        isInsightVizNode(modifiedQuery) &&
        !isHogQLQuery(modifiedQuery.source) &&
        !isActorsQuery(modifiedQuery.source) &&
        !isDefaultFilterApplied &&
        canvasFiltersOverride
    ) {
        updateAttributes({ ...attributes, isDefaultFilterApplied: true })
    }
    
    if (isDataTableNode(modifiedQuery) && isEventsQuery(modifiedQuery.source) && !isDefaultFilterApplied && canvasFiltersOverride) {
        updateAttributes({ ...attributes, isDefaultFilterApplied: true })
    }
}, [isDefaultFilterApplied, canvasFiltersOverride, query.kind, query.source?.kind])
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this specific case is safe, as we're updating isDefaultFilterApplied, which is not in the dependency array.

Copy link
Contributor

@daibhin daibhin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment on the prop in Notebooks. I'm going to tag the PA team because they own the query node (I'm trying to keep my involvement with notebooks to the framework level)

@daibhin daibhin requested a review from a team November 28, 2025 10:15
@arthurdedeus arthurdedeus force-pushed the feat/filter-canvas-content-per-entity branch from 1c8b4e8 to f4403f6 Compare November 28, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants