Uh oh!
There was an error while loading. Please reload this page.
Add host-wiring Embed macros, comment leaf-event forwarding, and V131 staff metadata migration - #585
Merged
Conversation
media_detail embeds CommentsComponent but defined no handle_info, so the
composer's Leaf editor {:leaf_changed, ...} message (which carries the
comment content) was dropped by LiveView's default handler — "Post
Comment" silently no-opped. Add a handle_info that forwards it to
CommentsComponent.forward_leaf_event/2 (runtime-resolved; comments is
optional from core), plus a catch-all so other messages still no-op now
that handle_info is defined. Browser-verified: posting renders + count 0→1.Every consumer of AITranslate.FormGlue (projects, catalogue) hand-
duplicated the same ~6 handle_event clauses (ai_toggle_modal /
ai_select_* / ai_generate_prompt / ai_translate_lang) plus the
handle_info({:ai_translation, ...}) that folds progress/result events
back into the form. Forgetting any was a silent failure (modal renders
but translations never run / progress never updates / form never
re-syncs).
`use PhoenixKitWeb.Components.AITranslate.Embed` injects all of it as
on_mount :handle_event / :handle_info lifecycle hooks, so it composes
with the form's own handlers (no clause-grouping clash, no clobbering) —
mirroring MediaBrowser.Embed / PhoenixKitComments.Embed. Form re-sync
defaults to assign(changeset:, form:) (the superset fitting every
consumer) with an optional ai_translate_assign_form/2 override.
Consumers still call FormGlue.assign_ai_translation/4 in mount (the
resource is dynamic).MediaSelectorModal, MarkdownEditor and MediaGallery are LiveComponents that report results by sending a process message to the host LiveView (they have no handle_info of their own). Each consumer handles the result with its own custom logic, so — unlike Comments/AITranslate — there's no uniform boilerplate to fold into a `use ...Embed` macro. Forgetting the host handler is a silent failure (selection/edit dropped, no crash). Harden each moduledoc with an explicit "required host wiring" contract spelling out the exact message(s) the host MUST handle and the silent-failure consequence, and noting why there's deliberately no macro. Docs only — no behavior change.
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
…d shadowing Address Mistral review follow-ups on PR #585: - Align media_detail.ex {:leaf_changed} forwarder with the canonical MediaBrowser.Embed pattern: function_exported?/2 guard, apply/3 to avoid compile-time binding to the optional phoenix_kit_comments dep, explicit :pass handling, and Logger.warning on unexpected return values (was silently swallowed). - Add accurate moduledoc note to AITranslate.Embed clarifying that host handle_info/handle_event clauses for AI events are shadowed by the halting lifecycle hook (correcting the review's "double-fire" framing — hooks run before the LV callback and halt, so host clauses never fire). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
The {:leaf_changed, _} forwarding block (optional-dep guard + apply/3 +
:pass/contract-drift handling) was duplicated near-verbatim between
MediaBrowser.Embed (macro-injected) and MediaDetail (inline). Extract it to
PhoenixKitWeb.CommentsForwarding so the phoenix_kit_comments contract lives in
one place; a future contract change updates one call site, not two.
Both handlers now delegate to forward_leaf_changed/2. The MediaBrowser.Embed
macro no longer injects `require Logger` into hosts — the only Logger use moved
into the shared module.
Addresses the cleanup finding from the PR #585 code review.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ddon pushed a commit
that referenced
this pull request
Jun 7, 2026
Release entry for the PR #585 work + follow-ups: AITranslate.Embed macro, V131 staff metadata migration, media-detail leaf-forwarding fix, CommentsForwarding helper extraction, host-wiring docs, and dependency bumps. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mdon added a commit
to mdon/phoenix_kit
that referenced
this pull request
Jun 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Foundation/host-wiring improvements extracted while hardening the comment + AI-translation embedding patterns, plus the migration backing staff soft-delete.
Commits
{:leaf_changed}process message to the host LiveView; media_detail wasn't forwarding it, so "Post Comment" silently posted empty content. Adds the runtime forward toCommentsComponent.forward_leaf_event/2(+ catch-all).PhoenixKitWeb.Components.AITranslate.Embed: anon_mountthat injects the 6 identicalai_*handle_eventclauses + the{:ai_translation}handle_infoviaattach_hook, removing the duplicated boilerplate every translate-form consumer was hand-copying. Default form re-sync matches the consumers'assign_form; optionalai_translate_assign_form/2override.MediaSelectorModal,MarkdownEditor, andMediaGallery(these stay docs-only by design — per-consumer logic, not uniform boilerplate, so no macro).metadata JSONB NOT NULL DEFAULT '{}'onphoenix_kit_staff_people(mirrorsentity_data); first consumer is staff soft-delete (stashes prior lifecycle status undermetadata["trashed_from_status"]). IdempotentADD COLUMN IF NOT EXISTS;@current_version→ 131.All compile clean against the integrated tree; no version/CHANGELOG bump (release-cut handled separately).