What happened
A review thread got a pull request linked with source created that it never opened. The thread's only intended link was a GitLab MR in repo A, added through link_pull_request (source agent). While this thread was running, T3 also linked an MR in repo B, a separate tracked repository, with source created.
The repo B MR was opened at 09:44:13 UTC from a branch checked out in the shared repo B checkout, most likely by another session or a terminal. This thread never used that checkout. At the time it was only waiting on its own background command, a shell loop polling a local JSON file, registered with t3_background_wait. It ran no git push, glab mr create or any other MR-creating command, and none of its tool output mentions that MR or its branch.
The user unlinked the MR with unlink_pull_request (wasLinked=true). Twelve seconds later, at the end of the next turn, T3 linked it again.
Diagnosis
The link came from the tracked-repository branch lookup, not from command output parsing.
- Another session's changes are recorded against this thread. At the end of a run,
CheckpointService.captureRepository (apps/server/src/orchestration-v2/CheckpointService.ts:1025-1066) records a checkpoint scope for every tracked repository whose clean HEAD or uncommitted files changed during the run. It does not know which process made the change. The project root holds about 40 auto-discovered tracked repositories. Another session worked in repo B while this thread's run 18 was active, so when run 18 ended, a repository:<repo B> checkpoint scope was recorded for this thread (09:46:11).
- Any open PR on that repo's branch is linked as
created. After the run, ThreadPullRequestServiceV2.linkRepositoryPullRequests (ThreadPullRequestService.ts:155-210) reads each tracked repository in the thread's checkpoint scopes, finds the open PR for its current branch and dispatches thread.pull-request.link with source: "created". The thread has no worktree (worktreePath: null), so the guard local.refName !== thread.branch at line 186 never runs, and any branch in the shared checkout qualifies. The link landed at 09:46:36.
- Unlinking does not stick. For a link outside a stack,
thread.pull-request.unlink just filters the link out (Orchestrator.ts:5339-5359). Only stack links leave a tombstone (stack-dismissed). The checkpoint scope stays, so the next turn-end lookup finds the same open PR and links it again (unlink at 10:09:24, relink at 10:09:36). This repeats after every turn until the PR is closed or merged, or until the checkout leaves that branch.
The comment on linkRepositoryPullRequests says "The tracked repositories a thread changed". In practice, a repository counts as changed by the thread if anything changed it while the thread was running.
Possible directions:
- Attribute a repository to a thread only when the thread's own tool calls touched it, such as commands run there or file edits inside it.
- Require the branch to be one the thread created or pushed.
- Have a manual unlink leave a tombstone that later automatic
created lookups respect, as stack dismissals already do.
Steps to reproduce
- Open a project whose root holds two or more git repositories (auto-discovered tracked folders), say
repo-a and repo-b.
- In thread X (no worktree), start a turn that only waits, for example a background
sleep 120 registered with t3_background_wait.
- While thread X's run is active, from a terminal or another thread: create a branch in
repo-b, commit, push, and open a PR for it.
- Let thread X's run finish.
- Thread X now shows the
repo-b PR with source created.
- Unlink it, then send thread X another message. The PR is linked again when that turn ends.
Version
0.1.12
Environment
Linux x64 (kernel 7.0), Node v24.22.1, desktop app with its local server (0.1.12), Claude agent provider, GitLab (gitlab.com) hosting
Evidence
# Checkpoint scope recorded for this thread in a repo it never touched
scope_id=checkpoint-scope:thread:mcp%3A<thread>:name:repository%3A~%2Fcode%2F<repo-b>
run=ordinal:18 kind=manual createdAt=2026-11-26T09:46:11.721Z
# Server trace (server.trace.ndjson), thread.pull-request.link dispatches
09:46:36Z command_id=server:thread-repository-pull-request:mcp:<thread>:8f481a28-... type=thread.pull-request.link
10:09:24Z command_id=server:mcp-pr-unlink:mcp:<thread>:eec88117-... type=thread.pull-request.unlink (user)
10:09:36Z command_id=server:thread-repository-pull-request:mcp:<thread>:d748ad7b-... type=thread.pull-request.link
# Resulting link in orchestration_v2_projection_threads.payload_json
{"host":"gitlab.com","repository":"<group>/<repo-b>","number":<n>,"source":"created","linkedAt":"2026-11-26T10:09:36.441Z"}
Related issues
None found. I searched for wrongly linked PRs, unlinks that don't stick and tracked-folder PR linking. #40350 and #40397 involve tracked repositories but are unrelated (review guides, the PR picker).
Fix applied or workaround
Nothing applied. Workarounds: add the repository to ignoreRepositories in the project's t3.json (this drops tracking for every thread in the project), wait until the PR is closed or merged and unlink it once more, or run threads in worktrees.
Filed by
Claude Code (claude-opus-5-5) via t3 triage