Skip to content

Conversation

mariusandra
Copy link
Collaborator

Problem

The web analytics tab would reload every time it was opened.

Changes

Attach the various dataNodeLogics to the scene's logic.

How did you test this code?

Clicked between the tabs, saw the count of queries to /query go from a dozen to just one. Still a bit of work to do to remove that last one.

@posthog-bot posthog-bot requested review from a team and rafaeelaudibert and removed request for a team September 12, 2025 10:59
Copy link
Contributor

github-actions bot commented Sep 12, 2025

Size Change: 0 B

Total Size: 2.73 MB

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

compressed-size-action

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.

23 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

Copy link
Contributor

@adamleithp adamleithp left a comment

Choose a reason for hiding this comment

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

ts error, but :check:

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 8)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

@posthog-bot
Copy link
Contributor

📸 UI snapshots have been updated

1 snapshot changes in total. 0 added, 1 modified, 0 deleted:

  • chromium: 0 added, 1 modified, 0 deleted (diff for shard 8)
  • webkit: 0 added, 0 modified, 0 deleted

Triggered by this commit.

👉 Review this PR's diff of snapshots.

Copy link
Member

@rafaeelaudibert rafaeelaudibert left a comment

Choose a reason for hiding this comment

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

I mean, it works, but I don't really understand why. I'd love a brownbag (or just a short video) going over the reasons why this works/is needed

I'll also do a follow-up PR simplifying that LogicWrapper | BuiltLogic type

@mariusandra
Copy link
Collaborator Author

The tldr is:

  • Each scene exports a logic in the SceneExport object
  • That logic is then held onto whenever you switch tabs. it'll remain active in the background.
  • If you have ad-hoc logics on the frontend that mount with a component, they will be unmounted when the react component unmounts
  • Most notably, all dataNodeLogics will be cleared and it'll refresh all the data.
  • This PR adds useAttachedLogic(myAdHocLogic, mySceneLogic) calls, which tie the ad-hoc logics to the scene logic.
  • Now if you switch tabs, none of those attached logics are unmounted, and when you come back, the data is all still there.

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.

5 participants