From 784aefee50df75fcc65b1c132f1d43dbad21afdc Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Sun, 8 Nov 2026 06:27:50 -0800 Subject: [PATCH] perf(tasks): look up the GitLab comment viewer only on phone reads (#39860) * perf(tasks): look up the GitLab comment viewer only on phone reads The phone is the only reader of viewerDidAuthor, so GitLab detail reads from desktop IPC and the Checks poll skip the `glab api user` lookup. The phone sends markViewerComments on every GitLab detail read. Ported from #39749 (GitLab part only); GitHub REST-fallback viewer lookup is unchanged. Co-authored-by: AmoabaKelvin <97001695+AmoabaKelvin@users.noreply.github.com> * perf(tasks): keep GitLab viewer marks by default; desktop detail reads opt out Older phones and callers that omit markViewerComments keep author marks. Co-authored-by: AmoabaKelvin <97001695+AmoabaKelvin@users.noreply.github.com> --------- Co-authored-by: m4air Co-authored-by: AmoabaKelvin <97001695+AmoabaKelvin@users.noreply.github.com> --- ...etail-gitlab-gitlab.workitemdetails-1.json | 827 +++++++++--------- .../tk-item-detail-gitlab-reactions.json | 149 ++-- .../goldens/tk-item-detail-gitlab.json | 119 +-- mobile/rpc-foundation/pilot-scenarios.json | 2 + .../use-mobile-tasks-item-detail-loading.tsx | 4 +- src/main/gitlab/work-item-details.test.ts | 89 +- src/main/gitlab/work-item-details.ts | 30 +- .../gitlab-work-item-handlers.ts | 3 +- .../gitlab/runtime-gitlab-query-commands.ts | 5 +- .../methods/source-control/gitlab/gitlab.ts | 3 +- src/shared/gitlab-types.ts | 2 +- src/shared/rpc-contract/gitlab-params.ts | 4 +- 12 files changed, 647 insertions(+), 590 deletions(-) diff --git a/mobile/rpc-foundation/goldens/matrix-tasks.item-detail-gitlab-gitlab.workitemdetails-1.json b/mobile/rpc-foundation/goldens/matrix-tasks.item-detail-gitlab-gitlab.workitemdetails-1.json index 337b9fae412..42fb92147d3 100644 --- a/mobile/rpc-foundation/goldens/matrix-tasks.item-detail-gitlab-gitlab.workitemdetails-1.json +++ b/mobile/rpc-foundation/goldens/matrix-tasks.item-detail-gitlab-gitlab.workitemdetails-1.json @@ -4,214 +4,6 @@ "family": "tasks.item-detail-gitlab", "namedDeltas": [], "values": { - "015b5a605d73": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "rejected", - "startedAt": 0, - "settledAt": 0, - "error": { - "category": "Error", - "message": "transport failure", - "isRpcDeliveryUnknown": true - } - } - }, - "05d9d719aedf": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true - } - } - }, - "0b1aa38d91fe": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "approvalState": { - "approvalsLeft": 0, - "approvalsRequired": 1 - }, - "assignees": [], - "body": "body", - "comments": [], - "item": { - "labels": ["bug"], - "mergeable": "MERGEABLE" - }, - "pipelineJobs": [], - "reviewers": [] - } - } - } - }, - "130315fb1ac1": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "error": { - "code": "method_not_found", - "message": "Unknown method" - }, - "id": "frame-1", - "ok": false - } - } - }, - "145f9d8e8016": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "error": "refused" - } - } - } - }, "16125975286b": { "name": "detailLoading", "ordinal": 3, @@ -262,6 +54,48 @@ "$rpc": "null" } }, + "1635b185b481": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "error": "inner refused", + "ok": false + } + } + } + }, "185dd46f0a38": { "name": "detailLoading", "ordinal": 8, @@ -272,6 +106,48 @@ "ordinal": 12, "value": false }, + "260f60ac62a3": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "error": { + "code": "refused", + "message": "outer refused" + }, + "id": "frame-1", + "ok": false + } + } + }, "274b8ecb4f73": { "name": "actionItem", "ordinal": 6, @@ -294,6 +170,45 @@ "title": "A GitLab issue" } }, + "28116db8d1bc": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "rejected", + "startedAt": 0, + "settledAt": 0, + "error": { + "category": "Error", + "message": "transport failure", + "isRpcDeliveryUnknown": true + } + } + }, "3d683d8ca027": { "name": "detailPayload", "ordinal": 13, @@ -470,6 +385,44 @@ "$rpc": "null" } }, + "54f8a6328304": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true + } + } + }, "5c69a0ab4415": { "name": "actionItem", "ordinal": 11, @@ -504,48 +457,7 @@ "title": "A GitLab issue" } }, - "5ecb7a6ae6e9": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "error": { - "code": "refused", - "message": "outer refused" - }, - "id": "frame-1", - "ok": false - } - } - }, - "676e5d7c56b0": { + "6c3b3a2c300d": { "name": "gitlab.workItemDetails#1", "ordinal": 7, "args": [ @@ -557,6 +469,7 @@ "name": "params", "value": { "iid": 4, + "markViewerComments": true, "projectRef": { "host": "gitlab.com", "path": "group/project" @@ -580,63 +493,17 @@ "id": "frame-1", "ok": true, "result": { - "error": "inner refused", - "ok": false + "$rpc": "null" } } } }, - "6b3f4d740608": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "rejected", - "startedAt": 0, - "settledAt": 0, - "error": { - "category": "Error", - "message": "", - "isRpcDeliveryUnknown": true - } - } - }, "6d653e11366f": { "name": "detailLoading", "ordinal": 11, "value": false }, - "72c0fc81a418": { - "name": "detailPayload", - "ordinal": 4, - "value": { - "$rpc": "null" - } - }, - "7bce9aa622f6": { + "71f39b93a6b4": { "name": "gitlab.workItemDetails#1", "ordinal": 7, "args": [ @@ -648,6 +515,7 @@ "name": "params", "value": { "iid": 4, + "markViewerComments": true, "projectRef": { "host": "gitlab.com", "path": "group/project" @@ -677,6 +545,13 @@ } } }, + "72c0fc81a418": { + "name": "detailPayload", + "ordinal": 4, + "value": { + "$rpc": "null" + } + }, "7eff2c9f8145": { "name": "detailError", "ordinal": 10, @@ -727,51 +602,6 @@ "$rpc": "null" } }, - "80934dd310af": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "$rpc": "null" - } - } - } - }, - "8ac545c58ec2": { - "name": "gitlab.workItemDetails#1", - "ordinal": 9, - "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"}}}" - }, "988fd3d6f1c4": { "name": "detailRefreshSeq", "ordinal": 5, @@ -822,6 +652,45 @@ "$rpc": "null" } }, + "a472ad8b3e3f": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "rejected", + "startedAt": 0, + "settledAt": 0, + "error": { + "category": "Error", + "message": "", + "isRpcDeliveryUnknown": true + } + } + }, "a4f1a8696a24": { "name": "detailError", "ordinal": 2, @@ -930,6 +799,64 @@ "provider": "gitlab" } }, + "ba6215ed3c22": { + "name": "gitlab.workItemDetails#1", + "ordinal": 9, + "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"},\"markViewerComments\":true}}" + }, + "c0f53c2b7ecd": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "approvalState": { + "approvalsLeft": 0, + "approvalsRequired": 1 + }, + "assignees": [], + "body": "body", + "comments": [], + "item": { + "labels": ["bug"], + "mergeable": "MERGEABLE" + }, + "pipelineJobs": [], + "reviewers": [] + } + } + } + }, "c187052ac3d0": { "name": "detailError", "ordinal": 10, @@ -947,6 +874,92 @@ "$rpc": "null" } }, + "db2c5ff09560": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "error": { + "code": "method_not_found", + "message": "Unknown method" + }, + "id": "frame-1", + "ok": false + } + } + }, + "eafe5f01950b": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "error": { + "message": "inner refused" + }, + "ok": false + } + } + } + }, "eb79a9b3682a": { "status": "fulfilled", "startedAt": 0, @@ -955,6 +968,47 @@ "$rpc": "undefined" } }, + "f21be2fb8222": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "error": "refused" + } + } + } + }, "f3032e4b7cc7": { "error": "", "item": { @@ -1056,49 +1110,6 @@ } ] }, - "f791a44b1e80": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "error": { - "message": "inner refused" - }, - "ok": false - } - } - } - }, "f9f4fedb976a": { "name": "items", "ordinal": 10, @@ -1142,8 +1153,8 @@ { "id": "tk-item-detail-gitlab.normal:mounted", "observation": { - "sender": ["0b1aa38d91fe"], - "payloads": ["8ac545c58ec2"], + "sender": ["c0f53c2b7ecd"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1166,8 +1177,8 @@ { "id": "tk-item-detail-gitlab.result-absent:mounted", "observation": { - "sender": ["05d9d719aedf"], - "payloads": ["8ac545c58ec2"], + "sender": ["54f8a6328304"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1188,8 +1199,8 @@ { "id": "tk-item-detail-gitlab.result-null:mounted", "observation": { - "sender": ["80934dd310af"], - "payloads": ["8ac545c58ec2"], + "sender": ["6c3b3a2c300d"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1210,8 +1221,8 @@ { "id": "tk-item-detail-gitlab.inner-ok-missing:mounted", "observation": { - "sender": ["145f9d8e8016"], - "payloads": ["8ac545c58ec2"], + "sender": ["f21be2fb8222"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1234,8 +1245,8 @@ { "id": "tk-item-detail-gitlab.inner-false-string-error:mounted", "observation": { - "sender": ["676e5d7c56b0"], - "payloads": ["8ac545c58ec2"], + "sender": ["1635b185b481"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1258,8 +1269,8 @@ { "id": "tk-item-detail-gitlab.inner-false-object-error:mounted", "observation": { - "sender": ["f791a44b1e80"], - "payloads": ["8ac545c58ec2"], + "sender": ["eafe5f01950b"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1282,8 +1293,8 @@ { "id": "tk-item-detail-gitlab.outer-refused:mounted", "observation": { - "sender": ["5ecb7a6ae6e9"], - "payloads": ["8ac545c58ec2"], + "sender": ["260f60ac62a3"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1304,8 +1315,8 @@ { "id": "tk-item-detail-gitlab.outer-refused-no-message:mounted", "observation": { - "sender": ["7bce9aa622f6"], - "payloads": ["8ac545c58ec2"], + "sender": ["71f39b93a6b4"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1325,8 +1336,8 @@ { "id": "tk-item-detail-gitlab.method-not-found:mounted", "observation": { - "sender": ["130315fb1ac1"], - "payloads": ["8ac545c58ec2"], + "sender": ["db2c5ff09560"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1347,8 +1358,8 @@ { "id": "tk-item-detail-gitlab.transport-rejection:mounted", "observation": { - "sender": ["015b5a605d73"], - "payloads": ["8ac545c58ec2"], + "sender": ["28116db8d1bc"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, @@ -1369,8 +1380,8 @@ { "id": "tk-item-detail-gitlab.transport-rejection-no-message:mounted", "observation": { - "sender": ["6b3f4d740608"], - "payloads": ["8ac545c58ec2"], + "sender": ["a472ad8b3e3f"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, diff --git a/mobile/rpc-foundation/goldens/tk-item-detail-gitlab-reactions.json b/mobile/rpc-foundation/goldens/tk-item-detail-gitlab-reactions.json index 7b954f54e29..a1f4c43b1b1 100644 --- a/mobile/rpc-foundation/goldens/tk-item-detail-gitlab-reactions.json +++ b/mobile/rpc-foundation/goldens/tk-item-detail-gitlab-reactions.json @@ -4,6 +4,74 @@ "family": "tasks.item-detail-gitlab", "namedDeltas": [], "values": { + "0b2033ec0891": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "approvalState": { + "approvalsLeft": 0, + "approvalsRequired": 1 + }, + "assignees": [], + "body": "body", + "comments": [ + { + "author": "octocat", + "authorAvatarUrl": "", + "body": "a discussion note", + "createdAt": "2020-01-01T00:00:00.000Z", + "id": 901, + "reactions": [ + { + "count": 2, + "name": "thumbsup" + } + ], + "url": "https://gitlab.example.com/group/project/-/issues/4#note_901" + } + ], + "item": { + "labels": ["bug"], + "mergeable": "MERGEABLE" + }, + "pipelineJobs": [], + "reviewers": [] + } + } + } + }, "12958fc227ba": { "error": "", "item": { @@ -171,78 +239,6 @@ "$rpc": "null" } }, - "8ac545c58ec2": { - "name": "gitlab.workItemDetails#1", - "ordinal": 9, - "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"}}}" - }, - "90e2c30bae69": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "approvalState": { - "approvalsLeft": 0, - "approvalsRequired": 1 - }, - "assignees": [], - "body": "body", - "comments": [ - { - "author": "octocat", - "authorAvatarUrl": "", - "body": "a discussion note", - "createdAt": "2020-01-01T00:00:00.000Z", - "id": 901, - "reactions": [ - { - "count": 2, - "name": "thumbsup" - } - ], - "url": "https://gitlab.example.com/group/project/-/issues/4#note_901" - } - ], - "item": { - "labels": ["bug"], - "mergeable": "MERGEABLE" - }, - "pipelineJobs": [], - "reviewers": [] - } - } - } - }, "988fd3d6f1c4": { "name": "detailRefreshSeq", "ordinal": 5, @@ -280,6 +276,11 @@ "provider": "gitlab" } }, + "ba6215ed3c22": { + "name": "gitlab.workItemDetails#1", + "ordinal": 9, + "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"},\"markViewerComments\":true}}" + }, "cc2ece9478f0": { "name": "actionItem", "ordinal": 1, @@ -338,8 +339,8 @@ { "id": "mounted", "observation": { - "sender": ["90e2c30bae69"], - "payloads": ["8ac545c58ec2"], + "sender": ["0b2033ec0891"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, diff --git a/mobile/rpc-foundation/goldens/tk-item-detail-gitlab.json b/mobile/rpc-foundation/goldens/tk-item-detail-gitlab.json index e68e16ce201..2596badc1bf 100644 --- a/mobile/rpc-foundation/goldens/tk-item-detail-gitlab.json +++ b/mobile/rpc-foundation/goldens/tk-item-detail-gitlab.json @@ -4,58 +4,6 @@ "family": "tasks.item-detail-gitlab", "namedDeltas": [], "values": { - "0b1aa38d91fe": { - "name": "gitlab.workItemDetails#1", - "ordinal": 7, - "args": [ - { - "name": "method", - "value": "gitlab.workItemDetails" - }, - { - "name": "params", - "value": { - "iid": 4, - "projectRef": { - "host": "gitlab.com", - "path": "group/project" - }, - "repo": "id:repo-1", - "type": "issue" - } - }, - { - "name": "options", - "value": { - "timeoutMs": 30000 - } - } - ], - "settlement": { - "status": "fulfilled", - "startedAt": 0, - "settledAt": 0, - "value": { - "id": "frame-1", - "ok": true, - "result": { - "approvalState": { - "approvalsLeft": 0, - "approvalsRequired": 1 - }, - "assignees": [], - "body": "body", - "comments": [], - "item": { - "labels": ["bug"], - "mergeable": "MERGEABLE" - }, - "pipelineJobs": [], - "reviewers": [] - } - } - } - }, "16125975286b": { "name": "detailLoading", "ordinal": 3, @@ -220,11 +168,6 @@ "$rpc": "null" } }, - "8ac545c58ec2": { - "name": "gitlab.workItemDetails#1", - "ordinal": 9, - "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"}}}" - }, "988fd3d6f1c4": { "name": "detailRefreshSeq", "ordinal": 5, @@ -235,6 +178,64 @@ "ordinal": 2, "value": "" }, + "ba6215ed3c22": { + "name": "gitlab.workItemDetails#1", + "ordinal": 9, + "json": "{\"id\":\"frame-1\",\"deviceToken\":\"recording-device\",\"method\":\"gitlab.workItemDetails\",\"params\":{\"repo\":\"id:repo-1\",\"iid\":4,\"type\":\"issue\",\"projectRef\":{\"host\":\"gitlab.com\",\"path\":\"group/project\"},\"markViewerComments\":true}}" + }, + "c0f53c2b7ecd": { + "name": "gitlab.workItemDetails#1", + "ordinal": 7, + "args": [ + { + "name": "method", + "value": "gitlab.workItemDetails" + }, + { + "name": "params", + "value": { + "iid": 4, + "markViewerComments": true, + "projectRef": { + "host": "gitlab.com", + "path": "group/project" + }, + "repo": "id:repo-1", + "type": "issue" + } + }, + { + "name": "options", + "value": { + "timeoutMs": 30000 + } + } + ], + "settlement": { + "status": "fulfilled", + "startedAt": 0, + "settledAt": 0, + "value": { + "id": "frame-1", + "ok": true, + "result": { + "approvalState": { + "approvalsLeft": 0, + "approvalsRequired": 1 + }, + "assignees": [], + "body": "body", + "comments": [], + "item": { + "labels": ["bug"], + "mergeable": "MERGEABLE" + }, + "pipelineJobs": [], + "reviewers": [] + } + } + } + }, "cc2ece9478f0": { "name": "actionItem", "ordinal": 1, @@ -293,8 +294,8 @@ { "id": "mounted", "observation": { - "sender": ["0b1aa38d91fe"], - "payloads": ["8ac545c58ec2"], + "sender": ["c0f53c2b7ecd"], + "payloads": ["ba6215ed3c22"], "settlements": { "mount": "eb79a9b3682a" }, diff --git a/mobile/rpc-foundation/pilot-scenarios.json b/mobile/rpc-foundation/pilot-scenarios.json index 0a350271da4..36719b8cfdb 100644 --- a/mobile/rpc-foundation/pilot-scenarios.json +++ b/mobile/rpc-foundation/pilot-scenarios.json @@ -12221,6 +12221,7 @@ "complete": "gitlab.workItemDetails#1", "params": { "iid": 4, + "markViewerComments": true, "projectRef": { "host": "gitlab.com", "path": "group/project" @@ -12267,6 +12268,7 @@ "complete": "gitlab.workItemDetails#1", "params": { "iid": 4, + "markViewerComments": true, "projectRef": { "host": "gitlab.com", "path": "group/project" diff --git a/mobile/src/tasks/use-mobile-tasks-item-detail-loading.tsx b/mobile/src/tasks/use-mobile-tasks-item-detail-loading.tsx index ba30b5337ef..a23806cbb65 100644 --- a/mobile/src/tasks/use-mobile-tasks-item-detail-loading.tsx +++ b/mobile/src/tasks/use-mobile-tasks-item-detail-loading.tsx @@ -135,7 +135,9 @@ export function useMobileTasksItemDetailLoading { expect(details?.pipelineJobs?.some((job) => job.name === 'child')).toBe(true) }) - it('marks only the notes the reading glab account wrote', async () => { - const note = (id: number, username: string) => ({ - id, - body: 'LGTM', - author: { username }, - created_at: `2026-06-01T00:0${id}:00Z` - }) - glabExecFileAsyncMock.mockImplementation(async (args: string[]) => { - const endpoint = args.at(-1) as string - if (endpoint === 'user') { - return { stdout: JSON.stringify({ id: 7, username: 'Me' }) } - } - if (endpoint.includes('/discussions')) { - return { - stdout: JSON.stringify([ - { id: 'd1', individual_note: true, notes: [note(1, 'alice')] }, - { id: 'd2', individual_note: true, notes: [note(2, 'me')] } - ]) + it.each([ + { markViewerComments: true, mine: true }, + { markViewerComments: undefined, mine: true }, + // Desktop detail reads opt out of the viewer lookup. + { markViewerComments: false, mine: undefined } + ])( + 'marks only the reading glab account notes unless the read opts out: %o', + async ({ markViewerComments, mine }) => { + const note = (id: number, username: string) => ({ + id, + body: 'LGTM', + author: { username }, + created_at: `2026-06-01T00:0${id}:00Z` + }) + glabExecFileAsyncMock.mockImplementation(async (args: string[]) => { + const endpoint = args.at(-1) as string + if (endpoint === 'user') { + return { stdout: JSON.stringify({ id: 7, username: 'Me' }) } } - } - return { - stdout: JSON.stringify({ - iid: 5, - title: 'Issue', - state: 'opened', - web_url: 'https://gitlab.com/g/p/-/issues/5', - updated_at: '2026-06-01T00:00:00Z' - }) - } - }) + if (endpoint.includes('/discussions')) { + return { + stdout: JSON.stringify([ + { id: 'd1', individual_note: true, notes: [note(1, 'alice')] }, + { id: 'd2', individual_note: true, notes: [note(2, 'me')] } + ]) + } + } + return { + stdout: JSON.stringify({ + iid: 5, + title: 'Issue', + state: 'opened', + web_url: 'https://gitlab.com/g/p/-/issues/5', + updated_at: '2026-06-01T00:00:00Z' + }) + } + }) - const details = await getWorkItemDetails('/repo', 5, 'issue') + const details = await getWorkItemDetails( + '/repo', + 5, + 'issue', + undefined, + null, + null, + {}, + { + markViewerComments + } + ) - expect(details?.comments.map((c) => [c.author, c.viewerDidAuthor])).toEqual([ - ['alice', undefined], - ['me', true] - ]) - }) + expect(details?.comments.map((c) => [c.author, c.viewerDidAuthor])).toEqual([ + ['alice', undefined], + ['me', mine] + ]) + } + ) }) diff --git a/src/main/gitlab/work-item-details.ts b/src/main/gitlab/work-item-details.ts index 191d7eeefe7..d8a6ffe0b6b 100644 --- a/src/main/gitlab/work-item-details.ts +++ b/src/main/gitlab/work-item-details.ts @@ -63,7 +63,7 @@ export async function getWorkItemDetails( connectionId?: string | null, projectRefOverride?: ProjectRef | null, localGitOptions: LocalGitExecOptions = {}, - options: { includeReviewDetails?: boolean } = {} + options: { includeReviewDetails?: boolean; markViewerComments?: boolean } = {} ): Promise { // Retain the list row's selected project to avoid same-number fork/upstream collisions. const projectRef = @@ -83,7 +83,14 @@ export async function getWorkItemDetails( await acquire() try { if (type === 'issue') { - return await fetchIssueDetails(repoPath, projectRef, iid, connectionId, localGitOptions) + return await fetchIssueDetails( + repoPath, + projectRef, + iid, + connectionId, + localGitOptions, + options.markViewerComments !== false + ) } return await fetchMRDetails(repoPath, projectRef, iid, connectionId, localGitOptions, options) } catch { @@ -98,7 +105,8 @@ async function fetchIssueDetails( projectRef: ProjectRef, iid: number, connectionId?: string | null, - localGitOptions: LocalGitExecOptions = {} + localGitOptions: LocalGitExecOptions = {}, + markViewerComments = true ): Promise { const [issueRes, comments] = await Promise.all([ glabExecFileAsync( @@ -109,7 +117,15 @@ async function fetchIssueDetails( ], glabRepoExecOptions(repoPath, connectionId, localGitOptions) ), - fetchDiscussionComments(repoPath, projectRef, 'issue', iid, connectionId, localGitOptions) + fetchDiscussionComments( + repoPath, + projectRef, + 'issue', + iid, + connectionId, + localGitOptions, + markViewerComments + ) ]) const issueRaw = JSON.parse(issueRes.stdout) as GitLabRawIssue const item: Omit = (() => { @@ -134,7 +150,7 @@ async function fetchMRDetails( iid: number, connectionId?: string | null, localGitOptions: LocalGitExecOptions = {}, - options: { includeReviewDetails?: boolean } = {} + options: { includeReviewDetails?: boolean; markViewerComments?: boolean } = {} ): Promise { // Discussion can overlap MR details; child jobs need its head_pipeline ID. const [mrRes, comments] = await Promise.all([ @@ -146,7 +162,6 @@ async function fetchMRDetails( ], glabRepoExecOptions(repoPath, connectionId, localGitOptions) ), - // Checks polling never reads viewerDidAuthor, so it skips the viewer lookup with the other review details. fetchDiscussionComments( repoPath, projectRef, @@ -154,7 +169,8 @@ async function fetchMRDetails( iid, connectionId, localGitOptions, - options.includeReviewDetails !== false + // Checks polling never reads viewerDidAuthor, so it skips the viewer lookup with the other review details. + options.markViewerComments ?? options.includeReviewDetails !== false ) ]) const mrRaw = JSON.parse(mrRes.stdout) as GitLabRawMR diff --git a/src/main/ipc/source-control/gitlab-work-item-handlers.ts b/src/main/ipc/source-control/gitlab-work-item-handlers.ts index 285fd99399e..4952abf38b9 100644 --- a/src/main/ipc/source-control/gitlab-work-item-handlers.ts +++ b/src/main/ipc/source-control/gitlab-work-item-handlers.ts @@ -71,7 +71,8 @@ export function registerGitLabWorkItemHandlers(store: Store): void { repoConnectionId(repo), undefined, localGitOptions, - { includeReviewDetails: args.includeReviewDetails } + // Only the phone reads viewerDidAuthor, so desktop skips the `glab api user` lookup. + { includeReviewDetails: args.includeReviewDetails, markViewerComments: false } ) return args.background ? guardWslUncPathAccess(repo.path, read, { wslDistro: localGitOptions.wslDistro }) diff --git a/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts b/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts index 79da438a46b..58241a24e70 100644 --- a/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts +++ b/src/main/runtime/integrations/gitlab/runtime-gitlab-query-commands.ts @@ -169,7 +169,8 @@ export class RuntimeGitLabQueryCommands { iid: number, type: 'issue' | 'mr', projectRef?: GitLabProjectRef | null, - includeReviewDetails?: boolean + includeReviewDetails?: boolean, + markViewerComments?: boolean ): Promise>> { const repo = await this.deps.resolveRepo(repoSelector) return getWorkItemDetails( @@ -180,7 +181,7 @@ export class RuntimeGitLabQueryCommands { getRepoRoutingConnectionId(repo), projectRef, this.deps.getLocalGitArgs(repo)[0] ?? {}, - { includeReviewDetails } + { includeReviewDetails, markViewerComments } ) } diff --git a/src/main/runtime/rpc/methods/source-control/gitlab/gitlab.ts b/src/main/runtime/rpc/methods/source-control/gitlab/gitlab.ts index 37f4be0065a..b64aa4a53fe 100644 --- a/src/main/runtime/rpc/methods/source-control/gitlab/gitlab.ts +++ b/src/main/runtime/rpc/methods/source-control/gitlab/gitlab.ts @@ -208,7 +208,8 @@ export const GITLAB_METHODS = [ params.iid, params.type, params.projectRef, - params.includeReviewDetails + params.includeReviewDetails, + params.markViewerComments ) }), defineMethod({ diff --git a/src/shared/gitlab-types.ts b/src/shared/gitlab-types.ts index ad6fb1a539c..57a309e0b6a 100644 --- a/src/shared/gitlab-types.ts +++ b/src/shared/gitlab-types.ts @@ -80,7 +80,7 @@ export type MRComment = { startLine?: number /** True when GitLab marks the author as a bot. Mirrors GitHub PRComment.isBot. */ isBot?: boolean - /** True only when the author is the glab account that read the thread (not looked up by Checks polling). Mirrors GitHub PRComment.viewerDidAuthor. */ + /** True only when the author is the glab account that read the thread; not looked up by Checks polling or desktop detail reads. Mirrors GitHub PRComment.viewerDidAuthor. */ viewerDidAuthor?: boolean } diff --git a/src/shared/rpc-contract/gitlab-params.ts b/src/shared/rpc-contract/gitlab-params.ts index 5a7f567c068..9211bc53076 100644 --- a/src/shared/rpc-contract/gitlab-params.ts +++ b/src/shared/rpc-contract/gitlab-params.ts @@ -141,7 +141,9 @@ export const WorkItemDetails = RepoSelector.extend({ iid: z.number().int().positive(), type: z.enum(['issue', 'mr']), projectRef: GitLabProjectRef, - includeReviewDetails: z.boolean().optional() + includeReviewDetails: z.boolean().optional(), + // Omitted means true so older phones keep author marks; desktop sends false to skip the `glab api user` read. + markViewerComments: z.boolean().optional() }) export const WorkItemByPath = RepoSelector.extend({