Skip to content

[Bug]: Unable to clear merged PR from subsequent chats on the same branch #14858

Description

@its-tech-nik

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web / apps/server (not sure which side owns the branch PR badge)

Steps to reproduce

  1. In a project, work on a long-lived branch (dev in my case) and open a PR from it while in a T3 Code chat that lands on main (my PR 206, dev into main).

  2. Merge the PR.

  3. Now carry on work in separate branches as normal workflow suggests, so new PRs land on dev after they get merged (i.e. feature branch -> dev).

  4. Start a new chat in the same project, merged PR (PR 206), still on dev, even though there are PRs merged more recently into it

Image

Expected behavior

New chats should not show the old merged PR on long lived branches, or there should be a way to dismiss it. A PR that is already merged, and whose head commit is no longer the branch tip, should not be treated as the branch's current PR.

Actual behavior

Every new chat on dev shows the merged PR badge (206) next to the branch picker (screenshot below). It persists across chats and there is no way to clear it.

It is not really linked to the chat:

  • list_thread_pull_requests (agent MCP tool) returns an empty list for the chat.
  • In state.sqlite, the thread row has linked_pull_request_json = NULL but branch_pull_request_json set to PR 206. Both threads on dev carry it: the one where the PR was opened (Sep 27) and a brand new one created Oct 2.

Possibly related: linking a PR to a new chat fails

When I tried to link the PR to the new chat, I got:

Orchestration command invariant failed (thread.pull-request.link): Thread '3ba0ec46-b6af-4fb4-9e0f-f91cae842438' does not exist for command 'thread.pull-request.link'.
Image

The thread does exist now (it has a thread.created event and a projection_threads row). But the server trace shows both failed link attempts (18:55:53 and 19:15:45 UTC) happened before that thread's thread.created event (19:16:05 UTC). So it looks like the link action is offered on a draft chat that has not been created on the server yet, and the command fails in requireThread.

Impact

Minor bug or occasional failure

Version or commit

0.0.42 (AUR t3code-bin)

Environment

Arch Linux (kernel 7.2.6), desktop app, Cursor agent provider

Logs or stack traces

OrchestrationCommandInvariantError: Orchestration command invariant failed (thread.pull-request.link): Thread '3ba0ec46-b6af-4fb4-9e0f-f91cae842438' does not exist for command 'thread.pull-request.link'.
    at invariantError (file:///opt/t3code-bin/resources/app.asar/apps/server/dist/bin.mjs:74866:9)
    at requireThread (file:///opt/t3code-bin/resources/app.asar/apps/server/dist/bin.mjs:74898:16)
    at file:///opt/t3code-bin/resources/app.asar/apps/server/dist/bin.mjs:76243:26
    at next (<anonymous>)
    at orchestration.command.thread.pull-request.link (file:///opt/t3code-bin/resources/app.asar/apps/server/dist/bin.mjs:77426:11)

Screenshots

Merged PR badge next to the branch picker, shown in every new chat on dev (attached in a comment below).

Workaround

None found.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions