mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +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
@@ -174,6 +174,61 @@ describe('useSessionsAcrossDirectories', () => {
|
||||
expect(result.current.data.map((session) => session.id)).toEqual(['ses_all1', 'ses_all2'])
|
||||
})
|
||||
|
||||
it('requests child sessions and records includeChildren in the query key', async () => {
|
||||
mocks.listSessionPage.mockResolvedValue({ items: [sessionInfo('ses_child', '/w/a')] })
|
||||
|
||||
const queryClient = createQueryClient()
|
||||
const { result } = renderHook(
|
||||
() => useSessionsAcrossDirectories(['/w/a'], { includeChildren: true }),
|
||||
{ wrapper: createWrapper(queryClient) },
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.isLoading).toBe(false)
|
||||
})
|
||||
|
||||
expect(mocks.listSessionPage).toHaveBeenCalledWith({
|
||||
directory: '/w/a',
|
||||
limit: 25,
|
||||
order: 'desc',
|
||||
search: undefined,
|
||||
includeChildren: true,
|
||||
})
|
||||
expect(queryClient.getQueryCache().getAll()[0]?.queryKey).toEqual([
|
||||
'opencode',
|
||||
'sessions',
|
||||
'/w/a',
|
||||
{
|
||||
search: undefined,
|
||||
limit: 25,
|
||||
allDirectories: false,
|
||||
project: undefined,
|
||||
subpath: undefined,
|
||||
includeChildren: true,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('keeps root-only and include-children lists in distinct cache entries', async () => {
|
||||
mocks.listSessionPage.mockResolvedValue({ items: [] })
|
||||
|
||||
const queryClient = createQueryClient()
|
||||
const wrapper = createWrapper(queryClient)
|
||||
renderHook(() => useSessionsAcrossDirectories(['/w/a']), { wrapper })
|
||||
renderHook(() => useSessionsAcrossDirectories(['/w/a'], { includeChildren: true }), { wrapper })
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mocks.listSessionPage).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
|
||||
const optionObjects = queryClient
|
||||
.getQueryCache()
|
||||
.getAll()
|
||||
.map((query) => query.queryKey[3] as { includeChildren?: boolean })
|
||||
expect(optionObjects.some((options) => options.includeChildren === true)).toBe(true)
|
||||
expect(optionObjects.some((options) => options.includeChildren === false)).toBe(true)
|
||||
})
|
||||
|
||||
it('pages a project scope through one cursor query with project and subpath', async () => {
|
||||
mocks.listSessionPage.mockImplementation(async ({ cursor }: { cursor?: string }) => {
|
||||
if (cursor === 'cursor_project') {
|
||||
|
||||
Reference in new issue
Block a user