Skip to content

feat(cli): Add junior conversations list - #2234

Closed
sentry-junior[bot] wants to merge 1 commit into
feat/conversation-list-cursorfrom
feat/conversations-list-cli
Closed

sentry-junior[bot] wants to merge 1 commit into
feat/conversation-list-cursorfrom
feat/conversations-list-cli

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

PR 2 of #2231. Stacked on #2232, which adds the list cursor and dashboardUrl. Merge #2232 first.

junior conversations list prints one JSON line for each active root Conversation of the token owner:

pnpm exec junior conversations list --base-url https://junior.example.com --token "$JUNIOR_API_TOKEN"
{"id":"slack:C123:1700000000.000100","title":"Deploy question","dashboardUrl":"https://junior.example.com/conversations/slack%3AC123%3A1700000000.000100","locationUrl":"https://example.slack.com/archives/C123/p1700000000000100"}
  • Follows nextCursor from GET /api/conversations until no pages remain.
  • dashboardUrl and locationUrl come from the API. The CLI does not build dashboard paths, so --base-url only says where the API is. Both fields are null when the API has no link.
  • The names match the API. locationUrl is provider-neutral, so the output does not put a provider name like slackUrl in core.
  • --token falls back to JUNIOR_API_TOKEN. Like briefs, the command skips app plugin loading, so it needs only a token.
  • apiUrl and fetchJson move from briefs.ts to cli/api-client.ts, and optionValue moves to cli/run.ts. Both token-only commands now use the same helpers.
  • New docs page: cli/conversations.md, added to the CLI sidebar.

Notes for review:

Tests: tests/component/conversations-cli.test.ts runs the command against the real API (createJuniorApi()) and SQL, with 51 conversations, so it must follow one cursor. It checks the JSONL fields, a dashboardUrl with a /dashboard base path that the API URL does not have, the location link, and the usage error. I checked that the test fails when the command does not follow nextCursor. pnpm lint, typecheck, and the docs build pass.

via @dingsdax.

--

View Junior Session [Sentry]

@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 7, 2026 3:22pm UTC

Request Review

@github-actions github-actions Bot added the risk: high PR risk score: high label Oct 26, 2026
@dingsdax
dingsdax marked this pull request as draft October 28, 2026 20:53
@sentry-junior
sentry-junior Bot force-pushed the feat/conversations-list-cli branch from f1a7cbd to fd2a003 Compare October 29, 2026 09:46
@sentry-junior
sentry-junior Bot force-pushed the feat/conversations-list-cli branch from fd2a003 to 29254f6 Compare October 29, 2026 09:57
thomasjiangcy added a commit that referenced this pull request Nov 5, 2026
`GET /api/conversations` (the dashboard sidebar) runs p50 688ms / p95
2.3s on the server, and the dashboard polls it every 10s while a listed
Conversation is active. In the 40 slowest prod requests over 3 days (all
over 2s, up to 17.7s), the slowest DB span was one of two event queries
in 34 of them:

| Query | Slowest in | Median | Max |
| --- | --- | --- | --- |
| participants `select distinct on (conversation_id, actor_identity_id)
…` | 21 / 40 | 2.5s | 17.4s |
| `readLastUserMessageAtByConversation` `max(created_at) … type in
(user_message, message)` | 13 / 40 | 1.9s | 6.1s |

Example trace: `19019d5f769341a2916e865e93267baa` (5.5s and 3.3s).

**Participants.** The old query joined every authored event to
identities, conversations, and participants before `DISTINCT ON`.
Postgres does not carry an `IN` list across a join, and no index starts
with `conversation_id` and covers authored rows. Locally it scanned the
non-null part of `junior_conversation_events_actor_identity_idx`, so its
cost grows with all human messages in the database, not with the 50
listed Conversations. Now:
- A `GROUP BY` subquery finds each author's first `seq`, then joins.
- It is served by a new partial index
`junior_conversation_events_author_idx (conversation_id,
actor_identity_id, seq) WHERE actor_identity_id IS NOT NULL`. Only
`message` / `message_updated` rows with an author set this column, so
the index is small (13 MB, against 221 MB for the existing actor index,
on the fixture below).
- The `IN` list is repeated on `junior_conversations`.
- The result is the same: the join filters depend only on (Conversation,
author), so the first `seq` per pair does not change.
`readConversationAuthors` (detail) uses the same rows and gets the same
speedup.

**Last user message time.** `isConversationPriority` reads
`lastUserMessageAt` only for assigned work with a finish time. The list
now reads it only for those ids, after `listConversationWork` (about
40ms in prod traces) and still inside the same `Promise.all`. Before, it
read and detoasted every `user_message` and `message` payload of all 50
Conversations.

**Evidence.** On a local Postgres 17 fixture (40k Conversations, 4.4M
events), the exact generated SQL dropped from 80ms / 16.3k buffers to
9ms / 2.6k buffers on a warm cache. That's a relative change only. Prod
runs on Neon with cold reads, so I expect a bigger absolute drop there,
but that's not measured.

**Migration.** `0078` follows the `0062` pattern. For a busy database,
first build the index `CONCURRENTLY` outside a transaction. The
migration then skips the DDL and checks that the index is valid and
ready.

**Overlap**
- #2713 also adds core migration `0078`, a different partial index on
`structured_event` rows, so the indexes don't duplicate. The PR that
merges second must renumber its migration to `0079` and regenerate the
journal and snapshot.
- #2232 / #2234 (cursor paging for this endpoint) change
`conversationRows` and the response. This PR changes only the auxiliary
reads after the page is chosen, so it composes with paging. Expect a
small textual conflict in `list.ts`.

**Not in this PR**
- The `conversation_subtree` auxiliary-cost aggregate
(`readConversationAuxiliaryCostsFromSql`) is the next slowest: median
0.9s, max 4.4s, slowest in 4 / 40.
- The 10s list poll (`useConversationsData`) runs on every dashboard
page, including open Conversations.

Checks:
- `vitest run tests/integration/api/conversations/
tests/integration/dashboard-reporting.test.ts` passed (74 tests)
- `tsc --noEmit` (junior), oxlint, prettier, `migration-metadata:check`,
`file-length:check`
- `db:generate` reports no further changes

<!-- junior-request-attribution:start -->
via @thomasjiangcy.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Aa40c0c19633f683c13aa6acb1ea1ee47 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Aa40c0c19633f683c13aa6acb1ea1ee47)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Aa40c0c19633f683c13aa6acb1ea1ee47/?project=4510944073809921)

<!-- junior-session-footer:end -->

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: Thomas Jiang <[email protected]>
Print one JSON line in the MCP Conversation shape for each root
Conversation of the token owner, then one line for each visible Thread
under it. The command follows nextCursor from GET /api/conversations,
uses the server-built dashboard url, and drops repeated ids. --status
archived lists archived roots.

The MCP Conversation view now carries kind and parentConversationId, and
moves to api/mcp/conversation-summary.ts so the token-only CLI can import
it without runtime state. The shared API URL and fetch helpers move to
cli/api-client.ts.

Refs #2231

Co-Authored-By: johdax <[email protected]>
Co-Authored-By: Johannes Daxboeck <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — 2a3d3f96 Deployed Nov 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant