feat(sidebar): add last activity task sorting (#2762)

This commit is contained in:
Carlos Florêncio
2026-08-18 10:15:42 +01:00
committed by GitHub
parent 270ddbff8f
commit 704f652f30
74 changed files with 2525 additions and 162 deletions
+1
View File
@@ -233,6 +233,7 @@ Subscription quota tracking and per-agent cheap-model profile routing.
| [external-vcs-file-links](ui/external-vcs-file-links.md) | shipped |
| [task-listing-display-preferences](ui/task-listing-display-preferences.md) | shipped |
| [sidebar-archived-filter](ui/sidebar-archived-filter.md) | draft |
| [sidebar-last-activity-sort](ui/sidebar-last-activity-sort.md) | draft |
| [task-workspace-content-search](ui/task-workspace-content-search.md) | shipped |
| [file-tree-chat-context](ui/file-tree-chat-context.md) | shipped |
| [task-review-shortcut](ui/task-review-shortcut.md) | approved |
@@ -1,7 +1,7 @@
---
status: approved
created: 2026-08-01
updated: 2026-08-15
updated: 2026-08-17
owner: kandev
---
@@ -52,6 +52,7 @@ The initial contract is:
| Field | Meaning | Bound |
| ---------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------ |
| `revision`, `updated_at` | Monotonic task-local version and projection time | Constant |
| `last_activity_at` | Latest durable task, user-prompt, or turn milestone | Constant |
| `primary_session` | Primary session ID and lifecycle state | One session |
| `foreground_activity`, `active_subagent_count` | Existing task-level busy aggregate | Constant |
| `pending_action` | `permission`, `clarification`, or absent | Constant |
@@ -115,6 +116,14 @@ remain during migration, but switchers use the summary when present.
- A semantic no-op does not increment `revision` or emit an update.
- Clients ignore a summary delta whose revision is not newer than the stored
revision.
- `last_activity_at` is separate from projection freshness. Task creation,
persisted task mutations, user-authored prompts, and turn start or completion
advance it by source time. Focus, subscriptions, Git or pull-request polling,
queue bookkeeping, summary repair, and streamed chunks do not advance it.
- Missing and older summaries rebuild `last_activity_at` in one batch from
task, user-message, and turn records. Live and rebuilt values use a monotonic
maximum, so replay and repair cannot move activity backward. See
[ADR-2026-08-17-separate-task-activity-from-summary-freshness](../../decisions/2026-08-17-separate-task-activity-from-summary-freshness.md).
## API and event surface
@@ -254,6 +263,9 @@ intermediate replacement.
changes its Git tree, or receives a PR update, **WHEN** its summary revision
arrives, **THEN** desktop and mobile rows update without a session
subscription.
- **GIVEN** an idle task receives Git or pull-request summary changes, **WHEN**
its replacement summary arrives, **THEN** `updated_at` can advance while
`last_activity_at` remains unchanged.
- **GIVEN** a recoverable error is dismissed or followed by a newer agent
response, **WHEN** the projector processes that occurrence, **THEN** the
independent error indicator clears on both task switchers.
+163
View File
@@ -0,0 +1,163 @@
---
status: draft
created: 2026-08-17
updated: 2026-08-17
owner: kandev
---
# Sidebar Last Activity Sort
## Why
Saved sidebar views can sort tasks by **Updated**. That value currently follows
task-status summary freshness. Background pull-request updates can refresh many
idle rows together, so this order does not answer which tasks a user or agent
worked on most recently.
Users need a separate **Last activity** option that remains stable during
background status refreshes.
## What
- Desktop and mobile sidebar view editors offer **Last activity** as a sort
option.
- The saved-view wire key is `lastActivityAt`. The key persists in saved views
and in-flight drafts through user settings, boot hydration, and live settings
updates.
- Ascending order places the oldest activity first. Descending order places the
newest activity first.
- Equal timestamps retain the existing input order. Sorting does not introduce
row movement for a tie.
- The existing `updatedAt` key and **Updated** label remain valid. Existing
saved views keep their current behavior.
- The built-in view and new-view defaults do not change.
- When a view sorts by **Last activity**, each row displays that activity time.
Other sort modes retain the existing row time behavior.
Decision:
[ADR-2026-08-17-separate-task-activity-from-summary-freshness](../../decisions/2026-08-17-separate-task-activity-from-summary-freshness.md).
## Activity definition
`last_activity_at` is the greatest known timestamp from these durable actions:
| Source | Activity time |
|---|---|
| Task creation | `tasks.created_at` |
| Persisted task mutation | `tasks.updated_at` |
| User-authored prompt, including a queued prompt | message `created_at` |
| Agent turn starts | turn `started_at` |
| Agent turn completes | turn `completed_at` |
The following events do not advance activity:
- opening, focusing, or subscribing to a task or session
- Git or pull-request polling and reconciliation
- queued-prompt count changes and other queue bookkeeping
- status-summary rebuilds or transport delivery
- session metadata maintenance without a user prompt or agent turn
- streamed agent chunks inside an already-started turn
A task-state or workflow-placement change counts because it is a persisted task
mutation. A foreground-activity publication that carries an unchanged task
timestamp does not advance activity.
## Data model and derivation
- `TaskStatusSummary` gains optional semantic field
`last_activity_at: RFC3339 timestamp`.
- `revision` and `updated_at` keep their existing meanings: task-local summary
version and projection freshness.
- A change to `last_activity_at` is semantic. It advances the summary revision
and uses the existing complete-replacement event.
- Live projection consumes both `task.updated` and `task.state_changed`, because
some persisted state transitions publish only the latter. It takes the
monotonic maximum of the stored value and a source event timestamp. An older
replay cannot move activity backward.
- Initial load and repair use one batched query for all requested task IDs. The
query combines task, user-message, and turn timestamps without one query per
task.
- Repair updates older summaries that lack the field. It preserves a stored
activity time that is newer than the rebuilt durable maximum.
- A missing summary or an older backend falls back to task `updated_at`, then
task `created_at`. The row remains sortable during partial recovery.
## API and persistence
The existing task surfaces carry the additive field:
- boot state and task-list snapshots use `status_summary.last_activity_at`
- `task.status_summary.updated` uses the same complete summary payload
- sidebar views and drafts persist sort key `lastActivityAt` through the
existing user-settings JSON contract
No new endpoint or WebSocket action is required. The summary remains bounded
and contains no transcript, file, or provider payload.
## Provider refresh stability
Equivalent GitHub status snapshots from the REST feedback path and the batched
GraphQL poller must produce one canonical task-PR state. A semantic no-op does
not emit `github.task_pr.updated`.
GitHub sync diagnostics record the names of changed semantic fields without
recording field values or provider content. This evidence makes future
cross-path oscillation visible without exposing sensitive data.
Provider changes can advance summary `updated_at`. They never advance
`last_activity_at`.
## Responsive behavior
Desktop uses the existing Tasks section view editor. Phones use the existing
task-switcher drawer and its shared view editor. Both surfaces use the same
sort key, comparator, draft, and saved setting.
The option stays inside the existing sort selector. It adds no mobile route,
drawer, popover, or scroll owner. The current task list remains the only
vertical scroll body.
## Failure modes
- If activity backfill fails, Kandev keeps the last valid summary and uses the
frontend fallback. A later list load or source event retries convergence.
- If a summary event is dropped, normal task-list hydration restores the
complete value.
- If user-settings sync fails, the existing saved-view rollback and error
treatment restores the previous view and draft.
- An unknown stored sort key keeps the existing migration fallback to Status.
`lastActivityAt` is added to the known-key set before it is offered in the
editor.
## Scenarios
- **GIVEN** several idle tasks receive pull-request status refreshes, **WHEN** a
view sorts by **Last activity**, **THEN** their order and displayed activity
times do not change.
- **GIVEN** a task with an older summary refresh but a newer user prompt,
**WHEN** the view sorts descending by **Last activity**, **THEN** that task
appears before a task with newer provider status but older activity.
- **GIVEN** a user sends a queued prompt, **WHEN** the prompt is stored,
**THEN** the task activity advances before the agent begins that turn.
- **GIVEN** an agent begins and completes a turn, **WHEN** each milestone is
projected, **THEN** activity advances at start and again at completion but
not for every streamed chunk.
- **GIVEN** an existing saved view sorted by **Updated**, **WHEN** Kandev is
upgraded, **THEN** the view keeps that sort and its current order.
- **GIVEN** a saved view sorted by **Last activity**, **WHEN** the page reloads,
**THEN** the selection, direction, order, and row timestamps persist.
- **GIVEN** a phone viewport, **WHEN** the user selects **Last activity** in the
task-switcher drawer, **THEN** the same order is applied and the selector
remains touch-reachable and viewport-contained.
## Out of scope
- Replacing or renaming the existing **Updated** sort.
- Changing the built-in view or new-view defaults.
- Sorting the Kanban board, Office task list, command panel, or quick-chat tabs.
- Treating passive focus, provider polling, or raw stream chunks as activity.
- Adding a general task activity feed or audit log.
## Implementation plan
- [Sidebar Last Activity Sort](../../plans/sidebar-last-activity-sort/plan.md)