[PATCH] ui: disambiguate patchset links with shared message IDs

Longlong Xia <[email protected]> Wed, 22 Jul 2026 10:57:17 +0800
Newsgroups dev.linux.lists.sashiko
Message-ID <[email protected]>
From: Longlong Xia <[email protected]>

Repeated local Git submissions use the same synthetic cover Message-ID
when they target the same revision range. Because the patchset list uses
that value before the database ID, each row opens the first matching
patchset and can display stale review results.

Use the unique patchset ID before falling back to Message-ID. Keep slugs
as the preferred route for forge submissions. Add a regression test for
the route ordering.

Fixes: d46ec40c1a66 ("feat(api): support Message-ID based lookups for patchsets and messages")
Signed-off-by: Longlong Xia <[email protected]>
---
 src/api.rs        | 20 ++++++++++++++++++++
 static/index.html |  2 +-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/api.rs b/src/api.rs
index 2800743..a90c88f 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -1235,3 +1235,23 @@ async fn forge_webhook(
         "message": format!("{} {} queued for review", forge.name(), action)
     })))
 }
+
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn patchset_list_prefers_unique_id_over_message_id() {
+        let index = include_str!("../static/index.html");
+        let route = index
+            .lines()
+            .find(|line| {
+                line.contains("const target = `#/patchset/")
+                    && line.contains("encodeURIComponent(p.")
+            })
+            .expect("patchset list route not found in static/index.html");
+
+        assert!(
+            route.contains("encodeURIComponent(p.slug || p.id || p.message_id)"),
+            "patchset list routes must prefer the unique database ID over the potentially shared message-ID: {route}"
+        );
+    }
+}
diff --git a/static/index.html b/static/index.html
index 9f424c7..f150c0b 100644
--- a/static/index.html
+++ b/static/index.html
@@ -1964,7 +1964,7 @@
 
                     const clickHandler = (e) => {
                         if (e.target.closest('.copy-btn')) return;
-                        const target = `#/patchset/${encodeURIComponent(p.slug || p.message_id || p.id)}`;
+                        const target = `#/patchset/${encodeURIComponent(p.slug || p.id || p.message_id)}`;
                         if (e.button === 1 || e.ctrlKey || e.metaKey) {
                             window.open(target, '_blank');
                         } else if (e.button === 0) {
-- 
2.43.0