Skip to content

refactor(Tokenizer): check sheet rows for action during render, not in an Effect - #9808

Merged
cixzhang merged 1 commit into
mainfrom
effect-tokenizer-sheet-warn
Nov 4, 2026
Merged

cixzhang merged 1 commit into
mainfrom
effect-tokenizer-sheet-warn

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Maintainer impact

The Tokenizer bottom sheet used an Effect to decide whether to print a development warning. The decision reads only rendered data (the result rows), so the render can make it. An Effect that does work the render can do makes the component harder to read, and it hides which Effects really sync an external system (architecture:react-component-runtime INV1 and INV3).

Intended invariant

Rendered output and the development warning stay the same. The warning still prints one time per page when a result row carries action, which the sheet rows do not render (component:Tokenizer, spec:AST-058 FR9).

Change

packages/core/src/Tokenizer/TokenizerBottomSheet.tsx:617: the useEffect that called warnOnce when a result has action is removed. The same check now runs during render. warnOnce keeps a module-level set of keys, so a second render, a StrictMode double render or a rerender prints nothing new.

Evidence

  • Failure before the change: an Effect did work that the render can do.
  • Success after the change: no Effect for the warning; the warning and the rows are the same.
  • Product/runtime behavior verified unchanged: the existing test (a row renders without its action and the warning prints one time) passes without changes. A new test renders the sheet under StrictMode and checks that the warning prints exactly one time.
  • CI impact: none expected. One Core source file, one test file and one Changeset.

Scope

  • No intended public API, product behavior, visual direction, or policy change.
  • Product changes discovered during the work were removed or split.
  • Public text and artifacts contain no internal Meta context.

No behavior change. The only difference is timing in development: the warning can print during render instead of after the commit. A [chore] Changeset covers the shipped source file.

Risk

Low. The check is a some() over the result rows, so it costs little on each render. Production builds skip warnOnce, as before.

Testing

  • vitest run --project ui packages/core/src/Tokenizer: 5 files, 197 tests pass (includes the new StrictMode test).
  • pnpm -F @astryxdesign/core typecheck: pass.
  • eslint and prettier on the changed files: pass.
  • pnpm review:pre: 0 findings, merge into main clean.
  • pnpm check:changesets and Changeset coverage: pass.
  • TokenizerEndLane.a11y.chromium.spec.ts: not run locally. It needs a Storybook build, and the shared machine is overloaded. It covers the inline field, which this change does not touch; CI runs it.

@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 3, 2026 9:03pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 3, 2026
@astracat-bot

astracat-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 3, 2026, 9:04 PM UTC

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2fd8760

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
PowerSearch 194.3 kB (0) · 21.6 kB CSS (0) — — · — · —
Tokenizer · Storybook 71.3 kB (0) · 17.1 kB CSS (0) 2,113 (−2) ✓ · ✓ · ✓

Package size: @astryxdesign/core 6.24 MB packed (−8 B); no new dependencies.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is ready to approve. The bottom sheet's action warning moves from an Effect into render. Its text, its once-per-page count and the rendered rows stay the same. The new StrictMode test pins the single warning.

Optional follow-ups, not blocking:

  • The headers of utils/devWarning.ts and hooks/useDevWarning.ts still steer components away from calling warnOnce during render. One line there saying that a key-deduplicated warnOnce is render-safe would keep that guidance in step with this pattern.
  • BaseTypeahead and Selector still use an Effect for the same action warning.

[Automated review]

@cixzhang
cixzhang marked this pull request as ready for review November 3, 2026 22:03
@cixzhang
cixzhang merged commit a5e334b into main Nov 4, 2026
147 of 148 checks passed
cixzhang added a commit that referenced this pull request Nov 4, 2026
…ved experimental prop

#9808 added the test with experimental.presentation; #9836 removed that
prop. Each was green alone; together main typecheck fails (TS2769).
Same change as #9847, folded in here so one pull request turns main green.

Co-authored-by: Xinzi Zhou <[email protected]>
cixzhang added a commit that referenced this pull request Nov 4, 2026
…tion, and the recorded module resolutions follow core (#9851)

* test(cli): the recorded module resolutions follow useLightbox's doc and drop the deleted usePressPin

#9752 gave useLightbox its own doc; #9756 deleted the internal
Layer/usePressPin.ts. Each was green alone because PR checks skip this
fixture test; main test-node fails on both lines.

* test(Tokenizer): the sheet-row test passes presentation, not the removed experimental prop

#9808 added the test with experimental.presentation; #9836 removed that
prop. Each was green alone; together main typecheck fails (TS2769).
Same change as #9847, folded in here so one pull request turns main green.

Co-authored-by: Xinzi Zhou <[email protected]>
@github-actions
github-actions Bot deleted the effect-tokenizer-sheet-warn branch November 4, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — 2fd87606 Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant