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", () => {
|
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
|
let calls = 0
|
||||||
const queryClient = new QueryClient()
|
const queryClient = new QueryClient()
|
||||||
const options = loadActiveSessionsQuery(ServerScope.local, {
|
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(await queryClient.fetchQuery(options)).toEqual({ ses_running: { type: "running" } })
|
expect(await queryClient.fetchQuery(options)).toEqual({ ses_running: { type: "running" } })
|
||||||
expect(calls).toBe(1)
|
expect(calls).toBe(1)
|
||||||
|
expect(options.enabled).toBe(true)
|
||||||
expect([...options.queryKey]).toEqual([ServerScope.local, "activeSessions"])
|
expect([...options.queryKey]).toEqual([ServerScope.local, "activeSessions"])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ export const loadActiveSessionsQuery = (
|
||||||
queryOptions<SessionActiveOutput, Error, SessionActiveOutput, readonly [ServerScope, "activeSessions"]>({
|
queryOptions<SessionActiveOutput, Error, SessionActiveOutput, readonly [ServerScope, "activeSessions"]>({
|
||||||
queryKey: [scope, "activeSessions"] as const,
|
queryKey: [scope, "activeSessions"] as const,
|
||||||
queryFn: () => api.active(),
|
queryFn: () => api.active(),
|
||||||
enabled: false,
|
enabled: true,
|
||||||
staleTime: Number.POSITIVE_INFINITY,
|
staleTime: Number.POSITIVE_INFINITY,
|
||||||
gcTime: Number.POSITIVE_INFINITY,
|
gcTime: Number.POSITIVE_INFINITY,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
|
|
@ -242,8 +242,8 @@ export function createServerSyncContextInner(serverSDK: ServerSDK) {
|
||||||
active: async () => {
|
active: async () => {
|
||||||
if ((await serverSDK.protocol) === "v1") {
|
if ((await serverSDK.protocol) === "v1") {
|
||||||
const statuses = (await serverSDK.client.session.status()).data ?? {}
|
const statuses = (await serverSDK.client.session.status()).data ?? {}
|
||||||
for (const [sessionID, status] of Object.entries(statuses)) {
|
seedActiveSessionStatuses(session, statuses)
|
||||||
session.set("session_status", sessionID, reconcile(status))
|
for (const sessionID of Object.keys(statuses)) {
|
||||||
void session.resolve(sessionID).catch(() => undefined)
|
void session.resolve(sessionID).catch(() => undefined)
|
||||||
}
|
}
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue