Skip to content

feat: add sentry conversation command group#1020

Open
sergical wants to merge 17 commits into
mainfrom
feat/ai-conversations-command
Open

feat: add sentry conversation command group#1020
sergical wants to merge 17 commits into
mainfrom
feat/ai-conversations-command

Conversation

@sergical
Copy link
Copy Markdown
Member

@sergical sergical commented May 24, 2026

Summary

  • Adds sentry conversation list — paginated list of AI conversations for an org (tokens, tool calls, errors, first input, user)
  • Adds sentry conversation view [org] <conversation-id> — full transcript with turns, user/assistant messages, tool calls
  • Transcript parsing ported from sentry-mcp's get-ai-conversation-details tool for feature parity
  • Follows existing CLI patterns: buildListCommand/buildCommand, pagination, resolveOrg, formatters

New files

  • src/commands/conversation/ — route map, list, view commands
  • src/lib/api/conversations.ts — API functions (list + detail endpoints)
  • src/lib/formatters/conversation.ts — table formatter + transcript parser
  • src/types/conversation.ts — Zod schemas for list items and conversation spans

Test plan

  • sentry conversation list shows recent conversations
  • sentry conversation list my-org with explicit org
  • sentry conversation list --json outputs JSON envelope
  • sentry conversation list -c next pagination works
  • sentry conversation view my-org conv-123 shows transcript
  • sentry conversation view conv-123 with auto-detected org
  • sentry conversation view my-org conv-123 --json outputs structured JSON
  • TypeScript compiles clean (npx tsc --noEmit — no errors in new files)

🤖 Generated with Claude Code

Add `sentry ai-conversations list` and `sentry ai-conversations view`
commands for browsing AI conversations from Sentry Explore.

- list: paginated conversation list with tokens, tool calls, errors
- view: full transcript with turns, user/assistant messages, tool calls
- Transcript parsing ported from sentry-mcp get-ai-conversation-details

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 24, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-1020/

Built to branch gh-pages at 2026-05-24 14:52 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

Comment thread src/commands/conversation/list.ts
Comment thread src/commands/conversation/view.ts
- Forward start/end params for absolute date ranges (GGA-VPD)
- Guard against Infinity timestamps on empty spans (5RV-D34)
- Consolidate view formatter into formatTranscriptResult
- Fix tsc strict null check on span index lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sergical
Copy link
Copy Markdown
Member Author

Addressed both Warden findings in 3021223:

GGA-VPD (absolute date ranges silently ignored): listConversations now accepts start/end params, and the list command spreads ...timeParams to forward all time range fields.

5RV-D34 (Infinity timestamps on empty spans): buildTranscriptResult returns 0 instead of Infinity/-Infinity when spans array is empty.

Also consolidated the duplicate view formatter into formatTranscriptResult in the formatters module.

AI-generated, verified against tsc and updated code.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/lib/formatters/conversation.ts
sergical and others added 2 commits May 24, 2026 08:34
- Add docs/src/fragments/commands/ai-conversations.md (required by CI)
- Fix generate-sdk.ts to quote hyphenated route names in generated TS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/commands/conversation/list.ts
Comment thread src/lib/api/ai-conversations.ts Outdated
Comment thread src/commands/conversation/view.ts
sergical and others added 3 commits May 24, 2026 08:50
- Use schema option in apiRequestToRegion for proper Zod validation
  with Sentry context instead of bare .parse() (silent-failure-hunter)
- Use MAX_PAGINATION_PAGES instead of hardcoded 10 (silent-failure-hunter)
- Log warning when pagination limit exhausted (silent-failure-hunter)
- Use reduce instead of Math.min/max spread for large arrays (silent-failure-hunter)
- Guard formatEpoch against NaN/zero timestamps (silent-failure-hunter)
- Re-export types from src/types/index.ts barrel (type-design-analyzer)
- Export ConversationTurn and ToolCall types (type-design-analyzer)
- Use barrel imports in commands (code-reviewer)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix lint: use Number.POSITIVE/NEGATIVE_INFINITY, reorder imports
- Fix formatTimestamp treating unix seconds as milliseconds (showed 1970 dates)
- Preserve --query filter in pagination hints
- Surface truncation warning when transcript exceeds pagination limit
- Make view command org optional with resolveOrg fallback
- Register ai-conversations commands in ORG_ONLY_COMMANDS for completions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 24, 2026

Codecov Results 📊

✅ Patch coverage is 92.18%. Project has 4301 uncovered lines.

Files with missing lines (2)
File Patch % Lines
src/lib/formatters/conversation.ts 88.51% ⚠️ 17 Missing and 16 partials
src/commands/conversation/list.ts 94.29% ⚠️ 2 Missing and 1 partials

Generated by Codecov Action

Comment thread src/lib/formatters/ai-conversations.ts Outdated
@sergical sergical marked this pull request as ready for review May 24, 2026 13:21
Comment thread src/commands/conversation/list.ts
Comment thread src/lib/api/ai-conversations.ts
- Filter out messages with null content instead of JSON-stringifying them
- Align DEFAULT_PERIOD (14d) with LIST_PERIOD_FLAG default (7d)
- Widen view span lookup from 30d to 90d to cover older conversations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/lib/formatters/conversation.ts Outdated
Comment thread src/commands/ai-conversations/view.ts Outdated
Comment thread src/lib/formatters/conversation.ts
Comment thread src/lib/formatters/ai-conversations.ts Outdated
sergical and others added 3 commits May 24, 2026 09:33
90d causes performance issues (sentry#7253568394).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Validate conversation-id is present before API call (zero-arg case)
- Sanitize user/assistant content and tool names to prevent terminal
  injection from stored AI responses containing ANSI/control characters

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follow CLI convention of singular resource names (issue, trace, replay).
Command is now `sentry conversation list` / `sentry conversation view`.

Renames all files, imports, pagination keys, usage hints, docs fragments,
completions sets, and AGENTS.md architecture tree.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sergical sergical changed the title feat: add sentry ai-conversations command group feat: add sentry conversation command group May 24, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ddcb856. Configure here.

Comment thread src/commands/conversation/view.ts
Comment thread src/lib/formatters/conversation.ts Outdated
Comment thread src/commands/conversation/view.ts
Comment thread src/lib/formatters/ai-conversations.ts Outdated
- Fix sanitize() removing newlines before split (multi-line content)
- Sanitize conversationId in list table output
- Mark conversation-id positional as optional for Stricli compatibility
- Add formatter tests covering table, turns, transcript, and edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/lib/formatters/conversation.ts
Comment thread src/lib/formatters/conversation.ts
sergical and others added 2 commits May 24, 2026 10:22
- list command: org resolution, query/time params, pagination hints, empty results (14 tests)
- view command: positional parsing, resolveOrg fallback, truncation, errors (11 tests)
- API module: listConversations params/pagination, getConversationSpans multi-page/truncation (20 tests)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Sanitize turn.model, turn.agentName, and tc.status in terminal output
- Extract appendContentBlock to reduce cognitive complexity
- Add 19 more formatter tests covering content extraction edge cases,
  tool calls, metadata rendering, and operation type detection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/commands/conversation/view.ts
sergical and others added 2 commits May 24, 2026 10:50
- Sanitize conversationId, org, and projects in formatTranscriptResult
- Sanitize org in list command human output
- Update docs fragment to use `conversation` instead of old `ai-conversations`
- Fix inaccurate "List last 10" comment (default limit is 25)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

1 participant