mirror of
https://github.com/stablyai/orca.git
synced 2026-09-28 08:02:43 +00:00
Add richer in-app feedback dialog (#468)
* Add richer feedback dialog * Keep anonymous submission client-side only * Use lowercase feedback API host * Fallback feedback submission when api host is unavailable
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
/* eslint-disable max-lines -- Why: co-locating all GitHub client functions keeps the
|
||||
concurrency acquire/release pattern and error handling consistent across operations. */
|
||||
import type { PRInfo, PRMergeableState, PRCheckDetail, PRComment } from '../../shared/types'
|
||||
import type {
|
||||
PRInfo,
|
||||
PRMergeableState,
|
||||
PRCheckDetail,
|
||||
PRComment,
|
||||
GitHubViewer
|
||||
} from '../../shared/types'
|
||||
import { getPRConflictSummary } from './conflict-summary'
|
||||
import { execFileAsync, ghExecFileAsync, acquire, release, getOwnerRepo } from './gh-utils'
|
||||
export { _resetOwnerRepoCache } from './gh-utils'
|
||||
@@ -55,6 +61,33 @@ export async function starOrca(): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the authenticated GitHub viewer when gh is available and logged in.
|
||||
* Returns null when gh is unavailable, unauthenticated, or the lookup fails.
|
||||
*/
|
||||
export async function getAuthenticatedViewer(): Promise<GitHubViewer | null> {
|
||||
await acquire()
|
||||
try {
|
||||
const { stdout } = await execFileAsync(
|
||||
'gh',
|
||||
['api', 'user', '--jq', '{login: .login, email: .email}'],
|
||||
{ encoding: 'utf-8' }
|
||||
)
|
||||
const viewer = JSON.parse(stdout) as { login?: string; email?: string | null }
|
||||
if (!viewer.login?.trim()) {
|
||||
return null
|
||||
}
|
||||
return {
|
||||
login: viewer.login.trim(),
|
||||
email: viewer.email?.trim() || null
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
} finally {
|
||||
release()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PR info for a given branch using gh CLI.
|
||||
* Returns null if gh is not installed, or no PR exists for the branch.
|
||||
|
||||
Reference in New Issue
Block a user