From cab8c540dac26962b4608594ebe58baa71b4a20a Mon Sep 17 00:00:00 2001 From: teernisse Date: Tue, 10 Mar 2026 11:40:23 -0400 Subject: [PATCH] fix(show): include gitlab_id on notes in issue/MR detail views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The show command's NoteDetail and MrNoteDetail structs were missing gitlab_id, making individual notes unaddressable in robot mode output. This was inconsistent with the notes list command which already exposed gitlab_id. Without an identifier, agents consuming show output could not construct GitLab web URLs or reference specific notes for follow-up operations via glab. Added gitlab_id to: - NoteDetail / NoteDetailJson (issue discussions) - MrNoteDetail / MrNoteDetailJson (MR discussions) - Both SQL queries (shifted column indices accordingly) - Both From<&T> conversion impls Deliberately scoped to show command only — me/timeline/trace structs were evaluated and intentionally left unchanged because they serve different consumption patterns where note-level identity is not needed. Co-Authored-By: Claude Opus 4.6 --- src/cli/commands/show/issue.rs | 12 +++++++----- src/cli/commands/show/mr.rs | 22 ++++++++++++---------- src/cli/commands/show/render.rs | 4 ++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/cli/commands/show/issue.rs b/src/cli/commands/show/issue.rs index 094bae9..b6ed57e 100644 --- a/src/cli/commands/show/issue.rs +++ b/src/cli/commands/show/issue.rs @@ -44,6 +44,7 @@ pub struct DiscussionDetail { #[derive(Debug, Serialize)] pub struct NoteDetail { + pub gitlab_id: i64, pub author_username: String, pub body: String, pub created_at: i64, @@ -277,7 +278,7 @@ fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result, _>>()?; let mut note_stmt = conn.prepare( - "SELECT author_username, body, created_at, is_system + "SELECT gitlab_id, author_username, body, created_at, is_system FROM notes WHERE discussion_id = ? ORDER BY position", @@ -287,11 +288,12 @@ fn get_issue_discussions(conn: &Connection, issue_id: i64) -> Result = note_stmt .query_map([disc_id], |row| { - let is_system: i64 = row.get(3)?; + let is_system: i64 = row.get(4)?; Ok(NoteDetail { - author_username: row.get(0)?, - body: row.get(1)?, - created_at: row.get(2)?, + gitlab_id: row.get(0)?, + author_username: row.get(1)?, + body: row.get(2)?, + created_at: row.get(3)?, is_system: is_system == 1, }) })? diff --git a/src/cli/commands/show/mr.rs b/src/cli/commands/show/mr.rs index 22bf009..9de104c 100644 --- a/src/cli/commands/show/mr.rs +++ b/src/cli/commands/show/mr.rs @@ -29,6 +29,7 @@ pub struct MrDiscussionDetail { #[derive(Debug, Serialize)] pub struct MrNoteDetail { + pub gitlab_id: i64, pub author_username: String, pub body: String, pub created_at: i64, @@ -224,7 +225,7 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result, _>>()?; let mut note_stmt = conn.prepare( - "SELECT author_username, body, created_at, is_system, + "SELECT gitlab_id, author_username, body, created_at, is_system, position_old_path, position_new_path, position_old_line, position_new_line, position_type FROM notes @@ -236,12 +237,12 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result = note_stmt .query_map([disc_id], |row| { - let is_system: i64 = row.get(3)?; - let old_path: Option = row.get(4)?; - let new_path: Option = row.get(5)?; - let old_line: Option = row.get(6)?; - let new_line: Option = row.get(7)?; - let position_type: Option = row.get(8)?; + let is_system: i64 = row.get(4)?; + let old_path: Option = row.get(5)?; + let new_path: Option = row.get(6)?; + let old_line: Option = row.get(7)?; + let new_line: Option = row.get(8)?; + let position_type: Option = row.get(9)?; let position = if old_path.is_some() || new_path.is_some() @@ -260,9 +261,10 @@ fn get_mr_discussions(conn: &Connection, mr_id: i64) -> Result for DiscussionDetailJson { impl From<&NoteDetail> for NoteDetailJson { fn from(note: &NoteDetail) -> Self { Self { + gitlab_id: note.gitlab_id, author_username: note.author_username.clone(), body: note.body.clone(), created_at: ms_to_iso(note.created_at), @@ -497,6 +499,7 @@ pub struct MrDiscussionDetailJson { #[derive(Serialize)] pub struct MrNoteDetailJson { + pub gitlab_id: i64, pub author_username: String, pub body: String, pub created_at: String, @@ -542,6 +545,7 @@ impl From<&MrDiscussionDetail> for MrDiscussionDetailJson { impl From<&MrNoteDetail> for MrNoteDetailJson { fn from(note: &MrNoteDetail) -> Self { Self { + gitlab_id: note.gitlab_id, author_username: note.author_username.clone(), body: note.body.clone(), created_at: ms_to_iso(note.created_at),