mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-30 08:43:38 +00:00
fix(app): hydrate v1 session progress (#38606)
This commit is contained in:
parent
adba484df4
commit
db88c42335
2 changed files with 5 additions and 4 deletions
|
|
@ -64,7 +64,7 @@ describe("MCP queries", () => {
|
|||
})
|
||||
|
||||
describe("active session query", () => {
|
||||
test("loads active sessions once per server cache", async () => {
|
||||
test("loads active sessions immediately and once per server cache", async () => {
|
||||
let calls = 0
|
||||
const queryClient = new QueryClient()
|
||||
const options = loadActiveSessionsQuery(ServerScope.local, {
|
||||
|
|
@ -77,6 +77,7 @@ describe("active session query", () => {
|
|||
expect(await queryClient.fetchQuery(options)).toEqual({ ses_running: { type: "running" } })
|
||||
expect(await queryClient.fetchQuery(options)).toEqual({ ses_running: { type: "running" } })
|
||||
expect(calls).toBe(1)
|
||||
expect(options.enabled).toBe(true)
|
||||
expect([...options.queryKey]).toEqual([ServerScope.local, "activeSessions"])
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export const loadActiveSessionsQuery = (
|
|||
queryOptions<SessionActiveOutput, Error, SessionActiveOutput, readonly [ServerScope, "activeSessions"]>({
|
||||
queryKey: [scope, "activeSessions"] as const,
|
||||
queryFn: () => api.active(),
|
||||
enabled: false,
|
||||
enabled: true,
|
||||
staleTime: Number.POSITIVE_INFINITY,
|
||||
gcTime: Number.POSITIVE_INFINITY,
|
||||
refetchOnMount: false,
|
||||
|
|
@ -242,8 +242,8 @@ export function createServerSyncContextInner(serverSDK: ServerSDK) {
|
|||
active: async () => {
|
||||
if ((await serverSDK.protocol) === "v1") {
|
||||
const statuses = (await serverSDK.client.session.status()).data ?? {}
|
||||
for (const [sessionID, status] of Object.entries(statuses)) {
|
||||
session.set("session_status", sessionID, reconcile(status))
|
||||
seedActiveSessionStatuses(session, statuses)
|
||||
for (const sessionID of Object.keys(statuses)) {
|
||||
void session.resolve(sessionID).catch(() => undefined)
|
||||
}
|
||||
return Object.fromEntries(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue