Add document, project, and initiative comments with threaded replies - #280
Merged
Conversation
This was referenced Sep 4, 2026
schpetbot
force-pushed
the
schpet/entity-comments
branch
from
September 4, 2026 21:13
ffc801e to
ddbaa34
Compare
The CLI could only comment on issues. Documents, projects, and initiatives all take comments in Linear (GitHub issue #230 asked for document comments), so this adds `document comment list|add`, `project comment list|add`, and `initiative comment list|add`, mirroring `issue comment` with the same --body / --body-file conventions and the shared Markdown hint. Every comment `add`, including the issue one, now takes `--reply-to <commentId>`; -p and --parent stay as aliases so existing scripts keep working. The entity-agnostic parts live in src/utils/comments.ts: a typed comment target union feeding one AddComment mutation, strict body handling (an explicitly blank --body or body file is an error, not a fall-through to the prompt), a CommentListFields fragment so the four --json shapes cannot drift, a page collector, and the threaded renderer. Comment lists now fetch every page instead of stopping silently at 50, and their JSON nodes, plus the comments in `issue view --json`, carry quotedText (the passage an inline comment quotes) alongside parent.id. Replies whose root is missing from the result are rendered as replies naming their parent instead of being dropped. API findings, verified live against scratch objects on 2026-09-04: - A reply must carry its entity id as well as parentId; parentId alone is rejected, so every add sends both. - Project comments attach via projectId, but the schema's Project.comments connection does not return them; only the root `comments` query filtered by project does. Initiative has no comments connection at all. Both list commands therefore use the root query and select the entity in the same operation so an unknown UUID is reported as not found rather than as an empty list. - Document comments attach via the document's documentContentId, which is looked up first; `document(id:)` accepts a UUID or slug directly. - Linear rejects a reply to a reply and a cross-entity parent with a user-presentable message, which is surfaced verbatim. Linear's not-found error carries the user-presentable message "Could not find referenced <Type>.", which isNotFoundError never matched, so the existing not-found branches were dead. Matching that wording exposed a `document view` catch block that re-threw instead of reporting; it now goes through handleError like everything else. Claude-Session: https://claude.ai/code/session_01A9qEGri4p2HZMQSuYsBmub
schpetbot
force-pushed
the
schpet/entity-comments
branch
from
September 5, 2026 14:19
ddbaa34 to
c04834c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second of a three-PR stack, based on #279. Merge that first; this PR's diff will shrink to one commit once it lands.
The CLI could only comment on issues. This adds
document comment list|add,project comment list|add, andinitiative comment list|add, mirroring the issue comment subcommands, plus--reply-to(aliases-p,--parent) on every commentaddincluding the existing issue one. JSON output now includesquotedTextand the parent id where the API returns them, and the human listing renders replies as threads.API findings worth knowing:
commentCreateacceptsprojectIdandinitiativeIddirectly, but theProject.commentsconnection does not return project-thread comments andInitiativehas no comments connection, so both lists use the rootcommentsquery filtered by entity. Document comments attach viadocumentContentId. A reply must carry the owning entity id as well asparentId.Two latent bugs found by QA are fixed here:
isNotFoundErrornever matched Linear's "Could not find referenced X." wording, anddocument viewre-threw unknown-document errors as a stack trace.Verified: 719 tests, live scratch document round-trip (comment, reply, list, JSON, not-found), a QA case table of 16 cases with every scratch object deleted, and a clean high-effort Codex review.
https://claude.ai/code/session_01A9qEGri4p2HZMQSuYsBmub