Skip to content

Tag cloud & category mindmap: search, clustering, server cache#220

Merged
AllTerrainDeveloper merged 2 commits into
trunkfrom
native-posts-improvements
May 15, 2026
Merged

Tag cloud & category mindmap: search, clustering, server cache#220
AllTerrainDeveloper merged 2 commits into
trunkfrom
native-posts-improvements

Conversation

@AllTerrainDeveloper
Copy link
Copy Markdown
Collaborator

@AllTerrainDeveloper AllTerrainDeveloper commented May 15, 2026

Summary

Adds a Content Graph–style search bar to the pixi tag cloud and category mindmap, pre-clusters the tag cloud by co-occurrence (tags that share posts sit near each other), and introduces a shared server cache with version-bump invalidation for the two terms-derived REST endpoints.

Search

  • New search input in both wpd-mindmap__toolbar and wpd-tagcloud__toolbar.
  • Substring match on name (plus slug for tags), top-10 by post count.
  • Mouse + keyboard: ArrowUp/Down, Enter, Escape; click delegates to existing focusNode / focusTag.
  • Fixes a stacking-context bug where the dropdown rendered behind the pixi canvas (toolbar now creates its own stacking context).

Co-occurrence clustering for tags

  • New GET /desktop-mode/v1/tag-cooccurrence — one SQL scan over term_relationships, returns top-N co-occurring siblings per tag with shared-post counts. Status filter mirrors core's _update_post_term_count.
  • findSpiralSlot extended with an optional anchor; new packBoxesWithClusters pulls each chip toward the centroid of its already-placed neighbors and seeds new clusters on a golden-angle meta-spiral when nothing co-occurs yet.
  • First paint = popularity spiral; when the cooccurrence fetch lands, non-persisted chips ease into their cluster positions via the existing pixi tick. User-dragged positions stay put.
  • Reflow re-packs with the current map and refreshes cooccurrence in the background.

Server cache

  • Shared transient cache for /tag-cooccurrence and /term-counts. One version option (desktop_mode_terms_cache_version) keyed into both caches.
  • /term-counts caches the whole taxonomy under one key (dmtcnt_v{N}_{taxonomy}) and projects the caller's requested ID subset out of it — every client variant shares the same entry.
  • Invalidation: 7 actions bump the version (set_object_terms, created_term, edited_term, delete_term, wp_trash_post, untrashed_post, before_delete_post). One option write retires every cached payload across both endpoints.
  • TTL DAY_IN_SECONDS as a floor on staleness if a hook ever fails to fire.

Tests

  • New PHPUnit:
    • Tests_DesktopMode_PostsWindowTagCooccurrence — 22 tests covering math, status filtering, limit cap, cache hit/miss, and per-hook invalidation.
    • Tests_DesktopMode_PostsWindowTermCounts — 13 tests covering auth, ID projection, shared-cache projection across subsets, status filtering, cache hit/miss, invalidation, caps.
  • npm run lint, tsc --noEmit, npm run test:js (1237 / 1237) — green.
  • Full @group desktop-mode PHPUnit: 780 / 781. The single failure is the pre-existing pluginsWindowRegistration test that tries to contact wordpress.org from the test container.
Open WordPress Playground Preview

- Introduced a fuzzy-search input for tags in the tags cloud, allowing users to search and select tags easily.
- Implemented a co-occurrence map to cluster tags that share posts, improving the visual layout of the tags cloud.
- Updated the spiral packing algorithm to consider tag clusters, ensuring related tags are placed near each other.
- Added a new function to refresh the layout based on the latest co-occurrence data.
- Created comprehensive unit tests for the `/desktop-mode/v1/tag-cooccurrence` REST endpoint, covering authorization, response structure, and cache invalidation.
- Ensured that the endpoint correctly handles various post statuses and limits the number of neighbors returned.
@AllTerrainDeveloper AllTerrainDeveloper enabled auto-merge (squash) May 15, 2026 12:32
@github-actions
Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@AllTerrainDeveloper AllTerrainDeveloper merged commit e8cff5e into trunk May 15, 2026
5 checks passed
@AllTerrainDeveloper AllTerrainDeveloper deleted the native-posts-improvements branch May 15, 2026 12:34
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