Skip to content

fix(desktop): make Export Logs skip locked files, reveal safely, and show toast feedback - #1679

Merged
Hona merged 1 commit into
devfrom
fix/export-logs-windows
Nov 29, 2026
Merged

Hona merged 1 commit into
devfrom
fix/export-logs-windows

Conversation

@Hona

@Hona Hona commented Nov 29, 2026

Copy link
Copy Markdown
Member

Summary

Addresses the unresponsive "Export Logs…" bug reported in #1649 (keeping #1649 open for the reporter's memory breakdown follow-up).

Root causes fixed

  1. Windows mandatory lock aborted the entire archive: rune-perf holds an exclusive LockFileEx lock on %LOCALAPPDATA%\rune-opencode\Logs\perf\.perf.lock while the app runs. On Windows, byte-range locks are mandatory, so within 24 hours of .perf.lock being created export_logs collected it and failed read_to_end() with ERROR_LOCK_VIOLATION, aborting the entire archive and leaving a partial zip.
  2. Errors and progress were silent: export_logs only printed failures via eprintln! (invisible in a Windows GUI app), returned silently if Downloads was unavailable, and gave zero toast feedback on start, success, or failure.
  3. Windows explorer.exe /select,<path> quoting and redirected Downloads: Command::arg(format!("/select,{}", file.display())) quotes paths containing spaces as "/select,C:\...", which Explorer rejects. Also dirs::downloads() always used %USERPROFILE%\Downloads instead of FOLDERID_Downloads.

Changes

  • Skip *.lock files and symlinks in export_logs::collect(), read each log file's tail resiliently (skipping unreadable/locked files and recording them under skipped in manifest.json), write the archive atomically via a sibling .part file with non-colliding filenames, and record crate::updater::build_version() / build_channel() in manifest.json.
  • Track background log export with an explicit ExportLogs state machine (Idle / Exporting) in opencode_kernel::StateSlots polled via stage::INGEST_LOCAL, showing waiting, success (with a Reveal action button), and error toasts.
  • Reveal the finished archive via harness_log::reveal (SHOpenFolderAndSelectItems on Windows), with a safe raw_arg explorer.exe /select,"<path>" fallback when Downloads is on a junction or redirected drive.
  • Expose win_install::downloads() (SHGetKnownFolderPath(FOLDERID_Downloads)) and use it in dirs::downloads() on non-rooted Windows runs.

Verification

  • Verified locally on Windows: pwsh scripts/guardrails.ps1 (10/10 passed), cargo check -p win-install -p opencode-desktop --lib --bins --features stories, and cargo clippy -p win-install -p opencode-desktop --lib --bins --no-deps (0 warnings in touched files).
  • Not verified live in a desktop GUI window or on macOS/Linux/wasm32 locally.

…show toast feedback

On Windows, rune-perf holds an exclusive mandatory LockFileEx lock on
%LOCALAPPDATA%\rune-opencode\Logs\perf\.perf.lock while the app runs.
Within 24 hours of first creating .perf.lock, Export Logs collected it
and aborted the entire archive with ERROR_LOCK_VIOLATION, swallowing the
error via eprintln! with no UI feedback.

- Skip *.lock sentinels and symlinks in collect(), and handle per-file
  read errors gracefully (recording skipped entries in manifest.json)
  instead of aborting the whole archive.
- Write the zip atomically via a sibling .part file with unique output
  names and record the real build version and channel in manifest.json.
- Reveal the archive via harness_log::reveal (SHOpenFolderAndSelectItems
  on Windows), with a raw_arg explorer.exe fallback for redirected or
  junction Downloads folders, and honor Windows FOLDERID_Downloads in
  dirs::downloads() when not rooted.
- Drive export lifecycle through an explicit ExportLogs state machine
  with waiting, success (with Reveal button), and failure toasts.
@Hona
Hona merged commit 824b522 into dev Nov 29, 2026
2 checks passed
@Hona
Hona deleted the fix/export-logs-windows branch November 29, 2026 12:19
@Hona Hona mentioned this pull request Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant