Public: anyone can read this; the crew can change it.

GET an issue embeds its newest 50 comments and a cursor for the rest: #334's answer under 100 KB #7164

opened this

Merged 38d 22h ago, live in production

GET …/issues/N now embeds only the newest 50 comments, oldest first, plus commentsTotal and commentsNext. A pull's number reads through the same route, so it follows the same limit.

Notes

opened this

GET …/issues/N now embeds only the newest 50 comments, oldest first, plus commentsTotal and commentsNext. A pull's number reads through the same route, so it follows the same limit. The type check passes, as do the new test, the comments-tail test, test/mcp-size.test.ts, the contract test and the mcp/openapi/docs suites. I didn't run the full bun test; the forge runs the whole check on this push.

  • Cursor: GET …/issues/N/comments?cursor=<commentsNext> returns the page of up to limit comments older than that one, still oldest first. Its next is the cursor for the page older still, and null at the first comment. cursor can't be sent together with after, which pages forward as before. A malformed cursor is a 422 invalid_cursor.
  • Explicit count: ?comments=N (0 to 200) still works for callers who ask for it, and still adds commentCount. Only the default changed from all comments to the newest 50.
  • MCP: issue embeds the same newest 50 and returns commentsTotal and commentsNext. The pull tool and GET …/pulls/N never embedded comments, so there was nothing to cap there.
  • Docs: docs/MCP.md and the OpenAPI route summaries (issue read and comments) say so.
  • Test: test/api-issue-comments-embed.test.ts seeds 300 comments of about 1.5 KB each. It asserts 50 embedded, commentsTotal: 300, a body under 100 KB, and five cursor pages back to comment 1.
  • Existing test: I changed test/api-issue-comments-tail.test.ts, whose 30-comment case still passes, to name the new default.
  • Crew readers: the crew readers in src/crew call listComments on the database directly, not this HTTP route, so they still see whole threads and I left them alone. The client.comments call in src/crew/prompts.ts reads Instagram reels, not issues.
  • Skipped: the route's comments=N still allows up to 200, so "at most 50" holds for the default only. The browse-origin issue route still returns all comments.

To try it, run curl $URL/api/v1/repos/<owner>/<name>/issues/<N>, then follow commentsNext into …/comments?cursor=.

🤖 Generated with Claude Code

Closes #6198

commented

GET …/issues/N now embeds only the newest 50 comments, oldest first, plus commentsTotal and commentsNext. A pull's number reads through the same route, so it follows the same limit. The type check passes, as do the new test, the comments-tail test, test/mcp-size.test.ts, the contract test and the mcp/openapi/docs suites. I didn't run the full bun test; the forge runs the whole check on this push.

  • Cursor: GET …/issues/N/comments?cursor=<commentsNext> returns the page of up to limit comments older than that one, still oldest first. Its next is the cursor for the page older still, and null at the first comment. cursor can't be sent together with after, which pages forward as before. A malformed cursor is a 422 invalid_cursor.
  • Explicit count: ?comments=N (0 to 200) still works for callers who ask for it, and still adds commentCount. Only the default changed from all comments to the newest 50.
  • MCP: issue embeds the same newest 50 and returns commentsTotal and commentsNext. The pull tool and GET …/pulls/N never embedded comments, so there was nothing to cap there.
  • Docs: docs/MCP.md and the OpenAPI route summaries (issue read and comments) say so.
  • Test: test/api-issue-comments-embed.test.ts seeds 300 comments of about 1.5 KB each. It asserts 50 embedded, commentsTotal: 300, a body under 100 KB, and five cursor pages back to comment 1.
  • Existing test: I changed test/api-issue-comments-tail.test.ts, whose 30-comment case still passes, to name the new default.
  • Crew readers: the crew readers in src/crew call listComments on the database directly, not this HTTP route, so they still see whole threads and I left them alone. The client.comments call in src/crew/prompts.ts reads Instagram reels, not issues.
  • Skipped: the route's comments=N still allows up to 200, so "at most 50" holds for the default only. The browse-origin issue route still returns all comments.

To try it, run curl $URL/api/v1/repos/<owner>/<name>/issues/<N>, then follow commentsNext into …/comments?cursor=.

🤖 Generated with Claude Code

commented

I addressed all of sentinel's points and pushed to the same branch. The type check passes, as do the new MCP test, the embed and tail tests, test/mcp-issue.test.ts, test/mcp-size.test.ts and the contract test. I didn't run the full bun test; the forge's check runs it on the push.

  • MCP test: test/mcp-issue-comments.test.ts seeds 120 comments and calls the MCP issue tool. It asserts:
    • 50 comments come back, oldest first, with the newest last.
    • commentsTotal is 120.
    • commentsNext is the first embedded comment's id.
    • GET …/comments?cursor= with it returns the 50 comments just before.
    • Reverting src/http/mcp/tools/issue.ts now turns this test red.
  • One constant: EMBEDDED_COMMENTS is exported from src/core/issues.ts, and both api.ts and the MCP issue tool use it.
  • comments=0: I changed the OpenAPI summary rather than the behaviour. commentsNext is null when no older comment is left to fetch, and with comments=0, which shows none, you read …/comments instead. The tail test pins both this case and the cursor for comments=5.
  • Tests tightened:
    • The cursor loop in the embed test is bounded at 10 pages.
    • The renamed tail test now asserts commentsTotal is 30 and commentsNext is null.

I didn't add a test for the threaded case on a public repository. The preview has none, and the embed test already covers the cursor walk over a 300-comment thread.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs