Skip to content

Fix alert banners (#1492)#2177

Merged
lancepioch merged 9 commits intomainfrom
lance/1492
Feb 15, 2026
Merged

Fix alert banners (#1492)#2177
lancepioch merged 9 commits intomainfrom
lance/1492

Conversation

@lancepioch
Copy link
Copy Markdown
Member

@lancepioch lancepioch commented Feb 6, 2026

Fixed hydration issues... which resolves #1492

tested with:

Route::get('/test-alert', function () {
    \App\Livewire\AlertBanner::make('test')
        ->title('Test Alert')
        ->body('This is a test alert banner')
        ->danger()
        ->closable()
        ->send();

    return redirect('/admin');
});

Add wire:poll.visible.15s to the alert banner container so new alerts
are picked up without requiring a manual page refresh.
@lancepioch lancepioch requested a review from Boy132 February 6, 2026 06:53
@lancepioch lancepioch self-assigned this Feb 6, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 6, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

New AlertBannerCollection class extends Filament's collection type with a static fromLivewire method. AlertBannerContainer updated to use this collection. AlertBanner.send() now flags Livewire-originated banners in session data. Livewire dehydration hook timing changed from standard listener to pre-hook.

Changes

Cohort / File(s) Summary
Alert Banner Collection System
app/Livewire/AlertBannerCollection.php, app/Livewire/AlertBannerContainer.php
New AlertBannerCollection class provides specialized collection handling with fromLivewire static method. AlertBannerContainer property type updated to use AlertBannerCollection, with inline session data processing that filters and converts entries.
Session Data Flagging
app/Livewire/AlertBanner.php
send() method now conditionally adds a from_livewire flag to session data when the request originates from Livewire, changing the shape of stored alert banner data.
Livewire Hook Timing
app/Providers/Filament/FilamentServiceProvider.php
Dehydration hook registration changed from Livewire\on() to Livewire\before(), altering when the hook fires in the component lifecycle, with corresponding import update.
🚥 Pre-merge checks | ✅ 4 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Merge Conflict Detection ⚠️ Warning ⚠️ Unable to check for merge conflicts: Failed to fetch base branch: From https://github.com/pelican-dev/panel
! [rejected] main -> main (non-fast-forward)
+ 160e0e5...810f237 main -> origin/main (forced update)
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix alert banners (#1492)' directly references the issue being addressed and accurately describes the main change: fixing alert banner functionality.
Description check ✅ Passed The description explains the fix addresses hydration issues and references the specific issue (#1492). It includes a test snippet demonstrating the alert banner functionality.
Linked Issues check ✅ Passed Changes implement automatic alert banner updates without page refresh by using AlertBannerCollection, modifying dehydration hook timing, and adding from_livewire flag for proper session handling [#1492].
Out of Scope Changes check ✅ Passed All changes are directly related to resolving the alert banner hydration issue: new AlertBannerCollection class, modified AlertBannerContainer, updated AlertBanner session handling, and hook timing change.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Boy132
Boy132 previously requested changes Feb 6, 2026
Copy link
Copy Markdown
Member

@Boy132 Boy132 left a comment

Choose a reason for hiding this comment

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

Still requires a page refresh.

@lancepioch lancepioch marked this pull request as draft February 6, 2026 12:51
wire:poll alone only re-renders without pulling new banners from the
session. Specify pullFromSession as the poll method so new alert banners
are picked up without a page refresh.
@lancepioch
Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 8, 2026

✅ Actions performed

Full review triggered.

Session-based polling doesn't work because nothing replenishes session
data during poll requests. Instead, listen for Livewire's navigated
event to re-pull session data after SPA page transitions, which catches
banners pushed by the new page's mount lifecycle.
@lancepioch lancepioch changed the title Auto-update alert banners with Livewire polling (#1492) Fix alert banners (#1492) Feb 15, 2026
@lancepioch lancepioch marked this pull request as ready for review February 15, 2026 16:27
@lancepioch lancepioch requested a review from Boy132 February 15, 2026 16:29
@lancepioch lancepioch dismissed Boy132’s stale review February 15, 2026 16:30

changed fix completely, need re-review

Copy link
Copy Markdown
Member

@Boy132 Boy132 left a comment

Choose a reason for hiding this comment

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

Still doesn't work, tested with Console & Files page.

@lancepioch lancepioch requested a review from Boy132 February 15, 2026 18:05
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@app/Providers/Filament/FilamentServiceProvider.php`:
- Line 37: Remove the invalid import "use function Livewire\before;" and any
calls to before('dehydrate', ...) in FilamentServiceProvider; instead implement
the dehydrate() lifecycle method on the relevant Livewire component classes (or
use Livewire.hook('commit.prepare', ...) for client-side behavior) so code that
must run before dehydration lives in the component's dehydrate() method (or
appropriate JS hook) rather than relying on a nonexistent global before()
helper.

use Livewire\Livewire;

use function Livewire\on;
use function Livewire\before;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

cat composer.json | jq '.require | to_entries[] | select(.key | contains("livewire"))'

Repository: pelican-dev/panel

Length of output: 43


🏁 Script executed:

cat -n app/Providers/Filament/FilamentServiceProvider.php | sed -n '30,45p;70,85p'

Repository: pelican-dev/panel

Length of output: 1114


🏁 Script executed:

# Search for Livewire\before in common hook-related files
rg -n "before\(" --type php | grep -i livewire | head -20

Repository: pelican-dev/panel

Length of output: 43


🏁 Script executed:

# Check if Livewire has before as a documented hook
web_search Livewire before hook function dehydrate

Repository: pelican-dev/panel

Length of output: 111


🏁 Script executed:

find . -name "composer.lock" -o -name "composer.json" | head -5

Repository: pelican-dev/panel

Length of output: 92


🏁 Script executed:

cat composer.json 2>/dev/null | grep -A 2 -B 2 "livewire"

Repository: pelican-dev/panel

Length of output: 234


🏁 Script executed:

# Search for any 'on(' or 'before(' usage in the codebase to understand the pattern
rg -n "Livewire\\\before|function before\(" --type php -A 3

Repository: pelican-dev/panel

Length of output: 2056


🏁 Script executed:

# Check vendor directory or any evidence of Livewire package
find . -type d -name "livewire" 2>/dev/null | head -5

Repository: pelican-dev/panel

Length of output: 87


🏁 Script executed:

cat composer.json | grep -A 20 '"require":'

Repository: pelican-dev/panel

Length of output: 783


🏁 Script executed:

# Get Livewire version from composer.lock
cat composer.lock | jq '.packages[] | select(.name == "livewire/livewire") | {name, version, source}'

Repository: pelican-dev/panel

Length of output: 270


🏁 Script executed:

# Also check require-dev for Livewire
cat composer.lock | jq '.packages[] | select(.name | contains("livewire")) | {name, version}'

Repository: pelican-dev/panel

Length of output: 189


🌐 Web query:

Livewire v3 before hook lifecycle function dehydrate

💡 Result:

In Livewire v3, there isn’t a separate “beforeDehydrate”/“dehydrating” lifecycle hook. The dehydrate() method itself is the hook that runs at the end of every component request (i.e., your last chance to change component state before it’s serialized and sent back). [1]

If what you mean by “before dehydrate()” is “the hook that runs immediately prior in the request,” then the relevant render-phase hooks are:

  • rendering() → runs before render()
  • rendered() → runs after render()
  • dehydrate() → runs at the end of the request [1]

If you’re using Volt, you can also register a dehydrate hook via dehydrate(fn () => ...), and Volt supports targeting specific properties via dehydrate(['count' => fn () => ...]). [2]

Sources:
[1] Livewire v3 Lifecycle Hooks (official docs)
[2] Livewire v3 Volt docs (lifecycle hooks)


🌐 Web query:

Livewire 3.7.6 before() function documentation

💡 Result:

Livewire 3.7.6 doesn’t have a documented component lifecycle hook named before(). In Livewire v3, the “before” equivalents are specific lifecycle hooks such as:

  • Before a property updates: updating() (and updatingFoo() for a specific property) (livewire.laravel.com)
  • Before render(): rendering() (livewire.laravel.com)
  • Before an update request finishes: use JavaScript hooks like Livewire.hook('commit.prepare', ...) (runs right before a request is sent) (livewire.laravel.com)

If you share where you’re calling before() (PHP component? JS? testing?), I can point you to the exact v3 API that matches what you’re trying to do.

Citations:


🌐 Web query:

Livewire 3 global before() helper function hooks

💡 Result:

Livewire 3 doesn’t have a “global before() helper” for components. The equivalents are:

  • Server-side (per component): use lifecycle hook methods like boot(), hydrate(), updating(), rendering(), dehydrate(), etc. to run code before/after key phases. [1]
  • Client-side (global, before requests/updates): register JavaScript hooks with Livewire.hook(...). For “before anything is sent”, use commit.prepare (before commit payloads are collected/sent) or request (before the network request). [2]

Example (global JS “before send”):

document.addEventListener('livewire:init', () => {
  Livewire.hook('commit.prepare', ({ component }) => {
    // runs right before the request is prepared/sent
  })

  Livewire.hook('request', ({ url, options, payload, respond, succeed, fail }) => {
    // runs before the network request
  })
})

Sources: lifecycle hooks [1], JS hooks including commit.prepare and request [2].

[1] https://livewire.laravel.com/docs/lifecycle-hooks
[2] https://livewire.laravel.com/docs/3.x/javascript


🏁 Script executed:

# Search for any function definition of 'before' in the codebase
rg "^\s*function before\(" --type php

Repository: pelican-dev/panel

Length of output: 43


🏁 Script executed:

# Search for where 'before' might be imported or defined
rg "def.*before|function.*before" --type php | grep -v Policy | grep -v "^Binary"

Repository: pelican-dev/panel

Length of output: 560


🏁 Script executed:

# Check if there's any Livewire hook registration for 'before'
rg "register.*hook|Livewire::.*hook" --type php -A 2

Repository: pelican-dev/panel

Length of output: 43


🏁 Script executed:

# Check if there's a custom Livewire service provider that might define before()
rg "before.*=|before\s*\(|register.*before" app/Providers --type php -B 2 -A 2

Repository: pelican-dev/panel

Length of output: 789


🏁 Script executed:

# Check Filament's Livewire integration
rg "use.*Livewire|Livewire::" app/Providers/Filament/FilamentServiceProvider.php -A 2 -B 2

Repository: pelican-dev/panel

Length of output: 454


Livewire\before() does not exist in Livewire v3.7.6 and will fail at runtime.

The before('dehydrate', ...) function call is not a valid Livewire v3 API. Livewire v3 provides lifecycle hooks like rendering(), rendered(), and dehydrate() as component methods, but does not expose a global before() helper function.

To run code before dehydration, use the dehydrate() lifecycle hook method directly in your component class, or use Livewire's JavaScript hooks like Livewire.hook('commit.prepare', ...) for client-side logic.

Also applies to: 77-77

🤖 Prompt for AI Agents
In `@app/Providers/Filament/FilamentServiceProvider.php` at line 37, Remove the
invalid import "use function Livewire\before;" and any calls to
before('dehydrate', ...) in FilamentServiceProvider; instead implement the
dehydrate() lifecycle method on the relevant Livewire component classes (or use
Livewire.hook('commit.prepare', ...) for client-side behavior) so code that must
run before dehydration lives in the component's dehydrate() method (or
appropriate JS hook) rather than relying on a nonexistent global before()
helper.

@lancepioch lancepioch merged commit 85d5f2e into main Feb 15, 2026
17 checks passed
@lancepioch lancepioch deleted the lance/1492 branch February 15, 2026 20:34
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Alert banners don't auto update but need a page refresh

2 participants