Skip to content

refactor(project): read a checkout's pull request in one place - #938

Merged
omartelo merged 1 commit into
mainfrom
feat/branch-pr-store
Oct 24, 2026
Merged

omartelo merged 1 commit into
mainfrom
feat/branch-pr-store

Conversation

@omartelo

Copy link
Copy Markdown
Collaborator

Summary

  • The pull request watch (internal/project/branchpr.go) is the one reader of a checkout's branch pull request. Each minute it reads every checkout a live agent runs in (relay.AgentCheckouts) and every checkout whose last read found an open pull request; any other is read when a window asks with the new project.RecheckPullRequest. One read per path at a time, and a recheck asked during a read reads again after it.
  • Every read goes out as branch-pull-request (api.BranchPullRequestEvent). The cards' badges listen to it instead of calling gh: the window keeps its triggers (branch or head moved, turn end, focus, account change, PR writes, Refresh) as rechecks, and its own one-minute cadence is gone. A failed read now keeps the badge instead of hiding it.
  • The merge notice from feat(relay): announce a pull request merged outside lich #937 comes from the same reads: open then merged calls relay.AnnounceMerge, which still announces a merge once. The relay's own watcher shrinks to AgentCheckouts.
  • project.PullRequest is removed (the window was its only caller); api.PullRequest carries title and head/base refs. Contract golden updated.
  • No behaviour change on what the badge follows: it is still the shell's cwd.
  • docs/ceilings.md merge bullet updated to the new watch.

Test plan

  • internal/project/branchpr_test.go: every read reported; open then merged announced once; first read merged or after a close not announced; a failed read keeps the last one; the watch follows agents and open PRs; a gone checkout is dropped; a recheck during a read reads again; the read runs as the project's gh account.
  • internal/relay: AgentCheckouts lists live agents' checkouts only; AnnounceMerge tells a merge once.
  • Window: badge tests drive the recheck and its event; a merge read by the backend takes the badge down; a path is rechecked only when its branch or head moves.
  • Local gate: gofmt, go vet ./... and go test ./... in the root and in native/; project, relay and window suites with -race.

The cards' badges asked gh themselves, once a minute per open pull request
of the shown project, while the merge watch read the same pull requests in
the backend. The pull request watch (internal/project, branchpr.go) is now
the one reader: it reads every checkout a live agent runs in and every one
last read with an open pull request each minute, and any other when a window
asks with project.RecheckPullRequest; every read goes out as
branch-pull-request, which the badges listen to, and a merge it sees after an
open read is announced through relay.AnnounceMerge as before.

project.PullRequest is gone: the window was its only caller. The badge still
follows the shell's cwd.
@omartelo
omartelo merged commit 82e9842 into main Oct 24, 2026
7 checks passed
@omartelo
omartelo deleted the feat/branch-pr-store branch October 24, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant