mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
<!-- Write all pull request text in Simplified Technical English (ASD-STE100): short sentences, one instruction per sentence, simple approved vocabulary, and the active voice. --> ## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The board and external tools read agent runs through the REST API > - The company heartbeat runs endpoint returns the run history for a company > - The endpoint accepted a limit value, but it ignored the offset value > - A caller that paged through the runs received the first page again and again, and tools that count runs or tokens silently over-counted > - This pull request adds offset support to the route, to the run list service, and to the OpenAPI entry > - The benefit is correct paging through the full run history of a company ## Linked Issues or Issue Description Fixes #15318 ## What Changed - The `GET /api/companies/:companyId/heartbeat-runs` route now reads the `offset` query parameter, clamps it at zero, and passes it to the heartbeat run list - `listRuns` in the heartbeat run state service accepts `options.offset` and applies it in the database query; an absent or zero offset keeps the current behavior - `listRuns` now orders by `createdAt` descending and then by `id` descending, so page boundaries stay stable when runs share a timestamp - The OpenAPI entry for the endpoint now documents the `agentId`, `limit`, `offset`, and `summary` query parameters - Tests: a mock-level test proves the offset reaches the query only when one is set, and an embedded-Postgres test proves limit and offset page in newest-first order ## Verification - `vitest run server/src/services/heartbeat/run-state.test.ts` — 4 passed, 6 skipped in my sandbox. The PostgreSQL suite self-skips when the tests run as root; the new paging test is in that suite and runs in CI. The mock-level offset test runs everywhere - Negative control: with the source change stashed, the new offset test fails on the unmodified code - `tsc --noEmit -p server/tsconfig.json` passes ## Risks - Low risk. The default behavior does not change when a caller sends no offset - Rows with equal `createdAt` values now have a deterministic order. The old order for equal timestamps was not specified, so no caller could rely on it ## Model Used - Provider: Meta - Model: Muse Spark 1.3 (Muse model family) - Capabilities: tool use, code execution, extended reasoning ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [x] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [x] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Signed-off-by: Josh Cox <joshuacox@users.noreply.github.com> Co-authored-by: Review <review@local>