mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
Use one token-based task search implementation on desktop and mobile. Preserve explicit issue/PR qualifiers, distinguish quoted search text, and follow shared reexports in mounted mobile recordings. Refs #10950 and #11121. Co-authored-by: MumuTW <42820974+MumuTW@users.noreply.github.com>
50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
import { getTaskPresetQuery } from './task-preset-query'
|
|
import { hasExplicitTaskScope, parseTaskQuery } from './task-query'
|
|
import type { TaskViewPresetId } from './ui-chrome-types'
|
|
export type GitHubTaskKind = 'issues' | 'prs'
|
|
|
|
export function isPRFocusedTaskView(preset: TaskViewPresetId | null, query: string): boolean {
|
|
const parsed = parseTaskQuery(query)
|
|
if (parsed.scope === 'issue') {
|
|
return false
|
|
}
|
|
if (preset === 'prs' || preset === 'my-prs' || preset === 'review') {
|
|
return true
|
|
}
|
|
return (
|
|
parsed.scope === 'pr' ||
|
|
parsed.state === 'merged' ||
|
|
parsed.draft ||
|
|
parsed.reviewRequested !== null ||
|
|
parsed.reviewedBy !== null
|
|
)
|
|
}
|
|
|
|
export function normalizeGitHubTaskPreset(
|
|
preset: TaskViewPresetId | null | undefined
|
|
): TaskViewPresetId {
|
|
// Why: the split Issues/PRs tabs dropped the mixed "All" view, so legacy saved defaults land on the first tab instead of mixing rows.
|
|
return !preset || preset === 'all' ? 'issues' : preset
|
|
}
|
|
|
|
export function getGitHubTaskKind(preset: TaskViewPresetId | null, query: string): GitHubTaskKind {
|
|
return isPRFocusedTaskView(preset, query) ? 'prs' : 'issues'
|
|
}
|
|
|
|
export function getDefaultPresetForGitHubTaskKind(kind: GitHubTaskKind): TaskViewPresetId {
|
|
return kind === 'prs' ? 'prs' : 'issues'
|
|
}
|
|
|
|
export function scopeGitHubTaskSearch(query: string, kind: GitHubTaskKind): string {
|
|
const trimmed = query.trim()
|
|
if (!trimmed) {
|
|
return getTaskPresetQuery(getDefaultPresetForGitHubTaskKind(kind))
|
|
}
|
|
if (hasExplicitTaskScope(trimmed)) {
|
|
return trimmed
|
|
}
|
|
const parsed = parseTaskQuery(trimmed)
|
|
const inferredKind = parsed.scope === 'pr' ? 'prs' : parsed.scope === 'issue' ? 'issues' : kind
|
|
return `${inferredKind === 'prs' ? 'is:pr' : 'is:issue'} ${trimmed}`
|
|
}
|