Skip to content

refactor: prototype for D3-based native wordcloud#5010

Merged
jabbadizzleCode merged 4 commits intowordcloudfrom
wordcloud-reworked
Apr 13, 2026
Merged

refactor: prototype for D3-based native wordcloud#5010
jabbadizzleCode merged 4 commits intowordcloudfrom
wordcloud-reworked

Conversation

@rschlaefli
Copy link
Copy Markdown
Member

@rschlaefli rschlaefli commented Feb 9, 2026

Context / Why

This PR starts replacing the legacy react-wordcloud integration with a native D3 implementation.

The current renderer dependency is outdated for the current stack (React 19 monorepo) and limits maintainability and control over layout/render behavior. The goal is to migrate in stages while preserving the existing evaluation UX contract.

What Was Implemented

  • Added a standalone workspace package: @klicker-uzh/word-cloud
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/src/layout.ts
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/src/render.ts
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/src/random.ts
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/src/types.ts
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/src/index.ts
  • Implemented native layout + SVG renderer API:
    • computeWordCloudLayout(words, options): LayoutResult
    • renderWordCloud(container, layoutResult, renderOptions): RendererHandle
    • RendererHandle.update(nextLayoutResult) / RendererHandle.destroy()
  • Added package demo and tiny static server:
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/demo/index.html
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/demo/main.js
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/demo/server.mjs
  • Added vitest coverage for deterministic layout / overlap / scaling / relayout behavior:
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/word-cloud/test/layout.test.ts
  • Integrated Standard mode in shared components using native package while keeping Premium on legacy path:
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/shared-components/src/charts/ElementWordcloud.tsx
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/shared-components/src/charts/NativeD3WordCloud.tsx
  • Wired workspace + lockfile + turbo dependencies and added temporary Premium fallback assertion in Cypress:
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/packages/shared-components/package.json
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/pnpm-lock.yaml
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/turbo.json
    • /Users/rolandschlaefli/.codex/worktrees/eaff/klicker-uzh/cypress/cypress/e2e/O-live-quiz-workflow.cy.ts

Behavior Preserved

  • Deterministic default seed ('42')
  • Default scale/spiral contract (log, archimedean)
  • Default rotations (0 / -90) and single-word rotation behavior
  • Hover tooltip + hover scaling behavior
  • Existing data/filter pipeline and external ElementWordcloud props contract
  • Existing empty/no-response i18n messages (with Standard-mode empty display now derived from layout result)

What Remains (Next Migration Steps)

  • Migrate Premium mode to native package path
  • Remove remaining legacy renderer dependencies after Premium migration
  • Final cleanup of legacy renderer-specific callbacks/options wiring
  • Keep/expand regression coverage while removing fallback paths

Validation

Executed successfully in this branch:

  • pnpm --filter @klicker-uzh/word-cloud check
  • pnpm --filter @klicker-uzh/word-cloud test
  • pnpm --filter @klicker-uzh/word-cloud build
  • Demo server smoke checks (/ and /dist/index.js) with render + tooltip behavior verified

Known Issue / Follow-Up

  • PR check Check syncpack conformity is currently failing and reports packages/shared-components/package.json for follow-up.

Follow-Up Artifact

Migration status is now tracked in:

This document tracks migration goals, concepts, completed steps, and open tasks until full native migration is complete.

Co-authored-by: Codex
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 9, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (4)
  • main
  • master
  • dev
  • v3

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 330c5a13-f0da-4e81-b7bb-8f179a592be5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 and usage tips.

@rschlaefli
Copy link
Copy Markdown
Member Author

@jabbadizzleCode I had Codex 5.3 do some prototyping for how our own "word-cloud" package could be structured/look like. We should try this and think about how well it maps to our use case :)

@jabbadizzleCode jabbadizzleCode marked this pull request as ready for review April 13, 2026 11:44
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Apr 13, 2026
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@dosubot dosubot bot added the enhancement label Apr 13, 2026
@jabbadizzleCode jabbadizzleCode merged commit 5768564 into wordcloud Apr 13, 2026
3 of 4 checks passed
@jabbadizzleCode jabbadizzleCode deleted the wordcloud-reworked branch April 13, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement size:XXL This PR changes 1000+ lines, ignoring generated files.

Development

Successfully merging this pull request may close these issues.

2 participants