mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(activity): animate the braille spinner in SVG and tighten the activity lists
- Draw the TUI braille spinner as a 2x4 SVG dot cell stepped by declarative <animate> timelines derived from SPINNER_FRAMES: no JavaScript timer or React render per frame, and it keeps animating under prefers-reduced-motion so an active session never looks stalled - Enlarge the spinner cell and dots so it stays legible next to 14px text - Add a compact ActivityList variant for the mobile More drawer and Repos sheet: one flat list capped at five rows, single-line rows, no group subheadings - Let ActivityList callers own navigation so a row tap navigates once instead of pushing a duplicate history entry - Share the picker keyboard navigation between the session and project tabs and reuse the shared session merge helpers in the sidebar repo groups
This commit is contained in:
1 parent
d8f2fcf29c
commit
8b6251d83b
24 files changed
+858
-787
No files matched your search
@@ -14,7 +14,7 @@ vi.mock('@/hooks/useActiveWork', () => ({
|
||||
useActiveWork: mocks.useActiveWork,
|
||||
}))
|
||||
|
||||
const WINDOW_MS = 30 * 60_000
|
||||
const WINDOW_MINUTES = 30
|
||||
const NOW = Date.now()
|
||||
|
||||
function createSession(id: string, title: string, updated = NOW - 60_000): Session {
|
||||
@@ -71,11 +71,16 @@ function setGroups(groups: {
|
||||
const renderList = (
|
||||
onNavigate = vi.fn(),
|
||||
path = '/',
|
||||
props: { hideWhenEmpty?: boolean; title?: string; variant?: 'full' | 'compact' } = {},
|
||||
props: {
|
||||
hideWhenEmpty?: boolean
|
||||
title?: string
|
||||
variant?: 'full' | 'compact'
|
||||
minutes?: number
|
||||
} = {},
|
||||
) =>
|
||||
render(
|
||||
<MemoryRouter initialEntries={[path]}>
|
||||
<ActivityList windowMs={WINDOW_MS} onNavigate={onNavigate} {...props} />
|
||||
<ActivityList minutes={WINDOW_MINUTES} onNavigate={onNavigate} {...props} />
|
||||
</MemoryRouter>,
|
||||
)
|
||||
|
||||
@@ -118,6 +123,14 @@ describe('ActivityList', () => {
|
||||
expect(screen.getByText('No active or recent sessions in the last 30 minutes')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('renders the empty state with an hour-scale window', () => {
|
||||
setGroups({})
|
||||
|
||||
renderList(vi.fn(), '/', { minutes: 1440 })
|
||||
|
||||
expect(screen.getByText('No active or recent sessions in the last 24 hours')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('calls onNavigate with the item when a row is clicked', () => {
|
||||
const onNavigate = vi.fn()
|
||||
const item = createItem({ state: 'recent', session: createSession('c1', 'Recent'), repo: createRepo(3, 'Gamma') })
|
||||
|
||||
@@ -4,17 +4,22 @@ import { useActiveWork } from '@/hooks/useActiveWork'
|
||||
import { SessionStatusIndicator } from '@/components/ui/session-status-indicator'
|
||||
import { parseRepoRoute } from '@/lib/navigation'
|
||||
import { cn, formatShortRelativeTime, getRepoBranchLabel, getRepoDisplayName } from '@/lib/utils'
|
||||
import type { ActiveWorkItem } from '@/lib/activeWork'
|
||||
import {
|
||||
ACTIVE_WORK_GROUPS,
|
||||
MS_PER_MINUTE,
|
||||
formatActivityEmptyMessage,
|
||||
type ActiveWorkItem,
|
||||
} from '@/lib/activeWork'
|
||||
|
||||
const UNTITLED_SESSION_TITLE = 'Untitled Session'
|
||||
const MS_PER_MINUTE = 60_000
|
||||
const COMPACT_MAX_ITEMS = 5
|
||||
|
||||
const FULL_ICON_CLASS = 'h-4 w-4'
|
||||
const COMPACT_ICON_CLASS = 'h-3.5 w-3.5'
|
||||
|
||||
interface ActivityListProps {
|
||||
windowMs: number
|
||||
/** Activity window in minutes. */
|
||||
minutes: number
|
||||
/** Called when a row is chosen; the caller owns navigation so each surface can apply its own history and close rules. */
|
||||
onNavigate: (item: ActiveWorkItem) => void
|
||||
hideWhenEmpty?: boolean
|
||||
@@ -137,14 +142,14 @@ function ActivityGroup({ heading, items, currentSessionID, currentRepoId, onSele
|
||||
}
|
||||
|
||||
export function ActivityList({
|
||||
windowMs,
|
||||
minutes,
|
||||
onNavigate,
|
||||
hideWhenEmpty = false,
|
||||
title,
|
||||
variant = 'full',
|
||||
}: ActivityListProps) {
|
||||
const location = useLocation()
|
||||
const { groups, isLoading, isError } = useActiveWork(windowMs)
|
||||
const { groups, isLoading, isError } = useActiveWork(minutes * MS_PER_MINUTE)
|
||||
|
||||
const route = parseRepoRoute(location.pathname)
|
||||
|
||||
@@ -163,11 +168,8 @@ export function ActivityList({
|
||||
|
||||
if (isEmpty) {
|
||||
if (hideWhenEmpty) return null
|
||||
const minutes = Math.round(windowMs / MS_PER_MINUTE)
|
||||
return (
|
||||
<p className="p-4 text-sm text-muted-foreground">
|
||||
No active or recent sessions in the last {minutes} minutes
|
||||
</p>
|
||||
<p className="p-4 text-sm text-muted-foreground">{formatActivityEmptyMessage(minutes)}</p>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -203,27 +205,16 @@ export function ActivityList({
|
||||
))
|
||||
) : (
|
||||
<>
|
||||
<ActivityGroup
|
||||
heading="Needs input"
|
||||
items={groups.needsInput}
|
||||
currentSessionID={route.sessionId}
|
||||
currentRepoId={route.repoId}
|
||||
onSelect={onNavigate}
|
||||
/>
|
||||
<ActivityGroup
|
||||
heading="Running"
|
||||
items={groups.running}
|
||||
currentSessionID={route.sessionId}
|
||||
currentRepoId={route.repoId}
|
||||
onSelect={onNavigate}
|
||||
/>
|
||||
<ActivityGroup
|
||||
heading="Recent"
|
||||
items={groups.recent}
|
||||
currentSessionID={route.sessionId}
|
||||
currentRepoId={route.repoId}
|
||||
onSelect={onNavigate}
|
||||
/>
|
||||
{ACTIVE_WORK_GROUPS.map((group) => (
|
||||
<ActivityGroup
|
||||
key={group.key}
|
||||
heading={group.heading}
|
||||
items={groups[group.key]}
|
||||
currentSessionID={route.sessionId}
|
||||
currentRepoId={route.repoId}
|
||||
onSelect={onNavigate}
|
||||
/>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useActivityWindowMs } from '@/hooks/useActiveWork'
|
||||
import { useActivityWindowMinutes } from '@/hooks/useActiveWork'
|
||||
import { ActivityList } from '@/components/activity/ActivityList'
|
||||
|
||||
/**
|
||||
@@ -6,11 +6,11 @@ import { ActivityList } from '@/components/activity/ActivityList'
|
||||
* Reads the network through `useActiveWork`, so it must only be mounted while visible.
|
||||
*/
|
||||
export function CompactActivityList({ onNavigate }: { onNavigate: (path: string) => void }) {
|
||||
const windowMs = useActivityWindowMs()
|
||||
const minutes = useActivityWindowMinutes()
|
||||
|
||||
return (
|
||||
<ActivityList
|
||||
windowMs={windowMs}
|
||||
minutes={minutes}
|
||||
title="Activity"
|
||||
hideWhenEmpty
|
||||
variant="compact"
|
||||
|
||||
Reference in new issue
Block a user