Repository navigation
Description
Summary
Archiving a session rewrites time_updated, and the session list is ordered by
time_updated with no archived filter by default. Any archive sweep therefore moves
every archived session to the top: on my DB the default page is 47 archived sessions
out of 50.
Measured on v2.3.0 (macOS, read-only copy of the live DB)
- 499 sessions across 41 projects; 176 archived.
- All 176 have
time_updated == time_archived. - The 176 came from one bulk loop,
PATCH /api/session/{id} {"archived":true}, at
2026-11-14T11:01:29–11:01:33Z. - The endpoint's default page is "the newest 50 sessions" (from the served OpenAPI).
In that ordering 47 of the 50 are archived: the three live sessions sit at
positions 1–3, and positions 4–50 are all archive.
-- copy of the DB, opened mode=ro&immutable=1
select count(*) from session_v2 where time_archived is not null and time_archived > 0;
-- 176
select count(*) from session_v2 where time_archived = time_updated and time_archived > 0;
-- 176
select count(*) from (
select time_archived from session_v2 order by time_updated desc limit 50
) where time_archived is not null and time_archived > 0;
-- 47In the app the archived sessions sit at the top of the list, ahead of everything
actually recent.
All fixes are small
GET /api/session already accepts archived (true | false) and project, so
any of these works:
- server — treat an absent
archivedparam asfalse, so archived sessions
are opt-in; - client — pass
archived=false(andproject=<id>when the list is scoped)
on the default list request; - ordering — order the default list by the last message instead of by a session
column that bookkeeping rewrites (same direction as session: idle sessions gain time_updated after a service restart and jump to the top of the list #63920), at the cost of a join.
One thing I could not measure: the desktop's list request parameters are not in the
retained server log, so I am not claiming which side drops them. #58364 was exactly
this shape on the TUI — the API filter existed and the picker did not pass it — and
was closed as completed on 2026-11-02. This is the same problem on the desktop side
and in the default API response.
Related
- tui: archived sessions still appear in the session picker (Ctrl+O) #58364 — TUI picker showed archived sessions although
?archived=falseworked
(closed, completed) - v2: --continue reopens a session whose tab was closed; picks by time.updated with no closed/archived filter #52655 —
--continuealso picks bytime.updatedwith no archive filter - [FEATURE]: opencode session archive/unarchive subcommands and an archived filter on session list #63518 — CLI
session archive/unarchiveand an archived filter forsession list - [FEATURE]: Pin Archived at the bottom of the Inbox and collapse it by default #61292, [FEATURE]: Collapsible project groups and archive filter for the session sidebar #60581 — sidebar layout for an archived section
- session: idle sessions gain time_updated after a service restart and jump to the top of the list #63920 — separate: an aborted browser attach also rewrites
time_updated. Fixing
that does not help here; the archive sweep writes on purpose.
I'm happy to prepare a patch if you say which side the default should live on.
Activity
opencodejr commentedon Nov 14, 2026
Thanks for the careful measurements and the offer of a patch, @ValDagon.
You're asking for
GET /api/sessionto stop putting archived sessions on the default page. That could mean leaving them out unlessarchivedis passed, or ordering the default list by something that archiving doesn't rewrite.From the code I read, this is how it currently works:
time_updatedalong withtime_archivedon purpose (packages/core/src/session/projector.ts), and unarchiving does the same.archivedis passed (packages/core/src/session/store.ts). So the default newest-50 page includes archived sessions, as you found.Since this is the current design, I've filed it as a feature request. Maintainers will decide whether the default belongs on the server, in the clients, or in the ordering, so please hold off on the patch until they've weighed in. I can't promise an outcome.
On the app side, I couldn't find where archived sessions would show. The views I read all leave them out:
packages/app/src/home/sessions/index.ts).archived: false.If a specific view in the desktop app on 2.3.0 does list archived sessions at the top, a comment naming that view (Home, the sidebar, the palette…) and a screenshot would help. That part would then be handled as a bug.
Related issues:
--continuepicks bytime.updatedwithout an archived filtertime_updatedrewritten after a service restarttime.updatedsession listValDagon commentedon Nov 14, 2026
Correction on the desktop part of this report
The API numbers stand: the default page of
GET /api/session(newest 50, noparameters) is 47/50 archived, because archiving stamps
time_updated.The line "In the app the archived sessions sit at the top of the list" is not
something I checked on a screen. It came from that API result, and I should have
said so instead of presenting it as an observation.
Reading
dev, no ordinary list shows them:time.archived !== undefined, both on load and on merge(
packages/app/src/home/sessions/index.ts).archived: false(
packages/app/src/shell/commands/palette.ts).Archived dialog, which loads them through a separate query
(
packages/app/src/shell/titlebar/inbox.tsx,inbox-model.ts).So "the client simply does not pass it" was wrong too.
What I am still asking for is narrower than what I wrote: the default response of
GET /api/sessionreturns archived rows and orders by a column that archivingrewrites, and the 47/50 page is what any consumer of that default gets. Treat the
desktop-UI half as withdrawn — if a maintainer wants it reopened, I will reproduce
on 2.3.0 and bring a screenshot.
oliver-mee commentedon Nov 25, 2026
Reproduced on v2.4.1 (Linux, fresh data directory).
time.updated == time.archived, 29s after that session was created.GET /api/sessionreturned the archived session first straight away.time.updated.time.archivedis cleared andtime.updatedmoves forward again, so restoring a session sends it to the top too.opencode session list --max-count 10shows the archived session at row 1 with the archive timestamp. Nothing marks it as archived and there is no flag to exclude it.time.updatedalone, so the reorder happens once per state change, not on every sweep.The query filter works correctly for both
?archived=trueand?archived=false, so the client and server options in the report both have what they need.