Skip to content

List tasks: GET /v1/tasks, newest first - #217

Merged
jinxi97 merged 1 commit into
mainfrom
jinxi97/new-task-api-v3
Oct 27, 2026
Merged

jinxi97 merged 1 commit into
mainfrom
jinxi97/new-task-api-v3

Conversation

@jinxi97

@jinxi97 jinxi97 commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

First of two stacked PRs that switch the console from sessions to tasks. The console's Tasks page needs a list, and the api didn't have one. The second PR (the console and the README) will be based on this one.

Changes

  • core: ListTasksRequest (namespace, limit, after?).
  • Store interface: listTasks returns one namespace's tasks, newest first.
  • pg store: listTasks uses the same keyset cursor as listSessions and listAgentConfigs. An unknown cursor, or one from another namespace, throws "unknown cursor".
  • Migration 20261027233451_add_tasks_list_scan: an index on tasks (namespace, created_at, id), the same as sessions_list_scan. The table's id is random, so without it every page would read and sort the namespace's whole task history. The migration's hash is pinned.
  • api: GET /v1/tasks?namespace=&limit=&after= returns the usual list envelope, { data, hasMore, lastId? }. An out-of-range limit or an unresolvable cursor gets a 400.

A session created directly with POST /v1/sessions isn't a task, so it doesn't appear in this list. That route stays in the api; only the console stops using it.

Tests

  • 6 conformance tests:
    • newest first, with the same rows getTask returns
    • limit and the cursor
    • paging with identical timestamps neither drops nor repeats a row
    • namespace scoping
    • a directly created session is not listed
    • an unknown or foreign cursor is rejected
  • 4 route tests: the envelope, paging through the whole list, an empty namespace, and the 400s.
  • pnpm typecheck, pnpm format:check and pnpm test pass.
  • The conformance suite also passes against a real postgres:16 container (109/109).

🤖 Generated with Claude Code

The console's Tasks page needs a list. listTasks pages a namespace's
tasks newest first with the same keyset cursor as sessions and agent
configs, and a new migration adds the (namespace, created_at, id) index
that keeps a page from sorting the whole history. A session created
directly is not a task and is not listed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jinxi97
jinxi97 merged commit 93c4513 into main Oct 27, 2026
3 checks passed
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