News for hackers. Stuff that matters.
Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by willsmith72 on Monday November 20, 2023 @09:45AM (#38349021)
everytime i check out some htmx source, it feels like it would be a complete nightmare to maintain at scale.

e.g.

hx-delete="/chat/{{ chat.id }}" hx-target="#chat-{{ chat.id }}" hx-swap="outerHTML"

Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by TheUndead96 on Monday November 20, 2023 @10:04AM (#38349247)
I think that snippet is perfectly reasonable if you are an individual or a small team in charge of the whole stack. This line of code is unlikely ever to change. Contrast this with React+Redux, where the code must constantly change to accommodate schema changes from the backend. The React project thus changes more often, but this is a false sense of maintainability. Further, imagine the 200+ dependencies a starter React app requires and how all of these must be kept up to date.
Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by nop_slide on Monday November 20, 2023 @10:00AM (#38349208)
I barely know htmx but this example seems quite easy to parse. This snippet deletes a chat from the backend and removes the corresponding element in the UI.

- send a DELETE request to /chat/chat.id

- the response is going to swap the content of the #chat-chat.id element

Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by hu3 on Monday November 20, 2023 @10:22AM (#38349415)
Hi! Thanks for parsing it.

How could I implement an error flash message in case the delete fails in this case?

Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by wild_egg on Monday November 20, 2023 @11:15AM (#38349942)
I've found the simplest option is to have the server respond with the markup for the flash message.

The server can include a couple response headers to override the placement of the message to not affect the existing page state

https://htmx.org/docs/#response-headers

This allows the error to either be added inline in the UI somewhere or (my preference) displayed as a toast by appending to the end of the <body>

Re:RustGPT: ChatGPT UI Built with Rust, Htmx, SQLite by hu3 on Monday November 20, 2023 @01:28PM (#38352132)
Perfect thanks!