Skill update round trip / roundtrip (false, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, ubuntu-latest, symlink, latest) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (false, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, macos-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, ubuntu-latest, symlink, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, copy, 1.5.17) (push) Canceled after 0s
Skill update round trip / roundtrip (true, windows-latest, symlink, 1.5.17) (push) Canceled after 0s
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import type { CrashReportStore } from '../crash-reporting/crash-report-store'
|
|
|
|
export const inFlightSubmissions = new Set<string>()
|
|
export const submittedReportIds = new Set<string>()
|
|
|
|
const MAX_SUBMITTED_REPORT_IDS = 256
|
|
|
|
export function rememberSubmittedReportId(reportId: string): void {
|
|
// Why: report ids are IPC input. Keep duplicate-send suppression useful for
|
|
// recent reports without retaining every id a broken renderer can vary.
|
|
submittedReportIds.delete(reportId)
|
|
submittedReportIds.add(reportId)
|
|
while (submittedReportIds.size > MAX_SUBMITTED_REPORT_IDS) {
|
|
const oldestId = submittedReportIds.keys().next().value
|
|
if (oldestId === undefined) {
|
|
break
|
|
}
|
|
submittedReportIds.delete(oldestId)
|
|
}
|
|
}
|
|
|
|
export async function getLatestPendingReport(
|
|
store: CrashReportStore
|
|
): Promise<Awaited<ReturnType<CrashReportStore['getLatestPending']>>> {
|
|
const reports = await store.listRecent()
|
|
return (
|
|
reports.find((report) => report.status === 'pending' && !submittedReportIds.has(report.id)) ??
|
|
null
|
|
)
|
|
}
|
|
|
|
export async function getLatestSendableReport(
|
|
store: CrashReportStore
|
|
): Promise<Awaited<ReturnType<CrashReportStore['getLatestPending']>>> {
|
|
const reports = await store.listRecent()
|
|
return (
|
|
reports.find(
|
|
(report) =>
|
|
(report.status === 'pending' || report.status === 'dismissed') &&
|
|
!submittedReportIds.has(report.id)
|
|
) ?? null
|
|
)
|
|
}
|
|
|
|
export async function getRequestedCrashReport(
|
|
store: CrashReportStore,
|
|
args?: { reportId?: string }
|
|
): Promise<Awaited<ReturnType<CrashReportStore['getLatestPending']>>> {
|
|
if (args?.reportId) {
|
|
return store.getById(args.reportId)
|
|
}
|
|
// Why: Help > Report Crash can intentionally submit without a report ID.
|
|
// Do not replace that uncaptured report with a pending crash that appears later.
|
|
return args ? null : getLatestPendingReport(store)
|
|
}
|