Commit e597d24
committed
MCP: log tail, recent listing errors, and state projection
Three additions that close the biggest gaps an MCP-driven smoke test hit
while verifying the previous SMB volume-id fix end-to-end:
- New `cmdr://logs?since=<iso>&filter=<substring>&limit=<n>` resource: tail
the live `cmdr.log` from MCP without grepping it off disk. `limit` defaults
to 100, clamped to 1000. `filter` is case-sensitive substring match (no
regex dep). `since` drops lines whose ISO-8601 prefix is <= the given
moment; lines without a recognizable timestamp prefix (Rust panics) are
kept. Reads the last ~5 MB of the file from the end so a 50 MB rotated log
doesn't blow up memory.
- `recentErrors:` section in `cmdr://state`: bounded ring buffer (capacity 20)
of the most recent directory-listing failures, populated from both
`emit_error` sites in `file_system::listing::streaming` right before the
`listing-error` Tauri event fires, so MCP sees what the FE sees. Lets tests
assert "no error since timestamp X" without grepping logs. Lives in the new
`mcp::listing_errors` module with unit tests for capacity, ordering, and
the `snapshot_since` filter.
- Query params on `cmdr://state`: `?include=panes,volumes,dialogs,listings,recentErrors`
to project only listed sections (defaults to all), and `?compact=true` to
drop the per-pane `files:` list (the biggest source of YAML noise when the
caller only cares about path / volumeId / cursor). Example:
`cmdr://state?include=listings,recentErrors` is the minimal payload for
"did the last listing succeed?". The `cursor`, `totalFiles`, and
`loadedRange` summary still render under `compact`, so direction is clear.
Wiring details:
- `read_resource` now `split_uri`s into base + query before dispatch and
parses each resource's options.
- `parse_query` is a small flat-map decoder that percent-decodes via the
existing `urlencoding` crate; no new deps.
- The unit-test-only `snapshot_since` helper is gated behind `#[cfg(test)]`
to keep `#![deny(unused)]` happy in non-test builds.
- `mcp::CLAUDE.md` updated with the new resource entries, the projection
examples, and a freshness contract for `recentErrors`.
- The `tests/resource_tests.rs::test_resource_count` and `test_resources_exist`
updated for 5 resources.
End-to-end verified via MCP against a running `pnpm dev` build:
`cmdr://logs?filter=SmbVolume&limit=3`, `cmdr://logs?since=<iso>&filter=mcp::server`,
`cmdr://state?include=listings,recentErrors`, `cmdr://state?compact=true&include=panes,listings`
all return the expected projections. `recentErrors: []` correctly stays empty
in a healthy session; the unit tests pin the populated case.
`./scripts/check.sh` green: 1914 unit tests (up from 1902 with the 12 new
ones), 32 SMB integration tests, svelte-check, eslint, everything else.1 parent f241455 commit e597d24
6 files changed
Lines changed: 588 additions & 147 deletions
File tree
- apps/desktop/src-tauri/src
- file_system/listing
- mcp
- tests
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
336 | 336 | | |
337 | 337 | | |
338 | 338 | | |
339 | | - | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
340 | 349 | | |
341 | 350 | | |
342 | 351 | | |
| |||
542 | 551 | | |
543 | 552 | | |
544 | 553 | | |
545 | | - | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
546 | 557 | | |
547 | 558 | | |
548 | 559 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
0 commit comments