fix(sync): defer incomplete assistant-only pages
This commit is contained in:
@@ -447,8 +447,9 @@ export function useSync() {
|
|||||||
// user sees content as soon as a user boundary appears, instead of
|
// user sees content as soon as a user boundary appears, instead of
|
||||||
// waiting for the full expansion sequence before the first paint.
|
// waiting for the full expansion sequence before the first paint.
|
||||||
if (!options?.before && !page.complete && !hasUserMessage(page.session)) {
|
if (!options?.before && !page.complete && !hasUserMessage(page.session)) {
|
||||||
for (const nextLimit of getInitialPageExpansionLimits()) {
|
const expansionLimits = getInitialPageExpansionLimits().filter((nextLimit) => nextLimit > limit)
|
||||||
if (nextLimit <= limit) continue
|
for (let index = 0; index < expansionLimits.length; index += 1) {
|
||||||
|
const nextLimit = expansionLimits[index]
|
||||||
if (options?.isStale?.()) {
|
if (options?.isStale?.()) {
|
||||||
setMetaFor(sessionID, { loading: false })
|
setMetaFor(sessionID, { loading: false })
|
||||||
return
|
return
|
||||||
@@ -458,12 +459,22 @@ export function useSync() {
|
|||||||
setMetaFor(sessionID, { loading: false })
|
setMetaFor(sessionID, { loading: false })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const hasBoundary = hasUserMessage(expandedPage.session)
|
||||||
|
const isFinalExpansion = index === expansionLimits.length - 1
|
||||||
|
if (expandedPage.complete || hasBoundary || isFinalExpansion) {
|
||||||
committed = commitMessagesToStore(expandedPage, options?.mode, options?.isStale)
|
committed = commitMessagesToStore(expandedPage, options?.mode, options?.isStale)
|
||||||
|
} else {
|
||||||
|
committed = {
|
||||||
|
messages: expandedPage.session,
|
||||||
|
cursor: expandedPage.cursor,
|
||||||
|
complete: expandedPage.complete,
|
||||||
|
}
|
||||||
|
}
|
||||||
if (options?.isStale?.()) {
|
if (options?.isStale?.()) {
|
||||||
setMetaFor(sessionID, { loading: false })
|
setMetaFor(sessionID, { loading: false })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (expandedPage.complete || hasUserMessage(expandedPage.session)) break
|
if (expandedPage.complete || hasBoundary) break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user