Repository navigation
Give agents access to inline Linear ticket screenshots and media - #7484
Conversation
Screenshots and media pasted into Linear issue descriptions and comments live as markdown/HTML links to private uploads.linear.app storage, not as first-class Linear attachments, so agents reading a ticket could not access them (the raw URLs 401). Agent issue reads now request temporary signed Linear file URLs (via the `public-file-urls-expire-in` header) and surface extracted media as `inlineMedia` in JSON output, covering the description, included comments, and child descriptions. Plain-text output (local + SSH) shows an inline media count and points to `--json` for URLs. Adds regression coverage that body reads route through the signed client (reverting re-breaks the exact bug) and that inlineMedia is collected from all three sources including nested children.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughThis PR adds inline media extraction for Linear issue descriptions, comments, and nested children. It introduces a shared parser for markdown and HTML media URLs, adds Changes
Sequence Diagram(s)sequenceDiagram
participant buildIssueContextResult
participant collectInlineMedia
participant extractLinearInlineMedia
participant getPublicFileUrlClient
participant LinearClient
buildIssueContextResult->>getPublicFileUrlClient: get signed client for entry
getPublicFileUrlClient-->>buildIssueContextResult: client with public-file-urls-expire-in header
buildIssueContextResult->>LinearClient: rawRequest(issue/comments/children queries)
buildIssueContextResult->>collectInlineMedia: pass built result
collectInlineMedia->>extractLinearInlineMedia: description, comment bodies, child descriptions
extractLinearInlineMedia-->>collectInlineMedia: LinearInlineMedia[]
collectInlineMedia-->>buildIssueContextResult: inlineMedia array or undefined
Estimated code review effort: 3 (moderate) Related PRs: None identified. Suggested labels: enhancement, linear-integration Suggested reviewers: None identified. Poem: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
left a comment
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (5)
src/shared/linear-inline-media.ts (1)
12-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a brief comment explaining the regex/host choices.
MARKDOWN_IMAGE_PATTERN,HTML_MEDIA_SRC_PATTERN, andLINEAR_UPLOAD_HOSTencode non-obvious parsing decisions (e.g., onlyimg/video/audio/sourcetags, single-hostname detection). A one-line comment on intent would help future maintainers.As per coding guidelines, "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does. Keep comments short — one or two lines, capturing only the non-obvious reason."
Source: Coding guidelines
src/main/linear/client.ts (2)
66-67: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider a short comment explaining the expiry choice.
The rationale for a 1-hour signed-URL expiry (vs. Linear's docs example of 60s) isn't obvious from the code. A one-line comment would help future readers.
As per coding guidelines: "When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does."
Source: Coding guidelines
554-561: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRepeated
LinearClientinstantiation on hot paths.
getPublicFileUrlClientbuilds a freshLinearClienton every call. Call sites invoke this per pagination page (readComments,readLevelinissue-context-includes.ts) and per recursion level, so a single issue-context read can construct many redundant client instances with identical config. Consider caching perentry(e.g., aWeakMap<LinearClientForWorkspace, LinearClient>) since the apiKey/header combination doesn't change within a read.♻️ Proposed caching
+const publicFileUrlClients = new WeakMap<LinearClientForWorkspace, LinearClient>() + export function getPublicFileUrlClient(entry: LinearClientForWorkspace): LinearClient { - return new LinearClient({ - apiKey: entry.apiKey, - headers: { - 'public-file-urls-expire-in': String(LINEAR_PUBLIC_FILE_URL_EXPIRY_SECONDS) - } - }) + let client = publicFileUrlClients.get(entry) + if (!client) { + client = new LinearClient({ + apiKey: entry.apiKey, + headers: { + 'public-file-urls-expire-in': String(LINEAR_PUBLIC_FILE_URL_EXPIRY_SECONDS) + } + }) + publicFileUrlClients.set(entry, client) + } + return client }src/main/linear/issue-context-client.ts (1)
196-197: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueAdd a short comment explaining the switch to the signed client.
The change from the plain client to
getPublicFileUrlClientis driven by a non-obvious constraint — without it,uploads.linear.applinks in the issue body return 401 for agents (as documented in the corresponding test file). Consider a one-line comment here so the intent survives future refactors without needing to consult the test suite.As per coding guidelines: "add a comment explaining why the code behaves the way it does... capturing only the non-obvious reason."
Source: Coding guidelines
src/main/linear/issue-context-includes.ts (1)
122-126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMissing rationale comment; client re-created per page/level.
Two things worth addressing here:
- Per coding guidelines, this non-obvious behavior change (switching to the signed public-file-url client to avoid 401s on
uploads.linear.applinks) should have a short inline comment, similar to the one already added inissue-context-includes.test.ts.getPublicFileUrlClient(entry)is called inside the per-page callback (readComments) and inside the recursivereadLevelclosure, so pagination and deep child trees construct a newLinearClientrepeatedly. See the related performance comment ongetPublicFileUrlClientinclient.ts— caching there would resolve this at the source without changes needed here.As per coding guidelines: "add a comment explaining why the code behaves the way it does... capturing only the non-obvious reason."
Also applies to: 169-173
Source: Coding guidelines
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9805b5fe-feac-4588-9937-9fac115aa857
📒 Files selected for processing (16)
skills/linear-tickets/SKILL.mdskills/orca-linear/SKILL.mdsrc/cli/linear-format.tssrc/main/linear/client.tssrc/main/linear/issue-context-client.test.tssrc/main/linear/issue-context-client.tssrc/main/linear/issue-context-includes.test.tssrc/main/linear/issue-context-includes.tssrc/main/linear/issue-context-inline-media.test.tssrc/main/linear/issue-context.test.tssrc/main/linear/issue-context.tssrc/main/ssh/ssh-remote-linear-output.tssrc/shared/linear-agent-access.tssrc/shared/linear-agent-result-types.tssrc/shared/linear-inline-media.test.tssrc/shared/linear-inline-media.ts
Comment bodies are capped at 20k chars for output; extracting media from the truncated body dropped any screenshot past the cutoff. Extract from the full body in readComments and carry it on the comment node so aggregation surfaces it regardless of truncation.
What changes
When an agent reads a Linear ticket (
orca linear issue … --full --json), inline screenshots and media pasted into the issue description, comments, and child descriptions are now accessible. Orca requests temporary signed Linear file URLs and returns the extracted media as a newinlineMediaarray in JSON output. Plain-text output (local and SSH) shows an inline-media count and points to--jsonfor the URLs.What does not change: Linear "attachments" (link/resource attachments like PR/MR links) are unaffected. This does not add UI; it is agent-facing CLI/read output only.
inlineMediais omitted when a ticket has none.Why
Inline media lives as markdown/HTML links pointing at private
uploads.linear.appstorage, not as first-class Linearattachments. Those raw URLs require auth — fetching them unauthenticated returns HTTP 401 — so before this change agents reading a ticket had no way to see pasted screenshots. Linear signs private file URLs when a request carries thepublic-file-urls-expire-inheader ("all URLs in responses pointing to file storage include a signature"), so agent issue reads now send that header (1‑hour expiry) on exactly the three GraphQL reads that return body markdown (issue, comments, children).Design approach
src/shared/linear-inline-media.tsextracts media URLs from markdownand HTML<img>/<video>/<audio>/<source>tags, dedupes per body, derives a filename, and flagslinearUploadforuploads.linear.apphosts.getPublicFileUrlClient(inclient.ts) wraps the workspace token with the signing header;issue-context-client.tsandissue-context-includes.tsuse it for the issue/comments/children reads.collectInlineMedia(inissue-context.ts) walks description + comments + recursively nested children intoresult.inlineMedia.orca-linear,linear-tickets) documentinlineMediaand warn that media bytes/OCR are untrusted ticket content and that signed URLs expire.Design review
Reviewed against the original request. No unapproved scope narrowing: all three body sources (description, comments, child descriptions) are covered, matching the ask. Non-body reads (attachments, relations, search) correctly stay on the plain client since they return no inline markdown.
Implementation / deviations
Matches the design. No deviations. During review two pre-existing sibling tests (
issue-context.test.ts,issue-context-client.test.ts) were found broken by the newgetPublicFileUrlClientimport — their./clientmocks were updated to expose it (routing through the same raw client). Added regression tests (see below).Completeness verification
All three body sources get both the signing header and extraction; both plain-text formatters updated;
--jsonemits the full result. Adding an optionalinlineMedia?field is backward-compatible across the SSH round-trip and RPC boundary (result is passed through untyped; the SSH guard does not strip unknown fields). No mobile/renderer serialization boundary needs updating.Headline behavior status: implemented and live-validated
inlineMediais populated from description + comments + nested children, URLs are requested signed, and plain-text shows the count. No part is dormant, fixture-only, or fallback-only.Broad app consistency
Source of truth is the agent-facing Linear issue read. Compared the two plain-text formatters (CLI
linear-format.tsandssh-remote-linear-output.ts) — both now emit the same count line, so local and SSH agent output agree. The renderer Linear surface is a separate UI-prompt path and is correctly out of scope (no user-visible media UI was requested).Perf
Touched path is a low-frequency agent-invoked read (not render/poll/startup).
getPublicFileUrlClientbuilds a new client per call/page but that is pure object setup with no network cost over a handful of pages; regexes are linear-time (disjoint character classes, no ReDoS);collectInlineMediais a single O(body-size) walk. No new polling, timers, listeners, or storage growth. No regression; verified by inspection.Code-review loop
Two independent adversarial reviewers (run in parallel) — no Critical/High/Medium findings. Both confirmed the header reaches every body-returning query, recursion is bounded, the auth header is preserved, and privacy handling is correct. Their one shared actionable point (the signed-URL wiring had no regression guard) is fixed here. Low-severity regex edge cases (literal
)in a URL path, escaped brackets in alt text, unquotedsrc) do not occur onuploads.linear.appURLs and are left as noted non-blockers.Validation — live end-to-end against real Linear ✅
Ran the real
extractLinearInlineMedia+ the realISSUE_QUERYwith the exact signing header against the live Stably workspace for STA-1246 (read-only):public-file-urls-expire-in)[0]screenshot?signature=…→ HTTP 200[1]screenshot?signature=…→ HTTP 200linearUpload: true.collectInlineMediagathers media from all three sources including nested children.The only layer not exercised live is the CLI→IPC→main plumbing, which is covered by unit tests and the existing
orca linear issuecommand (already returns thedescriptionfield correctly).Risks / non-goals
Static checks
typecheck:node/cli/webpass; oxlint + oxfmt clean (pre-commit); full Linear + skill-guidance test suites pass.