mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +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
@@ -48,6 +48,7 @@ function createItem(
|
||||
return {
|
||||
key: `${overrides.repo.id}:${overrides.session.id}`,
|
||||
path: `/repos/${overrides.repo.id}/sessions/${overrides.session.id}`,
|
||||
updatedAt: overrides.session.time.updated,
|
||||
...overrides,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ function ActivityRow({ item, isCurrent, onSelect }: ActivityRowProps) {
|
||||
<span className="block truncate text-xs text-muted-foreground">{repoLine}</span>
|
||||
</span>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
{formatShortRelativeTime(new Date(item.session.time.updated))}
|
||||
{formatShortRelativeTime(new Date(item.updatedAt))}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
@@ -109,7 +109,7 @@ function CompactActivityRow({ item, isCurrent, onSelect }: ActivityRowProps) {
|
||||
{getRepoDisplayName(item.repo)}
|
||||
</span>
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
{formatShortRelativeTime(new Date(item.session.time.updated))}
|
||||
{formatShortRelativeTime(new Date(item.updatedAt))}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -37,6 +37,7 @@ function createActiveWorkItem(): ActiveWorkItem {
|
||||
return {
|
||||
key: '1:s1',
|
||||
state: 'recent',
|
||||
updatedAt: now,
|
||||
path: '/repos/1/sessions/s1',
|
||||
session: {
|
||||
id: 's1',
|
||||
|
||||
@@ -105,12 +105,14 @@ function createRepo(id: number, name: string, fullPath: string) {
|
||||
}
|
||||
|
||||
function createActiveWorkItem(): ActiveWorkItem {
|
||||
const session = createSession('s1', Date.now(), '/path/to/repo1')
|
||||
return {
|
||||
key: '1:s1',
|
||||
state: 'recent',
|
||||
path: '/repos/1/sessions/s1',
|
||||
session: createSession('s1', Date.now(), '/path/to/repo1'),
|
||||
session,
|
||||
repo: createRepo(1, 'repo1', '/path/to/repo1'),
|
||||
updatedAt: session.time.updated,
|
||||
path: '/repos/1/sessions/s1',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ function createActivityItem(id: string, title: string, repoId: number, repoName:
|
||||
session,
|
||||
repo,
|
||||
state: 'recent',
|
||||
updatedAt: session.time.updated,
|
||||
path: `/repos/${repoId}/sessions/${id}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,11 +131,13 @@ function activeWorkItem(
|
||||
state: ActiveWorkState = 'recent',
|
||||
): ActiveWorkItem {
|
||||
const itemRepo = mocks.repos.find((candidate) => candidate.fullPath === directory) ?? mocks.repos[0]
|
||||
const itemSession = session(id, title, directory)
|
||||
return {
|
||||
key: `${directory}:${id}`,
|
||||
session: session(id, title, directory),
|
||||
session: itemSession,
|
||||
repo: itemRepo,
|
||||
state,
|
||||
updatedAt: itemSession.time.updated,
|
||||
path: `/repos/${itemRepo.id}/sessions/${id}`,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ interface SessionPickerRow {
|
||||
key: string
|
||||
session: Session
|
||||
repo: Repo
|
||||
updatedAt?: number
|
||||
}
|
||||
|
||||
interface SessionPickerSection {
|
||||
@@ -262,7 +263,7 @@ const SessionPickerRowItem = memo(function SessionPickerRowItem({
|
||||
>
|
||||
{showRepo && <span className="max-w-32 truncate">{getRepoDisplayName(row.repo)}</span>}
|
||||
{!showRepo && label && <span className="max-w-32 truncate">{label}</span>}
|
||||
<span>{formatShortRelativeTime(new Date(row.session.time.updated))}</span>
|
||||
<span>{formatShortRelativeTime(new Date(row.updatedAt ?? row.session.time.updated))}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center pr-1">
|
||||
@@ -811,7 +812,7 @@ function ActivePickerContent({
|
||||
const rows: SessionPickerRow[] = []
|
||||
for (const item of groups[definition.key]) {
|
||||
if (needle && !(item.session.title ?? '').toLowerCase().includes(needle)) continue
|
||||
rows.push({ key: item.key, session: item.session, repo: item.repo })
|
||||
rows.push({ key: item.key, session: item.session, repo: item.repo, updatedAt: item.updatedAt })
|
||||
}
|
||||
return rows.length > 0 ? [{ id: definition.key, heading: definition.heading, rows }] : []
|
||||
})
|
||||
|
||||
@@ -49,13 +49,6 @@ describe('ActivitySettings', () => {
|
||||
expect(screen.getByRole('combobox', { name: 'Recent activity window' })).toHaveTextContent('2 hours')
|
||||
})
|
||||
|
||||
it('shows a stored window that is not a preset option', () => {
|
||||
mockUseSettings({ preferences: { ...basePreferences, activityWindowMinutes: 45 } })
|
||||
render(<ActivitySettings />)
|
||||
|
||||
expect(screen.getByRole('combobox', { name: 'Recent activity window' })).toHaveTextContent('45 minutes')
|
||||
})
|
||||
|
||||
it('saves the chosen window in minutes', async () => {
|
||||
const user = userEvent.setup()
|
||||
const updateSettings = vi.fn()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { useMemo } from 'react'
|
||||
import { useSettings } from '@/hooks/useSettings'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
|
||||
@@ -9,15 +8,6 @@ export function ActivitySettings() {
|
||||
const { preferences, updateSettings } = useSettings()
|
||||
const activityWindowMinutes = preferences?.activityWindowMinutes ?? DEFAULT_ACTIVITY_WINDOW_MINUTES
|
||||
|
||||
const windowOptions = useMemo(() => {
|
||||
const options: number[] = [...ACTIVITY_WINDOW_MINUTE_OPTIONS]
|
||||
if (!options.includes(activityWindowMinutes)) {
|
||||
options.push(activityWindowMinutes)
|
||||
options.sort((a, b) => a - b)
|
||||
}
|
||||
return options
|
||||
}, [activityWindowMinutes])
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<h2 className="text-lg font-semibold text-foreground">Activity</h2>
|
||||
@@ -31,13 +21,18 @@ export function ActivitySettings() {
|
||||
</div>
|
||||
<Select
|
||||
value={String(activityWindowMinutes)}
|
||||
onValueChange={(value) => updateSettings({ activityWindowMinutes: Number(value) })}
|
||||
onValueChange={(value) => {
|
||||
const minutes = ACTIVITY_WINDOW_MINUTE_OPTIONS.find((option) => String(option) === value)
|
||||
if (minutes !== undefined) {
|
||||
updateSettings({ activityWindowMinutes: minutes })
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger id="activityWindowMinutes" className="w-full shrink-0 sm:w-40">
|
||||
<SelectValue placeholder="Select a window" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{windowOptions.map((minutes) => (
|
||||
{ACTIVITY_WINDOW_MINUTE_OPTIONS.map((minutes) => (
|
||||
<SelectItem key={minutes} value={String(minutes)}>
|
||||
{formatActivityWindow(minutes)}
|
||||
</SelectItem>
|
||||
|
||||
Reference in new issue
Block a user