Repository navigation
fix(agent): list every pull request and diff changes from the merge base - #157
Merged
kalaspuff merged 6 commits intoOct 20, 2026
Merged
Conversation
GitState gains pull_requests, every pull request fctl-agent follows, whichever branch, worktree or clone it came from, and unmerged, the commits after a merged pull request's head. pulls::found reads the list, so the control plane lists them and keeps their state current. SessionSpec carries the session's pull requests, so an agent in a new sandbox follows them too. All optional: older agents leave them out, older hosts drop the spec's. Refs #155
… base - Changes are what the branch changed since it left its base, from the merge base, so a base that moves on no longer shows its commits as the session's, reversed, and a merged branch keeps its changes. Once the branch's pull request merged, from the base as it was just before, which covers merge commits too. - fctl-agent follows the pull requests gh pr create prints, and those of the branches it looks up, in its state file, and looks them up again when a turn ends until they merge. - It doesn't push a branch whose pull request merged: GitHub deleted it, and the new commits stay in the sandbox, with a line that says so. A branch whose upstream is gone, or whose pull request was open, is looked up before it is pushed again. - The system prompt says to make another pull request's branch in the same checkout rather than in a worktree. Refs #155
fctl pushes only the session branch in the clones in ~/repos, so the system prompt's line on another pull request's branch says only what the session shows. Refs #155
main took ADR 0029 (#156): this branch's ADR is now 0030.
kalaspuff
approved these changes
Oct 20, 2026
kalaspuff
deleted the
fctl/95-fix-https-github-com-hyperstructure-fctl
branch
October 20, 2026 21:39
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.
Session pages missed pull requests opened from other branches, and showed the wrong changes once
mainmoved. Three causes in fctl-agent's git state (#155), all fixed here, with the decisions from the issue.What was wrong
gh pr view <branch>). The session behind fix(web): close a dropdown when you tap it again on iPhone and iPad #151 also opened fix(web): stop Home's composer taking presses in its project list #152, from a branch in a worktree, and its page never listed it.origin/<base>. After a squash merge the diff was empty ("No changes yet." over "+0 −0 · 1 commit"). Once someone else's commits reachedmain, they showed among the session's changes, reversed.git fetch --pruneremoved the branch GitHub had deleted,pushedturned false, and the next turn's push brought the branch back on GitHub.What changed
crates/fctl-agent/src/followed.rs). It follows the pull requests of the branches it looks up, those whose URLgh pr createprinted (Refreshreads the tool's result), and those the session lists when a sandbox starts (a newSessionSpec.pull_requests). Only repositories the session may use count. The list lives in the agent'sstate.json, so it survives restarts. fctl-agent looks each pull request up by URL when a turn ends, until it is merged, and reports them all in a newGitState.pull_requests.fctl_domain::pulls::foundreads that list, so the control plane lists every pull request with its current state.git merge-base origin/<base> HEAD, for both--numstatand--name-status. Uncommitted and untracked work counts as it is now, and the empty tree stays the fallback when there is no base, or no merge base.GitState::files's doc now says so. Once the branch's pull request is merged, the diff starts from the base as it was just before the merge (the pull request'sbaseRefOid), so a merge commit, which puts the branch's commits onmain, still shows the merged work.[gone]), or its pull request was open at the last lookup, fctl-agent looks the pull request up when a turn ends, before it pushes. If the pull request is merged, the commits stay in the sandbox and the transcript saysDidn't push <branch>: its pull request #N is merged, once per new head. A newunmergedcount holds the commits after the merged head.whereCommitsinweb/src/lib/git.ts).git switch -c), not in a worktree or another clone.docs/architecture.md(Repositories),docs/cli.md,docs/getting-started.md, and ADR 0030, which amends ADR 0027: a pull request that isn't merged is looked up each turn, wherever it came from.The decisions in the issue
gh pr create's output, and the system prompt asks agents to keep their branches in the checkout, where Changes follows them. Changes doesn't scan worktrees: their branches are neither shown nor pushed by fctl, and telling agents where to work is the simpler fix.Run::publish.What fctl still can't see: a pull request opened without
gh pr createprinting its URL into the transcript (output sent elsewhere, orgh api) is found only while its branch is checked out, as before.Compatibility
Every new field is optional. The control plane takes
GitState.pull_requestsandunmergedbefore agents send them; older agents leave them out and report as before. Older hosts dropSessionSpec.pull_requests, and then the agent follows only what it finds.ghversions withoutheadRefOid/baseRefOidget asked again with the fields fctl-agent asked for before, so pull requests are still found, just without the merged-work diff base and theunmergedcount. Old sessions in the web app read as before. There is no migration. Agents reach sandboxes with hosts' releases.Screenshots
At 41b72fc, from
cargo xtask dev; mergingmain(#156) changed nothing they show. Dev projects have no GitHub repository, so their sessions never get pull requests. For these screenshots, Playwright replaced the session's git state and pull requests in the browser with what each version of fctl-agent reports in the issue's case: #151 squash-merged and its branch deleted, the session resumed, and #152 opened from a worktree. The page itself is the real app:mainon the left, this branch on the right.The session's sidebar, light theme:
After, once the agent committed again on the merged branch (left), and in the dark theme (right):
The whole page, 1440 px wide: the header lists both pull requests, and the transcript's line counts the merged files.
On a phone (390 px), the details sheet, where the line after "#151 merged" wraps:
How I verified it
crates/fctl-agent/src/workspace.rs, with a stand-inghthat answers from the pull requests each test gives it. They assert the fixed behavior: after the squash merge and a resume,fileslistsa.txtand the branch shows merged; the next turn's end doesn't push, and the branch stays deleted on the fake GitHub; a new commit stays unpushed, the transcript says why once, andunmergedis 1; aftermainmoved on, onlya.txt, plus uncommitted and untracked work; the worktree's pull request is found, and its state follows when it merges, then lookups stop. More tests cover a branch the agent pushed without an upstream, a merge-commit merge, and an oldergh. With main's diff and push code put back, three of them fail.fctl_domain::pulls(reading URLs fromgh pr createoutput,foundwith the list),refresh.rs(URLs fromgh pr createresults only),followed.rs(repositories the session may use, a branch's open or latest pull request, olderghoutput, what is due when), the supervisor (a printed URL is reported and survives a restart), the prompt, andwhereCommitsin the web app.cargo xtask check --quickpasses.cargo xtask dev --smokepasses, and so does the same session throughcargo xtask serve(the control plane on workerd), sincespec.rschanged.Fixes #155
Session: https://app.fctl.sh/s/ses_01M5DGT18535H8SAX2DYXH3PQV