mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* fix(source-control): keep huge change sets responsive * Fix cancellation and retry handling for capped status * Harden capped status for conflict-heavy repositories * Harden capped status recovery and cancellation * fix(source-control): preserve capped status correctness * fix(source-control): translate submodule status at render time --------- Co-authored-by: Brennan Benson <79079362+brennanb2025@users.noreply.github.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
// Why: git status is capped at this many changed-file entries. A repo with an
|
|
// enormous un-ignored folder can otherwise freeze the renderer while it builds
|
|
// the source-control projections. When the cap is hit the view shows a "too many
|
|
// changes" state instead of the full list. Shared so native, WSL, SSH, and the
|
|
// renderer agree on the same responsive threshold.
|
|
export const DEFAULT_GIT_STATUS_LIMIT = 1_000
|
|
|
|
export function resolveGitStatusLimit(value: unknown): number {
|
|
return typeof value === 'number' && Number.isInteger(value) && value >= 0
|
|
? value
|
|
: DEFAULT_GIT_STATUS_LIMIT
|
|
}
|
|
|
|
export function capGitStatusEntries<T>(
|
|
entries: T[],
|
|
limit: number,
|
|
previous: { didHitLimit?: boolean; statusLength?: number } = {}
|
|
): { entries: T[]; didHitLimit?: true; statusLength?: number } {
|
|
const exceededLimit = limit > 0 && entries.length > limit
|
|
if (!exceededLimit && previous.didHitLimit !== true) {
|
|
return { entries }
|
|
}
|
|
return {
|
|
entries: exceededLimit ? entries.slice(0, limit) : entries,
|
|
didHitLimit: true,
|
|
statusLength: Math.max(previous.statusLength ?? 0, entries.length)
|
|
}
|
|
}
|