mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +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
@@ -23,12 +23,12 @@ vi.mock('react-router-dom', async () => {
|
||||
|
||||
const activityMocks = vi.hoisted(() => ({
|
||||
useActiveWork: vi.fn(),
|
||||
useActivityWindowMs: vi.fn(),
|
||||
useActivityWindowMinutes: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useActiveWork', () => ({
|
||||
useActiveWork: activityMocks.useActiveWork,
|
||||
useActivityWindowMs: activityMocks.useActivityWindowMs,
|
||||
useActivityWindowMinutes: activityMocks.useActivityWindowMinutes,
|
||||
useRepoActivityState: () => null,
|
||||
}))
|
||||
|
||||
@@ -155,7 +155,7 @@ describe('MoreDrawer', () => {
|
||||
cloneStatus: 'ready',
|
||||
clonedAt: 0,
|
||||
})
|
||||
activityMocks.useActivityWindowMs.mockReturnValue(30 * 60_000)
|
||||
activityMocks.useActivityWindowMinutes.mockReturnValue(30)
|
||||
setActivityGroups({})
|
||||
})
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ const { sessionsData, sessionsHookCalls, permissionSessions, createSessionDirect
|
||||
|
||||
const activityMocks = vi.hoisted(() => ({
|
||||
useActiveWork: vi.fn(),
|
||||
useActivityWindowMs: vi.fn(),
|
||||
useActivityWindowMinutes: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useActiveWork', () => ({
|
||||
useActiveWork: activityMocks.useActiveWork,
|
||||
useActivityWindowMs: activityMocks.useActivityWindowMs,
|
||||
useActivityWindowMinutes: activityMocks.useActivityWindowMinutes,
|
||||
useRepoActivityState: () => null,
|
||||
}))
|
||||
|
||||
@@ -168,7 +168,7 @@ describe('RepoQuickSwitchSheet', () => {
|
||||
sessionsData.splice(0, sessionsData.length)
|
||||
sessionsHookCalls.splice(0, sessionsHookCalls.length)
|
||||
permissionSessions.current.clear()
|
||||
activityMocks.useActivityWindowMs.mockReturnValue(30 * 60_000)
|
||||
activityMocks.useActivityWindowMinutes.mockReturnValue(30)
|
||||
setActivityGroups({})
|
||||
})
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ import { useToolPanel } from '@/hooks/useToolPanel'
|
||||
const activityMocks = vi.hoisted(() => ({
|
||||
useActiveWork: vi.fn(),
|
||||
useActiveWorkCounts: vi.fn(),
|
||||
useActivityWindowMs: vi.fn(),
|
||||
useActivityWindowMinutes: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useActiveWork', () => ({
|
||||
useActiveWork: activityMocks.useActiveWork,
|
||||
useActiveWorkCounts: activityMocks.useActiveWorkCounts,
|
||||
useActivityWindowMs: activityMocks.useActivityWindowMs,
|
||||
useActivityWindowMinutes: activityMocks.useActivityWindowMinutes,
|
||||
}))
|
||||
|
||||
vi.mock('@/components/file-browser/FileBrowser', () => ({
|
||||
@@ -91,7 +91,7 @@ function search(): URLSearchParams {
|
||||
return new URLSearchParams(screen.getByTestId('search').textContent ?? '')
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -152,7 +152,7 @@ function HomeHarness() {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
activityMocks.useActiveWorkCounts.mockReturnValue({ needsInput: 0, running: 0 })
|
||||
activityMocks.useActivityWindowMs.mockReturnValue(WINDOW_MS)
|
||||
activityMocks.useActivityWindowMinutes.mockReturnValue(WINDOW_MINUTES)
|
||||
setActivityGroups()
|
||||
})
|
||||
|
||||
|
||||
@@ -26,41 +26,56 @@ import { isPanelTool, type ToolPanelState, type PanelTool } from '@/hooks/useToo
|
||||
import { useOpenNavItem } from '@/hooks/useOpenNavItem'
|
||||
import { ActivityList } from '@/components/activity/ActivityList'
|
||||
import { ActivityCountPill } from '@/components/activity/ActivityCountPill'
|
||||
import { useActiveWorkCounts, useActivityWindowMs } from '@/hooks/useActiveWork'
|
||||
import { useActiveWorkCounts, useActivityWindowMinutes } from '@/hooks/useActiveWork'
|
||||
import { formatActivityWindow } from '@/lib/activeWork'
|
||||
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
|
||||
import { restoreOverlayFocus } from '@/lib/overlayFocus'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
const MS_PER_MINUTE = 60_000
|
||||
|
||||
const PANEL_WIDTH_CLASSES: Partial<Record<PanelTool, string>> = {
|
||||
activity: 'w-80',
|
||||
}
|
||||
|
||||
function ActivityWindowLabel() {
|
||||
const windowMs = useActivityWindowMs()
|
||||
const minutes = useActivityWindowMinutes()
|
||||
return (
|
||||
<span className="shrink-0 text-xs text-muted-foreground">
|
||||
Last {formatActivityWindow(Math.round(windowMs / MS_PER_MINUTE))}
|
||||
Last {formatActivityWindow(minutes)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
function ActivityPanelBody() {
|
||||
const navigate = useNavigate()
|
||||
const windowMs = useActivityWindowMs()
|
||||
const minutes = useActivityWindowMinutes()
|
||||
|
||||
return (
|
||||
<div className="min-h-0 flex-1 overflow-y-auto">
|
||||
<ActivityList
|
||||
windowMs={windowMs}
|
||||
minutes={minutes}
|
||||
onNavigate={(item) => navigate({ pathname: item.path, search: '?panel=activity' })}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function ActivityRailIndicator() {
|
||||
const { needsInput, running } = useActiveWorkCounts()
|
||||
const total = needsInput + running
|
||||
const label = total > 0 ? `Activity, ${needsInput} needs input, ${running} running` : 'Activity'
|
||||
|
||||
return (
|
||||
<>
|
||||
<span className="sr-only">{label}</span>
|
||||
<ActivityCountPill
|
||||
needsInput={needsInput}
|
||||
running={running}
|
||||
className="absolute -right-0.5 -top-0.5"
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
interface ToolSidePanelProps {
|
||||
panel: ToolPanelState
|
||||
filesBasePath: string | undefined
|
||||
@@ -81,11 +96,14 @@ interface RailButtonProps {
|
||||
item: MoreDrawerItem
|
||||
active: boolean
|
||||
onClick: () => void
|
||||
ariaLabel?: string
|
||||
/**
|
||||
* Rendered inside the button. When present, the indicator owns the button's accessible name,
|
||||
* so the item label is not applied as an `aria-label`.
|
||||
*/
|
||||
indicator?: ReactNode
|
||||
}
|
||||
|
||||
function RailButton({ item, active, onClick, ariaLabel, indicator }: RailButtonProps) {
|
||||
function RailButton({ item, active, onClick, indicator }: RailButtonProps) {
|
||||
const Icon = item.icon
|
||||
return (
|
||||
<Tooltip delayDuration={0}>
|
||||
@@ -93,7 +111,7 @@ function RailButton({ item, active, onClick, ariaLabel, indicator }: RailButtonP
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClick}
|
||||
aria-label={ariaLabel ?? item.label}
|
||||
aria-label={indicator ? undefined : item.label}
|
||||
aria-pressed={active}
|
||||
className={cn(
|
||||
'relative rounded-md p-2 transition-colors',
|
||||
@@ -137,7 +155,6 @@ export function ToolSidePanel({
|
||||
const { activeTool, toggleTool, closePanel } = panel
|
||||
const location = useLocation()
|
||||
const openNavItem = useOpenNavItem()
|
||||
const { needsInput, running } = useActiveWorkCounts()
|
||||
const railRef = useRef<HTMLElement>(null)
|
||||
const previousActiveToolRef = useRef(activeTool)
|
||||
|
||||
@@ -160,18 +177,6 @@ export function ToolSidePanel({
|
||||
}
|
||||
const activeLabel = panelTools.find(({ tool }) => tool === activeTool)?.item.label
|
||||
|
||||
const activityTotal = needsInput + running
|
||||
const activityAriaLabel =
|
||||
activityTotal > 0 ? `Activity, ${needsInput} needs input, ${running} running` : undefined
|
||||
const activityIndicator =
|
||||
activityTotal > 0 ? (
|
||||
<ActivityCountPill
|
||||
needsInput={needsInput}
|
||||
running={running}
|
||||
className="absolute -right-0.5 -top-0.5"
|
||||
/>
|
||||
) : undefined
|
||||
|
||||
if (panelTools.length === 0 && actionItems.length === 0) return null
|
||||
|
||||
const renderTool = (tool: PanelTool) => {
|
||||
@@ -277,8 +282,7 @@ export function ToolSidePanel({
|
||||
item={item}
|
||||
active={tool === activeTool}
|
||||
onClick={() => toggleTool(tool)}
|
||||
ariaLabel={tool === 'activity' ? activityAriaLabel : undefined}
|
||||
indicator={tool === 'activity' ? activityIndicator : undefined}
|
||||
indicator={tool === 'activity' ? <ActivityRailIndicator /> : undefined}
|
||||
/>
|
||||
))}
|
||||
{actionItems.length > 0 ? <div className="my-1 h-px w-6 shrink-0 bg-border" role="separator" /> : null}
|
||||
|
||||
@@ -7,6 +7,23 @@ import { partitionSessions, selectRootSessions } from '@/components/session/sess
|
||||
|
||||
export const SIDEBAR_SESSIONS_PER_REPO = 10
|
||||
|
||||
/** Collects the loaded session from each query result, dropping unresolved queries. */
|
||||
export const combineQuerySessions = (results: Array<{ data?: Session }>): Session[] =>
|
||||
results.flatMap((result) => (result.data ? [result.data] : []))
|
||||
|
||||
/** Appends extra sessions after the base list, deduplicating by id within both lists. */
|
||||
export function mergeExtraSessions(sessions: Session[], extraSessions: Session[]): Session[] {
|
||||
if (extraSessions.length === 0) return sessions
|
||||
const seen = new Set(sessions.map((session) => session.id))
|
||||
const extras: Session[] = []
|
||||
for (const session of extraSessions) {
|
||||
if (seen.has(session.id)) continue
|
||||
seen.add(session.id)
|
||||
extras.push(session)
|
||||
}
|
||||
return extras.length === 0 ? sessions : [...sessions, ...extras]
|
||||
}
|
||||
|
||||
export interface SidebarSessionItem {
|
||||
key: string
|
||||
session: Session
|
||||
@@ -50,7 +67,7 @@ export function buildRepoByDirectory(repos: Repo[]): Map<string, Repo> {
|
||||
return new Map(repos.map((repo) => [repo.fullPath, repo]))
|
||||
}
|
||||
|
||||
function normalizeDirectory(directory?: string | null): string | null {
|
||||
export function normalizeDirectory(directory?: string | null): string | null {
|
||||
return directory?.replace(/\/+$/, '') ?? null
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user