Skip to content

feat: show changes and pull requests while a session's turn runs - #143

Merged
kalaspuff merged 7 commits into
mainfrom
fctl/79-look-into-https-github-com-hyperstructur
Oct 20, 2026
Merged

kalaspuff merged 7 commits into
mainfrom
fctl/79-look-into-https-github-com-hyperstructur

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #132

While a session's turn ran, its page said No changes yet., and neither it nor the session lists showed pull requests, even after the agent had committed, pushed and opened one. fctl-agent reported the repositories' state only when a turn ended, and agents often do their whole task, waiting for CI included, in one turn.

What changed

  • fctl-agent refreshes the state while Claude works (crates/fctl-agent/src/refresh.rs). It refreshes after the results of Bash, Write, Edit and NotebookEdit calls, a subagent's too, and when a background task ends. A burst costs one refresh, two seconds after the last result, and refreshes come at most every ten seconds. A git event goes out only when the state changed. The end of a turn and a stop still report as before.
  • These refreshes only read (workspace::Moment). Pushing and moving work onto the session branch still wait for the end of the turn. A refresh looks up a pull request (gh pr view) only where one can have appeared: on a branch pushed since the last report, or whose pushed head moved, or after gh pr create. A pull request it found stays until a lookup finds another.
  • One refresh at a time. The refresh after a turn follows the one under way, and a refresh gives up after ten minutes, killing the commands it started. A repository caught mid-rebase (detached HEAD) is left for the next refresh, so the session's branch never reads HEAD.
  • The agent keeps its index lock. With stale stat data, git diff <base> rewrites the index it reads and holds index.lock while it does, even with GIT_OPTIONAL_LOCKS=0 (tested on git 2.39). An agent's git commit at that moment would fail with "Unable to create index.lock". The state is now read from a copy of each clone's index, and git status runs without optional locks.
  • The transcript shows a line when a branch changes, on the session page and in fctl attach/fctl logs. A change is a commit of the branch's own, a push, or a pull request the session hadn't had, and the line names only the repositories that changed (fctl_domain::branches, branchChanges in web/src/lib/git.ts). A state that only moves files shows only in the sidebar, which takes the newest state.
  • fake-claude takes two new words. push pushes the branch, to a bare stand-in remote in ~/.fake-github when there is no origin. watch <seconds> is one long tool call, like gh pr checks --watch. The smoke test now fails unless the session shows the commit pushed before the first turn's result.
  • Docs: ADR 0027, docs/architecture.md, docs/development.md, docs/getting-started.md, EventBody::Git, and the comments that said "after each turn".

This follows the decisions in the issue: a refresh at most every ten seconds, no pushes mid-turn, and a transcript line whenever a commit, a push or a new pull request happens.

Compatibility

There is no protocol change, and SessionDO already takes any number of git events. The web app and the CLI decide which states get a line. Sessions from older agents (one git event per turn) keep a line only for turns that committed, pushed or found a pull request, and that applies to old sessions' transcripts too. Sessions show changes during turns once their hosts run agents of this release.

There will be more git events: at most one every ten seconds while files change. Each one is stored and broadcast and can list up to 500 files.

Verification

  • Unit tests cover:
    • refresh triggers and timing (refresh.rs);
    • the supervisor reporting a commit before the turn's result, saying nothing for an unchanged or detached state, and running the after-turn sync once the refresh under way ends (commits_show_while_claude_works);
    • mid-turn syncs that neither push nor move work;
    • the pull request lookup rules;
    • the index left alone (reading_the_state_leaves_the_index_to_the_agent, which fails without the copy);
    • fctl_domain::branches, branchChanges and the transcript builder.
  • fake-claude: commits_pushes_and_watches_the_checks_in_one_turn.
  • cargo xtask dev --smoke passes and prints: "the agent committed "Add notes.md" and pushed it, the session showed both before the turn ended, …". With mid-turn refreshes switched off it fails with "the agent's first turn ended before the session showed its commit pushed".
  • cargo xtask check passes.
  • In cargo xtask dev, fctl logs shows ± 1 files (+3 −0) · 1 commits · pushed while the agent watches its checks, and no repeat at the turn's end.

