Skip to content

fix(nextjs): keep wallets across refreshes; allow README in address folders - #58

Merged
JamesCarnley merged 2 commits into
mainfrom
fix/real-wallet-reconnect
Oct 27, 2026
Merged

JamesCarnley merged 2 commits into
mainfrom
fix/real-wallet-reconnect

Conversation

@JamesCarnley

Copy link
Copy Markdown
Member

Summary

  • A page refresh no longer changes wallet state in the debug UI. Real wallets (MetaMask etc.) stay connected on faucet-configured builds, and an active Easy Edits session keeps its burner wallet across refreshes.
  • The Overview (README) pane now works at an address-folder root (/explorer/<address>), so you can add and edit the README in your own account folder.

Why

Reported problem: you couldn't edit the README in your own account folder. The pane didn't appear after connecting a wallet, and refreshing didn't help because the wallet didn't stay connected.

Refresh dropped wallets. The instant-burner work (57e221a) set wagmi reconnectOnMount={false} whenever NEXT_PUBLIC_FAUCET_URL is set (the live Sepolia build). The reason was the burner connector reports itself authorized on load, and wagmi's reconnect attaches every authorized connector, so visitors who never clicked Easy Edits would get a burner. That also dropped every real wallet on each refresh. Easy Edits itself was React state, so it reset too.

  • Reconnect is back on. In faucet builds the burner opts out of page-load restore (restoreOnLoad: false), and Easy Edits owns restoring it.
  • Easy Edits is remembered in localStorage until turned off, disconnected from the wallet menu, or a connect fails.
  • A tracker on the wagmi store marks when page-load reconnect has settled. Easy Edits waits for that before restoring the burner, so it can't race a real wallet being restored.
  • A refresh restores the burner only if it was the active wallet before the refresh. If MetaMask was active but can't be restored (for example, locked), Easy Edits ends rather than silently switching the visitor to the burner's address.
  • Faucet gas is still requested only on an explicit click.
  • Local dev (no faucet URL) keeps the stock scaffold-eth burner restore.

README pane missing at address roots. The Overview edit gate required a "real anchor" parent. An address root's anchor UID is the synthetic bytes32(uint160(addr)), which EAS rejects as a refUID (NotFound). specs/04 §4a already defines the route: attest the child anchor with refUID = 0, recipient = addr, and EFSIndexer.onAttest re-derives the parent. CreateItemModal already did this for files and folders, and uploadOnchainFile already accepts it; the Overview editor just never passed it.

  • That decision now lives in shared helpers in utils/efs/containers.ts (childAnchorParent, canAttachChildAnchor).
  • Both CreateItemModal (behavior unchanged) and the Overview gate use them.
  • Raw schema/attestation roots with no alias anchor stay non-writable.

Behavior notes for review

  • Easy Edits fallback (unchanged, now remembered): if Easy Edits is on and a real wallet is disconnected, the UI falls back to the burner. That was the existing design (.env.example); it now survives reloads.
  • README on other people's address folders: as with files, a connected visitor who is the top lens can add their own lens-scoped README there. It doesn't change what other viewers see.

Permanence tier

Ephemeral. packages/nextjs debug UI only; no contracts, schemas, or deployedContracts.ts changes.

Specs / ADRs touched or checked

  • specs/04-Core-Workflows.md §4a (address home): confirmed unchanged. This PR uses the documented refUID = 0, recipient = addr carve-out.
  • specs/02-Data-Models-and-Schemas.md §1 (ANCHOR refUID/recipient): confirmed unchanged.
  • ADR-0033 (root containers): confirmed still in force.
  • packages/nextjs/.env.example: updated the Easy Edits description.

Test plan

  • yarn workspace @se-2/nextjs test: 184 pass, with new tests for:
    • wagmi's real reconnect() against the burner and a stand-in injected wallet
    • the page-load tracker against a real wagmi config
    • the burner-restore rule
    • the Easy Edits storage helpers
    • the address-root anchor helpers
  • yarn next:check-types, yarn next:lint --max-warnings=0, yarn docs:check: pass.
  • Playwright against a faucet-configured Sepolia dev build with a fake injected MetaMask:
    • The real wallet survives a refresh. The drop reproduced before the fix.
    • Burner and Easy Edits survive a refresh, with no new faucet request.
    • Easy Edits off stays off after a refresh.
    • A wallet-menu disconnect sticks after a refresh.
    • A remembered MetaMask stays active when Easy Edits is also remembered.
    • A locked MetaMask at refresh isn't replaced by the burner.
    • A fresh visitor with a stored burner key is never auto-connected.
    • Wallet-gated explorer controls appear right after connecting and don't change on refresh.
  • Playwright on a local Sepolia fork (yarn preview) with the dev burner:
    • The burner's own address folder offers "Add an Overview".
    • The README saves on-chain via the recipient form.
    • It renders with "Edit this Overview", and both survive a reload.
  • Not run: a live Sepolia write with a real MetaMask extension.

