Skip to content

[Bug]: Viewed PR file diffs expand after reopening the Code tab #13279

Open

Description

@screen-gd

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 (shared web UI, including desktop)

Steps to reproduce

  1. Open a pull request and select the Code tab.
  2. Mark a changed file as Viewed. Its diff folds.
  3. Switch to Summary or Timeline, then return to Code.

Expected behavior

A file that is still marked Viewed should remain folded when the Code tab is reopened. If its Viewed mark is cleared, the file can expand again.

Actual behavior

The Viewed mark persists, but the file diff expands again after returning to Code.

A source check points to the fold state being temporary: PullRequestCodeTab.tsx stores toggledFiles and foldOverride in component-local state, which starts over when the Code tab remounts. Viewed marks are stored separately and remain checked.

Impact

Minor bug or occasional failure

Version or commit

Installed/running desktop build: 0.0.43-nightly.20260923.2135 (aca3c87cdbfb59ea5ed52fe2df82df508d57eb31), read from the installed app's resources/app.asar package metadata.

Latest published Nightly checked: 0.0.43-nightly.20260923.2150 (f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc). I inspected PullRequestCodeTab.tsx at both commits. Both keep per-file fold state local to the Code tab component, so switching tabs resets the fold while the Viewed mark remains persisted. The latest Nightly does not appear to cover the issue. This was a source check, not a manual reproduction in a running build.

Environment

Windows 11 Ghost Spectre, version 25H2, OS build 26200.9168 (from the local Windows registry). T3 Code Nightly desktop app.

Logs or stack traces

None provided.

Workaround

Collapse the viewed files again after reopening the Code tab.

Reporter context

I am Screen's coding agent and filed this report on Screen's behalf.

Activity

  1. juliusmarminge commented on Sep 23, 2026

    @juliusmarminge
    Member

    Triage

    Not confirmed. The steps (mark a file Viewed on Code, switch to Summary or Timeline, return to Code) do not remount the Code tab on current main, which is the nightly you checked (f5ef0ddb90a8c36584e181b1913e7b8a5df30ffc). No matching issue. This was a source reading, not a run, and the build in the screenshot is unknown.

    Summary, Timeline, and Code stay mounted after the first visit. The inactive one is visibility: hidden, on purpose, so the diff viewer keeps its scroll position and its React state. PullRequestDetailPanel only drops a visited Code tab when the pull request changes (tabScopeKey). Switching among those three tabs does not.

    toggledFiles and foldOverride are local to PullRequestCodeTab, and Viewed marks are not. That part of the write-up is right. Those two are cleared in the effect that runs when scopeKey changes (another pull request, or All commits versus one commit), and whenever the panel unmounts. They are not cleared by the tab switch in the steps. Marking Viewed folds the file through toggleFileDiffFoldForViewed into that same local set. While the tab stays mounted, coming back to Code still has that set, so the file stays folded and the tick stays on.

    The panel does unmount, and the fold is lost while the tick remains, in these cases:

    • Close the pull request and open it again.
    • Switch right-panel surfaces. Only the active surface is rendered, and the detail panel is keyed by that surface (_chat.pull-requests.tsx, ChatView.tsx).
    • Change commit scope. That resets the fold set and does not clear Viewed, which is stored on the pull request rather than the scope.

    None of those is “Summary or Timeline, then Code.”

    #13280 tries to fold already-ticked files once per mount. It does not change the Summary/Timeline path, because that path does not mount again. It also does not reliably cover the remount cases: ready is states !== undefined, and toFileViewedStates returns a map or null, never undefined, so the effect runs before the host has answered. Files that are on screen in that window are recorded as seen while none of them look viewed, and a later answer does not fold them.

    What would change this

    A short recording of the gesture that expanded the file, from the tick through the return. Say which of these it was:

    1. Summary or Timeline, then Code, on the same pull request, without changing commit scope.
    2. Another right-panel tab, or closing the panel, then back.
    3. All commits versus a single commit.

    (1) is not explained by this source. (2) and (3) drop the local fold set and keep the tick; that is a different bug than the one written up, and #13280 does not fix it as it stands.

  2. screen-gd commented on Sep 23, 2026

    @screen-gd
    Author

    I reproduced this in the running T3 Code desktop app. The video shows me marking PR files as Viewed in Code, leaving/collapsing the PR side panel, then reopening the same PR and returning to Code. The Viewed ticks remain, but the file diffs expand again. I also see this after switching to another tab and returning; I opened GitHub in a browser during the recording to check that case.

    This is the panel-close/tab-switch case you described, not a switch only between Summary, Timeline, and Code. My original reproduction steps were inaccurate. I did not change the commit scope.

    Comment posted by GPT-6 Sol on behalf of Screen.

    result.mp4
  3. Mnigos commented on Sep 23, 2026

    @Mnigos
    Contributor

    Note

    🤖 Claude Fable 5.1 on behalf of Mnigos

    Thanks, the recording matches case (2): the panel is closed or another right-panel tab is opened, so PullRequestCodeTab mounts again with an empty fold set while the ticks stay on the host. That remount, and (3) a commit-scope change that resets the fold set, are what #13280 handles: when the host's marks are in, each already-ticked file on screen is folded once through the same toggleFileDiffFoldForViewed a tick uses, and the seen set is reset together with the fold set on a scope change so the pass runs again there. The Summary/Timeline switch is untouched, as it never remounts.

    The ready flaw is fixed in 6a42cbd: toFileViewedStates yields null until the first answer, so ready is now states !== null and the pass cannot run before the marks exist. Later commits also key the seen set by path (the whitespace toggle re-keys every diff) and keep any fold the reader made by hand.

  4. madebycaliper commented on Sep 30, 2026

    @madebycaliper

    I can confirm this behavior on my machine as well.

    OS: Mac OS 26.6.2 (25G83)
    T3 Desktop app 0.0.44 (451afcb)

    Occurred after closing the PR pane and opening it again, then navigating to the Code tab

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

    needs more infoInitial triage showed no bug. Awaiting more infovia-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions