Repository navigation
[Bug]: Sidebar opens and/or focusses MR every time opening a thread #12040
Description
Activity
- addedbugSomething is broken or behaving incorrectly.Something is broken or behaving incorrectly.needs-triageIssue needs maintainer review and initial categorization.Issue needs maintainer review and initial categorization.
on Sep 16, 2026 Triage
Confirmed on current
main(b900fc94e) and on shipping0.0.42/ the reported0.0.41-nightly.20260916.1795. All three already contain #9276, #10113, and #10610. This is a real web/desktop right-panel bug, not a wash of those PRs. Desktop embeds the sameChatViewpath; nothing inapps/desktopowns this.The reporter likes server auto-link (“MR auto-assign”). The complaint is the right panel: opening a thread force-opens and force-focuses the assigned merge request, including after hide/close, including when that MR is already a tab, and sometimes as a second tab for the same MR. That matches the code. Auto-link itself is fine.
Two open paths. Both end in
openProactive→upsertSurface, which always setsisOpen: trueand activates the PR surface.What the code does
ChatView.tsxwatcheslinkedPullRequest ?? branchPullRequest(the auto-assigned / branch-detected MR fromThreadPullRequestReactor). On every active-thread effect it does two things:-
On-entry open (
shouldOpenProactivePullRequest, gated by Settings → General → Proactive panels).observeProactivePanelUserChoiceresetstargetKeytoundefinedwhenever the thread key changes. The helper is thenundefined → "<project>:<repo>:<n>"→ true. That is fix(web): open proactive panels when entering threads #10610: “opens an existing pull request on entry.” The test inChatView.logic.test.tsasserts exactly that. feat(web): add proactive panels #9276 originally promised historical panels stay closed on thread switches; fix(web): open proactive panels when entering threads #10610 reversed the PR half. -
Follow a changed server link (
shouldRetargetThreadPullRequestPanel). If the open surface is still the previous linked PR and the server assigns a different one, it callsopenProactiveeven with Proactive panels off.
openProactive(rightPanelStore.ts) refuses only whenuserActionRevisionhas moved since the snapshot this effect took. #10113 added that so a hide/Files click during a turn is kept. It does not survive a thread switch:observeProactivePanelUserChoicere-readsgetUserActionRevisionwhen!sameThread. Hide/close already incremented the count; the next visit snapshots the new count, so expected === current and the open is allowed again.- The revision map is not persisted (
partializewrites onlybyThreadKey). Reload zeros it.
So “closed 10 times” is real: close is a user action on this visit, forgotten on the next.
upsertSurfacehas an unusedactivate = truedefault and always opens the panel (isOpen: true+ focus that surface). If the MR tab already exists, it is not added again — but the panel is shown and that tab is focused. That is “already open in a sidebar tab” and “force focuses.” There is no background-add path.Duplicate tabs are a second, mechanical bug.
pullRequestSurfaceIdkeys on optionalenvironmentId+ optionalhost+ project + repo + number. A click throughopenPullRequestLinkstoreshost. Auto-open usespullRequestSurface(linkedThreadPullRequest).ThreadLinkedPullRequesthasurlbut nohost, and the helper does not parse one out ofurl. Same MR becomes:pull-request:<project>:<host>:<repo>:<n>(click)pull-request:<project>:<repo>:<n>(proactive)
Mixing click + auto-open creates two tabs. The GUI alone will not.
Not fixed after the reported nightly. The only later
ChatViewtouch is #12015 (worktree setup card). No open PR claims this.Related, not duplicates
Issue / PR Why it does not close this Merged #9276 Added opt-in Proactive panels. Original contract: newly linked PR / completed-turn diff only; historical panels stay closed on thread switches. Merged #10610 Made on-entry undefined → keyopen the existing PR. That is the “every time I open a thread” trigger. It did not add hide-across-switch, background-add, or host-stable ids.Merged #10113 Keeps hide/Files during a turn. Revision is re-snapshotted on thread change and dropped on reload. This report is the visit after that. Merged #9753 Empty diffs must not replace an open PR. Priority, not hide/focus. Merged #8160 Thread ↔ PR link. The assign the reporter likes. Not the panel. Open #9079 / #10650 Different PR UX; neither stops on-entry openProactive.No open or merged PR stops
upsertSurfacefrom reopening/focusing, persists the hide across thread keys, or unifies host-less vs host-ful PR surface ids.Suggested fix
Keep this as a right-panel bugfix in
apps/web(desktop inherits). Do not turn off auto-link.- Do not treat a thread revisit as a new link.
shouldOpenProactivePullRequest(undefined, key)is what fix(web): open proactive panels when entering threads #10610 added. First observation of a link on a thread (or a real project/repo/number change) may still open. Re-entering a thread whosetargetKeywas already that MR must not. Persist that last offered key with the panel state, or stop resettingtargetKeyon!sameThreadwhen the thread already has a matching PR surface / stored key. - Honor hide/close across visits. Either persist
userActionRevisionByThreadKey, or refuseopenProactivewhen the matching PR surface already exists andisOpen === false(same idea asdismissedDeviceSurfaceIds). A later new link or a later turn can still offer once. - Do not steal focus. If the surface id is already in
surfaces, callupsertSurface(..., activate=false)and do not forceisOpen: true. First add may still open+focus. “Respect my previously opened tab, even in the background.” - One tab per MR. When building a proactive surface from
ThreadLinkedPullRequest, parsehostfromurl(or match an existing tab by projectId + repository + number, ignoring a missing host). - Tests next to
ChatView.logic.test.ts/rightPanelStore.test.ts: hide → switch thread → come back stays closed; PR tab present with Files active → Files stays; click-with-host then proactive-without → one surface; setting off → on-entry does not open.
Do not revert #10610 wholesale if first-ever visit should still peek the PR when the setting is on. The defect is revisit / hide / focus / duplicate, not “never open.”
Workaround
Settings → General → Proactive panels off. That stops on-entry force-open. Follow-on-reassign can still steal focus if the panel is already showing the previous linked MR; hide the panel first. No in-app “open assigned MR in the background.”
Classification: bug · accepted · medium (web/desktop right panel; thread entry / auto-link force-opens and force-focuses the assigned MR)
Labels: addaccepted,via-triage; keepbug; removeneeds-triage
Discord tags:ui-
- addedacceptedfeature request acceptedfeature request acceptedvia-triageFiled through npx t3 triageFiled through npx t3 triageand removedneeds-triageIssue needs maintainer review and initial categorization.Issue needs maintainer review and initial categorization.
on Sep 16, 2026 - added a commit that references this issue
on Sep 18, 2026
Before submitting
Area
apps/desktop
Steps to reproduce
When having multiple conversations with multiple MRs, the new MR auto-assign feature (I like it very much!) always force-opens the MR sidebar.
Even if it was closed 10 times before. Even if no sidebar was open before. Even if the MR is already open in a sidebar tab. Sometimes it even opens the same MR in multiple tabs (which is not possible normally via the GUI :D)
Expected behavior
It shall respect my previously opened tab (even if opening it in the background) and not force open a sidebar every time its opened.
Actual behavior
It always force opens and force focuses the conversations assigned MR.
Impact
Major degradation or frequent failure
Version or commit
0.0.41-nightly.20260916.1795
Environment
macOS 26.6
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
No response