Agents involved

  • Dev: Claude Opus 5.5
  • Review: Claude Opus 5.5 (two independent expert-review subagents: wagmi/Easy Edits state machine; EAS address-root write path). The address-root review found no blocking issues. The wallet review raised two P2s:
    • A non-reactive settle signal. Fixed with useSyncExternalStore.
    • The burner taking over after a refresh when the active real wallet couldn't be restored. Fixed with the restore-only-if-burner-was-active rule.
  • Orchestrator: James

🤖 Generated with Claude Code

JamesCarnley and others added 2 commits October 27, 2026 17:35
On faucet-configured builds (live Sepolia) a refresh dropped every
wallet. The instant-burner work turned wagmi's reconnectOnMount off
globally, because the burner connector reports itself authorized on
load and wagmi's reconnect attaches every authorized connector, so a
visitor who never clicked Easy Edits would get a burner. That also
dropped MetaMask and every other real wallet on each refresh. Easy
Edits itself lived in React state, so it reset too.

Reconnect is back on for everyone. In faucet builds the burner opts
out of page-load restore (restoreOnLoad: false) and Easy Edits owns
it instead:

- Easy Edits is remembered in localStorage until the visitor turns it
  off, disconnects the burner from the wallet menu, or connect fails.
- A page-load tracker watches the wagmi store, so it can't miss the
  moment reconnect settles. Easy Edits waits for that before
  restoring the burner, so it can't race a real wallet being
  restored. The toggle stays hidden until then (no off->on flash, no
  stray click).
- A refresh restores the burner only if it was the active wallet
  before. If MetaMask was active but can't be restored (e.g. locked),
  Easy Edits ends rather than switching to the burner's address.
- Faucet gas is still requested only on an explicit click.

Local dev (no faucet URL) keeps the stock scaffold-eth burner restore.
Falling back to the burner when a real wallet is disconnected while
Easy Edits is on is unchanged; it is now remembered across reloads.

Verified: unit tests incl. wagmi's real reconnect() against the
burner + a stand-in injected wallet; Playwright against a
faucet-configured Sepolia dev build with a fake injected MetaMask:
real wallet survives refresh (reproduced the drop before the fix),
burner + Easy Edits survive refresh with no new faucet request, off
stays off, wallet-menu disconnect sticks, a remembered MetaMask stays
active over Easy Edits, a locked MetaMask isn't replaced by the
burner, and a fresh visitor with a stored burner key is never
auto-connected.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Permanence-tier: Ephemeral
The Overview pane never appeared at /explorer/<address>, even for the
connected wallet's own folder. The edit gate required a "real anchor"
parent, and an address root's anchor UID is the synthetic
bytes32(uint160(addr)), which EAS rejects as a refUID (NotFound).

specs/04 §4a already defines the route: attest the child anchor with
refUID = 0, recipient = addr and EFSIndexer.onAttest re-derives the
parent from the recipient. CreateItemModal already did this for files
and folders, and uploadOnchainFile already accepts the carve-out; the
Overview editor just never passed it.

Move that decision into shared helpers in utils/efs/containers.ts
(childAnchorParent, canAttachChildAnchor), use them in
CreateItemModal (behavior unchanged) and in the Overview gate, and
pass the parent through OverviewPane -> OverviewEditorModal ->
uploadOnchainFile. Raw schema/attestation roots without an alias
anchor stay non-writable. As with files, a connected visitor who is
the top lens can add their own (lens-scoped) README on any address
folder.

Verified: unit tests for both helpers; Playwright on a local Sepolia
fork with the dev burner: the burner's own address folder offers "Add
an Overview", the README saves on-chain via the recipient form,
renders with "Edit this Overview", and both survive a reload. Also
checked against Sepolia that wallet-gated explorer controls appear
right after connecting and don't change on refresh.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Reviewed-by: Claude Opus 5.5 <noreply@anthropic.com>
Tested-by: Claude Opus 5.5 <noreply@anthropic.com>
Permanence-tier: Ephemeral
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T22:37:34.359088Z 5739585 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@JamesCarnley
JamesCarnley merged commit fe49df2 into main Oct 27, 2026
3 checks passed
@JamesCarnley
JamesCarnley deleted the fix/real-wallet-reconnect branch October 27, 2026 22:53
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