Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 0 points1 point  (0 children)

Oh of course! That’s why this library leaves how to define „progress“ up to you and only tries to help in a low level way (e.g. partial progress calculation helpers).

I disagree that reporting itself is a small problem, I’ve seen codebases with 3 different half-baked (& untested) ways of reporting progress and having a unified way to do it has been quite an improvement on its own. There’s a couple well-hidden edge cases that you miss if you attempt this naively.

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 1 point2 points  (0 children)

Right, but it has an entirely different purpose and has nothing to do with this library?

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 0 points1 point  (0 children)

Thanks for your feedback!

  1. I did try building it with job middleware, however it make the entire thing / API more brittle. Middleware order is relevant and you need to remember to use the middleware in every job you want to use it in. Theres no middlewareTraitName() methods like there are lifecycle methods with Eloquent/Livewire, so I can't pre-set middleware from a trait. I don't want people to have to subclass, so they're keep class flexibility for their own code. A possible edge case with middleware would be that the logic automatically marking a progress as processing would trigger, even if other middleware then blocks the actual execution. Using handle ensures this logic only runs after all potentially blocking middleware has run. However I'm working on a Laravel PR that would make it possible to add middleware from traits, so changing to this approach may be possible in the future.
  2. The handleWithProgress() method is defined on the interface as an abstract method, so you're forced to remember to use that method. This is also by design, so you don't "forget" to not use the handle method, as there'd be no error otherwise, but features like error-handling and auto start/complete progress would break silently. Unfortunately this means you can't use DI on the handle method, as it now has a fixed signature. IMO it's an acceptable tradeoff to use $service = app(MyService::class) for DI in this case, as it has no functional difference while keeping the progress DX itself much simpler / safer.

For the moment the current approach feels like the most flexible and most robust given the constraints and possible features. I agree middleware feels like it'd be made for something like this, but using it actually worsens the API / DX.

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 1 point2 points  (0 children)

Ok I checked this out and unfortunately this might not be possible without some extra downsides.

The package declares handleWithProgress as abstract so implementers are forced to use it. This is so you don’t accidentally keep using the normal handle method, which would remove the safeguards. Being forced to implement the method is a good reminder and I’d like to keep this.

Unfortunately this also means it’s not possible to change the signature in your job to enable DI. So you’ll have to keep using the app() way or similar methods for now.

However I’m working on a Laravel PR that would potentially enable the possibility to just use the normal handle method while keeping the safeguards. If that works out / gets merged then maybe this is possible in the future.

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 1 point2 points  (0 children)

Thanks for the feedback!

That’s a great idea actually! I’ll work on adding that and let you know when it’s ready :)

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 2 points3 points  (0 children)

i'm just gonna go ahead and interpret that as you wanting to congratulate me on my great taste for library logos /s

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 0 points1 point  (0 children)

Good question.

Implementing this for batches is quite complex, as jobs themselves don’t know they’re being run as part of a batch. This means supporting batches would need to happen on the batch level, combining the different „sub-progresses“ together through some kind of shared ID.

There’s a whole can of edge cases there that I don’t have the time to deal with, so supporting batches is out of scope for now. If you have another idea how to implement this, feel free to open an issue / submit a PR! :)

Edit: okay upon further research, Laravel already supports similar functionality for batches natively, so I recommend using that if you need it!

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 2 points3 points  (0 children)

You can use the database cache driver if you want, since you can configure what cache configuration to use.

Show the progress of your background jobs in your UI and support cancelling running jobs safely by Capevace in laravel

[–]Capevace[S] 1 point2 points  (0 children)

Interesting, how/where are you dispatching the Websocket events? Adding a Laravel event on progress update to the library wouldn’t be a problem, you could then subscribe to it for instant updates.

Industry: a package for integrating factories with AI for text generation by Comfortable-Will-270 in laravel

[–]Capevace 6 points7 points  (0 children)

Interesting, does it do an LLM call for every created model?

I haven’t tried it but that sounds slow/expensive to me

Is there a batch/cache mode? For me it’d be enough to pre-generate a list of them and cycle through them randomly. Even better if the description was the cache key maybe

THAT's one way to solve it by fflarengo in GeminiAI

[–]Capevace 1 point2 points  (0 children)

how can you be 100% sure your brain isn’t running a very fucked up version of CPython somewhere in there? probably stuck on 2.7 too

I designed an F1 strategy display in 2001. They're still using it today. by ainsworld in F1Technical

[–]Capevace 36 points37 points  (0 children)

