Skip to content

Restore published-site context for mobile page revalidation - #176

Open
LuuSir wants to merge 1 commit into
classmethod:masterfrom
LuuSir:fix/mobile-public-page-revalidation
Open

LuuSir wants to merge 1 commit into
classmethod:masterfrom
LuuSir:fix/mobile-public-page-revalidation

Conversation

@LuuSir

@LuuSir LuuSir commented Oct 16, 2026 •

Copy link
Copy Markdown

Mobile database-peek requests can send an explicit blockId with requestedOnPublicDomain: false while omitting spaceDomain. Restore the configured published-site context before forwarding these requests.

This patch:

  • Fills in the missing spaceDomain.
  • Sets requestedOnPublicDomain: true.
  • Serializes the normalized request even when blockId is already present.

Rebased onto 3b9efd2, including #177 and the cross-workspace navigation security fix.

Validation:

  • npm ci, all 8 regression tests, and npm run build pass.
  • Fixtures use the desktop and mobile request shapes from the maintainer's review.
  • The previous PR implementation fails both desktop-container tests; unmodified current master fails both mobile-context tests.
  • Tests also cover routing headers, already-correct context, malformed JSON, and unchanged gzip telemetry bytes.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 08:33

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@shigahi shigahi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the detailed PR and the tests. I checked it against the current Notion client and live pages through a generated worker (desktop and iPhone emulation, master vs this branch).

The ?p= preference causes a desktop regression. On desktop, when the path has no page ID (/ or a pretty slug), the client requests the container page (slug, peekViewBlockId, peekMode, no blockId) and opens the item in a peek on top. With this change the worker injects the peek item as blockId, so the container is replaced: /?p=<item>&pm=s renders the item as both the page and the peek, while master renders the container with the item in the side peek. On mobile the client already sends the item's blockId, so the inference never applies there. Please drop the peekPage logic and its tests.

pageId is not a request field. The client never sends pageId to getPublicPageData (it is a response field), so !reqJson.pageId is always true. Please drop it and the related test.

Site context. I can confirm the mobile ?p= route drops spaceDomain and sends requestedOnPublicDomain: false, so restoring them is reasonable. However, I could not reproduce the switch to page-not-found on master (iPhone emulation, /?p=<item>&pm=s, the item was still rendered after 20s). Could you share reproduction steps (device and browser, tapping an item vs opening a URL, and a public site where it happens)?

Tests. Several cases use request shapes the client does not send (an empty body with an ID path in the Referer, pageId). Please base them on real payloads, e.g. a desktop { type: 'block-space', name: 'page', slug: '', spaceDomain, peekViewBlockId, peekMode, requestedOnPublicDomain: true } request keeps the container page, and a mobile { blockId: <item>, requestedOnPublicDomain: false } request without spaceDomain gets the site context restored. Running npm test in CI is welcome.

master has also moved on (#177 changed the /api/ branch). There is no textual conflict, but a rebase would be good.

@LuuSir
LuuSir force-pushed the fix/mobile-public-page-revalidation branch from eab05f7 to 1eb5c3e Compare October 22, 2026 09:14
@LuuSir
LuuSir force-pushed the fix/mobile-public-page-revalidation branch from 1eb5c3e to 8e299ac Compare October 22, 2026 09:28

@shigahi shigahi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the update. This addresses all points from my previous review.

Verified:

  • npm test passes (8/8), also in CI. Against master's code.ts, the two mobile site-context tests fail and the rest pass, so the tests cover the change.
  • Live comparison with master through a generated worker (desktop and iPhone emulation) for /, a slug, an item page, root and slug pages with a side peek, and an ID path with a center peek: same rendering and URLs as master. The differences I saw once were timing-dependent and also happened on master.

Could you update the PR description? It still describes the ?p= preference, the pageId handling and 11 tests.

@LuuSir LuuSir changed the title Fix published-page revalidation and database peek routing Restore published-site context for mobile page revalidation Oct 22, 2026
@LuuSir

LuuSir commented Oct 22, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough review and live testing! I've updated the PR title and description to reflect the narrower site-context fix and the 8-test suite, and removed the outdated claims about ?p= inference and pageId handling.

Thanks again for helping catch the desktop regression.

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.

3 participants