summaryrefslogtreecommitdiffhomepage
path: root/packages/app/src/pages
diff options
context:
space:
mode:
authorShoubhit Dash <[email protected]>2026-03-13 16:43:41 +0530
committerGitHub <[email protected]>2026-03-13 16:43:41 +0530
commit46ba9c81703fc6e7db7e623a607eeaab94fcd00f (patch)
tree15e7cb8c2f01e2fa56d83adef333520e57732de0 /packages/app/src/pages
parent80f91d3fd912b6fc8d476d1f1ae7d221c08d19e9 (diff)
downloadopencode-46ba9c81703fc6e7db7e623a607eeaab94fcd00f.tar.gz
opencode-46ba9c81703fc6e7db7e623a607eeaab94fcd00f.zip
perf(app): use cursor session history loading (#17329)
Diffstat (limited to 'packages/app/src/pages')
-rw-r--r--packages/app/src/pages/layout.tsx16
1 files changed, 10 insertions, 6 deletions
diff --git a/packages/app/src/pages/layout.tsx b/packages/app/src/pages/layout.tsx
index ed2221846..9b964b4b5 100644
--- a/packages/app/src/pages/layout.tsx
+++ b/packages/app/src/pages/layout.tsx
@@ -41,8 +41,8 @@ import {
getSessionPrefetch,
isSessionPrefetchCurrent,
runSessionPrefetch,
- SESSION_PREFETCH_TTL,
setSessionPrefetch,
+ shouldSkipSessionPrefetch,
} from "@/context/global-sync/session-prefetch"
import { useNotification } from "@/context/notification"
import { usePermission } from "@/context/permission"
@@ -770,9 +770,11 @@ export default function Layout(props: ParentProps) {
const next = items.map((x) => x.info).filter((m): m is Message => !!m?.id)
const sorted = mergeByID([], next)
const stale = markPrefetched(directory, sessionID)
+ const cursor = messages.response.headers.get("x-next-cursor") ?? undefined
const meta = {
- limit: prefetchChunk,
- complete: sorted.length < prefetchChunk,
+ limit: sorted.length,
+ cursor,
+ complete: !cursor,
at: Date.now(),
}
@@ -846,10 +848,12 @@ export default function Layout(props: ParentProps) {
const [store] = globalSync.child(directory, { bootstrap: false })
const cached = untrack(() => {
- if (store.message[session.id] === undefined) return false
const info = getSessionPrefetch(directory, session.id)
- if (!info) return false
- return Date.now() - info.at < SESSION_PREFETCH_TTL
+ return shouldSkipSessionPrefetch({
+ message: store.message[session.id] !== undefined,
+ info,
+ chunk: prefetchChunk,
+ })
})
if (cached) return