It looks like the issue might be related to how Inertia handles shared data between components. By default, shared data is only updated when the URL changes, which is why you're seeing the flash message only when you open the page in a new tab.
To fix this, you can use the shouldInterpolate option in your middleware to force Inertia to update the shared data on every request. Here's an example:
//HandleInertiaRequests middleware
return array_merge(parent::share($request), [
'flash' => function () use ($request) {
return [
'response' => $request->session()->get('message')
];
}
], [
'shouldInterpolate' => true // Add this line
]);
With this change, your shared flash data should be updated on every request, even if the URL doesn't change. This should allow your flash messages to show up properly in your default layout.
Note that forcing interpolation on every request can have performance implications, so make sure to test the impact on your app before using this approach in production.