fix(activity): roll subagent activity up to its root and accept only selectable windows

- List child sessions in the activity query and credit each child's latest update
  to its root, so Recent includes roots whose subagents were active inside the
  window; children never become rows, and only roots of in-window children are
  fetched
- Show and sort activity rows by that rolled-up time
- Restrict activityWindowMinutes to the selectable options on write, and coerce a
  stored unknown value to the default on read so it cannot reset every preference
This commit is contained in:
Chris Scott committed 2026-10-16 11:57:52 -04:00
1 parent 8b6251d83b
commit 84cdffa261
22 files changed
+343 -48

No files matched your search

+10 -3
View File
@@ -44,6 +44,7 @@ interface UseSessionsAcrossDirectoriesOptions {
keepPreviousResults?: boolean
allDirectories?: boolean
project?: { id: string; subpath: string }
includeChildren?: boolean
}
type SessionDirectoryCursors = Record<string, string>
@@ -73,7 +74,9 @@ export const useSessionsAcrossDirectories = (
const projectSubpath = options?.project?.subpath;
const projectScoped = !allDirectories && projectId !== undefined;
const singleCursor = allDirectories || projectScoped;
const includeChildren = options?.includeChildren ?? false;
const directoryKey = uniqueDirectories.join('|');
const childSessionsParam = includeChildren ? { includeChildren: true } : {};
const query = useInfiniteQuery<
SessionListPage,
@@ -86,7 +89,7 @@ export const useSessionsAcrossDirectories = (
'opencode',
'sessions',
directoryKey,
{ search: normalizedSearch, limit, allDirectories, project: projectId, subpath: projectSubpath },
{ search: normalizedSearch, limit, allDirectories, project: projectId, subpath: projectSubpath, includeChildren },
],
queryFn: async ({ pageParam }) => {
if (singleCursor) {
@@ -98,8 +101,9 @@ export const useSessionsAcrossDirectories = (
order: 'desc',
search: normalizedSearch,
...(projectScoped ? { project: projectId, subpath: projectSubpath } : {}),
...childSessionsParam,
}
: { cursor },
: { cursor, ...childSessionsParam },
);
return {
items: page.items,
@@ -115,6 +119,7 @@ export const useSessionsAcrossDirectories = (
limit,
order: 'desc',
search: normalizedSearch,
...childSessionsParam,
}),
),
);
@@ -134,7 +139,9 @@ export const useSessionsAcrossDirectories = (
const entries = Object.entries(pageParam.cursors);
const pages = await Promise.all(
entries.map(([directory, cursor]) => listSessionPage({ directory, cursor })),
entries.map(([directory, cursor]) =>
listSessionPage({ directory, cursor, ...childSessionsParam }),
),
);
const cursors: SessionDirectoryCursors = {};
const items: SessionInfo[] = [];