Repository navigation
feat(import): read the MR's review threads into the --from-mr extraction (#1187) - #1190
Merged
Merged
Conversation
scpia
force-pushed
the
feat/import-mr-discussions
branch
from
October 16, 2026 17:01
d9c0f40 to
6be73ef
Compare
…ion (Tencent#1187) `teamai import --from-mr` and `teamai ci extract-mr` now fetch the MR's review threads alongside the description, commits and diff: GitLab `/discussions` (paginated), GitHub review comments, reviews and conversation comments (through `gh api` or the REST fallback), and TGit notes. System notes and teamai's own `<!-- teamai:` CI comments are left out so the CI extraction does not feed its own output back in. The threads get a section of the prompt with its own budget (6000 characters): per thread the file and line it is anchored to, whether it is resolved, and its notes in order, each marked as the MR author's or a reviewer's. Threads with a reply come first and single remarks last; a thread over 1500 characters keeps its first and last notes, and once the budget is reached the remaining threads are counted instead of the section being cut off. The model is told that a decision in a resolved thread outweighs a restatement of the diff. A failure to read the threads warns and extracts without them. `--no-discussions` keeps the previous behaviour. In the same function, `language: en` in teamai.yaml now makes the learning English with English headings; `zh` or unset keeps the Chinese prompt byte for byte.
scpia
force-pushed
the
feat/import-mr-discussions
branch
from
October 16, 2026 17:26
6be73ef to
9a1c254
Compare
The description documents sufficient testing: post-build real-CLI runs cover extraction with and without discussions. Live GitLab/TGit coverage is explicitly deferred; no blocking testing finding. |
…view threads (Tencent#1187) `teamai ci extract-mr --comment-marker <marker>` posts its learning under that marker instead of the default `<!-- teamai:` prefix, so the thread filter missed those comments and a later run fed its own output back in. The marker now travels from `ci extract-mr` through `importFromMR` and `MRFetchOptions` into every provider's thread fetch, which drops it along with the default prefix.
|
No new findings in the specified diff.
Review was read-only; nothing from the PR was run, built, or installed. |
…ussions # Conflicts: # src/__tests__/github-mr-fetch.test.ts
|
No new findings in the specified diff.
Review was read-only; nothing from the PR was run, built, or installed. |
jeff-r2026
approved these changes
Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
teamai import --from-mrandteamai ci extract-mrnow read the MR's review threads into the extraction, alongside the description, commits and diff, so a learning carries the decision a review reached instead of a summary of the diff. In the same prompt,language: eninteamai.yamlmakes the learning English. Closes #1187.What is fetched:
GET /projects/:id/merge_requests/:iid/discussions, paginated viax-next-page./pulls/:n/comments, grouped into threads byin_reply_to_id), review bodies (/pulls/:n/reviews, prefixed with the verdict, pending reviews skipped) and conversation comments (/issues/:n/comments), throughgh apiwhenghserved the PR and through the REST fallback otherwise.teamai cialready uses, grouped bydiscussion_idwhere the instance reports one.System notes and teamai's own
<!-- teamai:CI comments are left out, so the CI extraction does not feed its output back in.The threads get their own section of the prompt with its own budget (6000 characters). Per thread: the file and line it is anchored to, whether it is resolved, and the notes in order, each marked
[author <user>]or[reviewer <user>]. Threads with a reply come first, single unanswered remarks last; a thread over 1500 characters keeps its first and last notes, and once the budget is reached the remaining threads are counted rather than the section cut off mid-thread. The model is told that a decision in a resolved thread outweighs a restatement of the diff.A failure to read the threads warns (
Review threads not read (...)) and extracts without them.--no-discussionsonimportand onci extract-mrkeeps the previous behaviour.language: engives an English prompt with English headings (## Background/## Solution/## Lessons/## Related Skills);zhor unset keeps the Chinese prompt byte for byte.Type of Change
Test Plan
npx tsc --noEmitpassesnpm run lintpassesnpx vitest runpasses — 10836 passed; the only failures are the twosubmodule-checkout.test.tscases (git config --get hook.teamai-post-checkout.commandfails on this machine), unrelated to this changeNew unit tests:
import-mr-threads.test.ts(prune, ordering, author marking, resolution labels, long-thread shortening, budget cut, prompt section,languagevariants),gitlab-mr-discussions.test.ts(pagination, system/teamai filtering, anchors,discussions: false, API error),github-mr-fetch.test.ts(threads from the three list endpoints,discussions: false, list error),tgit-mr-discussions.test.ts(grouping bydiscussion_id,discussions: false, notes error),import-mr.test.ts(--no-discussionsplumbing,language: enreaches the prompt). Thegitlab-provider.test.tsAPI-prefix cases now also expect the discussions URL.Real-CLI run (after
npm run build)Against the merged PR #1056 (19 conversation comments, one approving review), with the real
gh(2.94.0) andclaude(2.1.268), a project-scope sandbox config withlanguage: en, and--outputso nothing is published.With the threads, the learning leads with the review's decision and its reason (from its
## Solution):Without them, the same MR gives a summary of the diff, and the decision appears only as "flipped to conservative keep in commit 2 once reviewers weighed in", with no reason. Both learnings are in English, from
language: en.An earlier attempt with
ghunauthenticated (sandboxHOME) exercised the REST fallback:✔ MR data fetched (19 review threads)as well.Not covered here: TGit (no access from this environment; its path follows the notes endpoint
src/ci/mr-comment.tsalready uses) and a live GitLab instance (the fetcher is covered by the unit tests above). Deferred to CI / reviewers with access.Related Issues
Closes #1187
Notes for Reviewers
MRData.discussionsis optional and absent when the fetch left threads out, so every provider without the feature (GitCode) and every existing caller is unchanged.resolvedstays unset there; GitLab reports it.src/providers/mr-threads.tsholds the one shared piece (dropping teamai's own comments); the prompt rendering isformatMrThreadsinsrc/import-mr.ts.language.