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:
Neil
2026-08-12 23:32:36 -07:00
co-authored by Orca
parent 66c10851c1
commit a08577eba6
2 changed files with 13 additions and 7 deletions
@@ -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) {
+9 -3
View File
@@ -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 []
}