Skip to content

fix(mothership): fix url keeping markdown hash on resource switch#3968

Open
TheodoreSpeaks wants to merge 1 commit intomainfrom
fix/resource-hashtag-url
Open

fix(mothership): fix url keeping markdown hash on resource switch#3968
TheodoreSpeaks wants to merge 1 commit intomainfrom
fix/resource-hashtag-url

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

We recently added support for # to represent headers in markdown files. However, this needs to be cleared on switching resources. Added clearing logic.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

Validated switching resources does not keep trailing hash

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 5, 2026 2:05am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 5, 2026

PR Summary

Low Risk
Low risk, localized client-side URL update that only affects browser history state when changing activeResourceId. Potential impact is limited to navigation/deep-link behavior.

Overview
Clears any existing URL fragment (#...) when updating the resource query param on active resource changes in home.tsx, preventing markdown header hashes from persisting across resource switches.

Reviewed by Cursor Bugbot for commit eab6aed. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 5, 2026

Greptile Summary

This PR fixes a bug where the URL hash fragment (e.g. #some-heading set during markdown header navigation) was persisted in the browser URL when switching between resources in the Mothership view. The one-line fix (url.hash = '') is added to the existing useEffect that already synchronizes the ?resource= URL search param whenever activeResourceId changes, ensuring the URL fragment is cleaned up on every resource switch.

  • Adds url.hash = '' before window.history.replaceState in home.tsx so any #heading fragment accumulated from markdown navigation is cleared when the user switches to a different resource
  • No other files are affected; the change is minimal, well-targeted, and correctly placed in the existing URL-sync effect
  • No issues found during review

Confidence Score: 5/5

Safe to merge — single-line fix with no side effects

The change is a one-line addition that clears the URL hash fragment before replaceState. It is correctly placed in the useEffect responsible for URL synchronization, uses the standard URL API idiom (url.hash = '' fully removes the fragment from the serialized URL), and has no observable side effects beyond the intended fix. No custom rules are violated.

No files require special attention

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/home/home.tsx Adds url.hash = '' before replaceState in the activeResourceId sync effect to clear URL fragment on resource switch — minimal and correct fix

Sequence Diagram

sequenceDiagram
    participant User
    participant MothershipView
    participant Home
    participant BrowserHistory

    User->>MothershipView: Click resource tab
    MothershipView->>Home: setActiveResourceId(newId)
    Home->>Home: useEffect fires (activeResourceId changed)
    Note over Home: url.hash = '' clears #heading fragment
    Home->>BrowserHistory: replaceState(?resource=newId, no fragment)
    Note over BrowserHistory: URL is clean — no stale #heading
Loading

Reviews (1): Last reviewed commit: "fix(mothership): fix url keeping markdow..." | Re-trigger Greptile

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.

1 participant