YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context
Rust agentsagiaiai-memoryaudio-recordingcomputer-visionhermeshermes-agentllmlocal-ailocal-firstmachine-learningmcpmultimodalopenclawprivacyrewindscreen-recordingspeech-to-textycombinator
fix: ignore inherited entries in motion lifecycle registries (#7516)
Ezra Ellette8b35950a8dc2
diff --git a/apps/screenpipe-app-tauri/bun.lock b/apps/screenpipe-app-tauri/bun.lockindex 86e38db35..54e8f2d4e 100644--- a/apps/screenpipe-app-tauri/bun.lock+++ b/apps/screenpipe-app-tauri/bun.lock@@ -135,6 +135,9 @@},},},+ "patchedDependencies": {+ "[email protected]": "patches/[email protected]",+ },"packages": {"@adobe/css-tools": ["@adobe/[email protected]", "", {}, "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg=="],diff --git a/apps/screenpipe-app-tauri/lib/__tests__/motion-lifecycle.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/motion-lifecycle.test.tsnew file mode 100644index 000000000..ad36d891d--- /dev/null+++ b/apps/screenpipe-app-tauri/lib/__tests__/motion-lifecycle.test.ts@@ -0,0 +1,92 @@+// screenpipe — AI that knows everything you've seen, said, or heard+// https://screenpipe.com++import { createRequire } from "node:module";+import { createElement as reactElement } from "react";+import { render } from "@testing-library/react";+import * as motionEsm from "framer-motion";+import { describe, expect, it, vi } from "vitest";++const require = createRequire(import.meta.url);+const motionCjs = require("framer-motion") as typeof motionEsm;++function withInheritedEntry(run: () => void) {+ const key = "screenpipeInheritedMotionEntry";+ const previous = Object.getOwnPropertyDescriptor(Object.prototype, key);+ Object.defineProperty(Object.prototype, key, {+ configurable: true,+ enumerable: true,+ writable: true,+ value: {},+ });+ try {+ run();+ } finally {+ if (previous) Object.defineProperty(Object.prototype, key, previous);+ else Reflect.deleteProperty(Object.prototype, key);+ }+}++// Exercise both package entry points: Next bundles ESM while Node can use CJS.+describe.each([["ESM", motionEsm], ["CJS", motionCjs]] as const)("%s motion lifecycle", (_, motion) => {+ function createElement() {+ // The base class implements the lifecycle; renderer-specific abstract+ // methods are not involved in feature registration or event cleanup.+ return Reflect.construct(motion.VisualElement, [{+ props: {},+ visualState: { latestValues: {}, renderState: {} },+ }]) as motionEsm.VisualElement;+ }++ it("does not mount inherited properties as animation features", () => {+ const element = createElement();+ withInheritedEntry(() => {+ expect(() => element.updateFeatures()).not.toThrow();+ });+ element.unmount();+ });++ it("cleans up real listeners without treating inherited properties as listeners", () => {+ const element = createElement();+ const onUpdate = vi.fn();+ element.on("Update", onUpdate);+ element.notify("Update", { opacity: 1 });+ expect(onUpdate).toHaveBeenCalledOnce();++ withInheritedEntry(() => {+ expect(() => element.unmount()).not.toThrow();+ });+ element.notify("Update", { opacity: 0 });+ expect(onUpdate).toHaveBeenCalledOnce();+ });++ it("destroys motion values and releases their real listeners", () => {+ const value = motion.motionValue(0);+ const onChange = vi.fn();+ value.on("change", onChange);+ value.set(1);+ expect(onChange).toHaveBeenCalledOnce();++ withInheritedEntry(() => {+ expect(() => value.destroy()).not.toThrow();+ });+ value.set(2);+ expect(onChange).toHaveBeenCalledOnce();+ });++ it("updates and unmounts a real animated React element with inherited entries present", () => {+ const view = (opacity: number) => reactElement(motion.motion.div, {+ initial: false,+ animate: { opacity },+ transition: { duration: 0 },+ whileHover: { opacity: 0.5 },+ children: "Animated content",+ });+ const { rerender, unmount, getByText } = render(view(1));+ expect(getByText("Animated content")).toBeInTheDocument();+ withInheritedEntry(() => {+ rerender(view(0.8));+ unmount();+ });+ });+});diff --git a/apps/screenpipe-app-tauri/package.json b/apps/screenpipe-app-tauri/package.jsonindex 1d2f435a9..c5671732b 100644--- a/apps/screenpipe-app-tauri/package.json+++ b/apps/screenpipe-app-tauri/package.json@@ -220,5 +220,8 @@"packageManager": "[email protected]","trustedDependencies": ["@sentry/cli"- ]+ ],+ "patchedDependencies": {+ "[email protected]": "patches/[email protected]"+ }}diff --git a/apps/screenpipe-app-tauri/patches/[email protected] b/apps/screenpipe-app-tauri/patches/[email protected]new file mode 100644index 000000000..9e15a6da5--- /dev/null+++ b/apps/screenpipe-app-tauri/patches/[email protected]@@ -0,0 +1,84 @@+diff --git a/dist/cjs/index.js b/dist/cjs/index.js+index 2918c45f931f419182ddea09ada8a50edac89a11..9ab66a6ae5bc25350f7aa41d27118cb64910afb3 100644+--- a/dist/cjs/index.js++++ b/dist/cjs/index.js+@@ -457,7 +457,7 @@ class MotionValue {+ /**+ * An object containing a SubscriptionManager for each active event.+ */+- this.events = {};++ this.events = Object.create(null);+ this.updateAndNotify = (v, render = true) => {+ const currentTime = time.now();+ /**+@@ -5315,7 +5315,7 @@ class VisualElement {+ /**+ * Cleanup functions for active features (hover/tap/exit etc)+ */+- this.features = {};++ this.features = Object.create(null);+ /**+ * A map of every subscription that binds the provided or generated+ * motion values onChange listeners to this visual element.+@@ -5330,7 +5330,7 @@ class VisualElement {+ /**+ * An object containing a SubscriptionManager for each active event.+ */+- this.events = {};++ this.events = Object.create(null);+ /**+ * An object containing an unsubscribe function for each prop event subscription.+ * For example, every "Update" event can have multiple subscribers via+@@ -5475,7 +5475,7 @@ class VisualElement {+ }+ updateFeatures() {+ let key = "animation";+- for (key in featureDefinitions) {++ for (key of Object.keys(featureDefinitions)) {+ const featureDefinition = featureDefinitions[key];+ if (!featureDefinition)+ continue;+diff --git a/dist/es/render/VisualElement.mjs b/dist/es/render/VisualElement.mjs+index b11a0ac66cce0fbdcb5ee5e0ea0b6778a811a72e..6a95e4146a516191bda1d2c65a777b36d724451c 100644+--- a/dist/es/render/VisualElement.mjs++++ b/dist/es/render/VisualElement.mjs+@@ -77,7 +77,7 @@ class VisualElement {+ /**+ * Cleanup functions for active features (hover/tap/exit etc)+ */+- this.features = {};++ this.features = Object.create(null);+ /**+ * A map of every subscription that binds the provided or generated+ * motion values onChange listeners to this visual element.+@@ -92,7 +92,7 @@ class VisualElement {+ /**+ * An object containing a SubscriptionManager for each active event.+ */+- this.events = {};++ this.events = Object.create(null);+ /**+ * An object containing an unsubscribe function for each prop event subscription.+ * For example, every "Update" event can have multiple subscribers via+@@ -237,7 +237,7 @@ class VisualElement {+ }+ updateFeatures() {+ let key = "animation";+- for (key in featureDefinitions) {++ for (key of Object.keys(featureDefinitions)) {+ const featureDefinition = featureDefinitions[key];+ if (!featureDefinition)+ continue;+diff --git a/dist/es/value/index.mjs b/dist/es/value/index.mjs+index 7b53de65242cc7434dd055154530bc8692a1e0c5..4c1d05c507ad8e084b269bf2d9737589ca04c5d1 100644+--- a/dist/es/value/index.mjs++++ b/dist/es/value/index.mjs+@@ -46,7 +46,7 @@ class MotionValue {+ /**+ * An object containing a SubscriptionManager for each active event.+ */+- this.events = {};++ this.events = Object.create(null);+ this.updateAndNotify = (v, render = true) => {+ const currentTime = time.now();+ /**