feat: put Cyrus PRs front and center and work directly on existing PRs and branches - #1457
Open
jakelevirne wants to merge 6 commits into
Open
jakelevirne wants to merge 6 commits into
jakelevirne wants to merge 6 commits into
Conversation
Match Linear's own coding agent: the PR Cyrus opens is attached to the issue as a first-class GitHub-PR attachment the moment it is created (giving the issue its Diff tab and a review page in Linear Reviews when the GitHub integration has code access), pinned on the agent session header, and rendered as dedicated "Git Push <branch>" / "Create PR <title>" rows in the session timeline instead of generic Bash rows. - claude-runner: new git-command-labels.ts recognizes simple `git push` and `gh pr create` / `glab mr create` / `gt submit` commands; the formatter uses those semantic labels for Bash action rows. - PrMarkerHook: GitHub provider can read the PR back (`gh pr view`), and the hook accepts an onPullRequestDetected callback (errors are logged and swallowed so the session is never interrupted). - RunnerConfigBuilder: passes onPullRequestDetected through. - EdgeWorker: on first detection per session+PR, links the PR to the issue and pins it on the session; deduped, retried on failure. - IIssueTrackerService: optional linkPullRequestToIssue and addAgentSessionExternalUrl; Linear implementation uses the SDK's attachmentLinkGitHubPR and a raw agentSessionUpdate(addedExternalUrls) request (the pinned SDK predates that input field). - docs/LINEAR_PR_REVIEWS.md explains the full mechanism, workspace setup, the review-driven fix loop, and limitations. Claude-Session: https://claude.ai/code/session_01GFH2uEWasM9j2MtmyK4xw5
When an issue's branch name matched a branch that existed only on origin (an externally pushed PR branch), the local-refs-only existence check ran before the fetch, so Cyrus cut a fresh branch off the base branch and shadowed the remote work; later pushes then conflicted. After the fetch, check origin for the branch and create the worktree tracking origin/<branch> when it exists. Claude-Session: https://claude.ai/code/session_01TYbwKqXeuzViAJ3RhK1t7p
When an issue references an open GitHub PR for the routed repo — via attachment, a <pull-request> description embed, or a plain PR URL — adopt the PR's head branch as the session branch instead of Linear's generated branch name. Lookup uses the GitHub REST API (unauthenticated for public repos, GH_TOKEN/GITHUB_TOKEN when set); closed and cross-fork PRs are skipped, and any failure falls back to the normal branch-name flow. Claude-Session: https://claude.ai/code/session_01TYbwKqXeuzViAJ3RhK1t7p
Linear's API renders a synced-PR embed as [owner/repo#N](linear.app review URL), not the <pull-request> element or a github.com URL, so the first live run (SPE-73) found no candidates and created a fresh PR. Match owner/repo#N references in the description, and check description references before attachments — attachments accumulate automatically (Cyrus attaches every PR it creates), while a description reference is user-stated intent. Claude-Session: https://claude.ai/code/session_01TYbwKqXeuzViAJ3RhK1t7p
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.
Summary
Makes pull requests first-class in Cyrus sessions, in both directions: PRs Cyrus creates become front and center in Linear, and sessions work directly on PRs and branches that already exist instead of shadowing them.
PRs Cyrus creates — front and center in Linear:
git pushandgh pr create/glab mr create/gt submitcommands render as dedicated "Git Push <branch>" and "Create PR <title>" activity rows instead of generic Bash rows.docs/LINEAR_PR_REVIEWS.md(added in this PR) for the full mechanism and workspace setup.Existing PRs and branches — sessions adopt them:
origin/<branch>instead of cutting a fresh branch of the same name off base — which silently shadowed the remote work and caused push conflicts.owner/repo#Nreference in the description (including Linear's markdown-link rendering of synced-PR embeds), or a plain PR URL — has its head branch adopted as the session branch, so pushes update the existing PR. Description references outrank auto-added attachments (Cyrus attaches every PR it creates); closed and cross-fork PRs are skipped. Lookup uses the GitHub REST API: unauthenticated for public repos,GH_TOKEN/GITHUB_TOKENwhen set.Testing
pnpm build,pnpm typecheck,pnpm test:packages:runall pass on top of current main.https://claude.ai/code/session_01TYbwKqXeuzViAJ3RhK1t7p