Skip to content

mini app test#2225

Merged
ra3orblade merged 9 commits into
developfrom
mini-app-test
May 21, 2026
Merged

mini app test#2225
ra3orblade merged 9 commits into
developfrom
mini-app-test

Conversation

@zarkone

@zarkone zarkone commented May 20, 2026

Copy link
Copy Markdown
Contributor

No description provided.

zarkone and others added 9 commits April 9, 2026 19:25
When the React app pushed a new state via __ANYTYPE_API__.setState, the
host called C.BlockTextSetText to write the JSON sibling code block, but
the React app's display never updated until a full reload. The same
button click would send the same state value over and over because the
local React mirror was frozen.

Root cause: anytype-heart's BlockSetText event is debounced when echoing
back to the originating client (presumably to avoid hammering the CRDT
layer on every keystroke during normal text editing). The local mobx
store didn't see the change in time, so the embed component's observer
didn't re-render, the round-trip back to the iframe never started, and
the React app's 'anytype:state' listener was never fired.

Anytype's own normal text input solves this by doing two writes — local
mobx mutation first, then heart sync — see U.Data.blockSetText in
src/ts/lib/util/data.ts:449. This commit applies the same pattern to
the anytypeMiniAppState case: S.Block.updateContent before
C.BlockTextSetText. The local update fires the embed observer
synchronously, the new appStateText is detected on the next render,
init/setContent re-runs, the iframe receives the updated payload via
the state-only fast path, and the React app's listener finally sees
the new state.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	electron/ts/server.ts
#	package-lock.json
#	src/ts/component/block/embed.tsx
Strip auto-formatter drift introduced by the mini-app commits in
embed.tsx and lib/util/embed.ts (bracket-access spacing, trailing
whitespace, JSX prop reflow) so the diff vs develop is now only the
real mini-app additions. Revert main.ts to develop — the [Startup]
console.logs and 5s extension-install timeout race weren't needed.
@ra3orblade ra3orblade merged commit 6302a0f into develop May 21, 2026
3 checks passed
@ra3orblade ra3orblade deleted the mini-app-test branch May 21, 2026 11:56
@github-actions github-actions Bot locked and limited conversation to collaborators May 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants