fix(hotkeys): Skip the server label warning on runtimes without process #223
main fromrefs/pull/223/head·merged by KevinVandy Follow-up to #221.
warnServerPlatformcheckstypeof processbefore readingNODE_ENV. On runtimes withoutprocess, such as Cloudflare Workers without a bundler define, formatting a label during server rendering used to throw aReferenceError.NODE_ENVis still checked before the server check, so production builds still drop the warning (verified with an esbuild production bundle).- Adds a test that formats a label on a server runtime with no
process. - The React "Render a label only in the browser" snippet now formats inside a
ShortcutLabelchild. AformatForDisplaycall written directly as aClientOnlychild runs in the parent, which can be a Next.js Server Component. - The React, Octane, Solid and Angular quick starts say to set the provider platform from the request, not only to use the formatter hook.
- Patch changeset for
@tanstack/hotkeys.
Summary by CodeRabbit#
- Bug Fixes
- Fixed shortcut formatting in server-rendered environments without a
processglobal, including Cloudflare Workers.
- Fixed shortcut formatting in server-rendered environments without a
- Documentation
- Clarified how to configure the user’s platform for server-rendered shortcut labels across supported frameworks.
- Updated the React example to format shortcut labels on the client, avoiding server-rendered labels that may not match the user’s platform.
- 1
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: TanStack/hotkeys
- Branch: fix/ssr-labels-review-followups
- File: .coderabbit.yaml
- Commit: 21e35ef
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
86dd546a-d97f-4ff7-a672-3eacbd28be17
Commits-
Reviewing files that changed from the base of the PR and between ad7f4a4eebf53067643e7401d057af72b121660b and 21e35ef6430e891d3f60968aa0e1e292c71c6896.
Files selected for processing: 9-
.changeset/server-warning-workers.md.intent/review-state.jsondocs/framework/angular/quick-start.mddocs/framework/octane/quick-start.mddocs/framework/react/guides/formatting-display.mddocs/framework/react/quick-start.mddocs/framework/solid/quick-start.mdpackages/hotkeys/src/_server.tspackages/hotkeys/tests/server-platform.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
Walkthrough
-
The server warning now checks whether
processexists before readingNODE_ENV. A test coversformatForDisplayin a Cloudflare Workers runtime. Framework quick starts add provider platform guidance, and the React formatting example moves formatting into a client component.Changes: Server-rendering and platform formatting
Layer / File(s) Summary Worker-safe server warning
.changeset/server-warning-workers.md,.intent/review-state.json,packages/hotkeys/src/_server.ts,packages/hotkeys/tests/server-platform.test.tswarnServerPlatformchecks thatprocessexists before readingNODE_ENV. A test verifies thatformatForDisplay('Mod+S')returnsCtrl+Swhenprocessis undefined.Provider platform guidance
.intent/review-state.json,docs/framework/angular/quick-start.md,docs/framework/octane/quick-start.md,docs/framework/react/quick-start.md,docs/framework/solid/quick-start.mdThe server-rendering guidance in each quick start now says to set the provider’s platformfrom the request.React formatting example
.intent/review-state.json,docs/framework/react/guides/formatting-display.mdThe example formats a hotkey in ShortcutLabelinsideClientOnly. The guidance notes that a parent may be a Next.js Server Component.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
- TanStack/hotkeys#221: Adds the server-platform detection and formatter path that this change updates.
- TanStack/hotkeys#204: Changes React Server Component package boundaries; this change updates a formatting example for that boundary.
Suggested reviewers:
schiller-manuel
Merge Risk:
Minimal · up to21e35-
No actionable merge-blocking risk is identified in this change.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Description check The description explains the implementation, test coverage, documentation updates, and changeset. It does not use the required ## 🎯 Changes,## ✅ Checklist, and## 🚀 Release Impactsections, and…Reformat the description with all required template sections. Complete each checklist item and explicitly select the applicable release-impact option, including the generated changeset confirmation. Passed checks: 4 passed-
Check name Status Explanation Title check The title clearly identifies the main change: skipping the server label warning when processis unavailable.Docstring Coverage Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (7 skipped: 7 unsupported.)
-
Full details: Description check
-
Explanation
The description explains the implementation, test coverage, documentation updates, and changeset. It does not use the required
## 🎯 Changes,## ✅ Checklist, and## 🚀 Release Impactsections, and it omits the checklist items and explicit release-impact selection.Resolution
Reformat the description with all required template sections. Complete each checklist item and explicitly select the applicable release-impact option, including the generated changeset confirmation.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks the server’s gate,
No `process`? It can still format.
“Ctrl+S,” the shortcut hops,
Through client paths and platform props.
Quick-start pages mark the way.-
🚀 Changeset Version Preview#
1 package(s) bumped directly, 17 bumped as dependents.
🟩 Patch bumps#
Package Version Reason @tanstack/hotkeys0.23.0 → 0.23.1 Changeset @tanstack/alpine-hotkeys0.11.0 → 0.11.1 Dependent @tanstack/angular-hotkeys0.21.0 → 0.21.1 Dependent @tanstack/angular-hotkeys-devtools0.5.0 → 0.5.1 Dependent @tanstack/ember-hotkeys0.10.0 → 0.10.1 Dependent @tanstack/hotkeys-devtools1.8.0 → 1.8.1 Dependent @tanstack/lit-hotkeys0.22.0 → 0.22.1 Dependent @tanstack/octane-hotkeys0.10.0 → 0.10.1 Dependent @tanstack/preact-hotkeys0.20.0 → 0.20.1 Dependent @tanstack/preact-hotkeys-devtools0.13.0 → 0.13.1 Dependent @tanstack/react-hotkeys0.21.0 → 0.21.1 Dependent @tanstack/react-hotkeys-devtools0.14.0 → 0.14.1 Dependent @tanstack/solid-hotkeys0.20.0 → 0.20.1 Dependent @tanstack/solid-hotkeys-devtools0.13.0 → 0.13.1 Dependent @tanstack/svelte-hotkeys0.20.0 → 0.20.1 Dependent @tanstack/svelte-hotkeys-devtools0.5.0 → 0.5.1 Dependent @tanstack/vue-hotkeys0.21.0 → 0.21.1 Dependent @tanstack/vue-hotkeys-devtools0.13.0 → 0.13.1 Dependent @tanstack/alpine-hotkeys
npm i https://pkg.pr.new/@tanstack/alpine-hotkeys@223@tanstack/angular-hotkeys
npm i https://pkg.pr.new/@tanstack/angular-hotkeys@223@tanstack/angular-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/angular-hotkeys-devtools@223@tanstack/ember-hotkeys
npm i https://pkg.pr.new/@tanstack/ember-hotkeys@223@tanstack/hotkeys
npm i https://pkg.pr.new/@tanstack/hotkeys@223@tanstack/hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/hotkeys-devtools@223@tanstack/lit-hotkeys
npm i https://pkg.pr.new/@tanstack/lit-hotkeys@223@tanstack/octane-hotkeys
npm i https://pkg.pr.new/@tanstack/octane-hotkeys@223@tanstack/preact-hotkeys
npm i https://pkg.pr.new/@tanstack/preact-hotkeys@223@tanstack/preact-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/preact-hotkeys-devtools@223@tanstack/react-hotkeys
npm i https://pkg.pr.new/@tanstack/react-hotkeys@223@tanstack/react-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/react-hotkeys-devtools@223@tanstack/solid-hotkeys
npm i https://pkg.pr.new/@tanstack/solid-hotkeys@223@tanstack/solid-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/solid-hotkeys-devtools@223@tanstack/svelte-hotkeys
npm i https://pkg.pr.new/@tanstack/svelte-hotkeys@223@tanstack/svelte-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/svelte-hotkeys-devtools@223@tanstack/vue-hotkeys
npm i https://pkg.pr.new/@tanstack/vue-hotkeys@223@tanstack/vue-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/vue-hotkeys-devtools@223commit:
21e35efKevinVandy merged this04c7445
KevinVandy closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 21e35ef6430e891d3f60968aa0e1e292c71c6896
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR