Skip to content

fix(#193): restore saved filter on Open Session + add persistent error logging - #244

Merged
adamgell merged 2 commits into
mainfrom
fix/193-filter-restore-and-logging
Jul 11, 2026
Merged

adamgell merged 2 commits into
mainfrom
fix/193-filter-restore-and-logging

Conversation

@adamgell

@adamgell adamgell commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Addresses the three items in #193. Rebased onto current main (post #240 workspace/lockfile repair).

1. Out of Memory

Root-caused to the log-tailing bug fixed separately in #243 (rotated/truncated logs accumulated entries without bound). The persistent logging added here makes future OOM reports diagnosable.

2. Filter not restored on Open Session (fixed here)

Save Session persisted the filter clauses, but Open Session only re-applied highlight/find text and never wrote the clauses back into the filter store — and clearTabs() actively cleared any existing filter during load — so the filter came back empty every time.

  • session-restore.ts now restores the saved clauses into the filter store after files load, which re-applies the filter to the loaded entries and refreshes the toolbar badge, status bar, and Filter dialog.
  • session.ts now types and sanitizes SessionFilters.clauses as FilterClause[], so a malformed or hand-edited session file can't inject a bogus clause into the backend apply_filter.
  • New tests: session.test.ts (validation drops malformed clauses) and session-restore.test.ts (Open Session repopulates the filter store).

3. "Does it log errors, and where?" (added here)

Today: no — the backend uses the log facade throughout but no logger backend was registered, so nothing was written to disk.

This registers tauri-plugin-log to write to the OS app-log directory (cmtrace-open.log; on Windows %LOCALAPPDATA%\com.cmtrace.open\logs\) with a 5 MB cap + single-file rotation, and adds a panic hook so a hard crash leaves a line. Backend-only — no frontend log capability, so no tauri.conf.json change is needed. Cargo.toml + the root Cargo.lock are both updated (additive: tauri-plugin-log and its transitive deps).

Closes #193.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings July 11, 2026 00:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses issue #193 by restoring saved filter clauses when opening a session, hardening session-file filter clause deserialization to prevent invalid clauses reaching the backend, and adding persistent backend logging (including a panic hook) via tauri-plugin-log to help diagnose future failures.

Changes:

  • Restore saved filter clauses into the filter store during session restore so “Open Session” re-applies the saved filter.
  • Sanitize SessionFilters.clauses from session files to only accept valid FilterClause shapes/values, with new unit tests.
  • Register tauri-plugin-log to persist backend logs to the OS log directory with rotation, and add a panic hook.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/session.ts Types clauses as FilterClause[] and sanitizes session-loaded clauses before use.
src/lib/session.test.ts Adds tests verifying malformed filter clauses are dropped during session validation.
src/lib/session-restore.ts Repopulates the filter store clauses after restoring session files so filters persist across “Open Session”.
src/lib/session-restore.test.ts Adds a test ensuring restoreSession writes saved clauses into the filter store.
src-tauri/src/lib.rs Registers persistent backend logging and adds a panic hook to emit a line on crash.
src-tauri/Cargo.toml Adds tauri-plugin-log dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/session.ts
Comment on lines +85 to +92
if (
(FILTER_FIELDS as readonly string[]).includes(c.field as string) &&
(FILTER_OPS as readonly string[]).includes(c.op as string) &&
typeof c.value === "string"
) {
return [{ field: c.field as FilterField, op: c.op as FilterOp, value: c.value }];
}
return [];
adamgell and others added 2 commits July 10, 2026 22:12
Save Session persisted the filter clauses, but Open Session only
re-applied highlight/find state and never wrote the clauses back into the
filter store (which clearTabs() had just cleared), so the filter came
back empty every time.

Restore the clauses into the filter store after files load, which
re-applies the filter to the loaded entries and refreshes the toolbar
badge, status bar, and Filter dialog. Also type and sanitize
SessionFilters.clauses as FilterClause[] so a malformed or hand-edited
session file can't inject a clause into the backend apply_filter.

Refs #193

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The app used the `log` facade throughout the backend but never registered
a logger backend, so error/diagnostic messages went nowhere and there was
no file for users to attach to a crash report (issue #193, part 3).

Register tauri-plugin-log to write to the OS app-log directory
(cmtrace-open.log) with a 5 MB size cap and single-file rotation, keeping
stderr for dev. Add a panic hook so a hard crash (e.g. the reported
out-of-memory) leaves a line in the log.

Backend-only: no frontend log capability is added, so no tauri.conf.json
capability change is required. Lockfile update is deferred to the
in-progress workspace/Cargo.lock consolidation; CI builds from src-tauri/
and resolves the new dependency without --locked.

Refs #193

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@adamgell
adamgell force-pushed the fix/193-filter-restore-and-logging branch from e92be2d to eadecac Compare July 11, 2026 02:13
@adamgell
adamgell merged commit 0d1cfd0 into main Jul 11, 2026
15 checks passed
@adamgell
adamgell deleted the fix/193-filter-restore-and-logging branch July 11, 2026 02:37
adamgell added a commit that referenced this pull request Jul 11, 2026
Document the user-facing work merged since the 1.3.2 release: log error
navigation (#192), Teams MSIX log collection (#242), session filter
restore + error logging (#244), tail truncation/rotation reset (#243),
and the Tauri 2.11 / build repair (#240). Dependency bumps, CI-internal
changes, and README-only docs are intentionally omitted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
adamgell added a commit that referenced this pull request Jul 11, 2026
….3.2 (#247)

* chore(deps-dev): upgrade TypeScript 6 -> 7 (native compiler, GA)

TypeScript 7.0.2 -- the native Go compiler, GA'd 2026-07-09 -- is a clean
drop-in for this frontend. No source changes were required:

- `tsc --noEmit`: 0 errors
- `tsc && vite build`: passes
- vitest: 123/123 tests pass

Type-checking is ~5.5x faster: `tsc --noEmit` drops from ~3.79s to ~0.69s
(macOS, warm). vite and vitest transpile via esbuild and are unaffected;
tsc is used only for the type-check gate (CI "TypeScript Check" and the
`frontend:build` script), so both simply get faster.

The lockfile grows because the native compiler ships as per-platform
binary packages (@typescript/typescript-<os>-<arch>) via
optionalDependencies, resolved per-platform on install -- the same model
as esbuild/swc. linux-x64, win32-x64 and darwin binaries are all present,
so `npm ci` resolves correctly on every CI platform.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(changelog): note TypeScript 7 upgrade (#247)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* docs(changelog): catch up [Unreleased] with changes since 1.3.2

Document the user-facing work merged since the 1.3.2 release: log error
navigation (#192), Teams MSIX log collection (#242), session filter
restore + error logging (#244), tail truncation/rotation reset (#243),
and the Tauri 2.11 / build repair (#240). Dependency bumps, CI-internal
changes, and README-only docs are intentionally omitted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.

Version 1.3 / 1.3.1 / 1.3.2

2 participants