55from datetime import UTC
66from typing import TYPE_CHECKING
77
8+ from gh_llm .invocation import display_command , display_command_with
9+
810if TYPE_CHECKING :
911 from string .templatelib import Template
1012
@@ -142,7 +144,7 @@ def render_checks_section(
142144 if not is_open :
143145 return [
144146 "## Checks" ,
145- f"Closed PR: checks are hidden by default. ⏎ run `gh-llm pr checks --pr { context .number } --repo { repo } --all`" ,
147+ f"Closed PR: checks are hidden by default. ⏎ run `{ display_command_with ( f' pr checks --pr { context .number } --repo { repo } --all' ) } `" ,
146148 "" ,
147149 ]
148150
@@ -167,13 +169,15 @@ def render_checks_section(
167169 elif item .details_url :
168170 lines .append (f" ⏎ details: `{ item .details_url } `" )
169171 if show_all :
170- lines .append (f"⏎ show only non-passed: `gh-llm pr checks --pr { context .number } --repo { repo } `" )
172+ lines .append (
173+ f"⏎ show only non-passed: `{ display_command_with (f'pr checks --pr { context .number } --repo { repo } ' )} `"
174+ )
171175 elif hidden_count > 0 :
172176 lines .append (
173- f"{ hidden_count } passed checks hidden. ⏎ show all: `gh-llm pr checks --pr { context .number } --repo { repo } --all`"
177+ f"{ hidden_count } passed checks hidden. ⏎ show all: `{ display_command_with ( f' pr checks --pr { context .number } --repo { repo } --all' ) } `"
174178 )
175179 else :
176- lines .append (f"⏎ show all: `gh-llm pr checks --pr { context .number } --repo { repo } --all`" )
180+ lines .append (f"⏎ show all: `{ display_command_with ( f' pr checks --pr { context .number } --repo { repo } --all' ) } `" )
177181 lines .append ("" )
178182 return lines
179183
@@ -193,7 +197,7 @@ def render_hidden_gap(context: TimelineContext, hidden_pages: list[int]) -> list
193197 hidden_label ,
194198 * [
195199 _render_template (
196- t "- ⏎ `gh-llm { context.kind} timeline-expand {page} --{selector_name} {context.number} --repo {repo}`"
200+ t "- ⏎ `{display_command_with(f'{ context.kind} timeline-expand {page} --{selector_name} {context.number} --repo {repo}') }`"
197201 )
198202 for page in hidden_pages
199203 ],
@@ -204,7 +208,10 @@ def render_hidden_gap(context: TimelineContext, hidden_pages: list[int]) -> list
204208def _render_item (index : int , event : TimelineEvent , context : TimelineContext , command_group : str ) -> list [str ]:
205209 timestamp = event .timestamp .astimezone (UTC ).strftime ("%Y-%m-%d %H:%M UTC" )
206210 selector_name = "issue" if command_group == "issue" else "pr"
207- details_action = f"⏎ run `gh-llm { command_group } details-expand { index } --{ selector_name } { context .number } --repo { context .owner } /{ context .name } `"
211+ details_expand_cmd = display_command_with (
212+ f"{ command_group } details-expand { index } --{ selector_name } { context .number } --repo { context .owner } /{ context .name } "
213+ )
214+ details_action = f"⏎ run `{ details_expand_cmd } `"
208215 display_summary = (event .summary or "" ).replace (
209216 "(details body collapsed)" ,
210217 f"(details body collapsed; { details_action } )" ,
@@ -216,35 +223,36 @@ def _render_item(index: int, event: TimelineEvent, context: TimelineContext, com
216223 if event .reactions_summary :
217224 lines .append (f" Reactions: { event .reactions_summary } " )
218225 if event .editable_comment_id :
226+ edit_cmd = display_command_with (
227+ f"{ command_group } comment-edit { event .editable_comment_id } --body '<comment_body>' --{ selector_name } { context .number } --repo { context .owner } /{ context .name } "
228+ )
219229 lines .append (f" ◌ comment_id: { event .editable_comment_id } " )
220230 lines .append (" ⌨ comment_body: '<comment_body>'" )
221- lines .append (
222- f" ⏎ Edit comment via gh-llm: `gh-llm { command_group } comment-edit { event .editable_comment_id } --body '<comment_body>' --{ selector_name } { context .number } --repo { context .owner } /{ context .name } `"
223- )
231+ lines .append (f" ⏎ Edit comment via { display_command ()} : `{ edit_cmd } `" )
224232 else :
225233 lines .extend (_indent_block (display_summary ))
226234 if event .resolved_hidden_count > 0 :
227235 repo = f"{ context .owner } /{ context .name } "
228236 lines .append (
229237 f" { event .resolved_hidden_count } resolved review comments are collapsed; "
230- f"⏎ run `gh-llm pr review-expand { event .source_id } --pr { context .number } --repo { repo } `"
238+ f"⏎ run `{ display_command_with ( f' pr review-expand { event .source_id } --pr { context .number } --repo { repo } ' ) } `"
231239 )
232240 if event .minimized_hidden_count > 0 :
233241 repo = f"{ context .owner } /{ context .name } "
234242 reason_suffix = f" (reason: { event .minimized_hidden_reasons } )" if event .minimized_hidden_reasons else ""
235243 lines .append (
236244 f" { event .minimized_hidden_count } hidden review comments are collapsed{ reason_suffix } ; "
237- f"⏎ run `gh-llm pr review-expand { event .source_id } --pr { context .number } --repo { repo } `"
245+ f"⏎ run `{ display_command_with ( f' pr review-expand { event .source_id } --pr { context .number } --repo { repo } ' ) } `"
238246 )
239247 if event .kind .startswith ("review/" ):
240248 detail_text = (event .full_text or event .summary or "" ).lower ()
241249 if "diff hunk clipped" in detail_text :
242250 lines .append (
243- f" ⏎ run `gh-llm pr review-expand { event .source_id } --pr { context .number } --repo { context .owner } /{ context .name } --diff-hunk-lines 0` for full diff hunk context"
251+ f" ⏎ run `{ display_command_with ( f' pr review-expand { event .source_id } --pr { context .number } --repo { context .owner } /{ context .name } --diff-hunk-lines 0' ) } ` for full diff hunk context"
244252 )
245253 if event .is_truncated :
246254 lines .append (
247- f" ⏎ run `gh-llm { command_group } event { index } --{ selector_name } { context .number } --repo { context .owner } /{ context .name } ` for full content"
255+ f" ⏎ run `{ display_command_with ( f' { command_group } event { index } --{ selector_name } { context .number } --repo { context .owner } /{ context .name } ' ) } ` for full content"
248256 )
249257 if event .kind == "push/commit" :
250258 lines .append (
0 commit comments