Skip to content

feat(activity): add before_ts paging knob to /activity route - #2476

Merged
HongmingWang-Rabbit merged 1 commit into
stagingfrom
feat/activity-before-ts-filter
May 2, 2026
Merged

HongmingWang-Rabbit merged 1 commit into
stagingfrom
feat/activity-before-ts-filter

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

Self-review caught after #2472 merged: the wheel-side chat_history MCP tool (#2474) advertises a before_ts parameter for backward paging through long histories, and the docs (#111) describe it as the canonical pagination knob — but the server silently ignored it. Without this fix, an agent passing before_ts would always get the most-recent N rows and pagination is broken end-to-end.

Fix

Add before_ts query param parsed as RFC3339 at the trust boundary and translated into a created_at < \$X clause on the existing builder. Mirrors the strict-inequality shape since_id uses for forward paging (created_at > cursorTime) so paging across both directions has consistent semantics.

GET /workspaces/:id/activity?peer_id=<uuid>&before_ts=2026-05-01T00:00:00Z&limit=20

Test plan

  • 3 new branches in activity_test.go:
    • positive before_ts filter binds the parsed time correctly
    • composes with peer_id into the canonical chat_history paging shape (arg order pinned)
    • 4 malformed inputs reject with 400 (unparseable, missing-T, URL-encoded SQL injection, etc.)
  • All existing 12 TestActivityList_* tests still pass
  • Live verify on staging: chat_history(peer_id=X, before_ts=Y) actually pages backward

Related

🤖 Generated with Claude Code

The wheel-side chat_history MCP tool advertises a `before_ts`
parameter for backward paging through long histories, and the docs
describe it as the canonical pagination knob — but the server
silently ignored it until now. Without this fix, an agent passing
before_ts to chat_history would always get the most-recent N rows
and pagination would be broken end-to-end.

Add `before_ts` query param parsed as RFC3339 at the trust boundary
and translated into a `created_at < $X` clause on the existing
builder. Mirrors the strict-inequality shape since_id uses for
forward paging (`created_at > cursorTime`) so paging across both
directions has consistent semantics.

Tests: 3 new branches (positive filter, composition with peer_id
into the canonical chat_history paging shape, RFC3339 rejection
across 4 malformed inputs including URL-encoded SQL injection).
Mutation-verified pre-commit; existing 9 activity tests still pass.

Reported by self-review on PR #2474.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit
HongmingWang-Rabbit added this pull request to the merge queue May 2, 2026
HongmingWang-Rabbit pushed a commit that referenced this pull request May 2, 2026
Self-review on PR #2474 + #2476: the comment said we don't forward
before_ts, but the code below does. Misleading after #2476 added
the server-side filter. Replace with a one-liner that just states
the forward-and-validate contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Merged via the queue into staging with commit d50d6f4 May 2, 2026
22 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the feat/activity-before-ts-filter branch May 2, 2026 01:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant