Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): Refetch conversations when toggling the conversation panel #6190

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

amanape
Copy link
Member

@amanape amanape commented Jan 10, 2025

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below

Give a summary of what the PR does, explaining any non-trivial design decisions

  • staleTime is set to the default when fetching conversations
  • Move query config to frontend/src/query-client-config.ts to use in tests without hydration errors

Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:15aabc4-nikolaik   --name openhands-app-15aabc4   docker.all-hands.dev/all-hands-ai/openhands:15aabc4

@amanape amanape requested review from rbren and tofarr January 10, 2025 13:08
@amanape amanape self-assigned this Jan 10, 2025
@@ -9,5 +9,6 @@ export const useUserConversations = () => {
queryKey: ["user", "conversations"],
queryFn: OpenHands.getUserConversations,
enabled: !!userIsAuthenticated,
staleTime: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this mean we refetch constantly? Should it be something like 5s?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No:

Stale queries are refetched automatically in the background when:

  • New instances of the query mount
  • The window is refocused
  • The network is reconnected
  • The query is optionally configured with a refetch interval

source: https://tanstack.com/query/latest/docs/framework/react/guides/important-defaults

Really it just means that we will refetch every time the panel is toggled since the data is always stale. staleTime: 0 is actually the TanStack Query default, that is why we previously fetched frequently

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.

2 participants