Skip to content

Give agents access to inline Linear ticket screenshots and media - #7484

Merged
brennanb2025 merged 2 commits into
mainfrom
brennanb2025/linear-ticket-media
Jul 6, 2026
Merged

brennanb2025 merged 2 commits into
mainfrom
brennanb2025/linear-ticket-media

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

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 new inlineMedia array in JSON output. Plain-text output (local and SSH) shows an inline-media count and points to --json for 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. inlineMedia is omitted when a ticket has none.

Why

Inline media lives as markdown/HTML links pointing at private uploads.linear.app storage, not as first-class Linear attachments. 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 the public-file-urls-expire-in header ("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.ts extracts media URLs from markdown ![alt](url) and HTML <img>/<video>/<audio>/<source> tags, dedupes per body, derives a filename, and flags linearUpload for uploads.linear.app hosts.
  • getPublicFileUrlClient (in client.ts) wraps the workspace token with the signing header; issue-context-client.ts and issue-context-includes.ts use it for the issue/comments/children reads.
  • collectInlineMedia (in issue-context.ts) walks description + comments + recursively nested children into result.inlineMedia.
  • CLI/SSH formatters print the count; skills docs (orca-linear, linear-tickets) document inlineMedia and 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 new getPublicFileUrlClient import — their ./client mocks 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; --json emits the full result. Adding an optional inlineMedia? 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

inlineMedia is 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.ts and ssh-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). getPublicFileUrlClient builds 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); collectInlineMedia is 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, unquoted src) do not occur on uploads.linear.app URLs and are left as noted non-blockers.

Validation — live end-to-end against real Linear ✅

Ran the real extractLinearInlineMedia + the real ISSUE_QUERY with the exact signing header against the live Stably workspace for STA-1246 (read-only):

description media raw URL (no header) signed URL (with public-file-urls-expire-in)
[0] screenshot HTTP 401 ?signature=… → HTTP 200
[1] screenshot HTTP 401 ?signature=… → HTTP 200
  • The extractor returned exactly 2 items, both linearUpload: true.
  • Confirms the load-bearing external contract: Linear does sign inline-markdown-embedded description URLs when the header is set, and the signed URLs are fetchable (200) while raw ones 401.
  • Unit: 82 Linear tests pass, including new coverage that body reads route through the signed client (a simulated revert re-breaks the bug and fails the tests) and that collectInlineMedia gathers 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 issue command (already returns the description field correctly).

Risks / non-goals

  • Comment bodies are extracted after the existing 20k-char cap, so media past 20k in a single comment is dropped (pre-existing truncation; description is uncapped).
  • Signed URLs expire (1 hour) — documented in the skills so agents fetch promptly.
  • Media bytes / image OCR are untrusted ticket content — documented in the skills.

Static checks

typecheck:node/cli/web pass; oxlint + oxfmt clean (pre-commit); full Linear + skill-guidance test suites pass.

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.
@coderabbitai

ghost commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: cde8d1c4-1469-48b9-a40d-9b986e138ee9

📥 Commits

Reviewing files that changed from the base of the PR and between a395a86 and abcee33.

📒 Files selected for processing (4)
  • src/main/linear/issue-context-includes.test.ts
  • src/main/linear/issue-context-includes.ts
  • src/main/linear/issue-context.ts
  • src/shared/linear-agent-result-types.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/main/linear/issue-context-includes.test.ts
  • src/main/linear/issue-context.ts
  • src/main/linear/issue-context-includes.ts

📝 Walkthrough

Walkthrough

This 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 inlineMedia to shared result types, and populates it during issue-context assembly. A signed public-file-url client is added for issue, comment, and child GraphQL reads. CLI/SSH output now reports inline media counts, and skill docs describe the new JSON field and usage guidance.

Changes

