Skip to content

Full polyglot widget support with bleeding-edge Valdi#9

Merged
clholgat merged 18 commits intomainfrom
cholgate/polyglot-widgets
Apr 2, 2026
Merged

Full polyglot widget support with bleeding-edge Valdi#9
clholgat merged 18 commits intomainfrom
cholgate/polyglot-widgets

Conversation

@clholgat
Copy link
Copy Markdown
Collaborator

@clholgat clholgat commented Mar 13, 2026

Summary

Polyglot Widgets

  • Add polyglot widgets: DatePicker, TimePicker, IndexPicker, EmojiLabel with native implementations for iOS, macOS, Android, and web
  • Add WidgetsCatalog component showcasing all widgets in the playground
  • Add Android ValdiEmojiTextView + attributes binder
  • Add macOS IndexPicker native view
  • Fix iOS widget native class names for macOS compatibility (fallthrough to iosClass)
  • Fix web widget factories to use the new WebViewClassAttributeHandler pattern

Playground Fixes

  • Show widgets catalog by default in playground
  • Fix WidgetsCatalog layout and label attribute rendering
  • Defer WidgetsCatalog render to avoid first-frame crash
  • Use setTimeoutDisposable to avoid stale renderer on hot-reload
  • Fix TabsContent render crash, remove stale comment from onViewModelUpdate

Build & Tooling

  • Update WORKSPACE to Valdi 45b28375 via http_archive from public GitHub repo — includes macOS view resolution fallthrough, web custom-view attribute forwarding, CVDisplayLink deadlock fix, and Hermes engine flag
  • Replace per-component filegroups with simple globs in widgets BUILD.bazel
  • Convert web polyglot views from plain JS filegroup to typed TypeScript ts_project
  • Remove unused share module (not referenced by any other module)
  • Add valdi_js_engine flag alias to .bazelrc
  • Convert cross-component relative imports to absolute module paths
  • Remove forbidden strings (internal Valdi references), exclude package-lock.json
  • Remove docs/ folder and .github/copilot-instructions.md

AI / Developer Experience

  • Update AGENTS.md: add Valdi CLI install instructions, fix AI setup, remove .cursor/rules references
  • Remove AI cursor rules (now bundled in the Claude Code CLI)

Test plan

  • macOS: bazel build //valdi_modules/playground:app_macos — playground builds and renders from public Valdi repo
  • iOS: valdi install ios — playground builds and runs in simulator
  • Android: valdi install android — playground builds and installs on emulator
  • Web: ./scripts/bazel_web_serve.sh — playground builds and serves at localhost:8080
  • All four platforms show widgets catalog with DatePicker, TimePicker, IndexPicker, EmojiLabel
  • ts_project for web polyglot views compiles successfully

🤖 Generated with Claude Code

…), widgets catalog, and per-component Bazel targets

- Add native implementations for DatePicker, TimePicker, IndexPicker, EmojiLabel on iOS, macOS, Android, and web
- Add WidgetsCatalog playground screen with live-updating demo of each polyglot widget
- Add "Browse Widgets Catalog" button in Playground that opens/closes the catalog view
- Refactor widgets/BUILD.bazel with named filegroup targets per component (:animation, :button, :pickers, etc.)
- Move Android Kotlin binders from nested com/snap/widgets/pickers/ to flat android/ directory
- Point WORKSPACE at bleeding edge of public Valdi GitHub (d0cd062)
- Add enable_web=true to .bazelrc for Valdi compiler JS output
- Add web playground app (webpack) and bazel_web_serve.sh script
- Add Share module scaffold (iOS, Android, web, TypeScript)
- Add Cursor rules for polyglot modules, custom views, and web polyglot patterns

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@semgrep-code-snapchat
Copy link
Copy Markdown

Semgrep found 31 internal-sensitive-strings findings:

This literal might contain a Snapchat internal reference that should not be committed to open-source repositories.

