feat(inspect): add --filter flag to narrow timeline by method - #35
Conversation
When --filter <substring> is passed, inspectTranscript shows only the request frames whose method key (or tools/call[name] for tool calls) contains the substring, together with their paired response frames. The summary footer always covers the full transcript so counts remain meaningful. An empty or absent filter is a no-op for backward compatibility. CLI: mcprec inspect <file> --filter tools/call[search_issues]
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d5f613ba58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const msg = f.msg as { id?: unknown }; | ||
| return msg.id !== undefined && matchedIds.has(msg.id as string | number); |
There was a problem hiding this comment.
Pair responses by request occurrence, not a global ID set
When a transcript reuses a JSON-RPC ID—such as multiple HTTP clients each starting with id: 1, or a later request reusing an ID—this predicate includes every frame carrying that ID. Filtering for the later method therefore also shows responses belonging to earlier nonmatching requests (and can include reverse-direction requests with the same ID), so the filtered timeline is incorrect. Associate each matched request with its actual subsequent response using direction and position rather than collecting IDs globally.
Useful? React with 👍 / 👎.
Why
When debugging a transcript that spans many tool calls, the
inspecttimeline dumps every frame. There is no way to focus on a single method (e.g.tools/call[search_issues]) without scrolling past unrelated frames. A--filterflag makes the inspect command usable as a quick diagnostic for a specific tool in large sessions.What
src/inspect.ts: addsInspectOptionsinterface with an optionalfilter?: stringfield;inspectTranscriptnow acceptsopts: InspectOptions = {}as a second argument (backward-compatible). Whenfilteris set, only request frames whose method key contains the filter substring (and their paired response frames) appear in the timeline. The summary footer always reflects the full transcript. A "filter: (N frames shown)" line is added to the footer when a filter is active.src/cli.ts: wires a--filter <method>option on theinspectsub-command.test/inspect.filter.test.ts: 8 new tests covering exact-method filter, tool-name substring match, base-method match spanning multiple calls, no-match case, footer stats completeness, filter note presence, backward-compatible no-filter call, and empty-string filter.Tests
npm run lint(tsc --noEmit): cleannpm test(vitest run): 248 tests pass (240 existing + 8 new)Self-merge gate
Generated by Claude Code