Skip to content

feat(inspect): add --filter flag to narrow timeline by method - #35

Merged
protosphinx merged 1 commit into
mainfrom
bot/inspect-filter-flag
Aug 25, 2026
Merged

protosphinx merged 1 commit into
mainfrom
bot/inspect-filter-flag

Conversation

@protosphinx

Copy link
Copy Markdown
Member

Why

When debugging a transcript that spans many tool calls, the inspect timeline 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 --filter flag makes the inspect command usable as a quick diagnostic for a specific tool in large sessions.

What

  • src/inspect.ts: adds InspectOptions interface with an optional filter?: string field; inspectTranscript now accepts opts: InspectOptions = {} as a second argument (backward-compatible). When filter is 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 the inspect sub-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): clean
  • npm test (vitest run): 248 tests pass (240 existing + 8 new)

Self-merge gate

  • all CI checks pass
  • LOC delta < 250 (diff is 94 lines)
  • no public-API surface change (src/index.ts not modified; inspectTranscript signature change is backward-compatible optional second argument)
  • no runtime-dependency additions
  • no workflow file changes
  • tests added or extended (test/inspect.filter.test.ts, 8 tests)

Generated by Claude Code

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]
@protosphinx protosphinx added the automated Opened by the daily bot label Aug 25, 2026 — with Claude
@protosphinx
protosphinx merged commit f7f497f into main Aug 25, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/inspect.ts
Comment on lines +76 to +77
const msg = f.msg as { id?: unknown };
return msg.id !== undefined && matchedIds.has(msg.id as string | number);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated Opened by the daily bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant