Skip to content

Tanstack#10

Open
derjogi wants to merge 27 commits intomasterfrom
tanstack
Open

Tanstack#10
derjogi wants to merge 27 commits intomasterfrom
tanstack

Conversation

@derjogi
Copy link
Contributor

@derjogi derjogi commented Aug 11, 2025

Potential benefits of this PR:

  • Easier to manage (less parameters to be passed around, easier calls to fetch and update things)
  • Status indicator and automatic updates for summaries
  • Maybe a bit less data fetching (I tried to reduce this, but somehow it's still a lot that it's always fetching...)

But I might have also broken some things that I'm not aware of yet, and maybe made some things (some data fetching, maintainability, ...) worse overall 😓

==> I am not convinced myself whether the changes are net positive. We should only a) review this after testing at least some of the improved functionality and saying the functionality is better (mainly summary update status indication and auto update triggers); and b) if then the code review is also positive.
Also note that it will be possibly much easier reviewing all the changes together, instead of commit by commit; because I made some u-turns / replaced some implementations with others with others... 🥵

High-level technical overview of the main changes I did:

  • Uses TanStack Query -> This is an easy-to-use SWR-style mechanism that provides available data instantly on the client (where available) and then updates the data in the background, i.e. makes a database call, and updates the data on the frontend once that updated data is available. This is implemented for individual sessions and in various places throughout the components
  • For workspaces and for the dashboard it's fetching data on the server side and sends it to the client (via dehydration/rehydration). (When I started using Tanstack I wasn't aware that it is a client side thing only and in our code the client-server-boundary is often not very clear; doing it in this dehydration way is a bit more of a patch than best practice, although it's also not 'wrong')
  • Summary: Uses a singleton summary manager to schedule delayed updates. Things that update a session would update the edit date of the user session (chat session), and the tanstack mechanism would detect that data is outdated, then trigger a comparison of last edit dates, and finally trigger a debounced (delayed) update of the summary (change -> edit comparision -> edit newer than summary? -> start summary update in 30s; if other changes are made before the end of 30s it starts a new 30s timer)

Note: There might actually be better ways to achieve updating the summary when there are changes, e.g. there seems to be something like 'Logical Replication' which let's you subscribe to database changes. I wasn't aware of this before doing all this refactor.

@vercel
Copy link

vercel bot commented Aug 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
harmonica-web-app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 8:09am
harmonica-web-app-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 11, 2025 8:09am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant