fix(app): session load cap

This commit is contained in:
adamelmore
2026-01-26 12:58:46 -06:00
parent de3b654dcd
commit 319ad2a391
2 changed files with 129 additions and 40 deletions

View File

@@ -1592,6 +1592,7 @@ export default function Layout(props: ParentProps) {
mobile?: boolean
dense?: boolean
popover?: boolean
children?: Map<string, string[]>
}): JSX.Element => {
const notification = useNotification()
const notifications = createMemo(() => notification.session.unseen(props.session.id))
@@ -1600,6 +1601,16 @@ export default function Layout(props: ParentProps) {
const hasPermissions = createMemo(() => {
const permissions = sessionStore.permission?.[props.session.id] ?? []
if (permissions.length > 0) return true
const childIDs = props.children?.get(props.session.id)
if (childIDs) {
for (const id of childIDs) {
const childPermissions = sessionStore.permission?.[id] ?? []
if (childPermissions.length > 0) return true
}
return false
}
const childSessions = sessionStore.session.filter((s) => s.parentID === props.session.id)
for (const child of childSessions) {
const childPermissions = sessionStore.permission?.[child.id] ?? []
@@ -1898,6 +1909,19 @@ export default function Layout(props: ParentProps) {
.filter((session) => !session.parentID && !session.time?.archived)
.toSorted(sortSessions(Date.now())),
)
const children = createMemo(() => {
const map = new Map<string, string[]>()
for (const session of workspaceStore.session) {
if (!session.parentID) continue
const existing = map.get(session.parentID)
if (existing) {
existing.push(session.id)
continue
}
map.set(session.parentID, [session.id])
}
return map
})
const local = createMemo(() => props.directory === props.project.worktree)
const active = createMemo(() => {
const current = params.dir ? base64Decode(params.dir) : ""
@@ -1911,10 +1935,9 @@ export default function Layout(props: ParentProps) {
const open = createMemo(() => store.workspaceExpanded[props.directory] ?? local())
const boot = createMemo(() => open() || active())
const loading = createMemo(() => open() && workspaceStore.status !== "complete" && sessions().length === 0)
const hasMore = createMemo(() => local() && workspaceStore.sessionTotal > workspaceStore.session.length)
const hasMore = createMemo(() => workspaceStore.sessionTotal > sessions().length)
const busy = createMemo(() => isBusy(props.directory))
const loadMore = async () => {
if (!local()) return
setWorkspaceStore("limit", (limit) => limit + 5)
await globalSync.project.loadSessions(props.directory)
}
@@ -2073,7 +2096,9 @@ export default function Layout(props: ParentProps) {
<SessionSkeleton />
</Show>
<For each={sessions()}>
{(session) => <SessionItem session={session} slug={slug()} mobile={props.mobile} />}
{(session) => (
<SessionItem session={session} slug={slug()} mobile={props.mobile} children={children()} />
)}
</For>
<Show when={hasMore()}>
<div class="relative w-full py-1">
@@ -2288,8 +2313,21 @@ export default function Layout(props: ParentProps) {
.filter((session) => !session.parentID && !session.time?.archived)
.toSorted(sortSessions(Date.now())),
)
const children = createMemo(() => {
const map = new Map<string, string[]>()
for (const session of workspaceStore.session) {
if (!session.parentID) continue
const existing = map.get(session.parentID)
if (existing) {
existing.push(session.id)
continue
}
map.set(session.parentID, [session.id])
}
return map
})
const loading = createMemo(() => workspaceStore.status !== "complete" && sessions().length === 0)
const hasMore = createMemo(() => workspaceStore.sessionTotal > workspaceStore.session.length)
const hasMore = createMemo(() => workspaceStore.sessionTotal > sessions().length)
const loadMore = async () => {
setWorkspaceStore("limit", (limit) => limit + 5)
await globalSync.project.loadSessions(props.project.worktree)
@@ -2308,7 +2346,7 @@ export default function Layout(props: ParentProps) {
<SessionSkeleton />
</Show>
<For each={sessions()}>
{(session) => <SessionItem session={session} slug={slug()} mobile={props.mobile} />}
{(session) => <SessionItem session={session} slug={slug()} mobile={props.mobile} children={children()} />}
</For>
<Show when={hasMore()}>
<div class="relative w-full py-1">