Skip to content

fix(web): stop Home's composer taking presses in its project list - #152

Merged
kalaspuff merged 1 commit into
mainfrom
fctl/91-pick-in-composer
Oct 20, 2026
Merged

kalaspuff merged 1 commit into
mainfrom
fctl/91-pick-in-composer

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

On Home, pressing a project in the composer's project list didn't pick it. The list closed, the task field took focus, and the project stayed the same. app.fctl.sh has had this bug since #146 was deployed. No release has it yet.

What was wrong

#146 moved the composer's controls into a row of their own, TextareaControls. A press between the controls focuses the textarea, as a press in its margins does, but presses on links, buttons, inputs and labels are left alone. Home's project Select is in that row. Its list opens in the top layer, over the page, but in the DOM it is still inside the row. So a press on an option counted as a press between the controls. The textarea took focus, the Select's trigger lost it, and the Select closed its list on that blur. Once the list starts closing it stops taking the pointer, so the click that followed missed the option.

What changed

TextareaControls also leaves presses in a popover alone. A Select's list is a popover.

Verification

  • A new unit test in form.test.tsx puts a Select in TextareaControls, opens it, then presses and clicks an option. Before the change, the press moved focus to the textarea. Now the trigger keeps focus and the click picks the option.
  • On the real Home page with cargo xtask dev and two projects, Playwright (Chromium) pressed the project that wasn't selected. It used a mouse, taps at a Pixel 7's size, and taps at an iPhone 15's size, the last with Safari's focus rule added as in fix(web): close a dropdown when you tap it again on iPhone and iPad #151. WebKit on Linux refuses the dev stack's __Host- cookie over http, so these runs used Chromium. On main, the picker stayed on Playground and focus moved to the task field in all three. With this change, it picks Notes, closes the list and keeps focus on the picker.
  • On a page with the same components, Playwright also used a mouse in desktop WebKit and Firefox, and taps on an emulated iPhone 15 in WebKit. Before, a press on an option picked nothing. Now it picks, and a press between the controls still focuses the textarea.
  • With fix(web): close a dropdown when you tap it again on iPhone and iPad #151 applied as well, every check of both pull requests passes. On the iPhone, a second press on the picker also closes its list.
  • cargo xtask check --quick passes.

There are no screenshots: nothing looks different.

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

Since #146, the project select in Home's composer sits in the
TextareaControls row, which focuses the textarea on a press between its
controls. Its list opens in the top layer, but in the DOM it is still in
that row, so a press on an option counted as a press between the
controls: the textarea took focus, the select's trigger lost it and the
list closed before the click could pick the option.

