Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(ok): let a crash reach the user and its dump reach the report (PRD-7884 PRD-7836) (#3376)

Andrew Mikofalvye84b225e3629
diff --git a/.changeset/crash-signal-reaches-the-user.md b/.changeset/crash-signal-reaches-the-user.md
new file mode 100644
index 000000000..c8fcee9a5
--- /dev/null
+++ b/.changeset/crash-signal-reaches-the-user.md
@@ -0,0 +1,7 @@
+---
+"@inkeep/open-knowledge": patch
+---
+
+A crash you were never told about no longer stays that way. Previously a single unanswered crash prompt muted every later crash for the rest of the session — one report arrived from a window that had blinked and reloaded twice in 52 minutes with no explanation, because the second crash was silenced by a prompt from the first that nobody had answered. An unanswered invitation now only mutes crashes that belong to the same incident; a later, independent crash supersedes it and asks you about the crash that just happened. The handover is logged, so a silence is legible after the fact instead of looking like nothing occurred.
+
+Reporting a bug yourself now offers the crash dump the app is already holding. The opt-in used to appear only when a crash prompt opened the dialog for you, so the report filed moments after an unprompted crash — the one most likely to carry the answer — shipped without the dump sitting on disk the whole time. The row now appears whenever there is a dump to attach, left unchecked so the unredactable memory rides along only if you choose it.
diff --git a/packages/app/src/components/ReportBugCrashInviteTrigger.dom.test.tsx b/packages/app/src/components/ReportBugCrashInviteTrigger.dom.test.tsx
index 210ea2c7e..1d82c1b2b 100644
--- a/packages/app/src/components/ReportBugCrashInviteTrigger.dom.test.tsx
+++ b/packages/app/src/components/ReportBugCrashInviteTrigger.dom.test.tsx
@@ -136,6 +136,50 @@ describe('ReportBugCrashInviteTrigger', () => {
);
});
+ test('a superseding crash restarts the dialog instead of reusing the previous crash state', async () => {
+ // Main supersedes an invitation the user left unanswered, so a second
+ // event can land while this dialog is still on screen. Reconciling in
+ // place would carry the first crash's mount-time state onto the second and
+ // ship one crash's account stamped with the other's id.
+ const stub = makeCrashBridge();
+ uninstall = crashInviteStore.install({ bridge: stub.bridge });
+ render(<ReportBugCrashInviteTrigger bridge={stub.bridge} />);
+
+ stub.fire(INVITE);
+ await waitFor(
+ () => {
+ expect(screen.queryByRole('dialog')).not.toBeNull();
+ },
+ { timeout: ASYNC_TIMEOUT_MS },
+ );
+ // The first crash left no dump, so it offers no opt-in.
+ expect(screen.queryByRole('checkbox', { name: 'Crash dump' })).toBeNull();
+ const noteBox = screen.getByRole('textbox', { name: /what were you doing/i });
+ await userEvent.type(noteBox, 'I was editing a spec when the window blinked');
+
+ stub.fire({
+ eventId: 'crash:render:1751871900000:0',
+ kind: 'render-process-gone',
+ context: { reason: 'crashed', exitCode: 5 },
+ minidumpAvailable: true,
+ });
+
+ // Re-defaulted for the new crash: the note is gone rather than being
+ // re-attributed, and the dump opt-in reflects THIS event, checked per the
+ // invite contract rather than stuck on the dump-less predecessor.
+ await waitFor(
+ () => {
+ expect(
+ screen.getByRole('checkbox', { name: 'Crash dump' }).getAttribute('data-state'),
+ ).toBe('checked');
+ },
+ { timeout: ASYNC_TIMEOUT_MS },
+ );
+ expect(
+ (screen.getByRole('textbox', { name: /what were you doing/i }) as HTMLTextAreaElement).value,
+ ).toBe('');
+ });
+
test('Not now acks the crash event and closes the invitation', async () => {
const stub = makeCrashBridge();
uninstall = crashInviteStore.install({ bridge: stub.bridge });
diff --git a/packages/app/src/components/ReportBugCrashInviteTrigger.tsx b/packages/app/src/components/ReportBugCrashInviteTrigger.tsx
index 6f83a67a7..4bf47ddd2 100644
--- a/packages/app/src/components/ReportBugCrashInviteTrigger.tsx
+++ b/packages/app/src/components/ReportBugCrashInviteTrigger.tsx
@@ -27,6 +27,17 @@ export function ReportBugCrashInviteTrigger({ bridge }: { bridge: OkDesktopBridg
return (
<ReportBugDialog
+ // Remount per crash. Main supersedes an invitation the user left
+ // unanswered, so a second event can now replace this one while the
+ // dialog is still on screen. Reconciling in place would keep the
+ // mount-time state of the previous crash (the dump opt-in, the note the
+ // user typed, the phase) while the note's context lines recompute from
+ // the new event, shipping one crash's account stamped with the other's
+ // id. A report that misattributes its own crash is the failure this
+ // whole change exists to end, so the dialog restarts for the new event.
+ // A bundle already created for the previous crash is not lost: it is
+ // persisted to the report history by `onReportGenerated`.
+ key={invite.eventId}
open
onOpenChange={(open) => {
if (open) return;
diff --git a/packages/app/src/components/ReportBugDialog.dom.test.tsx b/packages/app/src/components/ReportBugDialog.dom.test.tsx
index 207b1fcf1..9eb52ba1f 100644
--- a/packages/app/src/components/ReportBugDialog.dom.test.tsx
+++ b/packages/app/src/components/ReportBugDialog.dom.test.tsx
@@ -91,6 +91,7 @@ interface BridgeLog {
opened: string[];
clipboard: string[];
screenshotCalls: number;
+ crashDumpAvailabilityCalls: number;
}
function installBridge(
@@ -99,6 +100,8 @@ function installBridge(
send?: (request: SendRequest) => Promise<OkBugReportSendResult>;
/** Omit to model a build without capture (the gate reveals with no screenshot). */
captureScreenshot?: () => Promise<OkBugReportScreenshot | null>;
+ /** Omit to model a build predating the probe, which offers no dump row. */
+ crashDumpAvailability?: () => Promise<{ available: boolean }>;
} = {},
): BridgeLog {
const log: BridgeLog = {
@@ -108,6 +111,7 @@ function installBridge(
opened: [],
clipboard: [],
screenshotCalls: 0,
+ crashDumpAvailabilityCalls: 0,
};
const bridge = {
bugReport: {
@@ -131,6 +135,14 @@ function installBridge(
},
}
: {}),
+ ...(handlers.crashDumpAvailability
+ ? {
+ crashDumpAvailability: () => {
+ log.crashDumpAvailabilityCalls += 1;
+ return handlers.crashDumpAvailability?.() ?? Promise.resolve({ available: false });
+ },
+ }
+ : {}),
},
shell: {
showItemInFolder: (path: string) => {
@@ -685,7 +697,7 @@ describe('ReportBugDialog', () => {
expect(log.createCalls[0]?.note).not.toContain('Crashed app version');
});
- test('the plain compose never renders the crash-dump opt-in and never sends the flag', async () => {
+ test('a plain compose with no dump on hand renders no crash-dump opt-in and sends no flag', async () => {
const log = installBridge();
await renderDialog();
@@ -695,6 +707,85 @@ describe('ReportBugDialog', () => {
expect(log.createCalls).toEqual([{ level: 'standard' }]);
});
+ test('a manually-opened report offers the dump main is holding, default unchecked', async () => {
+ // The report a user files right after a crash they were never prompted
+ // about is the one most likely to carry the decisive artifact — and it is
+ // exactly the report that used to withhold it.
+ const log = installBridge({
+ crashDumpAvailability: () => Promise.resolve({ available: true }),
+ });
+ await renderDialog();
+
+ const dumpBox = screen.getByRole('checkbox', { name: 'Crash dump' });
+ // Unchecked: nothing about this open says the user is reporting that crash,
+ // so unredactable process memory rides along only on an explicit choice.
+ expect(dumpBox.getAttribute('data-state')).toBe('unchecked');
+
+ await userEvent.click(dumpBox);
+ await createReport();
+ expect(log.createCalls[0]?.includeCrashDump).toBe(true);
+ });
+
+ test('a manually-opened report left untouched declines the dump rather than omitting the flag', async () => {
+ const log = installBridge({
+ crashDumpAvailability: () => Promise.resolve({ available: true }),
+ });
+ await renderDialog();
+
+ await screen.findByRole('checkbox', { name: 'Crash dump' });
+ await createReport();
+
+ // `false`, not absent: the row was shown and the user left it off, which is
+ // a decision main records as `declined` — absent would read as never-offered.
+ expect(log.createCalls[0]?.includeCrashDump).toBe(false);
+ });
+
+ test('a manually-opened report offers nothing when main holds no dump', async () => {
+ const log = installBridge({
+ crashDumpAvailability: () => Promise.resolve({ available: false }),
+ });
+ await renderDialog();
+
+ expect(screen.queryByRole('checkbox', { name: 'Crash dump' })).toBeNull();
+
+ await createReport();
+ expect(log.createCalls[0]).not.toHaveProperty('includeCrashDump');
+ });
+
+ test('offering a dump drops the blanket redaction reassurance', async () => {
+ // "Secrets are redacted automatically" directly above a row whose own hint
+ // says the dump cannot be redacted is a contradiction the reader has to
+ // resolve; the reassurance is suppressed wherever a dump is on offer.
+ installBridge({ crashDumpAvailability: () => Promise.resolve({ available: true }) });
+ await renderDialog();
+
+ await screen.findByRole('checkbox', { name: 'Crash dump' });
+ expect(
+ screen.queryByText('Secrets like API keys and tokens are redacted automatically.'),
+ ).toBeNull();
+ });
+
+ test('with no dump on offer the plain compose keeps its redaction reassurance', async () => {
+ installBridge({ crashDumpAvailability: () => Promise.resolve({ available: false }) });
+ await renderDialog();
+
+ expect(
+ screen.getByText('Secrets like API keys and tokens are redacted automatically.'),
+ ).not.toBeNull();
+ });
+
+ test('a crash invite reads availability off its own event, not the probe', async () => {
+ // The event already carries main's answer for the dump that crash left, and
+ // the invite opens unprompted — a second round-trip would only delay it.
+ const log = installBridge({
+ crashDumpAvailability: () => Promise.resolve({ available: false }),
+ });
+ await renderDialog({ crashInvite: BOOT_INVITE });
+
+ expect(screen.getByRole('checkbox', { name: 'Crash dump' })).not.toBeNull();
+ expect(log.crashDumpAvailabilityCalls).toBe(0);
+ });
+
test('the review card qualifies the redaction claim when a raw crash dump is bundled', async () => {
installBridge({
create: () =>
diff --git a/packages/app/src/components/ReportBugDialog.tsx b/packages/app/src/components/ReportBugDialog.tsx
index 4f1954d8c..5f2c73a6a 100644
--- a/packages/app/src/components/ReportBugDialog.tsx
+++ b/packages/app/src/components/ReportBugDialog.tsx
@@ -57,6 +57,10 @@ export function ReportBugDialog(props: ReportBugDialogProps) {
// dialog paints over the app; `screenshot` is the captured preview (or null).
const [ready, setReady] = useState(false);
const [screenshot, setScreenshot] = useState<OkBugReportScreenshot | null>(null);
+ // Whether main is holding a crash dump this report could carry. Only asked
+ // for a report the user opened themselves — a crash invite already carries
+ // main's answer for its own crash on the event.
+ const [crashDumpAvailable, setCrashDumpAvailable] = useState(false);
// Bumped on every open transition (and on close/unmount cleanup) so a capture
// that resolves after its open cycle ended drops its result.
const openCycleRef = useRef(0);
@@ -71,6 +75,25 @@ export function ReportBugDialog(props: ReportBugDialogProps) {
return;
}
const cycle = ++openCycleRef.current;
+ setCrashDumpAvailable(false);
+ // Probed alongside the capture rather than gating the reveal on it: the
+ // lookup walks the crash-dumps dir and parses dump headers, and a slow or
+ // stuck disk must cost the row, never the dialog. The row defaults
+ // unchecked, so arriving a beat late only adds an option.
+ const availability = window.okDesktop?.bugReport?.crashDumpAvailability;
+ if (props.crashInvite === undefined && typeof availability === 'function') {
+ availability()
+ .then((result) => {
+ if (openCycleRef.current !== cycle) return;
+ setCrashDumpAvailable(result.available);
+ })
+ .catch((err: unknown) => {
+ // Nothing to offer if main could not answer, but leave a breadcrumb:
+ // a probe that keeps failing presents as "no dump on disk", which is
+ // the exact symptom this row exists to end.
+ console.warn('[bug-report] crash-dump availability probe failed:', err);
+ });
+ }
const capture = window.okDesktop?.bugReport?.captureScreenshot;
// Skip the capture-before-show for the crash invite: it opens itself,
// unprompted, the moment main pushes a crash-detected event, so holding it
@@ -129,7 +152,12 @@ export function ReportBugDialog(props: ReportBugDialogProps) {
}
return (
<Suspense fallback={null}>
- <ReportBugDialogBody {...props} open={props.open && ready} screenshot={screenshot} />
+ <ReportBugDialogBody
+ {...props}
+ open={props.open && ready}
+ screenshot={screenshot}
+ crashDumpAvailable={crashDumpAvailable}
+ />
</Suspense>
);
}
diff --git a/packages/app/src/components/ReportBugDialogBody.tsx b/packages/app/src/components/ReportBugDialogBody.tsx
index 419b328b8..6df03ef73 100644
--- a/packages/app/src/components/ReportBugDialogBody.tsx
+++ b/packages/app/src/components/ReportBugDialogBody.tsx
@@ -255,6 +255,12 @@ export interface ReportBugDialogProps {
* threading it through each mount site.
*/
screenshot?: OkBugReportScreenshot | null;
+ /**
+ * Whether main is holding a crash dump this report could carry, as probed by
+ * the gate for a report the user opened themselves. Ignored under
+ * `crashInvite`, which carries main's answer for its own crash on the event.
+ */
+ crashDumpAvailable?: boolean;
}
function ReportBugDialog({
@@ -264,21 +270,26 @@ function ReportBugDialog({
crashContext,
crashInvite,
screenshot = null,
+ crashDumpAvailable: probedCrashDumpAvailable = false,
}: ReportBugDialogProps) {
const { t } = useLingui();
const [phase, setPhase] = useState<Phase>(COMPOSE_IDLE);
const [note, setNote] = useState('');
const [detailed, setDetailed] = useState(crashContext !== undefined || crashInvite !== undefined);
// The crash-dump opt-in only exists when main confirmed a minidump is on
- // disk for this event; a dump-less invite (e.g. a dirty shutdown that left
- // no native crash) offers no dead checkbox.
- const crashDumpAvailable = crashInvite?.minidumpAvailable === true;
- // Default ON when a dump is available: the crash is the whole reason for the
- // report, and its minidump is the artifact triage most needs. Consent is
- // preserved without a silent send — the row stays visible and uncheckable,
- // its hint states the memory is unredactable, and the review step flags
- // "crash dump not redacted" before the user sends.
- const [includeDump, setIncludeDump] = useState(crashDumpAvailable);
+ // disk; a dump-less invite (e.g. a dirty shutdown that left no native crash)
+ // offers no dead checkbox. An invite answers for its own crash off the event;
+ // a report the user opened themselves takes the gate's probe, so a crash that
+ // never prompted still gets its dump into the report filed about it.
+ const crashDumpAvailable =
+ crashInvite !== undefined ? crashInvite.minidumpAvailable === true : probedCrashDumpAvailable;
+ // Default ON only for an invite: the crash is the whole reason for that
+ // report, and its minidump is the artifact triage most needs. A manual report
+ // is about whatever the user came to say, so unredactable process memory
+ // rides along only on an explicit check. Either way consent is preserved
+ // without a silent send — the row states the memory is unredactable and the
+ // review step flags "crash dump not redacted" before the user sends.
+ const [includeDump, setIncludeDump] = useState(crashInvite?.minidumpAvailable === true);
// Default-on per the spec: when a screenshot was captured it rides along
// unless the user unchecks it. Only ever sent to `create` when one exists.
const [includeScreenshot, setIncludeScreenshot] = useState(true);
@@ -333,7 +344,7 @@ function ReportBugDialog({
if (phase.step === 'success' || phase.step === 'email' || phase.step === 'failure') {
setNote('');
setDetailed(crashContext !== undefined || crashInvite !== undefined);
- setIncludeDump(crashDumpAvailable);
+ setIncludeDump(crashInvite?.minidumpAvailable === true);
// Re-default the screenshot to on so the next open (which captures a
// fresh screenshot) starts checked, matching the compose default.
setIncludeScreenshot(true);
@@ -527,13 +538,16 @@ function ReportBugDialog({
<p id={whatToIncludeId} className="text-sm font-medium">
<Trans>What to include</Trans>
</p>
- {/* The crash-invite variant offers a non-redactable crash
- dump, so the blanket "secrets are redacted" reassurance
- would read oddly here — its banner already carries the
- "nothing is sent until you review it" line. crashContext
+ {/* Suppressed on two independent grounds. An invite's banner
+ already carries the "nothing is sent until you review it"
+ line; and wherever a crash dump is on offer the blanket
+ "secrets are redacted" claim would sit directly above a
+ row whose own hint says that dump cannot be redacted. The
+ second test is what covers a manual or crashContext report
+ that the availability probe found a dump for. crashContext
and crashInvite never co-occur, so this also gates the
error-details note. */}
- {crashInvite === undefined && (
+ {crashInvite === undefined && !crashDumpAvailable && (
<p className="text-1sm text-muted-foreground">
{crashContext !== undefined ? (
<Trans>
diff --git a/packages/app/src/lib/crash-invite-store.ts b/packages/app/src/lib/crash-invite-store.ts
index de242902d..3722f5c5b 100644
--- a/packages/app/src/lib/crash-invite-store.ts
+++ b/packages/app/src/lib/crash-invite-store.ts
@@ -57,6 +57,11 @@ export function createCrashInviteStore(): CrashInviteStore {
attached = true;
unsubscribeFromBridge = onCrashDetected((event) => {
// Main arms at most one invitation at a time, so last-wins is exact.
+ // It does NOT mean the previous invitation was answered: main
+ // supersedes one the user left unanswered, so this can replace an
+ // event whose dialog is still open. The trigger keys the dialog on
+ // `eventId` so that swap remounts rather than reconciling stale
+ // mount-time state onto the new crash.
current = event;
notify();
});
diff --git a/packages/app/tests/stress/fixtures/handoff-mocks.ts b/packages/app/tests/stress/fixtures/handoff-mocks.ts
index 7f83557ef..adbfcb6f8 100644
--- a/packages/app/tests/stress/fixtures/handoff-mocks.ts
+++ b/packages/app/tests/stress/fixtures/handoff-mocks.ts
@@ -472,6 +472,7 @@ export async function installHandoffMocks(page: Page, cfg: HandoffMockConfig): P
bugReport: {
create: async () => ({ ok: false as const, error: 'test mock' }),
captureScreenshot: async () => null,
+ crashDumpAvailability: async () => ({ available: false }),
send: async () => ({
ok: false as const,
reason: 'send-failed' as const,
diff --git a/packages/core/src/desktop-bridge.ts b/packages/core/src/desktop-bridge.ts
index 39d0b5d90..e267ecc42 100644
--- a/packages/core/src/desktop-bridge.ts
+++ b/packages/core/src/desktop-bridge.ts
@@ -22,6 +22,7 @@ import type { LanguagePreference } from './i18n/locales.ts';
import type {
OkBugReportCrashAckResult,
OkBugReportCrashDetectedEvent,
+ OkBugReportCrashDumpAvailability,
OkBugReportCreateResult,
OkBugReportDeleteResult,
OkBugReportListResult,
@@ -1579,6 +1580,12 @@ export interface OkDesktopBridge {
includeScreenshot?: boolean;
}): Promise<OkBugReportCreateResult>;
captureScreenshot(): Promise<OkBugReportScreenshot | null>;
+ /**
+ * Whether main is holding a crash dump this report could carry. Only a
+ * report the user opened themselves needs to ask — a crash invitation
+ * already carries the answer on its event.
+ */
+ crashDumpAvailability(): Promise<OkBugReportCrashDumpAvailability>;
send(request: OkBugReportSendInput): Promise<OkBugReportSendResult>;
crashAck(request: { eventId: string }): Promise<OkBugReportCrashAckResult>;
list(): Promise<OkBugReportListResult>;
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index fac8b80c2..8051bff96 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -43,6 +43,7 @@ export type {
LogPayload,
OkBugReportCrashAckResult,
OkBugReportCrashDetectedEvent,
+ OkBugReportCrashDumpAvailability,
OkBugReportCreateResult,
OkBugReportDeleteResult,
OkBugReportListResult,
diff --git a/packages/core/src/logger-types.ts b/packages/core/src/logger-types.ts
index 7b2a01470..fd5752562 100644
--- a/packages/core/src/logger-types.ts
+++ b/packages/core/src/logger-types.ts
@@ -219,6 +219,17 @@ export type OkBugReportCrashDetectedEvent =
*/
export type OkBugReportCrashAckResult = { ok: true } | { ok: false; error: string };
+/**
+ * Whether main is holding a crash dump a report opened right now could carry.
+ *
+ * Deliberately a bare boolean: which dump, when it was written, and how big it
+ * is are all per-crash identifiers, and the renderer only needs to decide
+ * whether to render the opt-in.
+ */
+export interface OkBugReportCrashDumpAvailability {
+ available: boolean;
+}
+
/**
* One row in the persisted bug-report history, projected from a report sidecar
* plus main-derived facts. `state` is the OPEN sidecar state (`'unknown'` for a
diff --git a/packages/desktop/src/main/crash-detection.test.ts b/packages/desktop/src/main/crash-detection.test.ts
index b14bc22c7..94d2dbe7c 100644
--- a/packages/desktop/src/main/crash-detection.test.ts
+++ b/packages/desktop/src/main/crash-detection.test.ts
@@ -268,6 +268,53 @@ describe('runtime process-gone invitations', () => {
detection.notifyRendererReady();
expect(rig.emitted).toHaveLength(1);
});
+
+ test('a crash an hour after an unanswered invitation supersedes it instead of staying silent', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ expect(rig.emitted).toHaveLength(1);
+ const first = rig.emitted[0];
+ if (!first) throw new Error('expected a first invitation');
+
+ // Nobody answers the first prompt. An hour later an independent crash
+ // fires — the user has to hear about that one, or the app recovers in
+ // silence and the only evidence is a window that blinked.
+ rig.advance(60 * 60_000);
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+
+ expect(rig.emitted).toHaveLength(2);
+ expect(rig.emitted[1]?.eventId).not.toBe(first.eventId);
+ });
+
+ test('a crash inside the relatedness window still dedupes against the pending invitation', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ // A crashloop's repeats belong to the incident the user was already asked
+ // about; stacking a second prompt on them is the noise the guard prevents.
+ rig.advance(30_000);
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+
+ expect(rig.emitted).toHaveLength(1);
+ });
+
+ test('a superseded invitation is logged so the silence is legible after the fact', () => {
+ const rig = makeRig();
+ const detection = createCrashDetection(rig.deps);
+
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+ const first = rig.emitted[0];
+ if (!first) throw new Error('expected a first invitation');
+ rig.advance(60 * 60_000);
+ detection.handleRenderProcessGone({ reason: 'crashed' });
+
+ const superseded = rig.warnings.find((w) => w.event === 'crash-detection.superseded');
+ expect(superseded).toBeDefined();
+ expect(superseded?.supersededEventId).toBe(first.eventId);
+ });
});
/**
diff --git a/packages/desktop/src/main/crash-detection.ts b/packages/desktop/src/main/crash-detection.ts
index 89aac27b0..5acb7ffac 100644
--- a/packages/desktop/src/main/crash-detection.ts
+++ b/packages/desktop/src/main/crash-detection.ts
@@ -101,6 +101,16 @@ const GPU_CRASH_INVITE_THRESHOLD = 3;
*/
const GPU_CRASH_WINDOW_MS = 5 * 60_000;
+/**
+ * How long a pending invitation keeps a later crash silent. The single-slot
+ * guard exists to stop one incident stacking prompts, so its reach has to end
+ * where the incident does — the same relatedness horizon `GPU_CRASH_WINDOW_MS`
+ * draws, for the same reason. Beyond it an unanswered invitation is not
+ * "the prompt already on screen" but a prompt the user walked away from, and
+ * letting it mute an independent crash means the app recovers in silence.
+ */
+const INVITE_SUPERSEDE_AFTER_MS = 5 * 60_000;
+
/**
* Acked ids older than the store's minidump baseline can never fire again,
* so the list only needs to outlive a plausible burst of distinct events.
@@ -347,8 +357,15 @@ function collectMinidumpEntries(dir: string, depth: number, out: MinidumpEntry[]
}
export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
- /** The one invitation in flight; a new signal while this is unacked stays silent. */
- let active: { event: OkBugReportCrashDetectedEvent; delivered: boolean } | null = null;
+ /**
+ * The one invitation in flight; a new signal while this is unacked and still
+ * recent stays silent. `armedAtMs` is what bounds "still recent".
+ */
+ let active: {
+ event: OkBugReportCrashDetectedEvent;
+ delivered: boolean;
+ armedAtMs: number;
+ } | null = null;
let runtimeSeq = 0;
/**
@@ -437,22 +454,41 @@ export function createCrashDetection(deps: CrashDetectionDeps): CrashDetection {
/**
* Arm an invitation without delivering — boot events wait for the first
* renderer-ready signal, runtime events follow up with `tryDeliver`.
- * Returns false when a prior invitation is still unanswered (new signals
- * stay silent rather than stacking prompts).
+ * Returns false when a recent invitation is still unanswered (new signals
+ * stay silent rather than stacking prompts); a pending one that has gone
+ * stale is superseded instead, so the newer crash is the one the user is
+ * asked about rather than being dropped behind a prompt nobody answered.
*/
function armInvite(event: OkBugReportCrashDetectedEvent): boolean {
+ const nowMs = deps.now().getTime();
if (active !== null) {
- deps.logger.info(
+ const pendingAgeMs = nowMs - active.armedAtMs;
+ if (pendingAgeMs < INVITE_SUPERSEDE_AFTER_MS) {
+ deps.logger.info(
+ {
+ event: 'crash-detection.suppressed',
+ eventId: event.eventId,
+ pendingEventId: active.event.eventId,
+ pendingAgeMs,
+ },
+ 'crash invitation already pending — new signal stays silent',
+ );
+ return false;
+ }
+ // Warn, not info: the superseded invitation is one the user never
+ // answered, so this line is the only record that a crash they were
+ // offered a prompt for went unaddressed before the next one arrived.
+ deps.logger.warn(
{
- event: 'crash-detection.suppressed',
+ event: 'crash-detection.superseded',
eventId: event.eventId,
- pendingEventId: active.event.eventId,
+ supersededEventId: active.event.eventId,
+ supersededAgeMs: pendingAgeMs,
},
- 'crash invitation already pending — new signal stays silent',
+ 'stale crash invitation superseded by a newer crash',
);
- return false;
}
- active = { event, delivered: false };
+ active = { event, delivered: false, armedAtMs: nowMs };
return true;
}
diff --git a/packages/desktop/src/main/index.ts b/packages/desktop/src/main/index.ts
index 3417324d9..cf2481e8f 100644
--- a/packages/desktop/src/main/index.ts
+++ b/packages/desktop/src/main/index.ts
@@ -265,6 +265,7 @@ import {
type BugReportScreenshotEntry,
handleBugReportCaptureScreenshot,
handleBugReportCrashAck,
+ handleBugReportCrashDumpAvailability,
handleBugReportCreate,
handleBugReportSend,
resolveBugReportIntakeUrl,
@@ -5405,6 +5406,17 @@ function registerIpcHandlers() {
request,
);
}
+ if (request.kind === 'crash-dump-availability') {
+ return handleBugReportCrashDumpAvailability({
+ newestMinidumpForReport: () =>
+ crashDetection?.newestMinidumpForReport() ?? {
+ path: null,
+ foreignSkipped: 0,
+ unknownSkipped: 0,
+ },
+ logger: getLogger('bug-report'),
+ });
+ }
if (request.kind === 'capture-screenshot') {
// Captured before the report dialog paints (the gate awaits this reply
// before revealing the Radix overlay), so the picture is the app state
diff --git a/packages/desktop/src/main/ipc/bug-report.test.ts b/packages/desktop/src/main/ipc/bug-report.test.ts
index 756337674..585dbab25 100644
--- a/packages/desktop/src/main/ipc/bug-report.test.ts
+++ b/packages/desktop/src/main/ipc/bug-report.test.ts
@@ -48,6 +48,7 @@ import {
DEFAULT_BUG_REPORT_INTAKE_URL,
handleBugReportCaptureScreenshot,
handleBugReportCrashAck,
+ handleBugReportCrashDumpAvailability,
handleBugReportCreate,
handleBugReportSend,
MAX_UPLOAD_ZIP_BYTES,
@@ -2261,6 +2262,70 @@ describe('handleBugReportCrashAck', () => {
});
});
+describe('handleBugReportCrashDumpAvailability', () => {
+ test('reports available when the ownership walk found a dump this app owns', () => {
+ const result = handleBugReportCrashDumpAvailability({
+ newestMinidumpForReport: () => ({
+ path: '/crash-dumps/pending/a44001a4.dmp',
+ foreignSkipped: 0,
+ unknownSkipped: 0,
+ }),
+ });
+
+ expect(result).toEqual({ available: true });
+ });
+
+ test('reports unavailable when the walk rejected everything it found', () => {
+ // Foreign and unreadable dumps are not ours to offer, and the lookup has
+ // already excluded them — a nonzero skip count is not availability.
+ const result = handleBugReportCrashDumpAvailability({
+ newestMinidumpForReport: () => ({ path: null, foreignSkipped: 3, unknownSkipped: 1 }),
+ });
+
+ expect(result).toEqual({ available: false });
+ });
+
+ test('reports unavailable rather than throwing when no lookup is wired', () => {
+ expect(handleBugReportCrashDumpAvailability({})).toEqual({ available: false });
+ });
+
+ test('a lookup that throws loses the option, not the report, and says so', () => {
+ // A walk that keeps throwing is indistinguishable from an empty crash
+ // database at the checkbox, so the failure has to leave a record.
+ const warnings: Record<string, unknown>[] = [];
+ const result = handleBugReportCrashDumpAvailability({
+ newestMinidumpForReport: () => {
+ throw new Error('crash-dumps dir is unreadable');
+ },
+ logger: {
+ info: () => {},
+ warn: (payload: Record<string, unknown>) => {
+ warnings.push(payload);
+ },
+ } as unknown as Parameters<typeof handleBugReportCrashDumpAvailability>[0]['logger'],
+ });
+
+ expect(result).toEqual({ available: false });
+ expect(warnings[0]?.event).toBe('bug-report.crash-dump-availability-failed');
+ });
+
+ test('a logger that throws cannot fail the probe', () => {
+ const result = handleBugReportCrashDumpAvailability({
+ newestMinidumpForReport: () => {
+ throw new Error('crash-dumps dir is unreadable');
+ },
+ logger: {
+ info: () => {},
+ warn: () => {
+ throw new Error('logger is down too');
+ },
+ } as unknown as Parameters<typeof handleBugReportCrashDumpAvailability>[0]['logger'],
+ });
+
+ expect(result).toEqual({ available: false });
+ });
+});
+
describe('bug-report sidecar wiring — create writes the record, send tracks state', () => {
const REPORT_ID = '2026-07-15T18-30-00-000Z-bugreport.zip';
diff --git a/packages/desktop/src/main/ipc/bug-report.ts b/packages/desktop/src/main/ipc/bug-report.ts
index 0c4d3b24b..4c80b77c9 100644
--- a/packages/desktop/src/main/ipc/bug-report.ts
+++ b/packages/desktop/src/main/ipc/bug-report.ts
@@ -31,6 +31,7 @@ import {
BUG_REPORT_SCREENSHOT_ZIP_NAME,
isReportIdShape,
type OkBugReportCrashAckResult,
+ type OkBugReportCrashDumpAvailability,
type OkBugReportCreateResult,
type OkBugReportScreenshot,
type OkBugReportSendMetadata,
@@ -91,12 +92,26 @@ export interface OkBugReportCrashAckRequest {
eventId: string;
}
+/**
+ * Ask main whether it is holding a crash dump this report could carry.
+ *
+ * A crash-detected invitation already answers this on its own event, so only a
+ * report the user opened themselves needs to ask. Without it that report can
+ * never offer the dump — which is precisely the report filed moments after a
+ * crash the user was never prompted about, and so the one where the dump
+ * matters most.
+ */
+interface OkBugReportCrashDumpAvailabilityRequest {
+ kind: 'crash-dump-availability';
+}
+
/** Every operation the `ok:bug-report:dispatch` channel carries. */
export type OkBugReportRequest =
| OkBugReportCreateRequest
| OkBugReportSendRequest
| OkBugReportCrashAckRequest
| OkBugReportCaptureScreenshotRequest
+ | OkBugReportCrashDumpAvailabilityRequest
| OkBugReportListRequest
| OkBugReportDeleteRequest;
@@ -301,14 +316,14 @@ export function resolveMinidumpAttachment(
* swallowed here — the same fail-soft posture as the sidecar write.
*/
function recordMinidumpDecision(
- deps: BugReportCreateDeps,
+ logger: BundleLogger | undefined,
level: 'info' | 'warn',
payload: Record<string, unknown>,
message: string,
): void {
try {
- if (level === 'warn') deps.logger?.warn(payload, message);
- else deps.logger?.info(payload, message);
+ if (level === 'warn') logger?.warn(payload, message);
+ else logger?.info(payload, message);
} catch {
// The logger is the thing that failed; there is nowhere left to report it.
}
@@ -385,7 +400,7 @@ export async function handleBugReportCreate(
// bundle carrying only this line still explains itself; `staging` is the one
// reason left open, and then the bundle's own `extra/` is the answer.
recordMinidumpDecision(
- deps,
+ deps.logger,
'info',
{ ...decisionFacts, phase: 'intent', reason: intent.reason },
'bug-report: crash-dump decision recorded before collection',
@@ -451,7 +466,7 @@ export async function handleBugReportCreate(
if (intent.reason === 'staging') {
const { attached, reason } = resolveMinidumpAttachment(intent, summary.files);
recordMinidumpDecision(
- deps,
+ deps.logger,
attached ? 'info' : 'warn',
{ ...decisionFacts, phase: 'outcome', attached, reason },
attached
@@ -1332,3 +1347,33 @@ export function handleBugReportCrashAck(
deps.ackCrashEvent(request.eventId);
return { ok: true };
}
+
+/**
+ * Answer the `crash-dump-availability` probe for a manually-opened report.
+ *
+ * Runs the same ownership walk `create` would, so a "yes" here means the very
+ * dump a later opt-in will attach — the checkbox cannot appear over a dump
+ * that turns out to be foreign or unreadable. A lookup that is absent (no
+ * crash detection wired) answers "no" rather than throwing: the probe governs
+ * whether an option is offered, and a failure to answer must lose the option,
+ * never the report.
+ */
+export function handleBugReportCrashDumpAvailability(deps: {
+ newestMinidumpForReport?: () => MinidumpReportLookup;
+ logger?: BundleLogger;
+}): OkBugReportCrashDumpAvailability {
+ try {
+ return { available: (deps.newestMinidumpForReport?.() ?? NO_MINIDUMP_LOOKUP).path !== null };
+ } catch (err) {
+ // A walk that keeps throwing presents to the reporter as "no dump on
+ // disk", which is the exact symptom the probe exists to end, so the
+ // failure has to be distinguishable from a genuinely empty crash database.
+ recordMinidumpDecision(
+ deps.logger,
+ 'warn',
+ { event: 'bug-report.crash-dump-availability-failed', err },
+ 'crash-dump availability lookup failed; offering no dump',
+ );
+ return { available: false };
+ }
+}
diff --git a/packages/desktop/src/preload/index.ts b/packages/desktop/src/preload/index.ts
index 767d8e121..db2a50aab 100644
--- a/packages/desktop/src/preload/index.ts
+++ b/packages/desktop/src/preload/index.ts
@@ -23,6 +23,7 @@ import type {
LanguagePreference,
OkBugReportCrashAckResult,
OkBugReportCrashDetectedEvent,
+ OkBugReportCrashDumpAvailability,
OkBugReportCreateResult,
OkBugReportDeleteResult,
OkBugReportListResult,
@@ -554,6 +555,10 @@ const bridge: OkDesktopBridge = {
invoke('ok:bug-report:dispatch', {
kind: 'capture-screenshot',
}) as Promise<OkBugReportScreenshot | null>,
+ crashDumpAvailability: () =>
+ invoke('ok:bug-report:dispatch', {
+ kind: 'crash-dump-availability',
+ }) as Promise<OkBugReportCrashDumpAvailability>,
// Param type derived from the contract, payload spread whole — a hand-copy
// of this shape drops fields with no type error on either half. A param
// type listing fewer fields is a SUPERTYPE of the contract's, so it is
diff --git a/packages/desktop/src/shared/ipc-channels.ts b/packages/desktop/src/shared/ipc-channels.ts
index 9c9f11e30..887322075 100644
--- a/packages/desktop/src/shared/ipc-channels.ts
+++ b/packages/desktop/src/shared/ipc-channels.ts
@@ -92,6 +92,7 @@ import type {
LanguagePreference,
LocalOpOkInitResponse,
OkBugReportCrashAckResult,
+ OkBugReportCrashDumpAvailability,
OkBugReportCreateResult,
OkBugReportDeleteResult,
OkBugReportListResult,
@@ -887,6 +888,9 @@ export interface RequestChannels {
* - `{kind: 'capture-screenshot'}` → capture the sender window before the
* dialog paints; returns a downscaled preview (or `null`) and holds the
* full-res bytes in main for a later `create` to stage.
+ * - `{kind: 'crash-dump-availability'}` → whether main is holding a crash
+ * dump this report could carry, for a report the user opened themselves.
+ * A crash invitation already carries the answer on its event.
* - `{kind: 'list'}` → the persisted report history (newest first), read
* from the per-report sidecars in `~/.ok/bug-reports/`.
* - `{kind: 'delete', id}` → remove a persisted report's zip + sidecar by
@@ -901,6 +905,7 @@ export interface RequestChannels {
| OkBugReportCreateResult
| OkBugReportSendResult
| OkBugReportCrashAckResult
+ | OkBugReportCrashDumpAvailability
| OkBugReportScreenshot
| OkBugReportListResult
| OkBugReportDeleteResult