Repository navigation
Description
While a session's turn runs, the session page says Changes: No changes yet. and lists no pull requests, and the session lists show neither, even after the agent has committed, pushed and opened a pull request. Everything appears at once when the turn ends. Meanwhile the Work counters (tool calls, agent time, tokens) move live, so the page looks up to date when it isn't.
Long turns are the common case: an agent often does its whole task in its first turn. In this repository, AGENTS.md also tells agents to wait for CI in the same turn (gh pr checks N --watch), because nothing wakes a session when CI finishes (#8). So a pull request stays out of fctl for exactly the minutes people most want to follow it.
How it works now
fctl-agent reports the repositories' state (changed files, commits, whether the branch is pushed, pull requests) as a git event in only two places:
Supervisor::after_turn(crates/fctl-agent/src/supervisor.rs), which runs when Claude'sresultends a turn. It callsworkspace::sync, which pushes new commits (push_on_commit) and looks up pull requests withgh pr view.Supervisor::finish, when the session stops, which looks up no pull requests.
workspace::sync (crates/fctl-agent/src/workspace.rs) is documented that way ("After a turn and when the session stops"), and so is EventBody::Git in crates/fctl-proto/src/event.rs ("The repository changed (after each turn)"). Everything people see about the repositories comes from the latest git event:
- the session page's Changes section (
TranscriptBuilder.latestGitinweb/src/lib/transcript.ts); - its Pull requests section and the session lists' pull requests and change counts (
SessionObject::apply_gitincrates/fctl-control/src/do_session.rssetspull_requests,pull_requestandstats.files_changed/additions/deletions).
A session's sandbox journals every event (~/.fctl/state/journal.jsonl). Session https://app.fctl.sh/s/ses_01M5CJW6J3ADQ4E3190AC5952E, which opened #131, ran its task as one 30-minute turn with 206 tool calls. Its journal holds 2,251 events, one of them a git event:
12:03:58 the turn starts
12:14:21 the agent's first edit in the repository
12:22:42 it commits on fctl/73-…
12:25:17 commits again and rebases onto main
12:31:25 git push
12:31:30 gh pr create → #131, then watches its CI in the same turn
12:34:32 the turn ends (result) → the session's first git event: 19 files, ahead 2, pushed, pull request #131
(Times in UTC.) For those 20 minutes the page said "No changes yet."
What should happen
Changes, pushes and pull requests show up while the turn runs, soon after they happen, not only when it ends.
- fctl-agent refreshes the repositories' state during a turn too: after tool results that can change them (
Bash,Write,Edit,NotebookEdit), debounced so a burst of tool calls costs one refresh. It emits agitevent only when the state differs from the last one. The local part (workspace::state) is a handful ofgitcommands. - Pull request lookups (
gh pr view, one GitHub API call per repository) happen mid-turn only when they can find something new: a branch was pushed or its head moved, orgh pr createran. GitHub isn't polled on every refresh. - The sidebar and the lists take the newest state. The transcript shows refreshes as decided below: today it has a "files changed · commits" line for every
gitevent (GitItem), so one per turn. - The docs say when the state is reported:
EventBody::Git,workspace::sync, and docs/architecture.md. - A test with fake-claude: a turn that commits and pushes before it ends, and the session's state shows the commit before the
result.
Compatibility
The refresh is fctl-agent's, which hosts put into their sandboxes, so it needs a release and hosts that run it. SessionDO already takes any number of git events: apply_git is idempotent, and pulls::merge keeps each pull request once. If the transcript has to tell mid-turn refreshes from a turn's final state, that is an optional field on GitState, or the web keeps one line per turn by itself. Either way the web (deployed with the control plane, which is never older than agents) must handle it before agents send refreshes. Each git event is stored and broadcast, and a large repository's has up to 500 files, so the debounce and "only when it changed" also keep the event log small.
Decisions for a person
- How fresh: a refresh at most every 10, 30 or 60 seconds during a turn. Decision: Refresh at most every 10 seconds.
- Whether a refresh mid-turn also pushes commits the agent hasn't pushed, or fctl keeps pushing only when a turn ends, as it tells agents (
crates/fctl-agent/src/prompt.rs,docs/cli.md). Decision: The agent pushes when a turn ends, no pushes mid-turn. - In the transcript: one line per turn as now, or a line whenever the branch changes (a commit, a push, a new pull request). Decision: a line whenever a commit happens, a push or new PR.
Activity