turbo-morphing
/turbo-morphing
Stosuje odświeżanie stron Turbo 8 z morfowaniem i transmisję odświeżeń, unikając pułapek, takich jak utrata stanu przeglądarki.
- Autor
- davidteren ↗
- Repozytorium
- hotwire-codex-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 02.07.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 3
- Skrypty
- 1
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 02.07.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
- 1 skrypt w paczce. Przejrzyj je przed instalacją, bo Claude może je uruchomić.
Skrypty: scripts/lint_morphing.sh
Co robi i kiedy
Stosuje odświeżanie stron Turbo 8 z morfowaniem i transmisję odświeżeń, unikając pułapek, takich jak utrata stanu przeglądarki.
Oryginalny opis (EN)
Apply Turbo 8 page refreshes with morphing and broadcast refreshes correctly, and avoid the morphing footguns. Use when adding smooth page refreshes (turbo_refreshes_with / turbo-refresh-method morph), broadcasting live updates with broadcasts_refreshes, deciding between morph-refresh vs targeted Turbo Streams vs frames, or when morphing resets browser state (an open details or dialog element, popovers, scroll, focus, JS widgets) after a refresh. Provides a decision guide and a morph-readiness checker.
Jak działa
- When to use
- Decision guide
- broadcastsrefreshes (the simplification)
- Avoid the footguns (morphing resets browser-only state)
- Check a repo
Podgląd SKILL.md
--- name: turbo-morphing description: Apply Turbo 8 page refreshes with morphing and broadcast refreshes correctly, and avoid the morphing footguns. Use when adding smooth page refreshes (turbo_refreshes_with / turbo-refresh-method morph), broadcasting live updates with broadcasts_refreshes, deciding between morph-refresh vs targeted Turbo Streams vs frames, or when morphing resets browser state (an open details or dialog element, popovers, scroll, focus, JS widgets) after a refresh. Provides a decision guide and a morph-readiness checker. --- # Turbo 8 morphing & page refreshes Turbo 8 added a second update model alongside targeted Turbo Streams: **page refreshes with morphing**. Render the current page again (e.g. submit → redirect back) and Turbo morphs only the changed DOM via idiomorph, preserving screen state. It's the simpler "happy path" — but it has sharp edges. This skill helps you pick the right tool and avoid the footguns. Full background: [`references/morphing-guide.md`](references/morphing-guide.md). Real-world note: `piazza-web/wip/analysis/08-turbo8-morphing-refreshes.md`. ## When to use - Adding `turbo_refreshes_with method: :morph, scroll: :preserve`. - Broadcasting live updates and considering `broadcasts_refreshes` vs targeted streams. - Morphing resets UI state (a `<details>` reopens for everyone, a popover closes, scroll jumps, a JS-initialized widget breaks) after a refresh/broadcast. - Reviewing a PR that enables morphing, especially in the global layout. ## Decision guide | Need | Use | |---|---| | Submit-and-redirect-back with many small scattered changes | morph page refresh: `turbo_refreshes_with method: :morph` | | Live multi-user updates, simplest server code, "good enough" fidelity | `broadcasts_refreshes` + `turbo_stream_from @record` | | High-fidelity append/prepend (chat), surgical control | targeted streams (`broadcast_append_to`, etc.) | | Reload one region during a full-page refresh / explicit `.reload()` | frame with `refresh="morph"` | | Morph a single element instead of replacing it | `turbo_stream.replace id, ..., method: :morph` | Mantra (37signals): morphing is an **implementation detail of a page refresh**, not a new partial-update tool. Use targeted streams when you need precision. ## broadcasts_refreshes (the simplification) ```ruby class Listing < ApplicationRecord broadcasts_refreshes # after create/update/destroy → <turbo-stream action="refresh"> end ``` ```erb <%= turbo_stream_from @listing %> <%= turbo_refreshes_with method: :morph, scroll: :preserve %> ``` Async via `Turbo::Streams::BroadcastJob` (needs a job backend), auto-**debounced** (only the last of a burst), and self-refreshes are deduped via `X-Turbo-Request-Id`. ## Avoid the footguns (morphing resets browser-only state) In order of preference: 1. `data-turbo-permanent` — exclude an element from morphing entirely. 2. `turbo:before-morph-element` / `turbo:before-morph-attribute` + a small Stimulus controller to veto a specific change (e.g. keep `<details open>` open). 3. **Best** — keep the state on the server (a user-pref record or a URL param like `?sidebar=1`) so the re-render already matches the browser; morph is then a no-op. Don't enable `turbo_refreshes_with` in the global layout without auditing stateful widgets first. ## Check a repo ```bash scripts/lint_morphing.sh path/to/rails-app ``` Reports: whether morph is enabled (and if it's **global** — in the layout — which is risky), stateful widgets (`<details open>`, `<dialog>`, scrollable/JS-controlled elements) that morphing may reset *without* a `data-turbo-permanent` / `before-morph` guard nearby, and `_later` broadcast usage that needs a job backend. Heuristic grep scan that names its ceiling — guidance, not a parser.
Pliki w paczce (3)
- SKILL.md 4 KB
- references/morphing-guide.md 4 KB
- scripts/lint_morphing.sh 4 KB
Wersje
W bazie nie ma innych skilli o nazwie turbo-morphing.
Migawka bazy z 28.10.2026 · wersja paczki 837d23b38f9e (skrót SHA-256 całej paczki)
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100turbo-frames-patterns
Zawęża nawigację do wybranego obszaru strony przez Turbo Frames i wykrywa błędy połączeń, które cicho nie działają. - 100turbo-patterns
Tworzy Turbo Streams, Turbo Frames i wzorce morfowania do aktualizacji interfejsu w czasie rzeczywistym i renderowania częściowego. - 100developing-with-turbo-frames
Pomaga pracować z Turbo Frames w Laravel dla nawigacji w zakresie ramki i leniwego ładowania: komponent x-turbo::frame, data-turbo-frame, atrybut src, data-turbo-action, wasFromTurboFrame() i morphing ramek. - 100developing-with-turbo-drive
Pomaga pracować z Turbo Drive w Laravel dla nawigacji jak w SPA: morphing stron, atrybuty data-turbo, kontrola cache, przejścia widoków i obsługa przekierowań formularzy. - 100rails-hotwire
Podpowiada dobre praktyki Hotwire w Rails: Turbo Drive, Frames, Streams, morphing w Turbo 8 i kontrolery Stimulus, w tym obsługę błędów i progresywne ulepszanie. - 100turbo-streams-patterns
Buduje precyzyjne Turbo Streams: transmisje modeli przez Action Cable, własne akcje, autoryzację subskrybentów i obecność Kredis.