Fix: Please replace / remove the string to avoid committing it to open-source repositories.

cholgateSC and others added 12 commits March 13, 2026 14:19
- bazel.md: WORKSPACE now uses git_repository (not http_archive); web_deps
  must be a plain JS filegroup (not ts_project); add per-component filegroup
  pattern with explanation of why sub-packages break the Valdi compiler
- web-polyglot.md: rewrite — plain .js files required (ts_project causes
  TS5055 on exec-platform); document current attribute-update limitation
- polyglot-module.md: flatten android/ structure (no deep com/snap/... nesting)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…age-lock.json

- docs/android-internal-valdi.md: remove Fix 2 which referenced the Snap
  internal monorepo (triggered .internal forbidden string check)
- .gitignore: exclude playground/web_app/package-lock.json (jsesc npm package
  path contained .sc- which triggered forbidden string check)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace all relative imports that cross component target boundaries with
absolute 'widgets/src/...' paths. This is a prerequisite for adding
per-component BUILD.bazel files (blocked on Valdi compiler adding a
module_root param to valdi_module() to prevent sub-package path stripping).

56 imports converted across 33 files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- SCWidgetsMacOSIndexPicker: NSPopUpButton subclass with screen-coordinate
  menu popup to work around Valdi layer-backed view hierarchy constraints
- SCWidgetsMacOSLabel: bind to 'value' attribute (was 'text'); add system
  and system-bold font support
- TabsContent: defer coordinator subscription to onRender to prevent
  synchronous setState during parent render (caused blank catalog page)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Render WidgetsCatalog one frame after showCatalog becomes true.
This prevents a stale-renderer crash that can occur when the hot
reloader initializes the runtime and a component with child
sub-components is rendered in the same frame as the navigation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…I setup note

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace incorrect `claude rules install` reference with the correct
`valdi skills install` command from the Valdi CLI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…reload

Raw setTimeout callbacks survive module reloads, firing against a stale
component instance and crashing with "Cannot call this outside of a
onRender callback". setTimeoutDisposable ties the timer to the component
lifecycle so it's cancelled when the component is reloaded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Update WORKSPACE to Valdi 45b28375 (http_archive from public repo)
  with full macOS view resolution and web custom-view attribute support
- Add valdi_js_engine flag alias to .bazelrc
- Add Android EmojiLabel widget (ValdiEmojiTextView)
- Fix iOS widget class names for macOS fallthrough compatibility
- Fix web widget factories for attribute handler pattern
- Show widgets catalog by default in playground
- Fix WidgetsCatalog layout and label rendering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat changed the title Add polyglot widgets, widgets catalog, and per-component Bazel targets Full polyglot widget support with bleeding-edge Valdi Mar 31, 2026
@semgrep-code-snapchat
Copy link
Copy Markdown

Semgrep found 9 internal-sensitive-strings findings:

This literal might contain a Snapchat internal reference that should not be committed to open-source repositories.

Fix: Please replace / remove the string to avoid committing it to open-source repositories.

cholgateSC and others added 3 commits March 31, 2026 11:11
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clholgat clholgat marked this pull request as ready for review March 31, 2026 18:16
@clholgat clholgat requested a review from gioneill March 31, 2026 18:21
cholgateSC and others added 2 commits March 31, 2026 13:41
…ts_project

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gioneill
Copy link
Copy Markdown
Collaborator

gioneill commented Apr 2, 2026

The setTimeout(..., 0) style “wait until next tick” workaround is a very common AI-generated move. It may be masking a real lifecycle or initialization bug rather than fixing it directly. I suspect there is a proper underlying fix here. I’m not convinced this alone should block the PR, but it’s worth calling out..

I've even added to my own agents files to "not add runtime or thread pausing as a solution to a problem, etc.."

@clholgat clholgat merged commit d05a63d into main Apr 2, 2026
2 checks passed
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.

3 participants