Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ndom91
Copy link

@ndom91 ndom91 commented Nov 8, 2025

Fixes: #8714

Reopening #8715. Good call, the new file name was available in the dropdown on the first party links

  • Updated pr-branches.ts getBranches to support the new UI, with fallback for the old UI
  • Unfortunately the since the dropdowns are now portaled we can't get the old filename from the file header in the main diff view. That old filename really doesn't seem to be anywhere in the portaled dropdown unfortunately.
  • But it looks like the new react UI props are available in a script tag that we can leverage. Was able to grab the old file name from any changes that are labelled "RENAMED" from there. What do you think of using those generally?

For example:

Set of react props from PR page script tag
{
    "payload": {
        "isSingleFileMode": false,
        "aliveChannel": "eyJjIjoicHVsbF9yZXF1ZXN0OjI5OTE1ODAzMDUiLCJ0IjoxNzYyNjI1ODAyfQ==--916b0885b1749d5aa89bf6de209b19f96ba2481b586140d4f928ca8b4c565055",
        "bannersData": {
            "banners": {
                "dependabotAutomatedSecurityUpdates": {
                    "render": false
                },
                "pausedDependabotUpdate": {
                    "render": false
                },
                "hiddenCharacterWarning": {
                    "render": false
                }
            }
        },
        "changeGroupGeneration": {
            "canAccessChangeGroups": false,
            "changeGroupFeedbackOptions": [
                {
                    "label": "Groups contain changes that do not belong together",
                    "value": "NOT_RELEVANT"
                },
                {
                    "label": "Groups are harmful or unsafe",
                    "value": "OFFENSIVE_OR_DISCRIMINATORY"
                },
                {
                    "label": "Groups are poorly formatted",
                    "value": "POORLY_FORMATTED"
                },
                {
                    "label": "Groups are not helpful",
                    "value": "NOT_HELPFUL"
                },
                {
                    "label": "Groups miss changes that should be included",
                    "value": "MISSED_CONTENT"
                },
                {
                    "label": "Other",
                    "value": "OTHER"
                }
            ],
            "changeGroups": [],
            "unavailableReason": null,
            "latestChangeGroupOrchestration": null,
            "changeGroupGenerationChannel": "eyJjIjoicHVsbF9yZXF1ZXN0OjI5OTE1ODAzMDU6Y2hhbmdlX2dyb3VwX2dlbmVyYXRpb24iLCJ0IjoxNzYyNjI1ODAyfQ==--cdf22234dc9a046fc1d932d776b71e65d92afae3e6cf57d4dcbe4889d79ad8f2"
        },
        "codeowners": null,
        "commits": [
            {
                "actorLogin": "ndom91",
                "createdAt": "2025-11-08T17:27:03+01:00",
                "messageHeadline": "Dummy commit",
                "oid": "43d8cb6ca432205345a0a881a163f932db7566f5",
                "shortOid": "43d8cb6"
            },
            {
                "actorLogin": "ndom91",
                "createdAt": "2025-11-08T17:30:23+01:00",
                "messageHeadline": "Rename commit",
                "oid": "106f9054bf4d387bca0ac3f2ea07a321726d2d29",
                "shortOid": "106f905"
            },
            {
                "actorLogin": "ndom91",
                "createdAt": "2025-11-08T18:46:06+01:00",
                "messageHeadline": "Discard changes to LICENSE",
                "oid": "ac6c7f8396a502bdb75e6c980ff36d262f88c016",
                "shortOid": "ac6c7f8"
            },
            {
                "actorLogin": "ndom91",
                "createdAt": "2025-11-08T19:10:59+01:00",
                "messageHeadline": "Discard changes to hometime.service",
                "oid": "3888cb117d589c609bab6e245dd65c42cfa0e635",
                "shortOid": "3888cb1"
            }
        ],
        "diffSummaries": [
            {
                "changeType": "MODIFIED",
                "isCodeowner": null,
                "isManifestFile": true,
                "isVendored": false,
                "linesAdded": 1,
                "linesChanged": 2,
                "linesDeleted": 1,
                "markedAsViewed": false,
                "path": "package.json",
                "pathDigest": "7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519",
                "highestAnnotationLevel": null,
                "markersMap": {}
            },
            {
                "changeType": "MODIFIED",
                "isCodeowner": null,
                "isManifestFile": false,
                "isVendored": false,
                "linesAdded": 1,
                "linesChanged": 1,
                "linesDeleted": 0,
                "markedAsViewed": false,
                "path": "tsconfig.json",
                "pathDigest": "b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0",
                "highestAnnotationLevel": null,
                "markersMap": {}
            }
        ],
        "diffContents": [
            {
                "isBinary": false,
                "isSubmodule": false,
                "isTooBig": false,
                "diffLines": [
                    {
                        "type": "HUNK",
                        "blobLineNumber": 0,
                        "position": 0,
                        "displayNoNewLineWarning": false,
                        "text": "@@ -1,6 +1,6 @@",
                        "html": "@@ -1,6 +1,6 @@",
                        "left": 0,
                        "right": 0,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 1,
                        "position": 1,
                        "displayNoNewLineWarning": false,
                        "text": " {",
                        "html": " {",
                        "left": 1,
                        "right": 1,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 2,
                        "position": 2,
                        "displayNoNewLineWarning": false,
                        "text": "   \"name\": \"hometime-server\",",
                        "html": "   <span class=\"pl-ent\">&quot;name&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>hometime-server<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 2,
                        "right": 2,
                        "problems": []
                    },
                    {
                        "type": "DELETION",
                        "blobLineNumber": 3,
                        "position": 3,
                        "displayNoNewLineWarning": false,
                        "text": "-  \"version\": \"1.0.0\",",
                        "html": "-  <span class=\"pl-ent\">\"version\"</span>: <span class=\"pl-s\"><span class=\"pl-pds\">\"</span><span class=\"x x-first x-last\">1</span>.0.0<span class=\"pl-pds\">\"</span></span>,",
                        "left": 3,
                        "right": 2,
                        "problems": []
                    },
                    {
                        "type": "ADDITION",
                        "blobLineNumber": 3,
                        "position": 4,
                        "displayNoNewLineWarning": false,
                        "text": "+  \"version\": \"2.0.0\",",
                        "html": "+  <span class=\"pl-ent\">\"version\"</span>: <span class=\"pl-s\"><span class=\"pl-pds\">\"</span><span class=\"x x-first x-last\">2</span>.0.0<span class=\"pl-pds\">\"</span></span>,",
                        "left": 3,
                        "right": 3,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 4,
                        "position": 5,
                        "displayNoNewLineWarning": false,
                        "text": "   \"description\": \"LED progress bar visualization for work hours and calendar events\",",
                        "html": "   <span class=\"pl-ent\">&quot;description&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>LED progress bar visualization for work hours and calendar events<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 4,
                        "right": 4,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 5,
                        "position": 6,
                        "displayNoNewLineWarning": false,
                        "text": "   \"main\": \"dist/index.js\",",
                        "html": "   <span class=\"pl-ent\">&quot;main&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>dist/index.js<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 5,
                        "right": 5,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 6,
                        "position": 7,
                        "displayNoNewLineWarning": false,
                        "text": "   \"scripts\": {",
                        "html": "   <span class=\"pl-ent\">&quot;scripts&quot;</span>: {",
                        "left": 6,
                        "right": 6,
                        "problems": []
                    }
                ],
                "linesAdded": 1,
                "linesChanged": 2,
                "linesDeleted": 1,
                "oldCommitOid": "611aaf78d8f24679931109aaae3e28c9f02735d0",
                "newCommitOid": "3888cb117d589c609bab6e245dd65c42cfa0e635",
                "oldTreeEntry": {
                    "mode": 100644,
                    "path": "package.json",
                    "lineCount": 27
                },
                "newTreeEntry": {
                    "mode": 100644,
                    "path": "package.json",
                    "lineCount": 27,
                    "isGenerated": false
                },
                "path": "package.json",
                "pathDigest": "7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519",
                "richDiff": {
                    "canToggleRichDiff": true,
                    "defaultToRichDiff": false,
                    "proseDiffHtml": null,
                    "renderInfo": null,
                    "dependencyDiffPath": "/ndom91/calendar-led-strip/dependency-review/611aaf78d8f24679931109aaae3e28c9f02735d0/3888cb117d589c609bab6e245dd65c42cfa0e635/rich_diff?manifest_path=package.json"
                },
                "submodule": null,
                "status": "MODIFIED",
                "truncatedReason": null,
                "diffSize": "",
                "reviewed": false
            },
            {
                "isBinary": false,
                "isSubmodule": false,
                "isTooBig": false,
                "diffLines": [
                    {
                        "type": "HUNK",
                        "blobLineNumber": 0,
                        "position": 0,
                        "displayNoNewLineWarning": false,
                        "text": "@@ -1,6 +1,7 @@",
                        "html": "@@ -1,6 +1,7 @@",
                        "left": 0,
                        "right": 0,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 1,
                        "position": 1,
                        "displayNoNewLineWarning": false,
                        "text": " {",
                        "html": " {",
                        "left": 1,
                        "right": 1,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 2,
                        "position": 2,
                        "displayNoNewLineWarning": false,
                        "text": "   \"compilerOptions\": {",
                        "html": "   <span class=\"pl-ent\">&quot;compilerOptions&quot;</span>: {",
                        "left": 2,
                        "right": 2,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 3,
                        "position": 3,
                        "displayNoNewLineWarning": false,
                        "text": "     \"target\": \"ES2020\",",
                        "html": "     <span class=\"pl-ent\">&quot;target&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>ES2020<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 3,
                        "right": 3,
                        "problems": []
                    },
                    {
                        "type": "ADDITION",
                        "blobLineNumber": 4,
                        "position": 4,
                        "displayNoNewLineWarning": false,
                        "text": "+    \"test\": \"12\",",
                        "html": "+    <span class=\"pl-ent\">&quot;test&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>12<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 3,
                        "right": 4,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 5,
                        "position": 5,
                        "displayNoNewLineWarning": false,
                        "text": "     \"module\": \"commonjs\",",
                        "html": "     <span class=\"pl-ent\">&quot;module&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>commonjs<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 4,
                        "right": 5,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 6,
                        "position": 6,
                        "displayNoNewLineWarning": false,
                        "text": "     \"lib\": [\"ES2020\"],",
                        "html": "     <span class=\"pl-ent\">&quot;lib&quot;</span>: [<span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>ES2020<span class=\"pl-pds\">&quot;</span></span>],",
                        "left": 5,
                        "right": 6,
                        "problems": []
                    },
                    {
                        "type": "CONTEXT",
                        "blobLineNumber": 7,
                        "position": 7,
                        "displayNoNewLineWarning": false,
                        "text": "     \"outDir\": \"./dist\",",
                        "html": "     <span class=\"pl-ent\">&quot;outDir&quot;</span>: <span class=\"pl-s\"><span class=\"pl-pds\">&quot;</span>./dist<span class=\"pl-pds\">&quot;</span></span>,",
                        "left": 6,
                        "right": 7,
                        "problems": []
                    }
                ],
                "linesAdded": 1,
                "linesChanged": 1,
                "linesDeleted": 0,
                "oldCommitOid": "611aaf78d8f24679931109aaae3e28c9f02735d0",
                "newCommitOid": "3888cb117d589c609bab6e245dd65c42cfa0e635",
                "oldTreeEntry": {
                    "mode": 100644,
                    "path": "tsconfig.json",
                    "lineCount": 19
                },
                "newTreeEntry": {
                    "mode": 100644,
                    "path": "tsconfig.json",
                    "lineCount": 20,
                    "isGenerated": false
                },
                "path": "tsconfig.json",
                "pathDigest": "b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0",
                "richDiff": null,
                "submodule": null,
                "status": "MODIFIED",
                "truncatedReason": null,
                "diffSize": "",
                "reviewed": false
            }
        ],
        "fileFilter": {
            "initialState": {
                "fileExtensions": {
                    ".json": 2
                },
                "filterText": "",
                "showDeletedFiles": true,
                "showOnlyManifestFiles": false,
                "showOnlyOwnedFiles": false,
                "showVendoredFiles": true,
                "showViewedFiles": true,
                "unselectedFileExtensions": []
            },
            "menuOptions": {
                "canSeeCodeownersFilter": false,
                "canSeeDeletedFilesFilter": false,
                "canSeeOnlyManifestFilesFilter": true,
                "canSeeVendorFilesFilter": false
            }
        },
        "pullRequest": {
            "author": {
                "login": "ndom91"
            },
            "aliveChannel": "eyJjIjoicHVsbF9yZXF1ZXN0OjI5OTE1ODAzMDUiLCJ0IjoxNzYyNjI1ODAyfQ==--916b0885b1749d5aa89bf6de209b19f96ba2481b586140d4f928ca8b4c565055",
            "baseBranch": "main",
            "commitsCount": 4,
            "comparison": {
                "baseOid": "611aaf78d8f24679931109aaae3e28c9f02735d0",
                "headOid": "3888cb117d589c609bab6e245dd65c42cfa0e635"
            },
            "globalRelayId": "PR_kwDOPhSFV86yT-SR",
            "headBranch": "dummy-branch",
            "headRepositoryName": "calendar-led-strip",
            "headRepositoryOwnerLogin": "ndom91",
            "id": 2991580305,
            "isInAdvisoryRepo": false,
            "mergedBy": null,
            "mergedTime": null,
            "number": 1,
            "pathName": "/ndom91/calendar-led-strip/pull/1",
            "state": "DRAFT",
            "title": "Dummy commit",
            "titleHtml": "Dummy commit",
            "viewerAllowedNonCommentReviewTypes": [],
            "viewerHasViolatedPushPolicy": false,
            "viewerIsCopilotAttributed": false
        },
        "repository": {
            "codespacesEnabled": true,
            "editorEnabled": false,
            "defaultBranch": "main",
            "id": 1041532247,
            "isEnterprise": false,
            "name": "calendar-led-strip",
            "ownerLogin": "ndom91",
            "viewerPermission": "admin"
        },
        "threads": {},
        "urls": {
            "images": {
                "mona-hifive": "/images/mona-hifive.gif"
            },
            "checks": "/ndom91/calendar-led-strip/pull/1/checks",
            "commits": "/ndom91/calendar-led-strip/pull/1/commits",
            "conversation": "/ndom91/calendar-led-strip/pull/1",
            "files": "/ndom91/calendar-led-strip/pull/1/files",
            "walkthrough": "/ndom91/calendar-led-strip/pull/1/walkthrough"
        },
        "user": {
            "canChangeBase": true,
            "canComment": true,
            "currentUserAvatarUrl": "https://avatars.githubusercontent.com/u/7415984?v=4",
            "currentUserLogin": "ndom91",
            "canEditTitle": true,
            "hasCopilotAccess": true,
            "canApplySuggestion": true,
            "isFileTreeExpanded": true,
            "lastReviewOid": null,
            "shouldShowViewedFilesCount": true,
            "tabSize": 2,
            "viewedFilesCount": 0,
            "viewSettings": {
                "hideWhitespace": false,
                "lineSpacing": "compact",
                "showChangeGroups": true,
                "splitPreference": "split",
                "commentsPreference": "visible"
            }
        },
        "userNotices": [
            {
                "name": "compact_diff_lines",
                "dismissed": true
            },
            {
                "name": "single_file_mode",
                "dismissed": true
            }
        ],
        "viewerPendingReview": {
            "id": null,
            "comments": []
        },
        "markers": {
            "threads": {},
            "annotations": {}
        },
        "pageLimits": {
            "annotationsLimit": 50,
            "annotationsLimitExceeded": false,
            "filesLimit": 1000,
            "filesLimitExceeded": false,
            "reviewCommentsPerThreadLimit": 20,
            "reviewThreadsLimit": 40,
            "reviewThreadsLimitExceeded": false
        }
    },
    "title": "Dummy commit by ndom91 · Pull Request #1 · ndom91/calendar-led-strip",
    "appPayload": {
        "helpUrl": "https://docs.github.com",
        "refListCacheKey": "v0:1762619230.0",
        "enabled_features": {
            "accessible_code_button": true,
            "copilot_workspace": false,
            "cotd_derive_thread_previews": false,
            "batch_suggested_changes": true,
            "prx_dynamic_split_pref": false,
            "prx_files": true,
            "prx_files_lite_throttle": false,
            "prx_files_medium_throttle": false,
            "pulls-files-skip-prefer-any-solo-entry": false,
            "generate_groups_on_files_view": false,
            "react_data_router_pull_request_files": false,
            "cotd_ui": true,
            "automated_review_comment_simplification": true
        }
    }
}
  • Tested both discard normal changes as well as renames and they both work 🙌

Test URLs

Screenshot

Still rendering in old view and renders nicely in new view now as well:

Old View

New View

CleanShot 2025-10-21 at 18 33 35 CleanShot 2025-10-21 at 18 32 46

@ndom91 ndom91 changed the title Add watch selector for new PR file view dropdown menu Fix restore-file for new GitHub PR file view 2 Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

restore-file broken in new GitHub PR File List view

1 participant