feat(ai-create): global 'AI is generating…' bar that persists across navigation#130
Open
dantaspaulo wants to merge 1 commit into
Open
feat(ai-create): global 'AI is generating…' bar that persists across navigation#130dantaspaulo wants to merge 1 commit into
dantaspaulo wants to merge 1 commit into
Conversation
…navigation
AI generation runs on the backend (the StreamPostCreation job broadcasts
.ai.creation.completed on the private user.{id}.ai-creation.{creationId}
channel), but only the dedicated loading screen listened to that channel. As
soon as the user navigated away, they lost any visual sign that a generation
was still running — only the final bell notification told them.
Introduce a global singleton composable (useAiGeneration) that is the sole owner
of the Echo subscription. Its module-level state persists across Inertia
navigations (SPA) and survives a hard reload via sessionStorage (it re-subscribes
to still-running generations, with a safety timeout). A thin bar at the top of
the content shows 'AI is generating your post…'; on completion it turns into a
clickable 'Your post is ready — View post', and on failure into a dismissible
error.
The loading screen no longer subscribes to Echo directly — it observes the
composable and redirects when its generation is done, which also removes the
two-owners conflict of both calling leave() on the same channel.
- useAiGeneration.ts (new): owns the subscription + state.
- AiGenerationBar.vue (new): the bar, mounted in AppSidebarLayout.
- Loading.vue: observes the composable instead of Echo directly.
- lang/{en,es,pt-BR}/posts.php: bar_* strings.
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 free
to 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.
Problem
AI generation runs on the backend — the
StreamPostCreationjob broadcasts.ai.creation.completedon the privateuser.{id}.ai-creation.{creationId}channel — but only the dedicated loading screen listened to that channel. As
soon as the user navigated away, they lost any visual sign that a generation was
still running; only the final bell notification told them.
Change
A global singleton composable,
useAiGeneration, becomes the sole owner ofthe Echo subscription. Its module-level state persists across Inertia
navigations (SPA) and survives a hard reload via
sessionStorage— itre-subscribes to still-running generations, with a safety timeout so the bar
never gets stuck.
A thin bar at the top of the content shows "AI is generating your post…". On
completion it turns into a clickable "Your post is ready — View post"; on failure
it becomes a dismissible error.
The loading screen no longer subscribes to Echo directly — it now observes
the composable and redirects when its generation is done. That also removes the
two-owners conflict of both the screen and the composable calling
leave()onthe same channel.
How
useAiGeneration.ts(new) — owns the channel subscription and the sharedstate (
track,hydrate,complete, per-idfind).AiGenerationBar.vue(new) — the bar, mounted at the top ofSidebarInsetinAppSidebarLayout.Loading.vue— observes the composable instead of Echo; owns no subscription.lang/{en,es,pt-BR}/posts.php—bar_*strings.The channel name, event (
.ai.creation.completed) and payload(
{ post_id, error }) are unchanged — the same contract the loading screenalready used.