fix: forward conversation and thread date filters#42
Conversation
doistbot
left a comment
There was a problem hiding this comment.
This PR wires the --since and --until CLI flags through to the SDK's newerThan/olderThan arguments in both conversation view and thread view, fixing a gap where the date filters were accepted but silently ignored.
Few things worth tightening:
- The
options.since ? new Date(options.since) : undefined/options.until ? new Date(options.until) : undefinedpattern is now duplicated acrossconversation/view.ts,thread/view.ts, andinbox.ts. A small shared helper (e.g.toDate(value?: string): Date | undefined) would centralize the conversion and make the planned boundary-semantics follow-up a one-line change instead of three. - The conversation test at line 878 uses an exact object literal in
toHaveBeenCalledWith, which will break ifgetMessagesgains another parameter. Switching toexpect.objectContaining({...})— as the thread tests already do — keeps the assertion focused on what it actually cares about.
I also included a few optional follow-up notes in the details below.
Optional follow-up notes (2)
src/commands/conversation/view.ts:43: The
options.since ? new Date(options.since) : undefined/options.until ? new Date(options.until) : undefinedpair is now duplicated acrossconversation/view.ts,thread/view.ts, andinbox.ts. Your PR description notes a follow-up to verify inclusive/exclusive boundary semantics — when that lands, any adjustment (e.g. adding/subtracting a day for--until) will need to be applied in three places. A small shared helper insrc/lib/options.tsorsrc/lib/dates.ts(e.g.toDate(value?: string): Date | undefined) would centralize the conversion and make that follow-up a one-line change. Low priority given it's only two lines today.src/commands/conversation/conversation.test.ts:878: The
toHaveBeenCalledWithassertion uses an exact object literal ({ conversationId, newerThan, olderThan, limit }). IfgetMessagesgains an additional parameter in the future, this test breaks even though the date-filter forwarding still works. The thread tests for the same behavior useexpect.objectContaining({...}), which is more resilient. Consider matching withexpect.objectContaininghere too, keeping the test focused on what it actually cares about.
|
Addressed: added -- Replied by Clanker 🤖 |
|
Addressed: updated the conversation filter test to use -- Replied by Clanker 🤖 |
henningmu
left a comment
There was a problem hiding this comment.
Looks good. Thank you, Jacobo 🙌
Date filters declared by conversation view did not reach the API, so
--sincewas silently ignored;--untilwould have been ignored as well.The handler accepted both flags but only passed the conversation ID and limit to the SDK message request.
This change forwards
--sinceand--untilas the SDKdate-filterarguments, with regression coverage for both flags.While investigating the reported conversation problem, I had an agent audit related date-filter wiring. That found a second omission:
thread viewaccepted--untilbut did not forward it. This PR fixes that case too.One concern remains intentionally out of scope: the CLI flag names may imply different inclusive/exclusive boundaries from the SDK
newerThanandolderThanarguments. This PR only wires the existing values through; a follow-up will verify API boundary behaviour before changing semantics.