Skip to content

Conversation

@pfefferle
Copy link
Member

@pfefferle pfefferle commented Nov 20, 2025

Summary

Adds a button-based filter to the ActivityPub feed that allows users to filter posts by object type (Article, Note, etc.) using the ap_object_type taxonomy.

Changes

  • Add ap_object_type field to FeedPost TypeScript interface
  • Add apObjectType parameter to useFeed hook with REST API integration
  • Create TypeFilter component using WordPress ButtonGroup
  • Integrate TypeFilter into feed stage with localStorage persistence
  • Filter buttons appear in DataViews header, aligned to the right

Features

  • Button-based UI: Clean ButtonGroup interface with "All", "Article", "Note" buttons
  • localStorage persistence: Selected filter is remembered across browser sessions
  • REST API integration: Properly filters posts via the ap_object_type taxonomy parameter
  • Reactive updates: Feed updates immediately when filter selection changes

Test plan

  • View the feed in the ActivityPub Social Web reader
  • Verify filter buttons appear in the header on the right side
  • Click "Article" button and verify only Article posts are shown
  • Click "Note" button and verify only Note posts are shown
  • Click "All" button and verify all posts are shown
  • Refresh the page and verify the selected filter persists
  • Clear localStorage and verify it defaults to "All"

Screenshots

Screenshot 2025-11-20 at 18 36 35

@github-actions github-actions bot added the [Focus] Editor Changes to the ActivityPub experience in the block editor label Nov 20, 2025
This adds a button-based filter to the feed that allows users to filter posts by ActivityPub object type (Article, Note, etc.).

Changes:
- Add ap_object_type field to FeedPost interface
- Add apObjectType parameter to useFeed hook with REST API integration
- Create TypeFilter component using WordPress ButtonGroup
- Integrate TypeFilter into feed stage with localStorage persistence
- Filter buttons appear in DataViews header aligned to the right

The selected filter is persisted to localStorage so it's remembered across sessions.
@pfefferle pfefferle force-pushed the add/feed-type-filter branch from 67a10f6 to 901a259 Compare November 20, 2025 16:22
@pfefferle pfefferle self-assigned this Nov 20, 2025
Copilot finished reviewing on behalf of pfefferle November 20, 2025 16:32
@obenland
Copy link
Member

Nice! Is that something we could add to the DataView settings?

@pfefferle
Copy link
Member Author

I tried... will give it another 30 mins...

Replace custom TypeFilter component with native DataViews filtering system.

Changes:
- Remove custom TypeFilter ButtonGroup component
- Add ap_object_type as a DataView filter field with 'isAny' operator
- Extract filter values from view.filters instead of separate state
- Remove localStorage persistence code (DataViews handles this internally)
- Taxonomy terms populate filter dropdown automatically

This integrates the type filter into DataViews' native filtering UI, providing:
- Consistent UX with other DataViews filters
- Built-in persistence through WordPress views system
- Better accessibility and keyboard navigation
- Automatic filter state management
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a type filter feature to the ActivityPub feed that allows users to filter posts by object type (Article, Note, etc.) using the ap_object_type taxonomy. The filter state is persisted in localStorage and properly integrated with the WordPress REST API.

Key Changes

  • Added ap_object_type field to TypeScript interface for feed posts
  • Implemented REST API integration with taxonomy filtering in the useFeed hook
  • Created a new TypeFilter component using WordPress ButtonGroup for the UI

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
src/social-web/types.ts Added optional ap_object_type field to FeedPost interface
src/social-web/hooks/use-feed.ts Added apObjectType parameter and REST API integration for taxonomy filtering
src/social-web/routes/feed/stage.tsx Integrated TypeFilter component with localStorage persistence and taxonomy term fetching
src/social-web/components/type-filter/index.tsx New component providing button-based filter UI
build/social-web/index.js Minified build output
build/social-web/index.asset.php Updated version hash for cache busting
build/social-web/feed-stage.js Minified build output for feed stage

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pfefferle
Copy link
Member Author

@obenland I am not sure if I like that more!? 025afc9

@pfefferle
Copy link
Member Author

pfefferle commented Nov 20, 2025

Might be nicer if we have some more filters in the future (single actor feeds could maybe be handled as filter too)

@obenland
Copy link
Member

