Skip to content

Add URL parameter for view mode in Bluesky thread viewer#119

Merged
simonw merged 1 commit intomainfrom
claude/add-thread-view-url-param-014kxN4gPMDGZEjwCykxgpD8
Nov 27, 2025
Merged

Add URL parameter for view mode in Bluesky thread viewer#119
simonw merged 1 commit intomainfrom
claude/add-thread-view-url-param-014kxN4gPMDGZEjwCykxgpD8

Conversation

@simonw
Copy link
Owner

@simonw simonw commented Nov 27, 2025

The view mode (thread/recent) is now persisted in the URL as a view
parameter. This allows users to refresh the page and maintain their
selected view mode. Changes:

  • Tab clicks update URL with current view
  • Form submission preserves view mode in URL
  • Page load reads view parameter to restore state

Bluesky thread viewer should use a URL parameter to record if the app is in thread view or most recent view, so hitting refresh works to see latest posts

The view mode (thread/recent) is now persisted in the URL as a `view`
parameter. This allows users to refresh the page and maintain their
selected view mode. Changes:
- Tab clicks update URL with current view
- Form submission preserves view mode in URL
- Page load reads view parameter to restore state
@claude
Copy link
Contributor

claude bot commented Nov 27, 2025

Claude finished @simonw's task —— View job


Code Review Complete ✅

Reviewing PR: Add URL parameter for view mode in Bluesky thread viewer

Todo List:

  • Read repository guidelines (CLAUDE.md) - No repo-specific guidelines found
  • Analyze the modified bluesky-thread.html file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Consider test coverage needs
  • Provide comprehensive feedback

Code Review

Overall Assessment:Good implementation with solid URL state management. The changes are well-structured and follow web standards.

Strengths

  1. Clean URL State Management (Lines 333-336, 375-379)

    • Proper use of URLSearchParams and history.replaceState()
    • No page reloads when switching views
    • URL updates happen at the right moments (tab clicks, form submission)
  2. Robust Input Validation (Lines 421-422)

    • Validates viewParam against allowed values ('thread' or 'recent')
    • Prevents invalid view states from URL manipulation
  3. Good UX Pattern (Lines 416-430)

    • Restores both URL and view state on page load
    • Auto-submits form if URL parameter exists
    • Tab state syncs correctly with URL parameter

🔍 Code Quality & Best Practices

Good:

  • Consistent variable naming (viewParam, urlParam)
  • Proper error boundary with validation
  • Clean separation of concerns

Minor Suggestions:

  • Consider extracting URL parameter keys as constants:
    const URL_PARAMS = { VIEW: 'view', URL: 'url' };

🐛 Potential Issues

Low Risk:

  1. URL Parameter Pollution - The URL keeps accumulating parameters on each form submission, but this is actually expected behavior for bookmarking.

  2. Browser History - Uses history.replaceState() instead of pushState(), which means users can't use back/forward to navigate view changes. This seems intentional and appropriate.

🚀 Performance Considerations

Excellent:

  • No performance concerns identified
  • URL updates use replaceState() (synchronous, minimal overhead)
  • View switching re-renders efficiently without data re-fetching

🔒 Security Assessment

Secure:

  • Input validation prevents XSS via URL parameters
  • URL construction uses proper URLSearchParams API
  • No dynamic script execution or unsafe DOM manipulation
  • External URLs are properly validated (bsky.app domain check exists elsewhere)

🧪 Test Coverage Considerations

Recommended Test Cases:

// URL parameter handling
- Load page with ?view=thread  should show thread view
- Load page with ?view=recent  should show recent view  
- Load page with ?view=invalid  should default to thread view
- Load page with ?url=...&view=recent  should load URL in recent view

// State management
- Switch tabs  should update URL
- Submit form  should preserve current view in URL
- Refresh page  should maintain view and URL state

Recommendations

  1. Consider adding URL parameter documentation in a comment for future maintainers
  2. The implementation is production-ready as-is

Final Verdict: ✅ Approved

This is a well-implemented feature that follows web standards, handles edge cases properly, and provides good user experience. The code is clean, secure, and performant.


@simonw simonw merged commit e173a76 into main Nov 27, 2025
4 checks passed
@simonw simonw deleted the claude/add-thread-view-url-param-014kxN4gPMDGZEjwCykxgpD8 branch November 27, 2025 00:49
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.

2 participants