mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* feat: expandable commits and actions in the git history panel Expand a commit row in the Commits panel to see its changed files inline; click a file to open that file's commit diff. Author and date surface on expand, so the dense row itself stays subject-only. Right-click a commit for: open in the in-app browser, copy hash, copy message, and explain changes (spawns the default agent seeded with the commit context). Open-in-browser resolves the provider commit URL in the main process via a new remoteCommitUrl resolver (GitHub/GitLab/Bitbucket), mirroring the existing remoteFileUrl chain end-to-end (repo, IPC, SSH provider, runtime RPC, preload) so it works for local and SSH/remote workspaces. Layout: subject-first single-line rows with a tighter graph, refs moved inline, and local/remote ref pills deduped when they point at the same commit. * fix: address git history review feedback * fix: address PR review feedback on the git history panel - Trim commit SHA before building the remote URL so whitespace input returns null instead of an invalid %20 URL. - Gate commit-row expansion on the file loader (onLoadCommitFiles) so a row can't expand into a perpetual loading state. - Harden the explain prompt: treat the commit subject and diff as untrusted data and run git show --no-ext-diff. - Keep ambiguous multi-segment remote refs instead of mis-deduping them against a local branch. - Use standard 10-char i18n keys for the new commit-history strings and translate them into es/ja/ko/zh. * refactor: extract commit-history actions into useGitHistoryCommitActions hook Moves the commit load/open/context-menu action callbacks (and the per-commit compare cache) out of SourceControl.tsx — which already carries a max-lines disable — into a focused hook, addressing the PR review nitpick. Behavior is unchanged. * Refine git history row rendering, ref deduplication, and OID validation - Prevent deduplication of remote branch badges in the history view when multiple remotes exist or when a ref is explicitly preserved. - Render GitHistoryRow as an accessible button with dynamic ARIA labels for expansion states. - Add double-click handler on commit files to open them permanently. - Validate commit SHAs as full 40-character Git object IDs before requesting remote commit URLs. --------- Co-authored-by: Jinjing <6427696+AmethystLiang@users.noreply.github.com>
54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { dedupeRemoteTrackingRefs } from './git-history-ref-display'
|
|
import type { GitHistoryItemRef } from './git-history-types'
|
|
|
|
function localBranch(name: string): GitHistoryItemRef {
|
|
return { id: `refs/heads/${name}`, name, category: 'branches' }
|
|
}
|
|
|
|
function remoteBranch(name: string): GitHistoryItemRef {
|
|
return { id: `refs/remotes/${name}`, name, category: 'remote branches' }
|
|
}
|
|
|
|
describe('dedupeRemoteTrackingRefs', () => {
|
|
it('drops a remote-tracking ref when the matching local branch is present', () => {
|
|
const refs = [localBranch('feature'), remoteBranch('origin/feature')]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual([localBranch('feature')])
|
|
})
|
|
|
|
it('keeps slash-containing remote refs because the remote name is ambiguous', () => {
|
|
const refs = [localBranch('bar/main'), remoteBranch('foo/bar/main')]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual(refs)
|
|
})
|
|
|
|
it('keeps a remote-tracking ref with no matching local branch', () => {
|
|
const refs = [localBranch('main'), remoteBranch('origin/release')]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual(refs)
|
|
})
|
|
|
|
it('keeps matching remote refs when multiple remotes point to the same branch name', () => {
|
|
const refs = [localBranch('main'), remoteBranch('origin/main'), remoteBranch('upstream/main')]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual(refs)
|
|
})
|
|
|
|
it('keeps a matching remote ref when the caller marks it as preserved context', () => {
|
|
const refs = [localBranch('main'), remoteBranch('origin/main')]
|
|
expect(
|
|
dedupeRemoteTrackingRefs(refs, { preserveRefIds: ['refs/remotes/origin/main'] })
|
|
).toEqual(refs)
|
|
})
|
|
|
|
it('keeps tags and non-remote refs untouched', () => {
|
|
const refs: GitHistoryItemRef[] = [
|
|
localBranch('main'),
|
|
{ id: 'refs/tags/v1', name: 'v1', category: 'tags' }
|
|
]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual(refs)
|
|
})
|
|
|
|
it('returns all refs when there are no local branches', () => {
|
|
const refs = [remoteBranch('origin/main')]
|
|
expect(dedupeRemoteTrackingRefs(refs)).toEqual(refs)
|
|
})
|
|
})
|