Hm, it looks like I don't have any articles…

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@obenland
Copy link
Member

obenland commented Nov 20, 2025

Are articles being associated correctly in the inbox? Did you create your test-articles manually?

I can't get the selector to show up, which has me wondering if that's because I only have note posts

@pfefferle
Copy link
Member Author

I have added some Articles, by hand and through the inbox.

@obenland
Copy link
Member

Hm, I do have one article post…

@obenland
Copy link
Member

oh! I was looking in the wrong place

@pfefferle
Copy link
Member Author

@obenland I just re-tested with my blogs and it works as expected.

Introduces a filter for ActivityPub object types in the feed-stage.js component. Fetches available object types and allows filtering posts by type, updating the feed query and UI accordingly.
pfefferle and others added 5 commits November 20, 2025 20:40
Use date_gmt field instead of date for reliable UTC parsing in comment timestamps. This ensures comment dates display correctly using relative time format (5m, 2h, 6d) consistent with post dates.
Reworks the ActivityPub feed-stage.js to improve filter and query param handling, including more robust support for taxonomy filters and ap_object_type. Updates the filterBy operators and render logic for the 'Type' filter, and refactors state management for view updates and feed queries.
The ap_object_type taxonomy terms are now fetched without specifying the per_page parameter, relying on the default behavior of useEntityRecords. This simplifies the code and avoids unnecessary explicit pagination.
Introduces support for filtering ActivityPub feed posts by object type. Updates feed-stage.js, feed route, and related hooks to handle object type taxonomy, and adds a new object-type field component. Also updates post type registration to include the ap_object_type parameter.
@pfefferle pfefferle requested a review from obenland November 20, 2025 20:24
Refactors the object type filter to follow Gutenberg field patterns:

- Use async `getElements` to fetch taxonomy terms (no React hooks in field)
- Change to single-value filtering with `is` operator instead of array-based `isAny`
- Extract first value from ap_object_type array for cleaner UX
- Fix filter handling in useFeed to support both single values and arrays
- Remove unused useEntityRecords hook from feed stage
- Simplify field definition following @wordpress/fields architecture

This provides a cleaner, radio-style selection for filtering posts by type
(Article, Note, etc.) while maintaining compatibility with the taxonomy structure.
Copy link
Member

@obenland obenland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bbfe23d I moved all of the entity stuff into the field definition, too, and refactored it to enable single type selections, I hope that's okay. I meant to provide all that stuff as feedback but it got to be a lot and pretty intricate.

The main missing thing is making these term names more accessible. Article and Note are technical terms (we literally save what activities send in their type), and not necessarily the best way to describe what we're trying to convey. I'm also not sure they're translated or translatable?

pfefferle and others added 2 commits November 20, 2025 23:22
Co-authored-by: Konstantin Obenland <[email protected]>
Filter to only Note and Article types and display them as
"Short form" and "Long form" for better user comprehension.
Also adds proper TypeScript typing using Term from @wordpress/core-data.
@obenland
Copy link
Member

In b2d41d2, updated to limit the filter to notes and articles and make the labels translatable. I'm not sure "Short form" and "Long form" are the best labels, happy for us to change those. It doesn't seem to be easily possible to not add the filter when there's only one term.

@pfefferle
Copy link
Member Author

I am not a fan of limiting the types! This is a similar pattern, Mastodon used (or still uses) an what made Articles a second class object on the Fediverse!

I will think about a way to better support all kinds of Objects and to translate at least most of them.

Updated the object type field to support all ActivityPub object types with user-friendly labels, instead of only Note and Article. The feed now displays and filters by a broader set of types, improving usability and consistency.
Set 'minimum' to 0 for integer items in the ActivityPub object type filter parameter and remove the custom sanitize_callback. This enforces non-negative values at the schema level.
@pfefferle pfefferle requested a review from obenland November 21, 2025 12:51
@pfefferle
Copy link
Member Author

@obenland Added some small changes to have best of both worlds. I also changed the translatable text a bit... I think "Long form" and "Short form" are no common (end-user friendly) terms...

@pfefferle pfefferle merged commit 51b2bda into add/reader Nov 21, 2025
13 checks passed
@pfefferle pfefferle deleted the add/feed-type-filter branch November 21, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Focus] Editor Changes to the ActivityPub experience in the block editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants