mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-29 23:56:43 +01:00
feat(ui): filter the Tasks list by when tasks were updated (#22965)
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The Tasks page lists tasks and provides a Filters panel for status,
assignee, project, and other fields
> - The panel has no time filter, so users cannot limit the list to
tasks updated in a recent time window or date range
> - Users need a quick way to find recent work (such as the last 3 days)
or inspect a custom date range across both desktop and mobile views
> - This pull request supersedes #21822 on current `master` and adds an
"Updated" section to all Tasks filter panels (Any time, Last 24 hours,
Last 3 days, Last 7 days, Last 30 days, and Custom range), keeps the
filter in the URL, aligns "Last updated" display and sort with the
filter timestamp, and adds an optional `updatedBefore` server list bound
> - The benefit is that users can filter tasks by update time window and
share filtered links cleanly across all Tasks views
## Linked Issues or Issue Description
Refs #21822 (rebased onto current `master` with merge conflicts and
post-pruning test updates resolved).
**What existing behavior does this improve?**
The Tasks list filters (`CoordinatorTasks`, Classic `IssuesList`, and
`LegacyIssuesList`) and the company issue list API (`GET
/api/companies/:companyId/issues`). The Filters panel had status,
responsible, project, creator, and label filters, but no time filter.
**Subsystem affected**
UI (Tasks list filters, sorting, and URL sync) and Server (`GET
/api/companies/:companyId/issues`).
**Current behavior**
Users cannot limit the Tasks list to tasks updated within a recent time
window or custom date range. They must scan rows manually to find recent
activity.
**Proposed behavior**
Add an "Updated" section to the Tasks filter panels with options: Any
time (default), Last 24 hours, Last 3 days, Last 7 days, Last 30 days,
and Custom range (start and end local calendar day). Filter on the same
timestamp shown on each row (`lastActivityAt ?? lastExternalCommentAt ??
updatedAt`), count it as 1 active filter, reset it on Clear, persist it
in the page URL (`updated`, `updatedFrom`, `updatedTo`), and send an
optional `updatedBefore` upper bound to the server for custom ranges.
**Reason and benefit**
Users can narrow large task lists to recent work or a specific date
window in one click, including on phones, and share filtered URLs that
open with the same filter applied.
**Breaking changes**
None. The filter defaults to Any time, and `updatedBefore` is an
optional query parameter.
## What Changed
- `server/src/routes/issues.ts`, `server/src/services/issues.ts`,
`docs/api/issues.md`: add the optional `updatedBefore` query parameter
(`issues.updatedAt < updatedBefore`) with `400` validation matching
`updatedSince`, apply both `updatedSince` and `updatedBefore` in
`blockedInboxIssueConditions` so `attention=blocked` enforces the same
bounds, and document both parameters.
- `ui/src/api/issues.ts`: add optional `updatedBefore` to
`IssueListFilters` and `issueListSearchParams`.
- `ui/src/lib/issue-filters.ts`,
`ui/src/hooks/useIssueUpdatedFilterNow.ts`: add `updatedWithin`,
`updatedFrom`, and `updatedTo` to `IssueFilterState`, plus
`issueUpdatedWithinOptions`, `issueUpdatedWithinPatch`,
`issueUpdatedTime`, `issueUpdatedTimeRange`,
`nextIssueUpdatedFilterExpiryMs`, `issueUpdatedServerBefore`,
`readIssueUpdatedParams`, and `writeIssueUpdatedParams`. Reject
impossible calendar dates (such as `2026-02-31`), swap reversed custom
ranges, count Updated as 1 active filter, filter in `applyIssueFilters`
on the row time, and schedule a single deadline timer when a relative
window (`24h`/`3d`/`7d`/`30d`) is active so tasks age out automatically
across task and inbox lists.
- `ui/src/components/IssueUpdatedRangeInputs.tsx`,
`ui/src/components/IssueFilterPanel.tsx`,
`ui/src/components/IssueFiltersPopover.tsx`: add the "Updated" section
and native date inputs (`text-base md:text-xs` to prevent mobile Safari
focus zoom) across refreshed, streamlined, and legacy filter panels.
- `ui/src/components/IssueColumns.tsx`,
`ui/src/components/TaskList.tsx`, `ui/src/lib/issue-sort.ts`,
`DESIGN.md`: align `TaskList` "Last updated" display and sort with
`issueUpdatedTime`, compute each task's sort key once before sorting
(`O(N)` context reads), and update `DESIGN.md` to document the shared
timestamp rule.
- `ui/src/components/IssuesList.tsx`,
`ui/src/components/LegacyIssuesList.tsx`, `ui/src/pages/Issues.tsx`,
`ui/src/pages/CoordinatorTasks.tsx`: sync `updated`, `updatedFrom`, and
`updatedTo` with the page URL, queue multiple URL filter writes in the
same event so Clear resets filters together, pass `updatedBefore` for
custom ranges while preserving `archiveQueryScope` as the final
`issuesQuery.queryKey` segment for `placeholderData`, and forward
`updatedBefore` to `CoordinatorTasks` and `Issues` `searchFilters`.
- `server/src/__tests__/issue-list-updatedsince-filter-routes.test.ts`,
`ui/src/lib/issue-filters.test.ts`, `ui/src/lib/issue-sort.test.ts`,
`ui/src/lib/inbox.test.ts`,
`ui/src/components/IssueFiltersPopover.updated.test.tsx`: add
embedded-Postgres route tests for `updatedBefore` (strict bound,
combined range, `400` validation), unit tests for time windows/custom
ranges/local time zone/invalid dates/URL params/sort key caching, and
component tests across `legacy`, `streamlined`, and `refreshed` panels.
## Verification
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/issue-list-updatedsince-filter-routes.test.ts`: **1 file,
6/6 tests pass** (embedded Postgres, including `attention=blocked` with
`updatedBefore` and `updatedSince`).
- `pnpm --filter @paperclipai/server typecheck`: **pass** (0 errors
across all server layers).
- `pnpm --filter @paperclipai/ui exec vitest run
src/lib/issue-filters.test.ts src/lib/issue-sort.test.ts
src/lib/inbox.test.ts
src/components/IssueFiltersPopover.updated.test.tsx
src/pages/Issues.test.tsx`: **5 files, 94/94 tests pass** (including
fake-timer relative window expiration and a 500-task bounded
timestamp-read render-cost test).
- `pnpm --filter @paperclipai/ui typecheck`: **pass** (0 errors,
Storybook catalog clean).
- `node scripts/check-token-gates.mjs`: **pass** (all 4 token gates
clean).
- `node scripts/check-test-budget.mjs --files
server/src/__tests__/issue-list-updatedsince-filter-routes.test.ts
ui/src/lib/issue-filters.test.ts ui/src/lib/issue-sort.test.ts
ui/src/lib/inbox.test.ts
ui/src/components/IssueFiltersPopover.updated.test.tsx`: **pass** (110
nightly suites validated, 5 test files checked).
- `pnpm verify --base 2d06567795
--explain`: exited `2` because `DESIGN.md` is a global CI input; focused
server and UI verification ran locally and full PR CI supplies repo-wide
coverage.
## Risks
- Low risk. The Updated filter is off by default (`Any time`), and
`updatedBefore` is optional.
- `IssueFiltersPopover` is shared by Inbox and agent work panels; those
views use `applyIssueFilters`, so the Updated section works consistently
there as well.
- The refreshed `TaskList` "Last updated" column now displays and sorts
by latest activity (`lastActivityAt ?? lastExternalCommentAt ??
updatedAt`), matching the Classic row and the Updated filter.
- Relative windows filter loaded pages in the browser (like other Tasks
filters); because the server sorts by update time descending, recent
tasks load first.
> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.
## Model Used
- Google Gemini (`gemini-3-pro` / Antigravity agentic coding environment
with tool use, shell execution, and embedded Postgres testing), building
on original work from #21822 authored with Anthropic Claude Opus 5.5
(`claude-opus-5-5`).
## 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
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge
---------
Co-authored-by: lucktastic <13757243+lucktastic@users.noreply.github.com>
Co-authored-by: Paperclip <noreply@paperclip.ing>
This commit is contained in:
27 files changed
+1035
-56
No files matched your search
@@ -173,4 +173,100 @@ describeEmbeddedPostgres("issue list routes updatedSince filter", () => {
|
||||
error: "updatedSince must be a valid ISO 8601 timestamp when provided",
|
||||
});
|
||||
});
|
||||
|
||||
it("returns only issues updated before an updatedBefore timestamp", async () => {
|
||||
const companyId = randomUUID();
|
||||
const olderIssueId = randomUUID();
|
||||
const edgeIssueId = randomUUID();
|
||||
const newerIssueId = randomUUID();
|
||||
const before = new Date("2026-07-01T00:00:00.000Z");
|
||||
|
||||
await db.insert(companies).values({
|
||||
id: companyId,
|
||||
name: "Paperclip",
|
||||
issuePrefix: uniqueIssuePrefix(),
|
||||
requireBoardApprovalForNewAgents: false,
|
||||
});
|
||||
await seedCloudTenantMember(companyId);
|
||||
await db.insert(issues).values([
|
||||
{ id: olderIssueId, companyId, title: "Older issue", status: "todo", priority: "medium", updatedAt: new Date("2026-06-30T23:59:59.000Z") },
|
||||
{ id: edgeIssueId, companyId, title: "Edge issue", status: "todo", priority: "medium", updatedAt: before },
|
||||
{ id: newerIssueId, companyId, title: "Newer issue", status: "todo", priority: "medium", updatedAt: new Date("2026-07-02T00:00:00.000Z") },
|
||||
]);
|
||||
|
||||
const app = createApp(companyId);
|
||||
const res = await request(app)
|
||||
.get(`/api/companies/${companyId}/issues`)
|
||||
.query({ updatedBefore: before.toISOString(), limit: "20" });
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||
expect(res.body.map((issue: { id: string }) => issue.id)).toEqual([olderIssueId]);
|
||||
|
||||
const between = await request(app)
|
||||
.get(`/api/companies/${companyId}/issues`)
|
||||
.query({ updatedSince: "2026-06-01T00:00:00.000Z", updatedBefore: "2026-07-03T00:00:00.000Z", limit: "20" });
|
||||
expect(between.status, JSON.stringify(between.body)).toBe(200);
|
||||
expect(between.body.map((issue: { id: string }) => issue.id).sort()).toEqual([olderIssueId, edgeIssueId, newerIssueId].sort());
|
||||
});
|
||||
|
||||
it("returns 400 for a malformed updatedBefore timestamp", async () => {
|
||||
const companyId = randomUUID();
|
||||
await db.insert(companies).values({
|
||||
id: companyId,
|
||||
name: "Paperclip",
|
||||
issuePrefix: uniqueIssuePrefix(),
|
||||
requireBoardApprovalForNewAgents: false,
|
||||
});
|
||||
await seedCloudTenantMember(companyId);
|
||||
|
||||
const app = createApp(companyId);
|
||||
const res = await request(app)
|
||||
.get(`/api/companies/${companyId}/issues`)
|
||||
.query({ updatedBefore: "not-a-date", limit: "20" });
|
||||
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body).toMatchObject({
|
||||
error: "updatedBefore must be a valid ISO 8601 timestamp when provided",
|
||||
});
|
||||
});
|
||||
|
||||
it("applies updatedBefore and updatedSince when attention=blocked", async () => {
|
||||
const companyId = randomUUID();
|
||||
const olderBlockedId = randomUUID();
|
||||
const edgeBlockedId = randomUUID();
|
||||
const newerBlockedId = randomUUID();
|
||||
const before = new Date("2026-07-01T00:00:00.000Z");
|
||||
|
||||
await db.insert(companies).values({
|
||||
id: companyId,
|
||||
name: "Paperclip",
|
||||
issuePrefix: uniqueIssuePrefix(),
|
||||
requireBoardApprovalForNewAgents: false,
|
||||
});
|
||||
await seedCloudTenantMember(companyId);
|
||||
await db.insert(issues).values([
|
||||
{ id: olderBlockedId, companyId, title: "Older blocked", status: "blocked", priority: "medium", updatedAt: new Date("2026-06-30T23:59:59.000Z") },
|
||||
{ id: edgeBlockedId, companyId, title: "Edge blocked", status: "blocked", priority: "medium", updatedAt: before },
|
||||
{ id: newerBlockedId, companyId, title: "Newer blocked", status: "blocked", priority: "medium", updatedAt: new Date("2026-07-02T00:00:00.000Z") },
|
||||
]);
|
||||
|
||||
const app = createApp(companyId);
|
||||
const res = await request(app)
|
||||
.get(`/api/companies/${companyId}/issues`)
|
||||
.query({ attention: "blocked", updatedBefore: before.toISOString(), limit: "20" });
|
||||
|
||||
expect(res.status, JSON.stringify(res.body)).toBe(200);
|
||||
expect(res.body.map((issue: { id: string }) => issue.id)).toEqual([olderBlockedId]);
|
||||
|
||||
const between = await request(app)
|
||||
.get(`/api/companies/${companyId}/issues`)
|
||||
.query({
|
||||
attention: "blocked",
|
||||
updatedSince: "2026-06-30T23:59:59.000Z",
|
||||
updatedBefore: "2026-07-02T00:00:00.000Z",
|
||||
limit: "20",
|
||||
});
|
||||
expect(between.status, JSON.stringify(between.body)).toBe(200);
|
||||
expect(between.body.map((issue: { id: string }) => issue.id)).toEqual([edgeBlockedId]);
|
||||
});
|
||||
});
|
||||
@@ -8855,6 +8855,7 @@ export function issueRoutes(
|
||||
const assigneeAgentFilterRaw = req.query.assigneeAgentId;
|
||||
let assigneeAgentId: string | null | undefined;
|
||||
const rawUpdatedSince = req.query.updatedSince as string | undefined;
|
||||
const rawUpdatedBefore = req.query.updatedBefore as string | undefined;
|
||||
|
||||
if (
|
||||
assigneeUserFilterRaw === "me" &&
|
||||
@@ -8977,6 +8978,15 @@ export function issueRoutes(
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
rawUpdatedBefore !== undefined &&
|
||||
!Number.isFinite(new Date(rawUpdatedBefore).getTime())
|
||||
) {
|
||||
res.status(400).json({
|
||||
error: "updatedBefore must be a valid ISO 8601 timestamp when provided",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const uuidQuery = parseIssueListUuidQueryParams(req.query);
|
||||
if (!uuidQuery.ok) {
|
||||
res.status(422).json({ error: uuidQuery.error });
|
||||
@@ -9040,6 +9050,7 @@ export function issueRoutes(
|
||||
afterId: req.query.afterId as string | undefined,
|
||||
sortDir: sortDir === "asc" || sortDir === "desc" ? sortDir : undefined,
|
||||
updatedSince: rawUpdatedSince,
|
||||
updatedBefore: rawUpdatedBefore,
|
||||
};
|
||||
// readCondition is a Drizzle SQL object with cyclic internal references;
|
||||
// actor identity already scopes the coordinator key, so only serializable
|
||||
|
||||
@@ -1949,6 +1949,8 @@ export interface IssueFilters {
|
||||
sortDir?: "asc" | "desc";
|
||||
/** ISO 8601 timestamp — only return issues with updatedAt strictly after this value. */
|
||||
updatedSince?: string;
|
||||
/** ISO 8601 timestamp — only return issues with updatedAt strictly before this value. */
|
||||
updatedBefore?: string;
|
||||
}
|
||||
|
||||
type IssueRow = typeof issues.$inferSelect & { displayStatus?: IssueDisplayStatus; externalConversationState?: "active" | "waiting" | null };
|
||||
@@ -6832,6 +6834,18 @@ async function blockedInboxIssueConditions(
|
||||
),
|
||||
);
|
||||
}
|
||||
if (filters?.updatedSince) {
|
||||
const since = new Date(filters.updatedSince);
|
||||
if (Number.isFinite(since.getTime())) {
|
||||
conditions.push(gt(issues.updatedAt, since));
|
||||
}
|
||||
}
|
||||
if (filters?.updatedBefore) {
|
||||
const before = new Date(filters.updatedBefore);
|
||||
if (Number.isFinite(before.getTime())) {
|
||||
conditions.push(lt(issues.updatedAt, before));
|
||||
}
|
||||
}
|
||||
if (
|
||||
filters?.excludeRoutineExecutions &&
|
||||
!filters?.originKind &&
|
||||
@@ -8759,6 +8773,12 @@ export function issueService(db: Db) {
|
||||
conditions.push(gt(issues.updatedAt, since));
|
||||
}
|
||||
}
|
||||
if (filters?.updatedBefore) {
|
||||
const before = new Date(filters.updatedBefore);
|
||||
if (Number.isFinite(before.getTime())) {
|
||||
conditions.push(lt(issues.updatedAt, before));
|
||||
}
|
||||
}
|
||||
if (
|
||||
filters?.excludeRoutineExecutions &&
|
||||
!filters?.originKind &&
|
||||
|
||||
Reference in new issue
Block a user