-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Checklist: Autocomplete "See what's new" on URL navigation #33167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughThe changes refactor URL location monitoring by migrating from a Changes
Sequence DiagramsequenceDiagram
participant Component
participant useLocationHash
participant LocationMonitor
participant window
rect rgb(200, 220, 240)
note over Component,window: Initialization
Component->>useLocationHash: Call hook
useLocationHash->>LocationMonitor: subscribe(callback)
LocationMonitor->>LocationMonitor: start polling if not running
end
rect rgb(220, 240, 220)
note over LocationMonitor,window: Polling Loop (100ms interval)
loop detect changes
LocationMonitor->>window: check location.hash
alt hash changed
LocationMonitor->>LocationMonitor: notify all listeners
LocationMonitor->>useLocationHash: callback(newHash)
useLocationHash->>Component: update state
end
end
end
rect rgb(240, 220, 220)
note over Component,LocationMonitor: Cleanup
Component->>LocationMonitor: unsubscribe (on unmount)
LocationMonitor->>LocationMonitor: stop polling if no listeners
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
✨ Finishing touches
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx,js,jsx,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
**/*.{ts,tsx,js,jsx,json,html,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
code/**/!(*.test).{ts,tsx,js,mjs}📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Files:
🧬 Code graph analysis (1)code/core/src/shared/checklist-store/checklistData.tsx (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (4)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (1)
code/core/src/manager/components/LocationMonitor.ts (1)
8-18: Consider using browser events instead of polling.The current implementation polls
window.location.hrefevery 100ms to detect changes. This approach works but is less efficient than using native browser events. Consider usingpopstatefor history navigation andhashchangefor hash changes.Here's an event-based alternative:
start() { if (this._intervalId === null) { const handleLocationChange = () => { const newLocation = globalThis.window?.location; if (newLocation && newLocation.href !== this._currentHref) { this._currentHref = newLocation.href; this._listeners.forEach((listener) => listener(newLocation)); } }; globalThis.window?.addEventListener('popstate', handleLocationChange); globalThis.window?.addEventListener('hashchange', handleLocationChange); // Store cleanup references this._eventCleanup = () => { globalThis.window?.removeEventListener('popstate', handleLocationChange); globalThis.window?.removeEventListener('hashchange', handleLocationChange); }; } }, stop() { if (this._eventCleanup) { this._eventCleanup(); this._eventCleanup = null; } },Note: This approach may miss programmatic navigation (e.g.,
api.navigate()) that doesn't trigger these events, so you might need to keep a hybrid approach or ensure navigation methods notify the monitor.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
code/core/src/manager/components/Focus/Focus.tsx(1 hunks)code/core/src/manager/components/LocationMonitor.ts(1 hunks)code/core/src/manager/components/useLocationHash.ts(0 hunks)code/core/src/manager/settings/Checklist/Checklist.tsx(1 hunks)code/core/src/shared/checklist-store/checklistData.tsx(2 hunks)
💤 Files with no reviewable changes (1)
- code/core/src/manager/components/useLocationHash.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx,js,jsx,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use camelCase for variable and function names
Files:
code/core/src/manager/components/Focus/Focus.tsxcode/core/src/manager/components/LocationMonitor.tscode/core/src/manager/settings/Checklist/Checklist.tsxcode/core/src/shared/checklist-store/checklistData.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx}: Enable TypeScript strict mode
Export functions from modules for testing purposes
Files:
code/core/src/manager/components/Focus/Focus.tsxcode/core/src/manager/components/LocationMonitor.tscode/core/src/manager/settings/Checklist/Checklist.tsxcode/core/src/shared/checklist-store/checklistData.tsx
**/*.{ts,tsx,js,jsx,json,html,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx,js,jsx,json,html,mjs}: Use ESLint and Prettier for code style enforcement
Run 'yarn prettier --write ' to format code after making changes
Run 'yarn lint:js:cmd ' to check for ESLint issues after making changes
Files:
code/core/src/manager/components/Focus/Focus.tsxcode/core/src/manager/components/LocationMonitor.tscode/core/src/manager/settings/Checklist/Checklist.tsxcode/core/src/shared/checklist-store/checklistData.tsx
code/**/!(*.test).{ts,tsx,js,mjs}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
code/**/!(*.test).{ts,tsx,js,mjs}: Use 'logger' from 'storybook/internal/node-logger' for server-side (Node.js) logging, not console.log/console.warn/console.error
Use 'logger' from 'storybook/internal/client-logger' for client-side (browser) logging, not console.log/console.warn/console.error
Do not use console.log, console.warn, or console.error directly unless in isolated files where importing loggers would significantly increase bundle size
Files:
code/core/src/manager/components/Focus/Focus.tsxcode/core/src/manager/components/LocationMonitor.tscode/core/src/manager/settings/Checklist/Checklist.tsxcode/core/src/shared/checklist-store/checklistData.tsx
🧠 Learnings (1)
📚 Learning: 2025-11-05T09:38:47.712Z
Learnt from: Sidnioulz
Repo: storybookjs/storybook PR: 32458
File: code/core/src/components/components/Select/Select.tsx:200-204
Timestamp: 2025-11-05T09:38:47.712Z
Learning: Repo: storybookjs/storybook — Guidance: Until Storybook 11 is released, do not suggest using React.useId anywhere (e.g., in code/core/src/components/components/Select/Select.tsx) to maintain compatibility with React 17 runtimes. Prefer advising: accept a caller-provided props.id and, if needed, generate a client-only fallback id to minimize SSR hydration issues — but avoid useId. Resume prompting for useId after Storybook 11.
Applied to files:
code/core/src/manager/components/Focus/Focus.tsxcode/core/src/manager/settings/Checklist/Checklist.tsx
🧬 Code graph analysis (1)
code/core/src/shared/checklist-store/checklistData.tsx (1)
code/core/src/manager/components/LocationMonitor.ts (1)
LocationMonitor(3-37)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: normal
- GitHub Check: Core Unit Tests, windows-latest
🔇 Additional comments (3)
code/core/src/manager/settings/Checklist/Checklist.tsx (1)
17-17: LGTM! Import path updated correctly.The import path has been successfully updated to reflect the new LocationMonitor module structure. The hook usage remains consistent throughout the file.
code/core/src/shared/checklist-store/checklistData.tsx (1)
32-32: LGTM! Import added for LocationMonitor.The import correctly references the new LocationMonitor module to enable subscription-based completion detection.
code/core/src/manager/components/Focus/Focus.tsx (1)
5-5: LGTM! Import path updated correctly.The import path has been successfully updated to reflect the new LocationMonitor module structure. The hook usage remains consistent throughout the file.
|
View your CI Pipeline Execution ↗ for commit 8f95c6d
☁️ Nx Cloud last updated this comment at |
What I did
Instead of relying on the user to click the "Go" button, this implements autocompletion for "See what's new" based on URL navigation. To detect location changes, I've leaned into the already existing useLocationHash mechanism and updated it to support whole Location objects besides hashes.
Checklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
This section is mandatory for all contributions. If you believe no manual test is necessary, please state so explicitly. Thanks!
Documentation
MIGRATION.MD
Checklist for Maintainers
When this PR is ready for testing, make sure to add
ci:normal,ci:mergedorci:dailyGH label to it to run a specific set of sandboxes. The particular set of sandboxes can be found incode/lib/cli-storybook/src/sandbox-templates.tsMake sure this PR contains one of the labels below:
Available labels
bug: Internal changes that fixes incorrect behavior.maintenance: User-facing maintenance tasks.dependencies: Upgrading (sometimes downgrading) dependencies.build: Internal-facing build tooling & test updates. Will not show up in release changelog.cleanup: Minor cleanup style change. Will not show up in release changelog.documentation: Documentation only changes. Will not show up in release changelog.feature request: Introducing a new feature.BREAKING CHANGE: Changes that break compatibility in some way with current major version.other: Changes that don't fit in the above categories.🦋 Canary release
This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the
@storybookjs/coreteam here.core team members can create a canary release here or locally with
gh workflow run --repo storybookjs/storybook publish.yml --field pr=<PR_NUMBER>Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.