feat: git status bar — show last commit link, remove branch name (#92)
* feat: show last commit hash in status bar, remove branch name Replace the hardcoded "main" branch display with a clickable short SHA linking to the GitHub commit. Add Rust get_last_commit_info command that returns the last commit hash and constructs a GitHub URL from the remote. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: add design/git-status-bar.pen with new status bar layout Shows the updated status bar with commit hash link, no branch name, and annotated change callouts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * ci: retrigger — runner 3 pnpm not found (env issue) --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { isTauri, mockInvoke } from '../mock-tauri'
|
||||
import type { GitPullResult, SyncStatus } from '../types'
|
||||
import type { GitPullResult, LastCommitInfo, SyncStatus } from '../types'
|
||||
|
||||
const DEFAULT_INTERVAL_MS = 5 * 60_000
|
||||
|
||||
@@ -21,6 +21,7 @@ export interface AutoSyncState {
|
||||
syncStatus: SyncStatus
|
||||
lastSyncTime: number | null
|
||||
conflictFiles: string[]
|
||||
lastCommitInfo: LastCommitInfo | null
|
||||
triggerSync: () => void
|
||||
}
|
||||
|
||||
@@ -34,6 +35,7 @@ export function useAutoSync({
|
||||
const [syncStatus, setSyncStatus] = useState<SyncStatus>('idle')
|
||||
const [lastSyncTime, setLastSyncTime] = useState<number | null>(null)
|
||||
const [conflictFiles, setConflictFiles] = useState<string[]>([])
|
||||
const [lastCommitInfo, setLastCommitInfo] = useState<LastCommitInfo | null>(null)
|
||||
const syncingRef = useRef(false)
|
||||
const callbacksRef = useRef({ onVaultUpdated, onConflict, onToast })
|
||||
callbacksRef.current = { onVaultUpdated, onConflict, onToast }
|
||||
@@ -46,6 +48,9 @@ export function useAutoSync({
|
||||
try {
|
||||
const result = await tauriCall<GitPullResult>('git_pull', { vaultPath })
|
||||
setLastSyncTime(Date.now())
|
||||
tauriCall<LastCommitInfo | null>('get_last_commit_info', { vaultPath })
|
||||
.then(info => setLastCommitInfo(info))
|
||||
.catch(() => {})
|
||||
|
||||
if (result.status === 'updated') {
|
||||
setSyncStatus('idle')
|
||||
@@ -90,5 +95,5 @@ export function useAutoSync({
|
||||
return () => clearInterval(id)
|
||||
}, [performPull, intervalMinutes])
|
||||
|
||||
return { syncStatus, lastSyncTime, conflictFiles, triggerSync: performPull }
|
||||
return { syncStatus, lastSyncTime, conflictFiles, lastCommitInfo, triggerSync: performPull }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user