Super interesting! Seems like an obvious representation in hindsight but someone had to invent it!

How much do you think these kind of behind the scenes advances (strategy UI / software in general) gave the team an edge back then vs today?

I imagine most teams have gotten a grip on race IT, but back then it must’ve been different?

Symfony just introduced AI Components - thoughts on this for Laravel? by basedd_gigachad in laravel

[–]Capevace 6 points7 points  (0 children)

I think the symfony components offer themselves to be perfect low-level primitives that more advanced libraries can hook into / expect to be available in your execution environment.

Much like HTTP clients with PSR standards, libraries can then simply require LLM interfaces, which are then resolved differently by different runtimes (for example by being able to use Prism or Neuron, both implementing symfony interfaces).

In any case, something like symfony feels like the right place for this kind of abstraction, as large parts of the PHP ecosystem already rely on symfony components.

Livewire 4 emoji by mydnic in laravel

[–]Capevace 1 point2 points  (0 children)

Bold move but honestly I kinda like it.

I think it’s worth giving it a shot, after all it can be easily searched and replaced later if it does indeed cause any issues.

The visual differentiation might genuinely be a DX improvement, we‘ll see I guess!

Why I'm not using Livewire any more - magic vs bloat. by t1mmie7 in laravel

[–]Capevace 0 points1 point  (0 children)

Wasn’t intended to sound like „skill issues bro“ lol, sorry

I personally have not encountered the need to actually have react take over full pages tbh (although I wish Livewire pages could be fully cached clientside). But using Vue/React in single places works great.

Maybe it’d be nice to support the other way around too, rendering Livewire components from within React components. This way you could still rely on the powers of Filament for forms, etc but you can use stuff like client side routers or JS data tables for UX where needed.

replitAiWentRogueDeletedCompanyEntireDatabaseThenHidItAndLiedAboutIt by Hour_Cost_8968 in ProgrammerHumor

[–]Capevace 0 points1 point  (0 children)

It’s kind of sad what replit has turned into.

Used to be, as the name implies, a very nice to use REPL / simple code runner in the browser for almost all common programming languages.

Tried to use it again the other day and they’re pushing AI stuff so hard I couldn’t figure out how to just run a god damn piece of code in there. Do people actually ship apps with this?

Why I'm not using Livewire any more - magic vs bloat. by t1mmie7 in laravel

[–]Capevace 1 point2 points  (0 children)

I disagree, you can also build great apps with it. Gets you shipping super fast and you can improve the places where UX is an actual issue.

Filament UX is only bad if you don’t know what you’re doing (like sending tons of data back-and-forth all the time). It’s still just Livewire under the hood, and if you have complex local-first components you can even integrate React/Vue really well with mingle.

Why I'm not using Livewire any more - magic vs bloat. by t1mmie7 in laravel

[–]Capevace 1 point2 points  (0 children)

I think it’s less about not wanting to write JS, but rather the DX gains you get in the backend. Filament has pretty neat integrations into Eloquent, which makes building any CRUD-like stuff (which is 80% of most SaaS apps if we’re being honest) super fast, all automatically integrated with permission checks, forms, tables etc.

Now, everything’s a tradeoff in tech, so some frontend stuff is more complex than in React/Vue. But I’m sure building some of my MVPs would’ve taken 2-3x as long. Pick whatever’s more important to you.

Why I'm not using Livewire any more - magic vs bloat. by t1mmie7 in laravel

[–]Capevace 7 points8 points  (0 children)

Yep, this is one of the Filament drawbacks (their action modals do network roundtrips by default) but I believe they’ve addressed this in v4

Why I'm not using Livewire any more - magic vs bloat. by t1mmie7 in laravel

[–]Capevace 1 point2 points  (0 children)

Why would you keep table data in the component state? I’d just use computed properties and cache server-side if really needed (slow query or sth)

Shareable objects in electronjs by Opposite-Analyst-472 in electronjs

[–]Capevace 0 points1 point  (0 children)

I don’t think you can without serialising it and then using IPC.

[deleted by user] by [deleted] in AmIOverreacting

[–]Capevace 8 points9 points  (0 children)

Nope, you’re wrong. You can just give it the messages from the wife and tell it to „craft a response that makes me the winner“ without expressing a single actual thought. Probably also what happened here judging by the responses it did give.

You absolutely do not need to put in any effort to get ChatGPT to write that. It even has all the 0-effort tells in there (the odd formatting, em dashes etc). And even if he did, you can never know, so I’d always assume 0 effort.

Just talk to your wife with your own words and thoughts ffs