Skip to content

fix(www): make embed view-only and save acknowledgement reliable - #41

Open
DavidBabinec wants to merge 1 commit into
mainfrom
fix/embed-view-only-save
Open

DavidBabinec wants to merge 1 commit into
mainfrom
fix/embed-view-only-save

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

What

In the hosted editor (coreframework.com/app, which embeds www in an iframe), View Only still showed both Save buttons and saved on Cmd/Ctrl+S. A save could also finish with no "Saved successfully" and no error. Both exist in 1.10.4 too.

Why

View Only removed #push1/#push2 from the DOM while the loader was still showing, so the buttons rendered afterwards anyway. The save waited for cf-push-response with a { once: true } listener, so any earlier message used it up. View Only is now an atom that hides the buttons and skips the save. The reply wait ignores other messages and times out after 30s.

Checked against the website's src/pages/app/[slug].tsx and 1.10.4: no message was dropped or renamed, and the embed never used the removed x-api-key importer.

Verification

bun run test:www            # 26 suites, 163 passed (7 new in embedBridge.test.ts)
bun run build:www / build:wp / build:figma   # exit 0
bun run check:open-source   # passed

Live, through a host page mirroring [slug].tsx: a save captured from the live 1.10.4 bundle loaded and re-saved in 2.x. View Only hid Save and ignored Cmd+S; a message sent before the reply swallowed the toast on main but not here. Failure replies and clipboard paste work.

The hosted editor at coreframework.com/app opens public projects with
isViewOnly, but the editor removed the save buttons from the DOM while
its loader was still showing, so they rendered anyway and Cmd/Ctrl+S
still saved. View-only is now an atom that hides both buttons and
skips the save.

After a save the editor waited for cf-push-response with a one-shot
listener, so any other message reaching the window first used it up
and the host's answer was dropped. It now ignores unrelated messages
and treats no answer within 30 seconds as a failure. The clipboard
read uses the same helper.

This branch has not been deployed

No deployments
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