Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Attach pasted images in the bug report dialog (PRD-8653) (#4901)

Andrew Mikofalvy54d324acd0e9
diff --git a/.changeset/bug-report-paste-images.md b/.changeset/bug-report-paste-images.md
new file mode 100644
index 000000000..c0658e84f
--- /dev/null
+++ b/.changeset/bug-report-paste-images.md
@@ -0,0 +1,5 @@
+---
+'@inkeep/open-knowledge': patch
+---
+
+Pasting an image while the Report a bug dialog is open now attaches it, the same as dropping or browsing for one.
diff --git a/docs/content/reference/what-open-knowledge-writes.mdx b/docs/content/reference/what-open-knowledge-writes.mdx
index c73b5fa12..505de2591 100644
--- a/docs/content/reference/what-open-knowledge-writes.mdx
+++ b/docs/content/reference/what-open-knowledge-writes.mdx
@@ -352,7 +352,7 @@ None of your content, by default. Everything above is written to your own disk.
| What | When | Where it goes |
| --- | --- | --- |
| Diagnostic bundle | Only when you run `ok diagnose bundle` (you can inspect it first). On macOS it also carries the crash reports the OS recorded for this app and its helper processes (listed above), which are machine-wide rather than project-scoped; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the summary printed before the zip is written says what that search found even when the answer is nothing | Wherever you send it |
-| In-app bug report | Only when you click **Send** in the desktop app's **Help → Report a bug…** dialog, or the `Cmd+Shift+D` / `Ctrl+Shift+D` shortcut that opens the same dialog — it builds a secret-redacted zip you can reveal and inspect first, and nothing is sent without that explicit click. The zip carries a picture of the app window unless you uncheck **Screenshot** in that dialog, and the preview there is the picture that would be sent. You can also attach up to three images by dragging them into the dialog or browsing for files. Neither these images nor the screenshot are scanned or redacted, so review them before sending. A report reached through a surface you opened only to get to the reporter — the command palette, the Help popover, or the Windows and Linux menu bar — waits for that surface to close first, and carries no marker, because the row it would point at has already gone. Every other report you start yourself photographs the screen as it is, so an open menu or another person's document visible at the time is in the picture, and carries a marker drawn where your pointer was, since a screenshot never includes the cursor. No marker is drawn either if the pointer has not moved since the window loaded, or has since left the window. The invitation that appears on its own after a crash is the exception to all of this: it carries no picture at all. After a crash, the same dialog adds an **off-by-default** "Include crash dump" checkbox: a crash dump is a memory snapshot that can contain document content and can't be redacted, and it is only ever attached when you check that box. On macOS the zip also carries the update helper's install log (listed above), which is machine-wide rather than project-scoped; the zip's own README names it and says where it came from. At the **Detailed diagnostics** level — pre-checked on the invitation that follows a crash — it additionally carries the crash reports macOS itself recorded for this app and its helpers (also listed above), which are machine-wide for the same reason and named in the same README; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the zip always says what that search found even when the answer is nothing. The zip also carries a short send history of the bug reports previously generated on this machine — when each was generated and whether sending it succeeded — which is what makes a report that failed to send diagnosable at all. That history is machine-wide too, so it names the other projects you have filed reports from; it carries no document content, and the README names it the same way | By default, Send makes no network request — it opens a prefilled email draft to [email protected] that you send yourself, naming the zip to attach. Only when an operator has configured a bug-report intake endpoint ([`OK_BUG_REPORT_INTAKE_URL`](./configuration.mdx#environment-variables)) does Send upload the zip there, falling back to the same email draft if the upload fails |
+| In-app bug report | Only when you click **Send** in the desktop app's **Help → Report a bug…** dialog, or the `Cmd+Shift+D` / `Ctrl+Shift+D` shortcut that opens the same dialog — it builds a secret-redacted zip you can reveal and inspect first, and nothing is sent without that explicit click. The zip carries a picture of the app window unless you uncheck **Screenshot** in that dialog, and the preview there is the picture that would be sent. You can also attach up to three images by dragging them into the dialog, pasting them from the clipboard (`Cmd+V` / `Ctrl+V`), or browsing for files. Neither these images nor the screenshot are scanned or redacted, so review them before sending. A report reached through a surface you opened only to get to the reporter — the command palette, the Help popover, or the Windows and Linux menu bar — waits for that surface to close first, and carries no marker, because the row it would point at has already gone. Every other report you start yourself photographs the screen as it is, so an open menu or another person's document visible at the time is in the picture, and carries a marker drawn where your pointer was, since a screenshot never includes the cursor. No marker is drawn either if the pointer has not moved since the window loaded, or has since left the window. The invitation that appears on its own after a crash is the exception to all of this: it carries no picture at all. After a crash, the same dialog adds an **off-by-default** "Include crash dump" checkbox: a crash dump is a memory snapshot that can contain document content and can't be redacted, and it is only ever attached when you check that box. On macOS the zip also carries the update helper's install log (listed above), which is machine-wide rather than project-scoped; the zip's own README names it and says where it came from. At the **Detailed diagnostics** level — pre-checked on the invitation that follows a crash — it additionally carries the crash reports macOS itself recorded for this app and its helpers (also listed above), which are machine-wide for the same reason and named in the same README; only this app's are collected, never another application's, though a report of ours still names the processes it was running alongside, and the zip always says what that search found even when the answer is nothing. The zip also carries a short send history of the bug reports previously generated on this machine — when each was generated and whether sending it succeeded — which is what makes a report that failed to send diagnosable at all. That history is machine-wide too, so it names the other projects you have filed reports from; it carries no document content, and the README names it the same way | By default, Send makes no network request — it opens a prefilled email draft to [email protected] that you send yourself, naming the zip to attach. Only when an operator has configured a bug-report intake endpoint ([`OK_BUG_REPORT_INTAKE_URL`](./configuration.mdx#environment-variables)) does Send upload the zip there, falling back to the same email draft if the upload fails |
| Uninstall feedback | Only if you answer the optional "Before you go" screen or prompt. The macOS desktop asks after you confirm removal, before the app quits and cleanup starts; feedback can be sent even if cleanup later fails. Interactive `ok uninstall` asks only after successful cleanup. Skipping sends nothing; CLI runs with `--yes`, `--json`, or non-interactive input never ask | `openknowledge.ai/api/feedback` — the reason you picked, your note, your email address if you gave one, plus the app version and platform. It files one ticket for the team; nothing from your notes is included |
| Semantic search embeddings | Only when you enable [semantic search](./configuration.mdx#semantic-search) **and** set a key — off by default | Your configured embeddings provider (OpenAI by default) |
| GitHub sync / share | When you sync, clone, publish, or share | GitHub |
diff --git a/knip.config.ts b/knip.config.ts
index 8b615429f..6a38348d8 100644
--- a/knip.config.ts
+++ b/knip.config.ts
@@ -143,15 +143,11 @@ export default {
'packages/server': {
entry: ['src/**/*.test.ts', 'src/parse-worker.ts'],
project: 'src/**',
- ignoreDependencies: [
- '@types/shell-quote',
- ],
+ ignoreDependencies: ['@types/shell-quote'],
},
'packages/cli': {
entry: ['src/**/*.test.ts', 'scripts/*.ts', 'tests/**/*.ts', 'src/parse-worker.ts'],
- ignoreDependencies: [
- 'yjs',
- ],
+ ignoreDependencies: ['yjs'],
},
'packages/desktop': {
entry: [
diff --git a/packages/app/src/components/ReportBugImageDropzone.dom.test.tsx b/packages/app/src/components/ReportBugImageDropzone.dom.test.tsx
index 8701f9f84..3dcda27de 100644
--- a/packages/app/src/components/ReportBugImageDropzone.dom.test.tsx
+++ b/packages/app/src/components/ReportBugImageDropzone.dom.test.tsx
@@ -1,17 +1,19 @@
-import { cleanup, fireEvent, render, screen } from '@testing-library/react';
+import { cleanup, createEvent, fireEvent, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { useState } from 'react';
import { afterEach, describe, expect, test, vi } from 'vitest';
+import { makeFilesDataTransfer } from '@/editor/composer-drop.test-helper';
import { MAX_IMAGE_ATTACHMENTS_TOTAL_BYTES } from '@/lib/image-attachments';
import { ReportBugImageDropzone } from './ReportBugImageDropzone';
afterEach(cleanup);
-function Harness() {
+function Harness({ disabled = false }: { disabled?: boolean }) {
const [files, setFiles] = useState<File[]>([]);
return (
<>
- <ReportBugImageDropzone files={files} onChange={setFiles} disabled={false} />
+ <textarea aria-label="What happened?" />
+ <ReportBugImageDropzone files={files} onChange={setFiles} disabled={disabled} />
<output>{files.map((f) => f.name).join(', ')}</output>
</>
);
@@ -23,6 +25,12 @@ function drop(files: File[]) {
});
}
+function paste(target: Element, clipboardData: object) {
+ const event = createEvent.paste(target, { clipboardData });
+ fireEvent(target, event);
+ return event;
+}
+
function png(name: string) {
return new File(['png'], name, { type: 'image/png' });
}
@@ -54,6 +62,74 @@ describe('report image drop target', () => {
expect(screen.queryByText('You can attach up to 3 images.')).toBeNull();
});
+ test('adds pasted clipboard images wherever focus is in the dialog', () => {
+ render(<Harness />);
+ const note = screen.getByRole('textbox', { name: 'What happened?' });
+ const fromNote = paste(note, makeFilesDataTransfer([png('image.png')]));
+ expect(fromNote.defaultPrevented).toBe(true);
+ paste(
+ screen.getByRole('button', { name: 'Attach images' }),
+ makeFilesDataTransfer([png('second.png')]),
+ );
+ paste(document.body, makeFilesDataTransfer([png('third.png')]));
+ expect(screen.getByText('image.png, second.png, third.png')).not.toBeNull();
+ });
+
+ test('keeps two different pasted screenshots that share the clipboard name', () => {
+ render(<Harness />);
+ const note = screen.getByRole('textbox', { name: 'What happened?' });
+ paste(note, makeFilesDataTransfer([png('image.png')]));
+ paste(
+ note,
+ makeFilesDataTransfer([new File(['bigger png'], 'image.png', { type: 'image/png' })]),
+ );
+ expect(screen.getByText('image.png, image.png')).not.toBeNull();
+ });
+
+ test('ignores pasted images while a dialog stacked above the report has focus', () => {
+ function Stacked() {
+ const [files, setFiles] = useState<File[]>([]);
+ return (
+ <>
+ <div role="dialog" aria-label="Report a bug">
+ <ReportBugImageDropzone files={files} onChange={setFiles} disabled={false} />
+ <output>{files.map((f) => f.name).join(', ')}</output>
+ </div>
+ <div role="dialog" aria-label="Screenshot preview">
+ <button type="button">Close</button>
+ </div>
+ </>
+ );
+ }
+ render(<Stacked />);
+ const event = paste(
+ screen.getByRole('button', { name: 'Close' }),
+ makeFilesDataTransfer([png('image.png')]),
+ );
+ expect(event.defaultPrevented).toBe(false);
+ paste(
+ screen.getByRole('button', { name: 'Attach images' }),
+ makeFilesDataTransfer([png('screen.png')]),
+ );
+ expect(document.querySelector('output')?.textContent).toBe('screen.png');
+ });
+
+ test('leaves text pastes alone and reports pasted images it cannot attach', () => {
+ render(<Harness />);
+ const note = screen.getByRole('textbox', { name: 'What happened?' });
+ const text = paste(note, { types: ['text/plain'], files: [], items: [], getData: () => 'hi' });
+ expect(text.defaultPrevented).toBe(false);
+ paste(note, makeFilesDataTransfer([new File(['gif'], 'image.gif', { type: 'image/gif' })]));
+ expect(screen.getByText('Only PNG, JPEG, or WebP images are allowed.')).not.toBeNull();
+ });
+
+ test('ignores pasted images while creation is in progress', () => {
+ render(<Harness disabled />);
+ const event = paste(document.body, makeFilesDataTransfer([png('image.png')]));
+ expect(event.defaultPrevented).toBe(false);
+ expect(screen.queryByText('image.png')).toBeNull();
+ });
+
test('prevents drops and browse actions while creation is in progress', async () => {
const onChange = vi.fn();
render(<ReportBugImageDropzone files={[]} onChange={onChange} disabled />);
diff --git a/packages/app/src/components/ReportBugImageDropzone.tsx b/packages/app/src/components/ReportBugImageDropzone.tsx
index 0edf11279..12b6b049f 100644
--- a/packages/app/src/components/ReportBugImageDropzone.tsx
+++ b/packages/app/src/components/ReportBugImageDropzone.tsx
@@ -1,10 +1,11 @@
import { Trans, useLingui } from '@lingui/react/macro';
import { UploadIcon } from 'lucide-react';
-import { useId, useRef, useState } from 'react';
+import { useEffect, useEffectEvent, useId, useRef, useState } from 'react';
import { isExternalFileDrag } from '@/components/file-tree-adapter';
import { useImageAttachmentProblemMessage } from '@/components/ImageAttachments';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
+import { collectImageFiles } from '@/lib/acp/image-attachment';
import {
ACCEPTED_IMAGE_TYPES,
type ImageAttachmentProblem,
@@ -20,6 +21,7 @@ interface ReportBugImageDropzoneProps {
export function ReportBugImageDropzone({ files, onChange, disabled }: ReportBugImageDropzoneProps) {
const { t } = useLingui();
+ const root = useRef<HTMLDivElement>(null);
const picker = useRef<HTMLInputElement>(null);
const hintId = useId();
const [dragging, setDragging] = useState(false);
@@ -30,7 +32,7 @@ export function ReportBugImageDropzone({ files, onChange, disabled }: ReportBugI
const problem = rejection?.files === files ? rejection.problem : null;
const problemMessage = useImageAttachmentProblemMessage();
- function addFiles(picked: FileList | null) {
+ function addFiles(picked: ArrayLike<File> | null) {
if (disabled || picked === null || picked.length === 0) return;
const unique = new Map(files.map((file) => [`${file.name}:${file.size}`, file]));
for (const file of Array.from(picked)) unique.set(`${file.name}:${file.size}`, file);
@@ -40,8 +42,24 @@ export function ReportBugImageDropzone({ files, onChange, disabled }: ReportBugI
if (error === null) onChange(next);
}
+ const pasteImages = useEffectEvent((event: ClipboardEvent) => {
+ if (disabled) return;
+ const target = event.target instanceof Element ? event.target : null;
+ const targetDialog = target?.closest('[role="dialog"]') ?? null;
+ if (targetDialog !== null && targetDialog !== root.current?.closest('[role="dialog"]')) return;
+ const pasted = collectImageFiles(event.clipboardData);
+ if (pasted.length === 0) return;
+ event.preventDefault();
+ addFiles(pasted);
+ });
+
+ useEffect(() => {
+ document.addEventListener('paste', pasteImages);
+ return () => document.removeEventListener('paste', pasteImages);
+ }, []);
+
return (
- <div className="flex min-w-0 flex-col gap-2">
+ <div ref={root} className="flex min-w-0 flex-col gap-2">
<Button
variant="outline"
className={cn(
diff --git a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
index a28cc2b18..8a60e5826 100644
--- a/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
+++ b/packages/app/tests/integration/bug3-source-mode-writeback.test.ts
@@ -1,4 +1,3 @@
-
import { readFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
index 4fc2c11f9..6fcdc23f2 100644
--- a/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
+++ b/packages/app/tests/integration/indented-jsx-byte-sacred.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { normalizeBridge } from '@inkeep/open-knowledge-core';
import { updateYFragment } from '@tiptap/y-tiptap';
diff --git a/packages/app/tests/integration/interior-edit-freshness.test.ts b/packages/app/tests/integration/interior-edit-freshness.test.ts
index 9f2f6feb6..40b5cdfd6 100644
--- a/packages/app/tests/integration/interior-edit-freshness.test.ts
+++ b/packages/app/tests/integration/interior-edit-freshness.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
index 2a085742b..93666af70 100644
--- a/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
+++ b/packages/app/tests/integration/keystroke-cadence-danger-space.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/producer-guard-wiring.test.ts b/packages/app/tests/integration/producer-guard-wiring.test.ts
index 878d5196b..867598d34 100644
--- a/packages/app/tests/integration/producer-guard-wiring.test.ts
+++ b/packages/app/tests/integration/producer-guard-wiring.test.ts
@@ -1,4 +1,3 @@
-
import { setTimeout as wait } from 'node:timers/promises';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
diff --git a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
index 4ada3cf26..0970ac12f 100644
--- a/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
+++ b/packages/app/tests/integration/qa-039-reconciliation-counters-http.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterEach, describe, expect, test } from 'vitest';
import { agentWriteMd, createTestServer, type TestServer } from './test-harness';
diff --git a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
index cbe2b705f..b632185e1 100644
--- a/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
+++ b/packages/app/tests/integration/qa-045-restore-after-gc.test.ts
@@ -1,4 +1,3 @@
-
import { execFileSync } from 'node:child_process';
import { randomUUID } from 'node:crypto';
import { join } from 'node:path';
diff --git a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
index 89bc9b4d9..c530ce4ba 100644
--- a/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
+++ b/packages/app/tests/integration/qa-050-rollback-undo-shipped-path.test.ts
@@ -1,4 +1,3 @@
-
import { randomUUID } from 'node:crypto';
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest';
import type * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-after-rollback.test.ts b/packages/app/tests/integration/undo-after-rollback.test.ts
index a78aeb0e4..d3767adc9 100644
--- a/packages/app/tests/integration/undo-after-rollback.test.ts
+++ b/packages/app/tests/integration/undo-after-rollback.test.ts
@@ -1,4 +1,3 @@
-
import { ROLLBACK_ORIGIN } from '@inkeep/open-knowledge-server';
import { afterAll, beforeAll, describe, expect, test } from 'vitest';
import * as Y from 'yjs';
diff --git a/packages/app/tests/integration/undo-recycle-reset.test.ts b/packages/app/tests/integration/undo-recycle-reset.test.ts
index e7cc69c3f..b076f955c 100644
--- a/packages/app/tests/integration/undo-recycle-reset.test.ts
+++ b/packages/app/tests/integration/undo-recycle-reset.test.ts
@@ -1,4 +1,3 @@
-
import { writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { setTimeout as wait } from 'node:timers/promises';
diff --git a/packages/app/tests/integration/undo-rederive-survival.test.ts b/packages/app/tests/integration/undo-rederive-survival.test.ts
index 9ddcd0730..7935e35f8 100644
--- a/packages/app/tests/integration/undo-rederive-survival.test.ts
+++ b/packages/app/tests/integration/undo-rederive-survival.test.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter } from '@inkeep/open-knowledge-core';
import { Plugin, PluginKey } from '@tiptap/pm/state';
import { updateYFragment, yXmlFragmentToProseMirrorRootNode } from '@tiptap/y-tiptap';
diff --git a/packages/core/src/bridge/compose.ts b/packages/core/src/bridge/compose.ts
index 2a597ec3d..f4cc8a286 100644
--- a/packages/core/src/bridge/compose.ts
+++ b/packages/core/src/bridge/compose.ts
@@ -1,4 +1,3 @@
-
import { prependFrontmatter, stripFrontmatter } from '../extensions/frontmatter.ts';
export type ComposeAdjustment = 'none' | 'body' | 'frontmatter' | 'unresolved';
diff --git a/packages/core/src/bridge/doc-boundary-space.ts b/packages/core/src/bridge/doc-boundary-space.ts
index 01ef76a9f..8fb428b90 100644
--- a/packages/core/src/bridge/doc-boundary-space.ts
+++ b/packages/core/src/bridge/doc-boundary-space.ts
@@ -1,4 +1,3 @@
-
import { FRONTMATTER_RE, stripFrontmatter } from '../extensions/frontmatter.ts';
import { carriedEdgeEmpties, type DocEdgeEmpties } from '../markdown/doc-edge-blank-runs.ts';
diff --git a/packages/core/src/markdown/comment-promoter.ts b/packages/core/src/markdown/comment-promoter.ts
index fb0ba5a7c..fc267cbea 100644
--- a/packages/core/src/markdown/comment-promoter.ts
+++ b/packages/core/src/markdown/comment-promoter.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Paragraph, PhrasingContent, Root, RootContent, Text } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/merged-walker.ts b/packages/core/src/markdown/merged-walker.ts
index fa3cfcd86..bfd7e3109 100644
--- a/packages/core/src/markdown/merged-walker.ts
+++ b/packages/core/src/markdown/merged-walker.ts
@@ -1,4 +1,3 @@
-
import type { Nodes, Parent, Root } from 'mdast';
import { SKIP, visit } from 'unist-util-visit';
import type { VFile } from 'vfile';
diff --git a/packages/core/src/markdown/safe-url.ts b/packages/core/src/markdown/safe-url.ts
index 8be632ba4..4d3250d3a 100644
--- a/packages/core/src/markdown/safe-url.ts
+++ b/packages/core/src/markdown/safe-url.ts
@@ -1,4 +1,3 @@
-
export const SAFE_URL_SCHEMES = ['https', 'http', 'mailto', 'tel', 'ftp', 'sms'] as const;
const SCHEME_ALT = SAFE_URL_SCHEMES.map((s) => `${s}:`).join('|');