mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 16:03:26 +00:00
type(github): propagate readonly workItemsCache through TaskPage
Widen fetchWorkItems, inflight promises, and TaskPage cache selectors so CacheEntry<readonly GitHubWorkItem[]> typechecks against consumers. Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -43,7 +43,7 @@ export type TaskPageWorkItemsFetchOptions = {
|
||||
noCache: boolean
|
||||
}
|
||||
|
||||
type WorkItemsCache = Record<string, CacheEntry<GitHubWorkItem[]>>
|
||||
type WorkItemsCache = Record<string, CacheEntry<readonly GitHubWorkItem[]>>
|
||||
export type TaskPageWorkItemPages = readonly (GitHubWorkItem[] | null)[]
|
||||
|
||||
export function deriveTaskPageGitHubWorkItemsFetchOptions(
|
||||
@@ -61,7 +61,7 @@ export function selectTaskPageWorkItemsCacheEntries(
|
||||
repos: readonly TaskPageRepoCacheInput[],
|
||||
limit: number,
|
||||
query: string
|
||||
): (CacheEntry<GitHubWorkItem[]> | undefined)[] {
|
||||
): (CacheEntry<readonly GitHubWorkItem[]> | undefined)[] {
|
||||
return repos.map(
|
||||
(repo) =>
|
||||
workItemsCache[
|
||||
@@ -72,7 +72,7 @@ export function selectTaskPageWorkItemsCacheEntries(
|
||||
|
||||
export function buildTaskPageRepoSourceState(
|
||||
repos: readonly TaskPageRepoCacheInput[],
|
||||
entries: readonly (CacheEntry<GitHubWorkItem[]> | undefined)[]
|
||||
entries: readonly (CacheEntry<readonly GitHubWorkItem[]> | undefined)[]
|
||||
): TaskPageRepoSourceState[] {
|
||||
return repos.map((repo, index) => {
|
||||
const entry = entries[index]
|
||||
@@ -126,7 +126,7 @@ function taskPageWorkItemCacheKey(item: GitHubWorkItem): string {
|
||||
|
||||
export function reconcileTaskPagePagesWithWorkItemsCache(
|
||||
pages: TaskPageWorkItemPages,
|
||||
entries: readonly (CacheEntry<GitHubWorkItem[]> | undefined)[]
|
||||
entries: readonly (CacheEntry<readonly GitHubWorkItem[]> | undefined)[]
|
||||
): (GitHubWorkItem[] | null)[] {
|
||||
const cachedItems = new Map<string, GitHubWorkItem>()
|
||||
for (const entry of entries) {
|
||||
|
||||
@@ -685,7 +685,7 @@ type InflightChecks = {
|
||||
const inflightChecksRequests = new Map<string, InflightChecks>()
|
||||
const inflightCommentsRequests = new Map<string, Promise<PRComment[]>>()
|
||||
type InflightWorkItems = {
|
||||
promise: Promise<GitHubWorkItem[]>
|
||||
promise: Promise<readonly GitHubWorkItem[]>
|
||||
force: boolean
|
||||
noCache: boolean
|
||||
requireComplete: boolean
|
||||
@@ -1974,7 +1974,7 @@ export type GitHubSlice = {
|
||||
limit: number,
|
||||
query: string,
|
||||
options?: FetchOptions
|
||||
) => Promise<GitHubWorkItem[]>
|
||||
) => Promise<readonly GitHubWorkItem[]>
|
||||
/**
|
||||
* Fan out one work-item query across repos; partial failures don't reject — a repo with no cached fallback increments `failedCount`, but one served stale cache on rejection isn't counted.
|
||||
* `githubUnavailable`: every selected GitHub source refresh failed because GitHub was unreachable (5xx/network/rate-limit), even if stale cache remains — lets the caller attribute the stale/empty list.
|
||||
@@ -2658,7 +2658,13 @@ export const createGitHubSlice: StateCreator<AppState, [], [], GitHubSlice> = (s
|
||||
return null
|
||||
},
|
||||
|
||||
fetchWorkItems: async (repoId, repoPath, limit, query, options): Promise<GitHubWorkItem[]> => {
|
||||
fetchWorkItems: async (
|
||||
repoId,
|
||||
repoPath,
|
||||
limit,
|
||||
query,
|
||||
options
|
||||
): Promise<readonly GitHubWorkItem[]> => {
|
||||
if (isGitHubWorkItemsQueryTooLarge(query)) {
|
||||
return []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user