mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
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:
1 parent
8b6251d83b
commit
84cdffa261
22 files changed
+343
-48
No files matched your search
@@ -11,6 +11,7 @@ import {
|
||||
buildRepoActivityIndex,
|
||||
collectActiveRoots,
|
||||
repoActivityFromIndex,
|
||||
rootSessionID,
|
||||
type ActiveWorkGroups,
|
||||
} from '@/lib/activeWork'
|
||||
import {
|
||||
@@ -103,15 +104,27 @@ export function useActiveWork(windowMs: number): {
|
||||
} = useSessionsAcrossDirectories(repoDirectories, {
|
||||
allDirectories: true,
|
||||
limit: ACTIVE_WORK_SESSION_LIMIT,
|
||||
includeChildren: true,
|
||||
})
|
||||
|
||||
const statuses = useSessionStatus((state) => state.statuses)
|
||||
const parents = useSessionStatus((state) => state.parents)
|
||||
const storeParents = useSessionStatus((state) => state.parents)
|
||||
const runningShells = useSessionStatus((state) => state.runningShells)
|
||||
const outcomes = useSessionStatus((state) => state.outcomes)
|
||||
const sessionDirectories = useSessionStatus((state) => state.directories)
|
||||
const pendingInputSessionIDs = usePendingInputSessionIDs()
|
||||
|
||||
const parents = useMemo(() => {
|
||||
const merged = new Map<string, string | null>()
|
||||
for (const session of sessions) {
|
||||
merged.set(session.id, session.parentID ?? null)
|
||||
}
|
||||
for (const [sessionID, parentID] of storeParents) {
|
||||
if (!merged.has(sessionID)) merged.set(sessionID, parentID)
|
||||
}
|
||||
return merged
|
||||
}, [sessions, storeParents])
|
||||
|
||||
const roots = useMemo(
|
||||
() => collectActiveRoots({ statuses, parents, runningShells, pendingInputSessionIDs }),
|
||||
[statuses, parents, runningShells, pendingInputSessionIDs],
|
||||
@@ -124,6 +137,12 @@ export function useActiveWork(windowMs: number): {
|
||||
|
||||
const missingRootIDs = useMemo(() => {
|
||||
const ids = new Set<string>()
|
||||
const windowStart = Date.now() - windowMs
|
||||
for (const session of sessions) {
|
||||
if (session.time.updated < windowStart) continue
|
||||
const rootID = rootSessionID(session.id, parents)
|
||||
if (!listedSessionIDs.has(rootID)) ids.add(rootID)
|
||||
}
|
||||
for (const sessionID of roots.needsInput) {
|
||||
if (!listedSessionIDs.has(sessionID)) ids.add(sessionID)
|
||||
}
|
||||
@@ -131,7 +150,7 @@ export function useActiveWork(windowMs: number): {
|
||||
if (!listedSessionIDs.has(sessionID)) ids.add(sessionID)
|
||||
}
|
||||
return [...ids]
|
||||
}, [roots, listedSessionIDs])
|
||||
}, [sessions, parents, listedSessionIDs, roots, windowMs])
|
||||
|
||||
const fetchedSessions = useQueries({
|
||||
queries: missingRootIDs.map((sessionID) =>
|
||||
@@ -152,10 +171,11 @@ export function useActiveWork(windowMs: number): {
|
||||
windowMs,
|
||||
repos,
|
||||
sessions: mergedSessions,
|
||||
parents,
|
||||
roots,
|
||||
outcomes,
|
||||
}),
|
||||
[windowMs, repos, mergedSessions, roots, outcomes],
|
||||
[windowMs, repos, mergedSessions, parents, roots, outcomes],
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user