Skip to content

Conversation

@yoen-velt
Copy link
Collaborator

@yoen-velt yoen-velt commented Jan 6, 2026

On first load, demo iframes would get stuck because Velt SDK tried to connect before authentication completed (~8s). This fix waits for auth to complete, then refreshes the iframes. Subsequent visits skip the delay by checking a localStorage flag per demo origin.

🤖 Generated with Claude Code

Pull Request

Description

Type of Change

  • New demo application
  • Bug fix
  • Feature enhancement
  • Documentation update
  • Infrastructure/tooling change
  • Other (please describe):

Monorepo Structure Checklist

If adding a new demo, ensure you've followed the 5-level structure:

  • Placed in correct path: apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/
  • Updated package.json with scoped name: @apps/<framework>-<document>-<library-or-solution>-<demo>
  • Created comprehensive README.md in the demo directory
  • Verified build passes: pnpm --filter <package-name> build
  • Verified dev server runs: pnpm --filter <package-name> dev

Deployment Checklist

If this demo should be deployed:

  • Added/updated Vercel project configuration
  • Updated GitHub Actions workflows (if applicable)
  • Verified deployment paths in CI/CD configs

Testing

  • Tested locally with pnpm -w install && pnpm -w build
  • Verified all affected apps still build
  • Tested dev servers for affected apps

Documentation

  • Updated relevant documentation (if needed)
  • Added demo to master-sample-app (if applicable)
  • Updated deployment docs (if applicable)

Related Issues

Screenshots/Videos

Additional Context


For Reviewers

Demo Location

Path: apps/<framework>/<document>/<type>/<implementation>/<library-or-solution>/<demo>/

Package name: @apps/<...>

How to Test

# Install dependencies
pnpm -w install

# Run the specific demo
pnpm --filter @apps/<package-name> dev

# Build the specific demo
pnpm --filter @apps/<package-name> build

Structure Verification

The demo follows the 5-level hierarchy:

  1. Framework:
  2. Document:
  3. Type:
  4. Implementation:
  5. Library/Solution:
  6. Demo:

Documentation: See README_MONOREPO.md and docs/structure.md for more details on the monorepo structure.


Note

Addresses demo iframe stalls caused by Velt SDK auth timing.

  • Iframe auth handling: IframePair waits ~8s for Velt auth, then refreshes iframes once; marks origins as initialized via localStorage (velt-initialized-<origin>) to skip future delays. Adds refs/timers with unmount cleanup and shows an "Initializing" overlay until refresh completes.
  • Stable iframe mounting: SampleViewer keys iframes only by sample.metadata.id (not documentId) to prevent remounts while document IDs change; continues to append documentId to iframe URLs and gates rendering until ready.
  • Minor cleanup: Normalizes localStorage key usage and small UI/formatting tweaks in page.tsx and viewer components.

Written by Cursor Bugbot for commit 20163cf. This will update automatically on new commits. Configure here.

On first load, demo iframes would get stuck because Velt SDK tried to
connect before authentication completed (~8s). This fix waits for auth
to complete, then refreshes the iframes. Subsequent visits skip the
delay by checking a localStorage flag per demo origin.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@yoen-velt yoen-velt self-assigned this Jan 6, 2026
@vercel
Copy link

vercel bot commented Jan 6, 2026

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

Project Deployment Review Updated (UTC)
master-sample-app Ready Ready Preview, Comment Jan 6, 2026 4:47pm
16 Skipped Deployments
Project Deployment Review Updated (UTC)
sample-apps-ag-grid-comment-aggregation Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-ag-grid-multiple-tools Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-ag-grid-single-tool Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-codemirror-crdt-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-dashboard-comments-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-dashboard-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-dashboard-mongo-db-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-dashboard-postgres-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-lexical-comments-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-reactflow-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-slatejs-comments-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-tanstack-comment-aggregation Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-tanstack-multiple-tools Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-tanstack-single-tool Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-tiptap-comments-demo Ignored Ignored Preview Jan 6, 2026 4:47pm
sample-apps-tiptap-crdt-demo Ignored Ignored Preview Jan 6, 2026 4:47pm

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
// Force refresh by resetting src
iframe1Ref.current.src = url
}
}, VELT_AUTH_WAIT_MS)
Copy link

Choose a reason for hiding this comment

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

Stale URL closure in timer causes wrong document

When the url prop changes (e.g., user clicks reset during the first 8-second wait), handleIframeLoad sets a new timer but doesn't cancel the existing one. The old timer's closure still captures the previous url value. When the old timer fires, it sets iframe.src to the stale URL, causing the iframe to briefly show the wrong document. The clearTimeout calls only exist in the unmount cleanup effect, not before setting new timers in handleIframeLoad.

Additional Locations (1)

Fix in Cursor Fix in Web

@yoen-velt yoen-velt merged commit b4fd6be into main Jan 6, 2026
20 checks passed
@yoen-velt yoen-velt deleted the master-sample-app-reload-fix branch January 6, 2026 20:31
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.

2 participants