Public: anyone can read this; the crew can change it.

Merge queue: show which open pulls touch the same files #17176

opened this

Merged 36h 47m ago, live in production

The queue page, a terminal screen and the flow MCP tool now show which open pulls collide, and one order to land them in. Tests for the new module, the terminal queue screen, the dead-code check and the page budget pass, and tsc is clean. I did not run the whole suite.

Notes

opened this

The queue page, a terminal screen and the flow MCP tool now show which open pulls collide, and one order to land them in. Tests for the new module, the terminal queue screen, the dead-code check and the page budget pass, and tsc is clean. I did not run the whole suite. One unrelated MCP test, "a writer's update names the agent and queues its run", failed in my run and also fails without my change. The preview has not been tried.

What changed

  • src/core/pull_collisions.ts finds, for every pair of open pulls that change a common file, whether git merge-tree --write-tree conflicts between their two heads, and in which files. Live branch tips are used, with no checkout.
  • It returns the colliding pairs and an order to land in: fewest conflicts first, then the oldest.
  • A pair that shares files but merges cleanly is reported as "both change X; git merges them".
  • The queue page (/<owner>/<name>/queue) has a "Pulls that collide" section that appears only when pulls collide. It names each pair, links the pulls and gives the order.
  • The terminal has a palette entry, "Pulls that collide", while a repository is open (src/tui/screens/collisions.ts).
  • The flow MCP tool takes { kind: collisions, repo } and returns { pairs, order, skipped, says }.
  • A sealed pull the viewer may not read is left out of all three.
  • The how-to is docs/features/queue-collisions.md.

Bounds

  • Pairs are tried only where the two pulls share a changed file.
  • A pass stops starting new reads after 400 ms and answers what it has, and results are cached by commit pair so the next load fills in the rest.
  • Only the first 30 open pulls are read. A fork's pull is skipped, because its head is not in this repository.

Left out

  • Nothing is sent when pulls collide: no comment on the pull and no notification.
  • The order is a sort, not a search for the best order.

Changes to existing files

  • queuePage is now async. I changed test/planner-ceiling.test.ts to await it, since it called the sync form.
  • The queue page's statement budget goes from 64 to 66, for the open-pulls read. The reason is in test/budgets/pages/owner-name-queue.json.

Reuse

  • I reused runGitCapture, isSafeOid, isSafeTreePath, refTip, repoDir, listOpenPulls, mayView and listCard.
  • The gate's similarity notes are unresolved. My keep helper resembles one in review_evidence.ts. My test's git and branch helpers resemble test/combined-git.test.ts.

To try

  • Open /<owner>/<name>/queue with two open pulls that edit the same line, and look for "#A collides with #B in file".
  • In the terminal, open the palette and choose "Pulls that collide".
  • Call flow with { kind: collisions, repo }.
[
  {"go": "/<owner>/<name>/queue", "look": "With two open pulls editing one line, a 'Pulls that collide' section", "expect": "A row '#A collides with #B in <file>' marked conflict, links to both pulls, and a land-in order"},
  {"go": "/<owner>/<name>/queue", "look": "With no overlapping pulls", "expect": "No collisions section"}
]

Closes #17037

2 earlier comments
commented

The queue page, a terminal screen and the flow MCP tool now show which open pulls collide, and one order to land them in. Tests for the new module, the terminal queue screen, the dead-code check and the page budget pass, and tsc is clean. I did not run the whole suite. One unrelated MCP test, "a writer's update names the agent and queues its run", failed in my run and also fails without my change. The preview has not been tried.

What changed

  • src/core/pull_collisions.ts finds, for every pair of open pulls that change a common file, whether git merge-tree --write-tree conflicts between their two heads, and in which files. Live branch tips are used, with no checkout.
  • It returns the colliding pairs and an order to land in: fewest conflicts first, then the oldest.
  • A pair that shares files but merges cleanly is reported as "both change X; git merges them".
  • The queue page (/<owner>/<name>/queue) has a "Pulls that collide" section that appears only when pulls collide. It names each pair, links the pulls and gives the order.
  • The terminal has a palette entry, "Pulls that collide", while a repository is open (src/tui/screens/collisions.ts).
  • The flow MCP tool takes { kind: collisions, repo } and returns { pairs, order, skipped, says }.
  • A sealed pull the viewer may not read is left out of all three.
  • The how-to is docs/features/queue-collisions.md.

Bounds

  • Pairs are tried only where the two pulls share a changed file.
  • A pass stops starting new reads after 400 ms and answers what it has, and results are cached by commit pair so the next load fills in the rest.
  • Only the first 30 open pulls are read. A fork's pull is skipped, because its head is not in this repository.

Left out

  • Nothing is sent when pulls collide: no comment on the pull and no notification.
  • The order is a sort, not a search for the best order.

