Skip to content

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

Fix Timeline overlay remaining visible when switching to Workflows (#7779)

Louis Beaumont441c6d9b5838
diff --git a/apps/screenpipe-app-tauri/components/rewind/native-timeline-attach.test.tsx b/apps/screenpipe-app-tauri/components/rewind/native-timeline-attach.test.tsx
index e20eb4c5f..6a050e797 100644
--- a/apps/screenpipe-app-tauri/components/rewind/native-timeline-attach.test.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/native-timeline-attach.test.tsx
@@ -80,6 +80,8 @@ import { NativeTimeline, NativeTimelineBridge } from "./native-timeline";
import { StorageMigrationGate } from "../storage-migration-gate";
class ResizeObserverMock {
+ static notify: () => void = () => {};
+ constructor(callback: () => void) { ResizeObserverMock.notify = callback; }
observe() {}
disconnect() {}
unobserve() {}
@@ -151,6 +153,36 @@ describe("native timeline startup API config", () => {
});
});
+ it("detaches when switching workspaces hides the timeline and reattaches on return", async () => {
+ const { rerender } = render(
+ <div style={{ display: "block" }}><NativeTimeline fallback={<div>react fallback</div>} /></div>,
+ );
+ await act(async () => { resolveApiReady?.(); });
+ await waitFor(() => expect(mocks.emit).toHaveBeenCalledWith("native-timeline-attach", expect.anything()));
+ mocks.emit.mockClear();
+
+ const rect = vi.mocked(HTMLElement.prototype.getBoundingClientRect);
+ const visibleRect = rect();
+ rect.mockReturnValue({ ...visibleRect, width: 0, height: 0 });
+ rerender(<div style={{ display: "none" }}><NativeTimeline fallback={<div>react fallback</div>} /></div>);
+ act(() => ResizeObserverMock.notify());
+ await waitFor(() => expect(mocks.emit).toHaveBeenCalledWith("native-timeline-detach", { windowLabel: "home" }));
+ expect(mocks.emit).not.toHaveBeenCalledWith("native-timeline-attach", expect.anything());
+ // Workflows keeps mutating the DOM while this hidden timeline stays mounted.
+ vi.useFakeTimers();
+ try {
+ act(() => ResizeObserverMock.notify());
+ await act(async () => { await vi.advanceTimersByTimeAsync(50); });
+ expect(mocks.emit).toHaveBeenCalledTimes(1);
+ } finally { vi.useRealTimers(); }
+ mocks.emit.mockClear();
+
+ rect.mockReturnValue(visibleRect);
+ rerender(<div style={{ display: "block" }}><NativeTimeline fallback={<div>react fallback</div>} /></div>);
+ act(() => ResizeObserverMock.notify());
+ await waitFor(() => expect(mocks.emit).toHaveBeenCalledWith("native-timeline-attach", expect.anything()));
+ });
+
it("does not keep pulling the playhead back after a starred timestamp is accepted", async () => {
mocks.nativeTimelineNavigate.mockResolvedValue(true);
render(<NativeTimeline fallback={<div>react fallback</div>} />);
diff --git a/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx b/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx
index adf0d8efe..6f092d8b4 100644
--- a/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/native-timeline.tsx
@@ -495,12 +495,20 @@ export function NativeTimeline({
if (!host) return;
const detachPayload = { windowLabel: getCurrentWindow().label };
+ let hostHidden = false;
// Rounded, because a fractional rect leaves a seam between the child
// window and the webview underneath it.
const place = (underlay = false) => {
const box = host.getBoundingClientRect();
- if (box.width < 1 || box.height < 1) return;
+ if (box.width < 1 || box.height < 1) {
+ // Workspace switching keeps this component mounted under display:none.
+ // Its native child must yield too, or it covers the new workspace.
+ if (!hostHidden) void emit("native-timeline-detach", detachPayload);
+ hostHidden = true;
+ return;
+ }
+ hostHidden = false;
void emit("native-timeline-attach", {
// Which window is asking. Two surfaces show a timeline — the main
// window's section and the overlay — and each needs its own.
diff --git a/docs/pr-assets/timeline-workflows-switch/workflows-browser-preview.png b/docs/pr-assets/timeline-workflows-switch/workflows-browser-preview.png
new file mode 100644
index 000000000..19592da7f
Binary files /dev/null and b/docs/pr-assets/timeline-workflows-switch/workflows-browser-preview.png differ