File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
sessions/WebSocketSession Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,14 @@ export async function connectToSandbox(options: {
2222 instanceId : options . session . id ,
2323 onFocusChange :
2424 options . onFocusChange ||
25- ( ( ) => {
26- return ( ) => { } ;
25+ ( ( notify ) => {
26+ const listener = ( ) => {
27+ notify ( document . hasFocus ( ) ) ;
28+ } ;
29+ window . addEventListener ( "visibilitychange" , listener ) ;
30+ return ( ) => {
31+ window . removeEventListener ( "visibilitychange" , listener ) ;
32+ } ;
2733 } ) ,
2834 requestPitcherInstance : async ( id ) => {
2935 const session = hasConnected
Original file line number Diff line number Diff line change @@ -34,9 +34,9 @@ export class Commands {
3434 }
3535
3636 /**
37- * Create and run command in a new shell.
37+ * Create and run command in a new shell. Allows you to listen to the output and kill the command.
3838 */
39- async run ( command : string | string [ ] , opts ?: ShellRunOpts ) {
39+ async runBackground ( command : string | string [ ] , opts ?: ShellRunOpts ) {
4040 const disposableStore = new DisposableStore ( ) ;
4141 const onOutput = new Emitter < string > ( ) ;
4242 disposableStore . add ( onOutput ) ;
@@ -76,6 +76,15 @@ export class Commands {
7676 return cmd ;
7777 }
7878
79+ /**
80+ * Run a command in a new shell and wait for it to finish, returning its output.
81+ */
82+ async run ( command : string | string [ ] , opts ?: ShellRunOpts ) : Promise < string > {
83+ const cmd = await this . runBackground ( command , opts ) ;
84+
85+ return cmd . waitUntilComplete ( ) ;
86+ }
87+
7988 /**
8089 * Get all running commands.
8190 */
You can’t perform that action at this time.
0 commit comments