Skip to content

improvement(nav): cut prefetch and session-recorder waste - #6656

Merged
waleedlatif1 merged 1 commit into
stagingfrom
investigate/artie-slow
Aug 13, 2026
Merged

improvement(nav): cut prefetch and session-recorder waste#6656
waleedlatif1 merged 1 commit into
stagingfrom
investigate/artie-slow

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Seed the workspace list rather than prefetching it. The empty-list case was signalled by throwing inside queryFn; the retry: 1 default then re-ran the whole read, a retry delay later, purely to re-derive an outcome already known. Also logs the failure path, which was silent — contract drift between the read and the response schema would have degraded into every viewer waterfalling with nothing in the logs.
  • Add slimDOMOptions to session recording so non-painted nodes (comments, script bodies, head meta) stay out of every rrweb snapshot. Enumerated rather than true/'all' so headTitleMutations stays off and replays keep document.title.

Prefetch concurrency and await semantics are unchanged, so sidebar paint timing matches staging.

Context

Came out of investigating a report that opening a workflow from the sidebar took a long time. These are the two contained wins that fell out of it; neither is the fix for that report.

What this does not fix

The dominant cost on the workflow canvas is workflow-block-border.tsx rewriting a spring-animated SVG path per block per frame, which trips PostHog's mutation throttler. No posthog-js option can throttle that — sampling has no mutation key and isn't on posthog-js's rrweb allowlist anyway, and the throttler that does exist runs after serialization, so it only trades payload for fidelity. Fixing it at the source means driving the silhouette imperatively from the rAF loop instead of React state — a deliberate rewrite, out of scope here.

Sidebar navigation also still gives no feedback on click, which is what leads users to click again and escalate a soft navigation into a full document load. A pending affordance was prototyped and pulled — it didn't fit the sidebar's visual language. Worth solving with an affordance the design system already uses.

We collect no navigation timing and no INP, so none of this is measurable today. That instrumentation is the real follow-up.

Type of Change

  • Bug fix

Testing

type-check, biome, and repo lint:check (23/23) pass, along with the workspace layout test. No UI changes in this PR.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 13, 2026 4:14am

Request Review

@cursor

cursor Bot commented Aug 13, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Workspace onboarding depends on correct empty-list handling and React Query dehydrate/retry defaults; wrong seeding could block default-workspace creation for new viewers.

Overview
Cuts waste on workspace sidebar hydration and PostHog session recording without changing sidebar prefetch concurrency or paint timing.

Workspace list: Replaces prefetchQuery with seedWorkspaceList, which uses setQueryData when workspaces exist and does nothing on an empty list or failure. The old path threw on empty lists to force the client GET /api/workspaces default-workspace flow, which also triggered a retry: 1 second read and could hydrate a permanent error under retryOnMount: false. Failures are now logged instead of failing silently.

PostHog: Adds explicit slimDOMOptions on session recording so non-painted head/script/comment nodes are omitted from rrweb snapshots, shrinking main-thread serialization and payloads while avoiding true/all presets that would drop document.title via headTitleMutations.

Reviewed by Cursor Bugbot for commit 0936ab6. Configure here.

- Seed the workspace list instead of prefetching it. The empty-list case was
  signalled by throwing inside queryFn, which the retry: 1 default re-ran the
  entire read to re-derive, a retry delay later. Log the failure path, which
  was silent — contract drift would have degraded into every viewer
  waterfalling with nothing in the logs.
- Drop non-painted nodes from rrweb snapshots via slimDOMOptions. Enumerated
  rather than true/'all' so headTitleMutations stays off and replays keep
  document.title.

Prefetch concurrency and await semantics are unchanged, so sidebar paint
timing matches staging.
@waleedlatif1
waleedlatif1 force-pushed the investigate/artie-slow branch from 2eb5b38 to 0936ab6 Compare August 13, 2026 04:14
@waleedlatif1 waleedlatif1 changed the title improvement(nav): acknowledge sidebar workflow clicks, cut prefetch and recorder waste improvement(nav): cut prefetch and session-recorder waste Aug 13, 2026
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR replaces the retrying workspace-list prefetch with an awaited cache seed that leaves empty and failed reads for the client API fallback, and reduces PostHog replay snapshots by omitting non-painted DOM content.

  • Seeds normalized non-empty workspace-list responses directly into the React Query cache.
  • Logs seed failures while preserving the client-fetch fallback.
  • Configures an explicit subset of PostHog slimDOMOptions without suppressing title mutations.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking issue identified.

The workspace seed uses the existing normalized response shape and query key, is awaited before dehydration, and intentionally leaves empty or failed reads uncached so the client route can perform required side effects; the recorder change only removes selected non-painted nodes.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/prefetch.ts Replaces workspace-list prefetch retries with an awaited direct cache seed while preserving empty/error fallback to the client route.
apps/sim/app/_shell/providers/posthog-provider.tsx Adds explicit session-recording DOM slimming options while retaining document-title mutations.

Reviews (2): Last reviewed commit: "improvement(nav): cut prefetch and sessi..." | Re-trigger Greptile

@waleedlatif1
waleedlatif1 merged commit ec70c4d into staging Aug 13, 2026
29 of 31 checks passed
@waleedlatif1
waleedlatif1 deleted the investigate/artie-slow branch August 13, 2026 04:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 0936ab6. Configure here.

waleedlatif1 added a commit that referenced this pull request Aug 13, 2026
… could not fail (#6659)

The audit found the seed contract — the whole point of #6656 — had no test, and
that one existing assertion was vacuous.

- prefetchWorkspaceSidebar and seedWorkspaceList now have coverage: the empty
  list seeds nothing (so the client reaches the route's default-workspace
  creation path), a populated list seeds, a rejected read neither throws nor
  seeds, and a host context for another workspace seeds nothing at all.
  Verified falsifiable — removing the empty-list guard turns the first red.
- The graceful-failure row for prefetchFilesBrowser asserted on the file-list
  key, which that function deliberately never writes, so it held no matter what
  the code did. It now asserts the folder key it owns, and the setup rejects
  the folder read.
- The sidebar was the third hand-rolled copy of the folder prefetch the shared
  helper was extracted to remove; it now calls prefetchResourceFolders too.
- prefetchKnowledgeBases returns early without a userId like every sibling,
  rather than reaching the authenticator and throwing per render.
- Dropped two docblock claims about a `retry` default that no longer applies
  server-side.
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.

1 participant