Files
werkregie/doc/prs/2026-10-20-PR#98-pr-session-link.md
claude-code 3327b65cd2
werkator build succeeded after 01:10
werkator/deploy build succeeded after 00:36
The session of each pull request, by its URL in the transcripts (#98)
Co-authored-by: claude-code <claude-code@javagil.de>
2026-10-20 17:15:31 +02:00

8.5 KiB

PR#98: The Session of Each Pull Request, by Its URL in the Transcripts

Version: minor

WARNING: This document describes only the change applied in this PR. It may already be outdated once the next PR is merged. Historic PR documentation is not maintained along with new PRs; treat it as a snapshot.

  • werkregie PR#74: the author session of a stuck pull request, by its branch.
  • werkrevisor PR#126: the case of a session in a checkout of werkdock that opened a pull request of werkrevisor.

Problem

The user runs many Claude Code sessions, and they open pull requests in several repositories. To continue the work on a pull request, the user searches for its session.

werkregie shows the session only for a stuck pull request, and finds it by the last branch of its transcript in a checkout of the same repository. It does not find a session in a checkout of another repository, nor one that moved on to another branch.

Non-Goals

  • No session of a machine without a relay.
  • No change of "Agent arbeitet": it keeps the match by branch.
  • No GitHub pull requests; werkregie reads only Gitea.

Specification

Feature: the session that works on a pull request

Scenario#98.01: each pull request shows its session

… so that the user opens the session of a pull request with one click.

  • Given an open pull request, and a Claude Code session that named its URL
  • When werkregie shows the pull request in the panel of the pull requests or in "Du bist dran"
  • Then its row shows the Claude logo and the title of the session, and a click opens the session
Verified by

Scenario#98.02: a session in a checkout of another repository

… so that the link finds also the work across repositories.

  • Given a session in a checkout of werkdock that opened mi/werkrevisor PR#126 and named its URL
  • When werkregie shows mi/werkrevisor PR#126
  • Then its row shows that session
Verified by

Scenario#98.03: the URL beats the branch

… so that a session that moved on still shows at its pull request.

  • Given a pull request, a session that named its URL, and another session whose last line is on its branch
  • When werkregie shows the pull request
  • Then its row shows the session that named its URL
Verified by

Scenario#98.04: the latest mention wins

… so that the row shows the session that worked on the pull request last.

  • Given a pull request whose URL two sessions named
  • When werkregie shows the pull request
  • Then its row shows the session that named it last
Verified by

Scenario#98.05: a session without a URL

… so that a session of an older relay still shows by its branch.

  • Given a pull request whose URL no session named, and a session whose last line is on its branch
  • When werkregie shows the pull request
  • Then its row shows that session, as before
Verified by

Scenario#98.06: a command beats a text

… so that a session that only reports on a pull request does not hide the session that works on it.

  • Given a pull request, a session that named its URL in a shell command, and another session that named its URL later, but only in a text
  • When werkregie shows the pull request
  • Then its row shows the session that named the URL in a shell command
Verified by

Solution

TranscriptPulls reads each transcript of a session from where the last fetch stopped, by parts of 1 MiB, and completes a line cut at the end of a part with the next part. The first read starts 32 MiB before the end; a file shorter than the last read is read anew. Only a line with /pulls/ or /issues/ is parsed. The addresses count from Claude's texts, from shell commands, and from the output of a command if it names one pull request only. PullUrls.key makes one address of http, https, Gitea's API and /issues/, without the scheme. A session keeps the 20 pull requests it named last, each with the time of the latest mention and whether a command named it.

Author gets these as pulls, and branch may be absent, for a session outside a git checkout. Authors.attach gives every pull request its session: by its address, a command before a text, then the latest mention; else by its branch, as before. The message stays for a stuck pull request only. "Agent arbeitet" keeps the match by branch. The page shows the session in each row of the panel, as "Du bist dran" does.

Release Notes

Each pull request shows the Claude Code session that works on it; a click opens the session.

Open Questions

  • Which hosts count? Any host: the relay sends the addresses without a list of the Gitea instances, and the server matches them with the addresses of its pull requests; an address of another host matches none.
  • Which mentions count? Claude's texts, shell commands and the output of a command about one pull request. A list of open pull requests in an output names many; the user's texts, files, messages to other sessions and thoughts name pull requests the session does not work on, e.g. the report of a side session or the brief for it. Claude's texts count, since a session often builds the address of Gitea's API in a shell variable.
  • Why does a command beat a text? A session that started others repeats their reports with the links to their pull requests; its text would else show it at a pull request of another session.
  • What does an older relay send? No addresses: its sessions show by branch, as before. A new relay with an older server would fail on a session without a branch; the server is deployed first, with the merge.
  • Does "Agent arbeitet" use the address too? No; this PR leaves it unchanged.

Additional Changes

  • The demo shows a session at a pull request that is not stuck.

Follow-up PRs

  • "Agent arbeitet" by the URL. Today "Agent arbeitet" finds a session only by the branch, in a checkout of the same repository. The follow-up PR also finds a session that named the URL of the pull request in the last 10 minutes.