Hi everyone,
I’m really struggling with AutoRefresh — I realize I had a lot of misconceptions about how it actually works.
My main goal is to build a ChatGPT-like chat in my app using open-ihp.
According to the docs, “The package is designed to work well with IHP AutoRefresh and IHP DataSync”.
I built a POC that works with AutoRefresh, but then I realized that AutoRefresh monitors the entire table, re-executes the action for all connected users, and broadcasts the results to every client over WebSocket. That feels really unscalable — am I right about this?
Is there a way to refresh a view only when the specific user’s row changes?
On the UX side, I also want to have a skeleton loader before the interface renders. I managed to do this nicely with HTMX:
mainView =
[hsx|
<div
id=“chat-pane”
class=“h-full”
hx-get={pathTo (RefineChatPaneAction uuid)}
hx-trigger=“load once”
hx-swap=“innerHTML”
>
{skeleton}
|]
The issue is that whenever a token arrives in the DB from OpenAI, the skeleton keeps re-appearing.
I tried attaching AutoRefresh to RefineChatPaneAction, but then it doesn’t update at all. Does AutoRefresh not work with HTMX?
It seems like what I actually need is a localized AutoRefresh (as described here
), though I don’t necessarily care about SSE.
I also came across the DataSubscriptionApi . which does synchronize db to frontend for specific row, but only usable with react ? is there an equivalent with haskell views ?
(Ref: IHP Realtime SPAs Guide
)
For me, the main selling point of IHP was having a reactive stack from DB to frontend.
What I expected was something like:
RefineChatPaneAction uuid = autoRefresh do
row ← fetch uuid
mainView =
[hsx|
<div
id=“chat-pane”
class=“h-full”
hx-get={pathTo (RefineChatPaneAction uuid)}
hx-trigger=“load once”
hx-swap=“innerHTML”
>
{skeleton}
|]
…which would refresh the view automatically whenever the row with this uuid changes, without re-showing the skeleton each time.
Is there a way to achieve this behavior without React?