1- import { formatChangeRequestText } from "@t3tools/client-runtime/source-control-clients" ;
1+ import {
2+ currentChangeRequestTerms ,
3+ formatChangeRequestText ,
4+ } from "@t3tools/client-runtime/source-control-clients" ;
25import {
36 STATIC_KEYBINDING_COMMANDS ,
47 type KeybindingCommand ,
@@ -46,6 +49,7 @@ export type KeybindingSource = "Default" | "Custom" | "Project";
4649export interface KeybindingRow {
4750 readonly id : string ;
4851 readonly command : KeybindingCommand ;
52+ readonly label : string ;
4953 readonly key : string ;
5054 readonly when : string ;
5155 readonly source : KeybindingSource ;
@@ -56,7 +60,10 @@ export interface KeybindingRow {
5660}
5761
5862export type WhenVariableOption = string ;
59- export type KeybindingCommandOption = KeybindingCommand ;
63+ export interface KeybindingCommandOption {
64+ readonly command : KeybindingCommand ;
65+ readonly label : string ;
66+ }
6067
6168const CORE_WHEN_VARIABLES = [
6269 "terminalFocus" ,
@@ -196,7 +203,7 @@ export function keybindingConflictLabels(
196203 shortcutConflictKey ( candidate . binding . shortcut , platform ) === conflictKey &&
197204 conflictsWithWhen ( candidate . when , input . when )
198205 ) {
199- conflicts . push ( commandLabel ( candidate . command ) ) ;
206+ conflicts . push ( candidate . label ) ;
200207 }
201208 }
202209 return [ ...new Set ( conflicts ) ] . toSorted ( ) ;
@@ -250,6 +257,7 @@ export function groupKeybindingRows(
250257export function buildKeybindingRows (
251258 keybindings : ResolvedKeybindingsConfig ,
252259 platform = navigator . platform ,
260+ terms = currentChangeRequestTerms ( ) ,
253261) : ReadonlyArray < KeybindingRow > {
254262 const rowsById = new Map < string , KeybindingRow > ( ) ;
255263 for ( const binding of keybindings ) {
@@ -260,6 +268,7 @@ export function buildKeybindingRows(
260268 rowsById . set ( id , {
261269 id,
262270 command : binding . command ,
271+ label : commandLabel ( binding . command , terms ) ,
263272 key,
264273 when,
265274 source : sourceForBinding ( binding ) ,
@@ -304,7 +313,7 @@ export function filterKeybindingRows(
304313 return rows . filter ( ( row ) => {
305314 return (
306315 row . command . toLowerCase ( ) . includes ( normalizedQuery ) ||
307- commandLabel ( row . command ) . toLowerCase ( ) . includes ( normalizedQuery ) ||
316+ row . label . toLowerCase ( ) . includes ( normalizedQuery ) ||
308317 row . key . toLowerCase ( ) . includes ( normalizedQuery ) ||
309318 row . when . toLowerCase ( ) . includes ( normalizedQuery ) ||
310319 row . source . toLowerCase ( ) . includes ( normalizedQuery )
@@ -360,15 +369,23 @@ export function buildWhenVariableOptions(): ReadonlyArray<WhenVariableOption> {
360369
361370export function buildKeybindingCommandOptions (
362371 keybindings : ResolvedKeybindingsConfig ,
372+ terms = currentChangeRequestTerms ( ) ,
363373) : ReadonlyArray < KeybindingCommandOption > {
364374 const commands = new Set < KeybindingCommand > ( STATIC_KEYBINDING_COMMANDS ) ;
365375 for ( const binding of keybindings ) {
366376 commands . add ( binding . command ) ;
367377 }
368- return [ ...commands ] . toSorted ( ( left , right ) => compareCommands ( left , right , commandLabel ) ) ;
378+ return [ ...commands ]
379+ . toSorted ( ( left , right ) =>
380+ compareCommands ( left , right , ( command ) => commandLabel ( command , terms ) ) ,
381+ )
382+ . map ( ( command ) => ( { command, label : commandLabel ( command , terms ) } ) ) ;
369383}
370384
371- export function commandLabel ( command : KeybindingCommand ) : string {
385+ export function commandLabel (
386+ command : KeybindingCommand ,
387+ terms = currentChangeRequestTerms ( ) ,
388+ ) : string {
372389 if ( command === "workspace.focusNext" ) return "Focus Next Workspace Area" ;
373390 if ( command === "workspace.focusPrevious" ) return "Focus Previous Workspace Area" ;
374391 if ( command === "composer.sendAlternate" ) return "Composer: Opposite Queue or Steer Action" ;
@@ -377,7 +394,7 @@ export function commandLabel(command: KeybindingCommand): string {
377394 if ( command === "thread.steerQueuedMessage" ) return "Queue: Send First Queued Message" ;
378395 if ( command === "thread.editQueuedMessage" ) return "Queue: Edit Last Queued Message" ;
379396 if ( command === "thread.copyReference" )
380- return formatChangeRequestText ( "Pull Request: Copy Link or Thread" ) ;
397+ return formatChangeRequestText ( "Pull Request: Copy Link or Thread" , terms ) ;
381398 const usageMetric = METRIC_OPTIONS . find ( ( option ) => option . command === command ) ;
382399 if ( usageMetric ) return `Usage: ${ usageMetric . label } ` ;
383400 const usagePeriod = WINDOW_OPTIONS . find ( ( option ) => option . command === command ) ;
@@ -388,7 +405,7 @@ export function commandLabel(command: KeybindingCommand): string {
388405 if ( raw . startsWith ( "script." ) && raw . endsWith ( ".run" ) ) {
389406 return `Run Script: ${ titleCaseCommandSegment ( raw . slice ( "script." . length , - ".run" . length ) ) } ` ;
390407 }
391- return formatChangeRequestText ( raw . split ( "." ) . map ( titleCaseCommandSegment ) . join ( ": " ) ) ;
408+ return formatChangeRequestText ( raw . split ( "." ) . map ( titleCaseCommandSegment ) . join ( ": " ) , terms ) ;
392409}
393410
394411function titleCaseCommandSegment ( segment : string ) : string {
0 commit comments