mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
feat(activity): surface active work across the session picker, tool rail and mobile
This commit is contained in:
1 parent
be874ee07c
commit
d8f2fcf29c
46 files changed
+3120
-277
No files matched your search
@@ -13,12 +13,22 @@ vi.mock('react-router-dom', async () => {
|
||||
}
|
||||
})
|
||||
|
||||
const activityMocks = vi.hoisted(() => ({
|
||||
useRepoActivityState: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/hooks/useActiveWork', () => ({
|
||||
useRepoActivityState: activityMocks.useRepoActivityState,
|
||||
}))
|
||||
|
||||
const defaultProps = {
|
||||
repo: {
|
||||
id: 1,
|
||||
repoUrl: 'https://github.com/test/test-repo',
|
||||
localPath: 'repos/test-repo',
|
||||
fullPath: '/Users/test/repos/test-repo',
|
||||
defaultBranch: 'main',
|
||||
clonedAt: 0,
|
||||
branch: 'main',
|
||||
currentBranch: 'main',
|
||||
cloneStatus: 'ready' as const,
|
||||
@@ -45,6 +55,7 @@ const renderWithRouter = (ui: React.ReactElement) => {
|
||||
describe('RepoCard', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
activityMocks.useRepoActivityState.mockReturnValue(null)
|
||||
})
|
||||
|
||||
it('should not navigate when cloneStatus is not ready', () => {
|
||||
@@ -156,4 +167,29 @@ describe('RepoCard', () => {
|
||||
|
||||
expect(screen.getByText('Cloning...')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show the running indicator when a session in the repo is running', () => {
|
||||
activityMocks.useRepoActivityState.mockReturnValue('running')
|
||||
|
||||
renderWithRouter(<RepoCard {...defaultProps} />)
|
||||
|
||||
expect(screen.getByLabelText('Sessions running')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should show the needs-input indicator when a session in the repo needs input', () => {
|
||||
activityMocks.useRepoActivityState.mockReturnValue('needs-input')
|
||||
|
||||
renderWithRouter(<RepoCard {...defaultProps} />)
|
||||
|
||||
expect(screen.getByLabelText('Session needs input')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should not show an activity indicator when the repo is idle', () => {
|
||||
activityMocks.useRepoActivityState.mockReturnValue(null)
|
||||
|
||||
renderWithRouter(<RepoCard {...defaultProps} />)
|
||||
|
||||
expect(screen.queryByLabelText('Sessions running')).not.toBeInTheDocument()
|
||||
expect(screen.queryByLabelText('Session needs input')).not.toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
@@ -2,24 +2,13 @@ import { useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Loader2, GitBranch, FolderOpen, AlertCircle } from "lucide-react";
|
||||
import { getRepoDisplayName } from "@/lib/utils";
|
||||
import type { Repo } from "@/api/types";
|
||||
import type { GitStatusResponse } from "@/types/git"
|
||||
import { RepoActivityIndicator } from "@/components/activity/RepoActivityIndicator"
|
||||
import { RepoRowActions } from "./RepoRowActions"
|
||||
|
||||
interface RepoCardProps {
|
||||
repo: {
|
||||
id: number;
|
||||
name?: string | null;
|
||||
repoUrl?: string | null;
|
||||
localPath?: string;
|
||||
sourcePath?: string;
|
||||
branch?: string;
|
||||
currentBranch?: string;
|
||||
cloneStatus: string;
|
||||
isWorktree?: boolean;
|
||||
isLocal?: boolean;
|
||||
fullPath?: string;
|
||||
lastAccessedAt?: number;
|
||||
};
|
||||
repo: Repo;
|
||||
onDelete: (id: number) => void;
|
||||
isDeleting: boolean;
|
||||
isSelected?: boolean;
|
||||
@@ -90,6 +79,7 @@ export function RepoCard({
|
||||
{isReady && (
|
||||
<div className={`w-2 h-2 rounded-full shrink-0 ${isDirty ? 'bg-highlight' : 'bg-success'}`} />
|
||||
)}
|
||||
<RepoActivityIndicator repo={repo} />
|
||||
</div>
|
||||
|
||||
{!manageMode && !isSelected && !hasSelectedRepos && (
|
||||
|
||||
Reference in new issue
Block a user