Skip to content

[bug] teamai push --branch: team-config edits attach to an existing PR group instead of the new branch #800

Closed

Description

@jeff-r2026

Summary

teamai push --branch <name> was added in #690 (merged as 9d3a91c). A latent
grouping bug ships with it: when uncommitted teamai.yaml edits are pushed
alongside both an existing open-PR group and a new --branch group, the
config rides on the first group — which is always the reused existing PR —
so the explicit --branch never receives the config, and an unrelated review
gets modified.

Flagged as a P1 in the #690 review and merged as a known issue; filing it for
follow-up.

Root cause

In pushCore() the config rides on the first group and is then cleared:

// src/push.ts:1502
let configRider = pendingTeamConfig !== null;
...
for (const group of groups) {
  const outcome = await pushGroup({
    ...
    includeTeamConfig: configRider,   // src/push.ts:1513
    branch: options.branch,           // src/push.ts:1514
  });
  ...
  configRider = false;                // src/push.ts:1529 — only the first group gets it
}

But planPushGroups() (src/utils/pending-push.ts) always orders reused
(existing-PR) groups first
and collapses all new resources into the single
trailing group:

// reused entries pushed first…
for (const entry of newestFirst) { ...; groups.push({ items, reuse: entry }); }
// …new resources appended last as one group
const rest = selected.filter((i) => !claimed.has(...));
if (rest.length > 0) groups.push({ items: rest });

So configRider is consumed by the reused group, and --branch (which only
sets branchName for the new group) never carries the config.

Impact

When triggered:

  • the --branch destination does not get the teamai.yaml change (the
    feature silently no-ops for config); and
  • an unrelated existing open PR is amended with the user's config edit, with no
    warning — it can be merged into the default branch as part of that PR and
    pollute the team-wide teamai.yaml.

The amendment is silent, so it is easy to miss until it has already spread.

Reproduction

  1. Have an uncommitted teamai.yaml edit in the team-repo clone
    (e.g. after teamai source add, which writes but does not commit).
  2. Have at least one unmerged open PR whose resources are selected again this
    run (forms a reuse group).
  3. Run teamai push --branch <name> with a new resource in the same run.

Observed: the config lands on the existing PR's branch, not <name>; <name>
carries only the new resource.

Suggested fix

When options.branch is set, route configRider to the new group rather
than the first (reused) group — or reject the ambiguous combination
(edited teamai.yaml + existing-PR group + --branch) with a clear error,
mirroring the existing multi-new-group guard at src/push.ts:1478.

Related

Follow-up to #690 (fixes #663). Known P1 merged deliberately.

Environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions