Skip to content

Commit ec1d96a

Browse files
author
Chris Scott
committed
Fix session caching - enable refetch on focus and reconnect
1 parent 08e3414 commit ec1d96a

3 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ A full-stack web application for running [OpenCode](https://github.com/sst/openc
8585

8686
```bash
8787
# Clone the repository
88-
git clone https://github.com/yourusername/opencode-webui.git
88+
git clone https://github.com/cstech-dev/opencode-webui.git
8989
cd opencode-webui
9090

9191
# Start with Docker Compose (single container)
@@ -125,7 +125,7 @@ docker exec -it opencode-web sh
125125

126126
```bash
127127
# Clone the repository
128-
git clone https://github.com/yourusername/opencode-webui.git
128+
git clone https://github.com/cstech-dev/opencode-webui.git
129129
cd opencode-webui
130130

131131
# Install dependencies (uses Bun workspaces)

‎frontend/src/hooks/useOpenCode.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export const useSessions = (opcodeUrl: string | null | undefined, directory?: st
2828
queryKey: ["opencode", "sessions", opcodeUrl, directory],
2929
queryFn: () => client!.listSessions(),
3030
enabled: !!client,
31+
refetchOnWindowFocus: true,
32+
refetchOnReconnect: true,
33+
staleTime: 10000,
3134
});
3235
};
3336

@@ -38,6 +41,9 @@ export const useSession = (opcodeUrl: string | null | undefined, sessionID: stri
3841
queryKey: ["opencode", "session", opcodeUrl, sessionID, directory],
3942
queryFn: () => client!.getSession(sessionID!),
4043
enabled: !!client && !!sessionID,
44+
refetchOnWindowFocus: true,
45+
refetchOnReconnect: true,
46+
staleTime: 15000,
4147
});
4248
};
4349

@@ -49,8 +55,9 @@ export const useMessages = (opcodeUrl: string | null | undefined, sessionID: str
4955
queryFn: () => client!.listMessages(sessionID!),
5056
enabled: !!client && !!sessionID,
5157
refetchOnMount: false,
52-
refetchOnWindowFocus: false,
53-
refetchOnReconnect: false,
58+
refetchOnWindowFocus: true,
59+
refetchOnReconnect: true,
60+
staleTime: 30000,
5461
gcTime: 10 * 60 * 1000,
5562
placeholderData: (previousData) => previousData,
5663
});

‎frontend/src/hooks/useSSE.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,6 @@ export const useSSE = (opcodeUrl: string | null | undefined, directory?: string)
333333
setIsConnected(true)
334334
setError(null)
335335
resetReconnectDelay()
336-
queryClient.invalidateQueries({ queryKey: ['opencode', 'sessions', opcodeUrl, directory] })
337-
queryClient.invalidateQueries({ queryKey: ['opencode', 'messages', opcodeUrl] })
338336
}
339337

340338
eventSource.onerror = () => {

0 commit comments

Comments
 (0)