TextareaControls now leaves presses in a popover alone, as it does those
on links, buttons, inputs and labels.
@kalaspuff
kalaspuff merged commit 4254420 into main Oct 20, 2026
5 checks passed
@kalaspuff
kalaspuff deleted the fctl/91-pick-in-composer branch October 20, 2026 20:25
kalaspuff pushed a commit that referenced this pull request Oct 20, 2026
…ase (#157)

Session pages missed pull requests opened from other branches, and
showed the wrong changes once `main` moved. Three causes in fctl-agent's
git state (#155), all fixed here, with the decisions from the issue.

## What was wrong

1. **Pull requests were looked up only for the checked-out branch** (`gh
pr view <branch>`). The session behind #151 also opened #152, from a
branch in a worktree, and its page never listed it.
2. **Changes were a diff against the moving tip of `origin/<base>`.**
After a squash merge the diff was empty ("No changes yet." over "+0 −0 ·
1 commit"). Once someone else's commits reached `main`, they showed
among the session's changes, reversed.
3. **A merged branch was pushed again after a resume.** `git fetch
--prune` removed the branch GitHub had deleted, `pushed` turned false,
and the next turn's push brought the branch back on GitHub.

## What changed

- **fctl-agent follows every pull request of its session**
(`crates/fctl-agent/src/followed.rs`). It follows the pull requests of
the branches it looks up, those whose URL `gh pr create` printed
(`Refresh` reads the tool's result), and those the session lists when a
sandbox starts (a new `SessionSpec.pull_requests`). Only repositories
the session may use count. The list lives in the agent's `state.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 new
`GitState.pull_requests`. `fctl_domain::pulls::found` reads that list,
so the control plane lists every pull request with its current state.
- **Changes are what the branch changed since it left its base:** the
diff from `git merge-base origin/<base> HEAD`, for both `--numstat` and
`--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's `baseRefOid`), so a merge commit, which
puts the branch's commits on `main`, still shows the merged work.
- **A branch whose pull request merged isn't pushed again.** If GitHub
deleted the branch after it was pushed (its upstream is `[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 says `Didn't
push <branch>: its pull request #N is merged`, once per new head. A new
`unmerged` count holds the commits after the merged head.
- **Changes say a merged branch is merged:** "#151 merged" in place of
"not pushed yet", with "1 commit since, not pushed" when the agent
committed again (`whereCommits` in `web/src/lib/git.ts`).
- **The system prompt** now says fctl pushes the branch "until its pull
request is merged", and tells agents to make another pull request's
branch where the repository is checked out (`git switch -c`), not in a
worktree or another clone.
- Docs: `docs/architecture.md` (Repositories), `docs/cli.md`,
`docs/getting-started.md`, and [ADR
0030](docs/adr/0030-sessions-follow-every-pull-request-their-agent-opens.md),
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

- *Worktrees and clones outside the checkout* ("use your recommended
approach"): fctl lists their pull requests, from `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.
- *New commits on a merged, deleted branch* ("It should likely be shown
if possible"): I read this as "leave them unpushed and say so". fctl
doesn't push them. The transcript says why, and Changes shows them as "N
commits since, not pushed". If you meant pushing them to bring the
branch back, that is a small change in `Run::publish`.
- *Changes once merged* ("shown as merged … with the merged work"):
Changes lists the merged work and says "#N merged".

What fctl still can't see: a pull request opened without `gh pr create`
printing its URL into the transcript (output sent elsewhere, or `gh
api`) is found only while its branch is checked out, as before.

## Compatibility

Every new field is optional. The control plane takes
`GitState.pull_requests` and `unmerged` before agents send them; older
agents leave them out and report as before. Older hosts drop
`SessionSpec.pull_requests`, and then the agent follows only what it
finds. `gh` versions without `headRefOid`/`baseRefOid` get asked again
with the fields fctl-agent asked for before, so pull requests are still
found, just without the merged-work diff base and the `unmerged` count.
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`; merging `main` (#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: `main` on the
left, this branch on the right.

The session's sidebar, light theme:

| Before | After |
|---|---|
| ![Before: Changes says "No changes yet." over "+0 −0, 1 commit, not
pushed yet", and Pull requests lists only
#151](https://app.fctl.sh/api/v1/published/buVTqu01848iLrRYX3UUj49jtmmJ7QhO7Xxs0vXdT6x/rail-before.png)
| ![After: Changes lists select.test.tsx and select.tsx with "+34 −0, 1
commit, #151 merged", and Pull requests lists #151 and
#152](https://app.fctl.sh/api/v1/published/37Md9MuKPAM15sVrVsRgVO7COhOp8QWETx1X5xr7pi2/rail-after.png)
|

After, once the agent committed again on the merged branch (left), and
in the dark theme (right):

| Commits after the merge | Dark |
|---|---|
| ![Changes says "+36 −0, 2 commits, #151 merged" and "1 commit since,
not
pushed"](https://app.fctl.sh/api/v1/published/fph75kYbfeoZvuXGMrveBXsZ4rJiQTXCDpUf6de3UAE/rail-after-more.png)
| ![The same as the light after, in the dark
theme](https://app.fctl.sh/api/v1/published/MiusrJZONhFEL3TbQM7wYsJvixso0RcsYM6Uc8kuiiF/rail-after-dark.png)
|

The whole page, 1440 px wide: the header lists both pull requests, and
the transcript's line counts the merged files.

| Before | After |
|---|---|
| ![Before: the session page, the header names fctl#151
alone](https://app.fctl.sh/api/v1/published/2bBWDb5zUrgvLmxbteJfXwzRs13SuzGPmxUTvIqN3fe/before-light.png)
| ![After: the session page, the header names fctl#151 and
fctl#152](https://app.fctl.sh/api/v1/published/WTuCtMcgyoZt1qkjUn86XuOTlP7Hgvk643c8WMftWdj/after-light.png)
|

On a phone (390 px), the details sheet, where the line after "#151
merged" wraps:

![The details sheet on a phone: Pull requests lists #151 and #152;
Changes says "+36 −0, 2 commits, #151 merged" and "1 commit since, not
pushed"](https://app.fctl.sh/api/v1/published/FvlJHmdViaxAjsI8rTdoBbPuwMrlHAqpWZCwmmAPaj6/after-more-390.png)

## How I verified it

- The issue's reproductions are now tests in
`crates/fctl-agent/src/workspace.rs`, with a stand-in `gh` that answers
from the pull requests each test gives it. They assert the fixed
behavior: after the squash merge and a resume, `files` lists `a.txt` and
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, and `unmerged` is 1; after `main` moved
on, only `a.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 older `gh`. With main's diff and
push code put back, three of them fail.
- Unit tests: `fctl_domain::pulls` (reading URLs from `gh pr create`
output, `found` with the list), `refresh.rs` (URLs from `gh pr create`
results only), `followed.rs` (repositories the session may use, a
branch's open or latest pull request, older `gh` output, what is due
when), the supervisor (a printed URL is reported and survives a
restart), the prompt, and `whereCommits` in the web app.
- `cargo xtask check --quick` passes.
- `cargo xtask dev --smoke` passes, and so does the same session through
`cargo xtask serve` (the control plane on workerd), since `spec.rs`
changed.

Fixes #155

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

---------

Co-authored-by: fctl-sh[bot] <343971779+fctl-sh[bot]@users.noreply.github.com>
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.

1 participant