@@ -70,15 +70,6 @@ Interestingly, some environments like Cursor enable these APIs even without the
7070This approach allows us to leverage advanced features when available while ensuring broad compatibility.
7171*/
7272declare module "vscode" {
73- // https://github.com/microsoft/vscode/blob/f0417069c62e20f3667506f4b7e53ca0004b4e3e/src/vscode-dts/vscode.d.ts#L7442
74- interface Terminal {
75- shellIntegration ?: {
76- cwd ?: vscode . Uri
77- executeCommand ?: ( command : string ) => {
78- read : ( ) => AsyncIterable < string >
79- }
80- }
81- }
8273 // https://github.com/microsoft/vscode/blob/f0417069c62e20f3667506f4b7e53ca0004b4e3e/src/vscode-dts/vscode.d.ts#L10794
8374 interface Window {
8475 onDidStartTerminalShellExecution ?: (
@@ -89,6 +80,16 @@ declare module "vscode" {
8980 }
9081}
9182
83+ // Extend the Terminal type to include our custom properties
84+ type ExtendedTerminal = vscode . Terminal & {
85+ shellIntegration ?: {
86+ cwd ?: vscode . Uri
87+ executeCommand ?: ( command : string ) => {
88+ read : ( ) => AsyncIterable < string >
89+ }
90+ }
91+ }
92+
9293export class TerminalManager {
9394 private terminalIds : Set < number > = new Set ( )
9495 private processes : Map < number , TerminalProcess > = new Map ( )
@@ -139,16 +140,17 @@ export class TerminalManager {
139140 } )
140141
141142 // if shell integration is already active, run the command immediately
142- if ( terminalInfo . terminal . shellIntegration ) {
143+ const terminal = terminalInfo . terminal as ExtendedTerminal
144+ if ( terminal . shellIntegration ) {
143145 process . waitForShellIntegration = false
144- process . run ( terminalInfo . terminal , command )
146+ process . run ( terminal , command )
145147 } else {
146148 // docs recommend waiting 3s for shell integration to activate
147- pWaitFor ( ( ) => terminalInfo . terminal . shellIntegration !== undefined , { timeout : 4000 } ) . finally ( ( ) => {
149+ pWaitFor ( ( ) => ( terminalInfo . terminal as ExtendedTerminal ) . shellIntegration !== undefined , { timeout : 4000 } ) . finally ( ( ) => {
148150 const existingProcess = this . processes . get ( terminalInfo . id )
149151 if ( existingProcess && existingProcess . waitForShellIntegration ) {
150152 existingProcess . waitForShellIntegration = false
151- existingProcess . run ( terminalInfo . terminal , command )
153+ existingProcess . run ( terminal , command )
152154 }
153155 } )
154156 }
@@ -162,7 +164,8 @@ export class TerminalManager {
162164 if ( t . busy ) {
163165 return false
164166 }
165- const terminalCwd = t . terminal . shellIntegration ?. cwd // one of cline's commands could have changed the cwd of the terminal
167+ const terminal = t . terminal as ExtendedTerminal
168+ const terminalCwd = terminal . shellIntegration ?. cwd // one of cline's commands could have changed the cwd of the terminal
166169 if ( ! terminalCwd ) {
167170 return false
168171 }
0 commit comments