Cohort / File(s) Change Summary
Extraction utility (src/shared/linear-inline-media.ts, test) New extractLinearInlineMedia function and LinearInlineMedia/LinearInlineMediaSource types; parses markdown/HTML for media URLs, classifies Linear uploads, derives alt text/filename, dedupes results.
Shared types (linear-agent-access.ts, linear-agent-result-types.ts) Re-export LinearInlineMedia type; add optional inlineMedia field to LinearIssueContextResult and LinearIssueCommentNode.
Aggregation (issue-context.ts, test) New collectInlineMedia/collectChildInlineMedia helpers populate result.inlineMedia from description, comments, and nested children.
Signed client (client.ts, issue-context-client.ts, issue-context-includes.ts, tests) New LINEAR_PUBLIC_FILE_URL_EXPIRY_SECONDS constant and getPublicFileUrlClient function; wired into issue, comment, and children raw GraphQL requests.
Output/docs (linear-format.ts, ssh-remote-linear-output.ts, SKILL.md files) CLI/SSH formatters show inline media counts; documentation explains reading inlineMedia and avoiding orca linear attach for screenshots.

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
Loading

Estimated code review effort: 3 (moderate)

Related PRs: None identified.

Suggested labels: enhancement, linear-integration

Suggested reviewers: None identified.

Poem:
A rabbit hops through issues deep,
Finding images tucked inside,
Signed URLs wake briefly, then keep
Their short-lived light for media applied.
Inline media gathered, shown in view —
No attach command; read JSON through.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change and rationale, but it misses required template sections like Screenshots, Testing, AI Review Report, Security Audit, and Notes. Rewrite it to follow the repo template: Summary, Screenshots (or 'No visual change'), Testing checklist, AI Review Report, Security Audit, and Notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: giving agents access to inline Linear ticket media.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (5)
src/shared/linear-inline-media.ts (1)

12-14: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider a brief comment explaining the regex/host choices.

MARKDOWN_IMAGE_PATTERN, HTML_MEDIA_SRC_PATTERN, and LINEAR_UPLOAD_HOST encode non-obvious parsing decisions (e.g., only img/video/audio/source tags, 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 value

Consider 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 win

Repeated LinearClient instantiation on hot paths.

getPublicFileUrlClient builds a fresh LinearClient on every call. Call sites invoke this per pagination page (readComments, readLevel in issue-context-includes.ts) and per recursion level, so a single issue-context read can construct many redundant client instances with identical config. Consider caching per entry (e.g., a WeakMap<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 value

Add a short comment explaining the switch to the signed client.

The change from the plain client to getPublicFileUrlClient is driven by a non-obvious constraint — without it, uploads.linear.app links 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 value

Missing rationale comment; client re-created per page/level.

Two things worth addressing here:

  1. Per coding guidelines, this non-obvious behavior change (switching to the signed public-file-url client to avoid 401s on uploads.linear.app links) should have a short inline comment, similar to the one already added in issue-context-includes.test.ts.
  2. getPublicFileUrlClient(entry) is called inside the per-page callback (readComments) and inside the recursive readLevel closure, so pagination and deep child trees construct a new LinearClient repeatedly. See the related performance comment on getPublicFileUrlClient in client.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

📥 Commits

Reviewing files that changed from the base of the PR and between 61bd98d and a395a86.

📒 Files selected for processing (16)
  • skills/linear-tickets/SKILL.md
  • skills/orca-linear/SKILL.md
  • src/cli/linear-format.ts
  • src/main/linear/client.ts
  • src/main/linear/issue-context-client.test.ts
  • src/main/linear/issue-context-client.ts
  • src/main/linear/issue-context-includes.test.ts
  • src/main/linear/issue-context-includes.ts
  • src/main/linear/issue-context-inline-media.test.ts
  • src/main/linear/issue-context.test.ts
  • src/main/linear/issue-context.ts
  • src/main/ssh/ssh-remote-linear-output.ts
  • src/shared/linear-agent-access.ts
  • src/shared/linear-agent-result-types.ts
  • src/shared/linear-inline-media.test.ts
  • src/shared/linear-inline-media.ts

Comment thread src/main/linear/issue-context.ts Resolved
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.
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