Skip to content

fix: load state when the URL hash changes - #568

Open
Pixel998 wants to merge 2 commits into
mainfrom
fix/load-state-on-hash-change
Open

Pixel998 wants to merge 2 commits into
mainfrom
fix/load-state-on-hash-change

Conversation

@Pixel998

@Pixel998 Pixel998 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

This PR fixes a bug where opening a share link in a tab that already shows Code Explorer doesn't load the shared state, so the page keeps showing the previous state.

Steps to reproduce

  1. Replace the editor contents with const a = 1; and copy the page URL.
  2. Change the code to const b = 2;.
  3. Paste the copied URL into the address bar and press Enter.
  4. Notice the editor still shows const b = 2;.

What changes did you make? (Give an overview)

Reloaded the persisted state on hashchange using persist.rehydrate().

Related Issues

Is there anything you'd like reviewers to focus on?

Summary by CodeRabbit

  • Bug Fixes
    • The editor now updates its saved state when navigating between URL hashes with browser back and forward, without requiring a page reload.

@eslint-github-bot eslint-github-bot Bot added the bug Something isn't working label Oct 1, 2026
@netlify

netlify Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for eslint-code-explorer ready!

Name Link
🔨 Latest commit edc6ac6
🔍 Latest deploy log https://app.netlify.com/projects/eslint-code-explorer/deploys/6ac93b069f99880007d1222a
😎 Deploy Preview https://deploy-preview-568--eslint-code-explorer.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: eslint/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 996051ef-88e4-4cd3-ab2d-d7bae851093a

📥 Commits

Reviewing files that changed from the base of the PR and between 62a4ad7 and edc6ac6.


📒 Files selected for processing (2)
  • e2e-tests/persistence.test.ts
  • src/hooks/use-explorer.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

A hashchange listener now rehydrates useExplorer persisted state when the URL hash changes. An end-to-end test checks editor values after browser back and forward navigation.

Changes

Hash-based state restoration

Layer / File(s) Summary
Hash-change rehydration and validation
src/hooks/use-explorer.ts, e2e-tests/persistence.test.ts
A hashchange event triggers useExplorer.persist.rehydrate(). The end-to-end test checks that browser back and forward navigation restore the corresponding editor values.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to edc6a

Share-link navigation and browser back/forward restore the editor state encoded in the current hash instead of leaving newer editor contents visible. No actionable merge risk remains.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: loading persisted editor state when the URL hash changes.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@eslintbot eslintbot added this to Triage Oct 1, 2026
@Pixel998
Pixel998 marked this pull request as draft October 1, 2026 00:25
@Pixel998
Pixel998 marked this pull request as ready for review October 9, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants