fix download logs IPC for details panel

Merged
MP
7mo ago
+370-21

Summary

Closes #47.

This PR fixes the download details logs panel by wiring it to a real Tauri IPC command and a backend log source scoped by download_id.

Root Cause

LogsSection was invoking a non-existent IPC command, query_download_logs, and was passing the download id as a string. As a result, the panel always fell back to No logs.

What Changed

  • renamed the frontend IPC call to download_logs
  • converted downloadId to a numeric id before invoking Tauri
  • added a lightweight per-download in-memory log store in Rust
  • added an event bridge that records log lines from DomainEvents for each download
  • exposed a new download_logs(id, limit) Tauri command
  • added regression tests for the frontend IPC contract and Rust log-store behavior

Impact

The logs section in the details panel now shows actual lines for the selected download during the current app session instead of always rendering No logs.

Validation

  • npm run lint
  • npm run typecheck
  • npm test -- src/views/DownloadDetailsPanel/__tests__/LogsSection.test.tsx
  • cargo fmt --check --manifest-path src-tauri/Cargo.toml
  • cargo test --manifest-path src-tauri/Cargo.toml download_log_
  • pre-push hooks:
    • Rust test suite
    • TypeScript typecheck
    • TypeScript test suite
  • rtk proxy npx -y react-doctor@latest . --verbose --diff

Summary by cubic

Fixes the Download Details logs panel by wiring LogsSection to a real IPC and a per‑download in‑memory log store, so it shows logs for the selected download, auto‑refreshes, and clears when a download is removed. Addresses issue #47 by scoping log retrieval to download_id.

  • Bug Fixes
    • Frontend: call download_logs with { id: Number(downloadId), limit }, set stable query keys, add refetchInterval, and use stable keys for duplicate lines.
    • Backend: add DownloadLogStore (per‑download ring buffer) and log bridge to record lines from DomainEvents; introduce DownloadRemoved and publish it from cancel/remove so logs purge on removal.
    • IPC/App: expose download_logs(id, limit) via Tauri, include download_log_store in AppState, and forward download-removed events; add tests for IPC invocation, event mapping/removal purge, and panel refetch.

Summary by CodeRabbit

  • New Features
    • Per-download activity logs capturing lifecycle and segment events (start, pause, resume, retry, complete, fail, etc.).
    • Logs can be fetched via the app and are shown in the Download Details panel with periodic auto-refresh while open.
  • Behavior
    • Removing a download clears its stored logs.
  • Tests
    • Added tests for log entry formatting, no-ops for unrelated events, log-clearing on removal, and UI refetch behavior.