@@ -45,35 +45,44 @@ type Osc16162Command =
4545 | { command : "I" ; data : { inputempty ?: boolean } }
4646 | { command : "R" ; data : Record < string , never > } ;
4747
48+ function normalizeCmd ( decodedCmd : string ) : string {
49+ let normalizedCmd = decodedCmd . trim ( ) ;
50+ normalizedCmd = normalizedCmd . replace ( / ^ (?: \w + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | \S + ) \s + ) * / , "" ) ;
51+ normalizedCmd = normalizedCmd . replace ( / ^ e n v \s + / , "" ) ;
52+ return normalizedCmd ;
53+ }
54+
4855function checkCommandForTelemetry ( decodedCmd : string ) {
4956 if ( ! decodedCmd ) {
5057 return ;
5158 }
5259
53- if ( decodedCmd . startsWith ( "ssh " ) ) {
60+ const normalizedCmd = normalizeCmd ( decodedCmd ) ;
61+
62+ if ( normalizedCmd . startsWith ( "ssh " ) ) {
5463 recordTEvent ( "conn:connect" , { "conn:conntype" : "ssh-manual" } ) ;
5564 return ;
5665 }
5766
5867 const editorsRegex = / ^ ( v i m | v i | n a n o | n v i m ) \b / ;
59- if ( editorsRegex . test ( decodedCmd ) ) {
68+ if ( editorsRegex . test ( normalizedCmd ) ) {
6069 recordTEvent ( "action:term" , { "action:type" : "cli-edit" } ) ;
6170 return ;
6271 }
6372
6473 const tailFollowRegex = / ( ^ | \| \s * ) t a i l \s + - [ f F ] \b / ;
65- if ( tailFollowRegex . test ( decodedCmd ) ) {
74+ if ( tailFollowRegex . test ( normalizedCmd ) ) {
6675 recordTEvent ( "action:term" , { "action:type" : "cli-tailf" } ) ;
6776 return ;
6877 }
6978
70- if ( isClaudeCodeCommand ( decodedCmd ) ) {
79+ if ( ClaudeCodeRegex . test ( normalizedCmd ) ) {
7180 recordTEvent ( "action:term" , { "action:type" : "claude" } ) ;
7281 return ;
7382 }
7483
7584 const opencodeRegex = / ^ o p e n c o d e \b / ;
76- if ( opencodeRegex . test ( decodedCmd ) ) {
85+ if ( opencodeRegex . test ( normalizedCmd ) ) {
7786 recordTEvent ( "action:term" , { "action:type" : "opencode" } ) ;
7887 return ;
7988 }
@@ -83,10 +92,7 @@ export function isClaudeCodeCommand(decodedCmd: string): boolean {
8392 if ( ! decodedCmd ) {
8493 return false ;
8594 }
86- let normalizedCmd = decodedCmd . trim ( ) ;
87- normalizedCmd = normalizedCmd . replace ( / ^ (?: \w + = (?: " [ ^ " ] * " | ' [ ^ ' ] * ' | \S + ) \s + ) * / , "" ) ;
88- normalizedCmd = normalizedCmd . replace ( / ^ e n v \s + / , "" ) ;
89- return ClaudeCodeRegex . test ( normalizedCmd ) ;
95+ return ClaudeCodeRegex . test ( normalizeCmd ( decodedCmd ) ) ;
9096}
9197
9298function handleShellIntegrationCommandStart (
0 commit comments