Screenshots

These were taken at ab80206; later commits don't change what they show. The session page is in the light theme, 1440 px wide, a few seconds into fake-claude watching its checks after it committed and pushed notes.md (task: "write notes.md, push it, watch 120 seconds of checks"). The before screenshot is this branch with mid-turn refreshes switched off, which is how agents report today.

Before: no changes until the turn ends After: the commit and the push, seconds after they happen
Before: the session page during the turn says No changes yet, although the agent committed and pushed After: during the turn the Changes section lists notes.md, 1 commit, pushed, and the transcript has a line for it

Session: https://app.fctl.sh/s/ses_01M5CSW6SK9RB34FTXA7ZMHPQV

fctl-sh Bot added 7 commits October 20, 2026 14:22
fctl-agent reported changes, pushes and pull requests only when a turn
ended and when the session stopped, so a long turn showed "No changes
yet" for as long as it ran.

Now it also refreshes the state soon after tool results that can change
the repositories (Bash, Write, Edit, NotebookEdit, a subagent's too) and
when a background task ends: a burst costs one refresh, two seconds after
the last result, and refreshes come at most every ten seconds. A refresh
emits a git event only when the state changed. It only reads: pushes and
moving work onto the session branch still wait for the end of the turn.
It looks up a pull request only where one can have appeared: on a branch
pushed since the last report, or whose pushed head moved, or after
`gh pr create` ran. One refresh runs at a time; the one after a turn
follows the one under way.

The refresh reads a copy of each clone's index: `git diff` against the
working tree rewrites the index it reads when stat data is stale, under
the index lock, even with GIT_OPTIONAL_LOCKS=0, which would make the
agent's own `git commit` fail if it ran at that moment.

Refs #132
The transcript had a "files changed · commits" line for every git event,
one per turn. Now that fctl-agent reports the state while Claude works,
most reports only move files, so the session page and `fctl attach` show
a line only when a repository's branch changes: a commit of its own, a
push, or a pull request the session hadn't had, as decided in #132. The
line names only the repositories that changed. The sidebar's Changes
section still takes the newest state.

The rule is fctl_domain::branches for the CLI and branchChanges in
web/src/lib/git.ts for the web app.

Refs #132
A refresh that caught a repository mid-rebase reported its HEAD detached:
the session's branch would read HEAD until the next one, and the
transcript would show the half-replayed commits. A refresh while Claude
works now skips such a state; the next tool result calls for another.
The supervisor also checks that a refresh is due before it copies the
session's configuration, which it did every second.

Refs #132
fake-claude takes two more words: `push` pushes the branch, to a bare
repository in ~/.fake-github when there is no origin (the dev instance's
projects have no repository), and `watch <seconds>` watches the checks in
one tool call that long, as agents wait for CI before they end their
turn. The smoke test's task uses both, and fails unless the session shows
the commit pushed before the first turn's result.

Refs #132
ADR 0027 records the decisions in #132: refreshes while Claude works, at
most every ten seconds, without pushes, with pull request lookups only
where one can have appeared, reading a copy of the index, and transcript
lines only when a branch changes. The architecture, development and
getting-started docs, EventBody::Git and the comments that said "after
each turn" now say so.

Refs #132
One refresh of the repositories' state runs at a time, so one that hung
(a push or a pull request lookup stuck on the network) would hold back
every later report, the ones after each turn included. A refresh now
gives up after ten minutes and the next one goes ahead; the commands it
ran are killed with it.

Refs #132
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner October 20, 2026 14:47
@kalaspuff
kalaspuff merged commit df05ec3 into main Oct 20, 2026
5 checks passed
@kalaspuff
kalaspuff deleted the fctl/79-look-into-https-github-com-hyperstructur branch October 20, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

A session's changes and pull requests appear only when its turn ends

1 participant