fix(cli): apply the documented mex timeline --type filter - #148
Open
tonydzi wants to merge 1 commit into
Open
Conversation
`mex timeline --type <kind>` was silently ignored. Commander stores the
flag as `opts.type`, but `runTimeline` reads `TimelineOpts.kind`, so
spreading the parsed options left `kind` undefined and the filter matched
every event.
Two visible effects:
mex timeline --type decision # listed notes and risks too
mex timeline --type session_start # exit 0, listed everything
The second one is the worse half: `mex log --type session_start` rejects
that value with `Unknown event type "session_start". Use decision, note,
risk, or todo.`, while `timeline` accepted it and answered with unfiltered
output. `--since`, `--limit`, and `--json` were unaffected — only the kind
option was misnamed across the boundary.
The `log` command in the same file already does this mapping
(`{ kind: opts.type }`); `timeline` did not.
Tests:
- test/cli.test.ts now asserts the handler is called with `kind`, and the
in-file program copy mirrors the real wiring. The previous assertion
(`type: "risk"`) encoded the bug.
- a spawn test drives the built `dist/cli.js` end to end: `--type decision`
returns 1 of 2 events, and `--type session_start` exits 1 with the same
message `mex log` prints.
- test/events.test.ts covers `runTimeline` filtering and unknown-kind
rejection directly.
Reverting only the `src/cli.ts` change turns the spawn test red with
"expected 2 events to have a length of 1".
Assisted-by: Claude Code / claude-opus-5
Machine: MacBook-Anton
Account: a
Operator: robot:git-s3-docs-fix-lane
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
mex timeline --type <kind>is documented as "Filter by event type" and does nothing.Commander parses the flag into
opts.type, butrunTimelinereadsTimelineOpts.kind. The action passed the parsed options straight through, sokindstayedundefinedand this line inrunTimelinenever filtered anything:The
logcommand, ten lines up in the same file, already does the mapping the way it should:runLog(config, message, { kind: opts.type, ... }).timelinewas the one that forgot.How I checked it
Fresh clone of
mainat4f315c7,npm install && npm run build, a scratch project with three events (onedecision, onerisk, onenote):All three, for a filter that should return one.
The second symptom is the one I'd care about more:
session_startis not an event kind and never can be —EVENT_KINDSisdecision | note | risk | todo, andreadEventsdrops any line whose kind is outside that set.mex log --type session_startsays so plainly:timelineanswered a nonsense filter with unfiltered output and exit 0. Anything reading that output — a person or an agent — gets a confident wrong answer instead of an error.Control:
--since 2030-01-01correctly printed "No events found", so this is not options-passing broken in general. Only the kind option was misnamed across the boundary.What changed
One line of behaviour in
src/cli.ts— passkind: opts.typeexplicitly instead of spreadingopts. That restores both halves of the intended design: the filter filters, and an unknown kind is rejected by the existingnormalizeKindwith the same messagemex logprints.Tests:
test/cli.test.ts— the existing assertion wasexpect(runTimeline).toHaveBeenCalledWith(config, { ..., type: "risk" }), which encoded the bug. It now assertskind: "risk", and the in-file program copy mirrors the real wiring.test/cli.test.ts— a new spawn test drives the builtdist/cli.jsend to end, next to the existing spawn tests:--type decisionreturns 1 of 2 events,--type session_startexits 1 with themex logmessage.test/events.test.ts—runTimelinefiltering and unknown-kind rejection covered directly.Proof the tests bite
Reverting only the
src/cli.tschange, leaving the tests alone, and rebuilding:Suite state
npm run typecheckclean,npm run buildclean.npm run teston this branch: 517 passed, 4 failed. The same command on untouchedmainon the same machine: 514 passed, 5 failed. The failures are the same set either way —compiler-extraction,engine, andgraph-v2-integritycases timing out at the default 5000 ms on my laptop, and the set shifts run to run. They are load-related and unrelated to this change; nothing undersrc/graph/is touched here. The 3 added tests are the delta in the totals. Happy to attach the full control output if useful.The new spawn test carries an explicit
30_000timeout, matching the convention already used ingraph-integration.test.tsand friends, so it does not join that flaky set on a loaded runner.