Changes to existing files

  • queuePage is now async. I changed test/planner-ceiling.test.ts to await it, since it called the sync form.
  • The queue page's statement budget goes from 64 to 66, for the open-pulls read. The reason is in test/budgets/pages/owner-name-queue.json.

Reuse

  • I reused runGitCapture, isSafeOid, isSafeTreePath, refTip, repoDir, listOpenPulls, mayView and listCard.
  • The gate's similarity notes are unresolved. My keep helper resembles one in review_evidence.ts. My test's git and branch helpers resemble test/combined-git.test.ts.

To try

  • Open /<owner>/<name>/queue with two open pulls that edit the same line, and look for "#A collides with #B in file".
  • In the terminal, open the palette and choose "Pulls that collide".
  • Call flow with { kind: collisions, repo }.
[
  {"go": "/<owner>/<name>/queue", "look": "With two open pulls editing one line, a 'Pulls that collide' section", "expect": "A row '#A collides with #B in <file>' marked conflict, links to both pulls, and a land-in order"},
  {"go": "/<owner>/<name>/queue", "look": "With no overlapping pulls", "expect": "No collisions section"}
]
commented

The queue page no longer waits on git, and the other four review points are addressed.

What changed

  • First paint (1): /queue answers from the readings earlier passes kept (viewerCollisions(…, cachedOnly)) and starts no git process. If the reading is partial, warmCollisions fills the cache after the response is sent. That fill runs one pass at a time per repository and at most once every 5 s, so anonymous traffic cannot stack work.
  • Stored oids (1): the live refTip spawns are gone. Readings use each pull's stored headOid and baseOid. The terminal screen and the flow tool still read live, since both need a signed-in viewer.
  • Partial readings (5): a pass cut short by the 30-pull limit, the 400 ms budget or a cold cache is now flagged on Collisions (partial). partialLine words it in one line, for example "Left out of this reading: #9. The order may change." or "Some pairs are not read yet. The order may change." The page, the terminal screen and the flow tool's says all show it. docs/features/queue-collisions.md describes it.
  • Cleanup (3, 4): I removed the unused title and the trailing blank line. The cache trimming now comes from a small shared src/core/bounded.ts (keepNewest), used by both pull_collisions.ts and review_evidence.ts. That keep was private and typed to its own cache, so I made a generic one in core/ instead of importing web/studio from core.
  • Tests (2):
    • test/pull-collisions.test.ts now covers the 30-pull limit, the 400 ms budget, cachedOnly and the partial line on the page.
    • The new test/queue-collisions-surfaces.test.ts covers:
      • a sealed pull left out for a viewer who may not read it;
      • the flow tool, including a guest refused on a private repository;
      • the terminal screen;
      • the page showing the partial line cold and the pairs once the cache is filled.

tsc, the gate (no failures), bun scripts/design-lint.ts and the two collision test files pass. unused-exports also passes; its output names two unrelated src/spawn exports as no longer dead. I did not run the full suite, and I did not exercise the preview, since you saw a 404 there.

Left out: a first visit to a busy repository shows the partial line until the background fill finishes, which is the cost of not waiting on git. The terminal and the flow tool still run git inside their own request, within the 400 ms budget.

[
  {"go": "/alice/lib/queue (a repository with two or more open pulls that edit the same lines, first load after a restart)", "look": "the Pulls that collide section", "expect": "answers at once with a line 'Some pairs are not read yet. The order may change.' or 'Left out of this reading: …'"},
  {"go": "reload the same page a moment later", "look": "the Pulls that collide section", "expect": "the pair sentences ('#1 collides with #3 in code.txt') and the order, with no partial line"}
]
commented

The check failed because src/core/pull_collisions.ts added two module-level collections, filling and filledAt, that request code writes to. I replaced them with one bounded map, passes, which records for each repository when its last refill pass started and whether one is running. I pushed the fix as 98a5da095.

  • Why it passes: passes is written through keepNewest, capped at 2000 entries, like the existing touched and merged caches. The module-state test accepts that pattern.
  • Behaviour: warmCollisions still runs one pass at a time per repository and at most one every 5 seconds.
  • Checks run: test/module-state.test.ts and the two collision test files passed (13 tests in the collision files). bun x tsc --noEmit printed nothing. bun scripts/gate.ts --fix printed only "one implementation?" similarity notes for test helpers and changed no files. I did not run the full suite, and I did not run design-lint because nothing in src/web/ changed.
  • Not done: the helper-similarity notes are about test code from earlier commits, which I left alone.
  • Door rule: the commit line says No door:, since this is internal state only with no page, action, route or tool change.

This was a fix to the failing check on the existing pull, so the pull description is unchanged.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs