Design & Medialow risk

export-download-debugging

Diagnose and fix browser, preview, or Electron export/download failures, especially image export issues involving Save As, Blob/Data URLs, the File System Access API, createWritable failures, and 0 KB files.

nexu-io/open-design·skills/export-download-debugging/SKILL.md
61/ 100推薦值

匯入這個 Skill

選擇你的 coding agent,複製專案級或個人級安裝指令。

固定至平台收錄的 commit
匯入目前專案.agents/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a codex -y
匯入個人環境~/.agents/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a codex -g -y
手動放置目錄.agents/skills/export-download-debuggingOfficial docs ↗
匯入目前專案.claude/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a claude-code -y
匯入個人環境~/.claude/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a claude-code -g -y
手動放置目錄.claude/skills/export-download-debuggingOfficial docs ↗
匯入目前專案.agents/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a github-copilot -y
匯入個人環境~/.copilot/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a github-copilot -g -y
手動放置目錄.agents/skills/export-download-debuggingOfficial docs ↗
匯入目前專案.agents/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a cursor -y
匯入個人環境~/.cursor/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a cursor -g -y
手動放置目錄.agents/skills/export-download-debuggingOfficial docs ↗
匯入目前專案.agents/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a gemini-cli -y
匯入個人環境~/.gemini/skills/export-download-debugging
npx skills add https://github.com/nexu-io/open-design/tree/7533db3f4342d09b27368fa5d907ebd3cdb93b75/skills/export-download-debugging -a gemini-cli -g -y
Native Gemini CLIgemini skills install https://github.com/nexu-io/open-design.git --scope workspace --path skills/export-download-debugging
手動放置目錄.agents/skills/export-download-debuggingOfficial docs ↗
⚠ 安裝指令使用開源 skills CLI。執行前請檢查來源、腳本與權限。
# Export Download Debugging

Use this when an export or download appears to run but produces an empty,
missing, or unusable file. It is tuned for browser previews, iframe capture,
and Electron shells.

## Core rule

Separate capture from save. Prove the export payload has non-zero bytes before
debugging the destination path. A 0 KB file often means the native picker or
host created the target file, then the write failed or was blocked.

## Evidence

- Record the payload type, MIME type, byte length, object URL or data URL path,
  and thrown error name/message.
- Check browser console output and app logs around `showSaveFilePicker`,
  `createWritable`, `<a download>`, `URL.createObjectURL`, and URL revocation.
- In Electron, inspect the `will-download` path: filename, MIME, file extension,
  save dialog filters, cancellation, and final file size.
- Confirm the actual downloaded file size on disk and whether it opens in a
  normal image viewer.

## Fix order

1. Prepare and validate the export payload first; disable Save until bytes are
   available.
2. Prefer the simplest stable save channel for the host. If
   `showSaveFilePicker().createWritable()` fails, is sandboxed, or creates empty
   files, route to `<a download>` or Electron's download manager instead.
3. Avoid opening a native picker before the payload is ready. This prevents the
   host from creating an empty destination file on later write failure.
4. For PNG fallback, prefer a verified non-empty data URL when blob URLs,
   revocation timing, CSP, or iframe sandboxing are suspicious.
5. In Electron, add explicit Save As filters for exported image extensions
   (`.png`, `.jpg`, `.jpeg`, `.webp`) so users can choose a real image target.
6. Keep the UI restrained: format selection, filename/path hint, clear pending
   and error states, and one primary save action.

## Validation

- Add or update tests for non-empty payload preparation, fallback save behavior,
  file extension/MIME mapping, and UI disabled/error states.
- Run focused export tests, then `pnpm --filter @open-design/web typecheck`.
- If Electron download handling changed, also run
  `pnpm --filter @open-design/desktop typecheck`.
- Before landing, run `pnpm guard`, inspect the staged diff for unrelated files,
  generated artifacts, and accidental secrets, then use the repository's PR
  quality-gate workflow if the fix is being prepared for review.