Skip to content

feat(server): include message times in session list - #62671

Open
dluc wants to merge 6 commits into
anomalyco:devfrom
dluc:session-message-time
Open

dluc wants to merge 6 commits into
anomalyco:devfrom
dluc:session-message-time

Conversation

@dluc

@dluc dluc commented Nov 8, 2026 •

Copy link
Copy Markdown

Issue for this PR

#62655

Type of change

  • New feature

What does this PR do?

Adds the last stored user and assistant message times to session lists, avoiding per-session message requests.

Experimental

Return experimental.time.lastUserMessage and lastAssistantMessage by default in session lists. Each is a creation timestamp in milliseconds, or null when absent. No flag or client opt-in is required. The fields are specific to list items; the shared Session.Info and import schemas are unchanged.

Database performance

The existing list query selects the page first, then performs two indexed lookups per session in the same SQL statement. It does not read message content or require a migration. The trade-off is extra indexed work for session-list requests; internal store operations that do not need the timestamps avoid it.

Pagination

Ordering and cursors remain based on time.updated and session ID. This avoids changing existing behavior, but metadata changes can still affect ordering and concurrent updates can shift pages. Message-activity ordering is a separate follow-up discussed in the feature request.

Semantics

“Last” follows stored timeline order. Assistant timestamps include tool-only steps and are not necessarily the last visible chat reply. The two separate fields let clients choose how to interpret activity without fetching message content.

How did you verify your code works?

  • bun run check; focused server and Effect-client tests.
  • Isolated live HTTP test with synthetic sessions, pagination, and a server restart.

Visual

SVG source (API-only change)
<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72">
  <style>
    @media (prefers-reduced-motion: no-preference) { .pulse { animation: pulse 2s infinite; } }
    @keyframes pulse { 50% { opacity: .45; } }
  </style>
  <g fill="currentColor">
    <rect x="12" y="12" width="216" height="48" rx="8" opacity=".1"/>
    <rect x="24" y="23" width="62" height="7" rx="3.5" opacity=".45"/>
    <rect x="24" y="42" width="62" height="7" rx="3.5" opacity=".45"/>
    <rect class="pulse" x="112" y="23" width="98" height="7" rx="3.5" opacity=".9"/>
    <rect class="pulse" x="112" y="42" width="72" height="7" rx="3.5" opacity=".7"/>
  </g>
</svg>

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Fixes #62655

Public API: GET /api/session items become Session.ListInfo (Session.Info plus optional experimental.time.lastUserMessage/lastAssistantMessage); backwards compatible

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 8, 2026

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new timestamps work as described. I imported a session with one user message and one assistant message into an in-memory server. On the base, GET /api/session has no experimental field. With this PR it returns lastUserMessage: 6000, lastAssistantMessage: 7000 for that session and null/null for an empty one, and GET /api/session/:id still leaves the field out. The core, server and client tests pass, schema/core/client type-check cleanly, and bun run generate produces no changes.

Public API: adds optional experimental.time.lastUserMessage / experimental.time.lastAssistantMessage (milliseconds or null) to Session.Info in the OpenAPI spec and generated client types. It's filled in only by GET /api/session. The same optional field also appears in the input type of POST /api/experimental/session/import. This is backwards compatible: nothing is removed or renamed, and existing clients can ignore the new field.

Two concerns, both inline: where the field sits on the shared Session.Info schema, and the size of the 101-session server test.

Fixes #62655

Comment thread packages/schema/src/session.ts Resolved
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier concerns are fixed: the timestamps now live on a list-only Session.ListInfo, so Session.Info, GET /api/session/:id and the import input no longer carry them, and the paging test is down to 3 sessions. I re-ran my server probe: the list returns lastUserMessage/lastAssistantMessage as expected, and get-by-id leaves them out. The core, server, client and protocol tests pass, and bun run generate produces no changes.

Public API: GET /api/session items change from Session.Info to a new Session.ListInfo schema, which is Session.Info plus optional experimental.time.lastUserMessage / lastAssistantMessage (milliseconds or null). Generated promise client: adds a SessionListInfo type and SessionsResponse.data becomes Array<SessionListInfo>. Effect client: SessionListOutput.data becomes ReadonlyArray<Session.ListInfo>. All of this is backwards compatible: the new types are supersets of the old ones, so existing callers that treat list items as SessionInfo / Session.Info keep type-checking and working.

No further concerns.

Fixes #62655

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only new commit merges dev and doesn't touch this PR's files. After the merge, the session list, session import and OpenAPI tests still pass. Both earlier points (the list-only Session.ListInfo and the smaller paging test) were already addressed in d1bc669. Public API is the same as in my last review: GET /api/session items become Session.ListInfo (Session.Info plus optional experimental.time.lastUserMessage / lastAssistantMessage), which is backwards compatible. No new concerns.

This branch has not been deployed

No deployments
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.

[FEATURE]: Add last chat message timestamp to GET /api/session

1 participant