mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
feat(sidebar): add repo-grouped session navigation with live status (#361)
* feat(sidebar): add repo-grouped session navigation with live status - Add a searchable, collapsible session tree to the desktop sidebar, grouped by repository with pinned and time-bucketed ordering. - Track per-session busy, retry, and compact status in a shared store fed by the SSE event stream and scoped by directory. - Extract shared navigation components reused by the desktop tree and the mobile repo quick-switch sheet. - Show a Git tab and hide Schedules inside a repo on the mobile tab bar; add Repos and Assistant entries to the session More drawer. - Replace the CommitsTab local relative-time formatter with a shared formatShortRelativeTime util. * refactor(sidebar): unify session status tracking and navigation helpers * feat(sidebar): add collapsible sessions and menu sections * fix(sessions): keep specific live status over snapshot busy
This commit is contained in:
1 parent
1389e8e59c
commit
015a44a5f3
45 files changed
+3347
-763
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useGitLog } from '@/api/git'
|
||||
import { Loader2, GitCommit, AlertCircle, ArrowUp } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { cn, formatShortRelativeTime } from '@/lib/utils'
|
||||
import { GIT_UI_COLORS } from '@/lib/git-status-styles'
|
||||
|
||||
interface CommitsTabProps {
|
||||
@@ -9,26 +9,6 @@ interface CommitsTabProps {
|
||||
onSelectCommit?: (hash: string) => void
|
||||
}
|
||||
|
||||
function formatRelativeTime(timestamp: string): string {
|
||||
const date = new Date(parseInt(timestamp, 10) * 1000)
|
||||
|
||||
const now = new Date()
|
||||
const diffMs = now.getTime() - date.getTime()
|
||||
const diffSeconds = Math.floor(diffMs / 1000)
|
||||
const diffMinutes = Math.floor(diffSeconds / 60)
|
||||
const diffHours = Math.floor(diffMinutes / 60)
|
||||
const diffDays = Math.floor(diffHours / 24)
|
||||
const diffWeeks = Math.floor(diffDays / 7)
|
||||
const diffMonths = Math.floor(diffDays / 30)
|
||||
|
||||
if (diffSeconds < 60) return 'just now'
|
||||
if (diffMinutes < 60) return `${diffMinutes}m ago`
|
||||
if (diffHours < 24) return `${diffHours}h ago`
|
||||
if (diffDays < 7) return `${diffDays}d ago`
|
||||
if (diffWeeks < 4) return `${diffWeeks}w ago`
|
||||
return `${diffMonths}mo ago`
|
||||
}
|
||||
|
||||
export function CommitsTab({ repoId, branch, onSelectCommit }: CommitsTabProps) {
|
||||
const { data, isLoading, error } = useGitLog(repoId, 50, branch)
|
||||
|
||||
@@ -78,7 +58,7 @@ export function CommitsTab({ repoId, branch, onSelectCommit }: CommitsTabProps)
|
||||
<span>·</span>
|
||||
<span className="truncate">{commit.authorName}</span>
|
||||
<span>·</span>
|
||||
<span className="flex-shrink-0">{formatRelativeTime(commit.date)}</span>
|
||||
<span className="flex-shrink-0">{formatShortRelativeTime(new Date(parseInt(commit.date, 10) * 1000))}</span>
|
||||
{commit.unpushed && (
|
||||
<span className={cn('flex items-center gap-0.5 px-1 rounded', GIT_UI_COLORS.unpushed)}>
|
||||
<ArrowUp className="w-3 h-3" />
|
||||
|
||||
Reference in new issue
Block a user