You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
V2: session.time_updated goes stale during active turns, breaking recency sort #36893
The session row's time_updated is only bumped by a small set of projected events, so a session that is actively streaming an assistant turn keeps a stale timestamp. Session lists sort by time_updated, so the most active session can appear old.
Evidence
Session ses_09f05df32ffewmX7otmzvMPbKb (next channel), 2026-07-14: session metadata time_updated remained at 14:43:36Z while durable events (steps, tools, text, executions) continued for more than an hour afterward. Event persistence itself was healthy and contiguous.
Where
packages/core/src/session/projector.ts sets time_updated only for:
session creation
input admitted
agent selected
model selected
title updated
revert set/cleared
Step, tool, text, reasoning, compaction, and execution lifecycle events do not touch it.
packages/core/src/session.ts:414 sorts session lists by SessionTable.time_updated, so the staleness is user-visible as wrong recency ordering (for example in session pickers and the web app list).
Suggested Direction
Bump time_updated (to event.created) when projecting execution and step lifecycle events — session.execution.started/succeeded/failed at minimum, since they bracket every turn cheaply. Updating on every projected session event would also be correct but touches the row far more often for streaming deltas.
A regression test: project an admitted input followed by step/tool/execution events and assert time_updated equals the terminal execution event's timestamp.
I rechecked this on current dev (c69abee). The projector still does not bump time_updated for execution/step/tool/text events, but SessionV2.list now orders by time_created, so the reported recency-sort path no longer matches the current implementation. Should this be reframed as restoring last-activity ordering (and then bumping time_updated on execution lifecycle events), or considered superseded by the created-time ordering change?
This also affects transcript viewers that use session.time_updated as a change-detection signal for the container.
Without a reliable session-level timestamp that envelopes child writes, viewers have to periodically scan message and part rows across every session to determine which ones changed, and that doesn't scale on large databases where OpenCode activity leads to 200-700% CPU usage, because one active session triggers a full re-read of every session's children.
Bumping time_updated on execution lifecycle events as suggested here would let viewers skip unchanged sessions using just the session row, without periodic full-table verification passes.
I'd like to work on this. My understanding is that the projector should bump session.time_updated (to event.created) when projecting execution lifecycle events (session.execution.started/succeeded/failed), with a regression test asserting time_updated matches the terminal execution event. Validation would be bun typecheck and the projector tests in packages/core.
One question first: since SessionV2.list now orders by time_created (per the comment above), should the fix also restore last-activity ordering in that list, or just keep time_updated accurate as a change-detection signal for viewers?
Can I pick this up? If lancy69 is still on it, no worries, happy to step back.
Still repros on dev (228e909). The step started/ended/failed handlers in the projector only update the message row, they never touch time_updated on the session row. So it just sits at whatever it was before the turn started.
Plan is to set time_updated from the event timestamp in those three handlers and add a test. Not going to touch the list sort order unless you want that changed too.
#43847 is against the old v2 branch btw, so it won't merge as is.
Hello @Namit2003! I was waiting for an approval from any maintainer. I was not sure if I can open a PR directly without being assigned to, so I didn't touch it till now. You may pick this up if you like :)
Activity
rasitakyol commentedon Jul 16, 2026
I rechecked this on current dev (c69abee). The projector still does not bump time_updated for execution/step/tool/text events, but SessionV2.list now orders by time_created, so the reported recency-sort path no longer matches the current implementation. Should this be reframed as restoring last-activity ordering (and then bumping time_updated on execution lifecycle events), or considered superseded by the created-time ordering change?
rodboev commentedon Sep 1, 2026
This also affects transcript viewers that use
session.time_updatedas a change-detection signal for the container.Without a reliable session-level timestamp that envelopes child writes, viewers have to periodically scan message and part rows across every session to determine which ones changed, and that doesn't scale on large databases where OpenCode activity leads to 200-700% CPU usage, because one active session triggers a full re-read of every session's children.
Bumping
time_updatedon execution lifecycle events as suggested here would let viewers skip unchanged sessions using just the session row, without periodic full-table verification passes.lancy69 commentedon Sep 2, 2026
I'd like to work on this. My understanding is that the projector should bump
session.time_updated(toevent.created) when projecting execution lifecycle events (session.execution.started/succeeded/failed), with a regression test assertingtime_updatedmatches the terminal execution event. Validation would bebun typecheckand the projector tests inpackages/core.One question first: since
SessionV2.listnow orders bytime_created(per the comment above), should the fix also restore last-activity ordering in that list, or just keeptime_updatedaccurate as a change-detection signal for viewers?Namit2003 commentedon Sep 14, 2026
Can I pick this up? If lancy69 is still on it, no worries, happy to step back.
Still repros on dev (228e909). The step started/ended/failed handlers in the projector only update the message row, they never touch time_updated on the session row. So it just sits at whatever it was before the turn started.
Plan is to set time_updated from the event timestamp in those three handlers and add a test. Not going to touch the list sort order unless you want that changed too.
#43847 is against the old v2 branch btw, so it won't merge as is.
lancy69 commentedon Sep 15, 2026
Hello @Namit2003! I was waiting for an approval from any maintainer. I was not sure if I can open a PR directly without being assigned to, so I didn't touch it till now. You may pick this up if you like :)
rodboev commentedon Sep 15, 2026
As far as I know you don't need approval; you can open PRs here. If you can fix, that'd be great.
Namit2003 commentedon Sep 15, 2026
Thanks both. Will get a PR up against dev shortly.
fix(core): bump session time_updated on step lifecycle events
bilogic commentedon Oct 7, 2026
Will this move sessions to the top only if:
and not when streaming/working?
jlongster commentedon Oct 7, 2026
Merged the PR, sorry for the delay. @bilogic it'll update it whenever something changes