Skip to content

Commit b07acb5

Browse files
Add direct function for outputting to user
1 parent c9a195b commit b07acb5

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

kernel/src/kernel.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ export class EmbeddedKernel extends BaseKernel {
3939
await this.serviceContainer.deviceService.sendInterrupt();
4040
}
4141

42+
outputResponse(msg: string): void {
43+
console.log("[Kernel] outputResponse - Streaming output:", msg);
44+
45+
msg += '\n';
46+
47+
this.stream(){
48+
name: 'stdout',
49+
text: msg,
50+
}
51+
}
52+
4253
async executeRequest(
4354
content: KernelMessage.IExecuteRequestMsg['content'],
4455
): Promise<KernelMessage.IExecuteReplyMsg['content']> {
@@ -58,28 +69,13 @@ export class EmbeddedKernel extends BaseKernel {
5869
console.log("[Kernel] executeRequest - Processing code");
5970
const { code } = content;
6071

61-
console.log('Before reconnect check');
6272
if (code.includes(reconnectString)) {
6373
// Reconnect the device or connect for the first time
64-
console.log('Reconnect command detected, reconnecting device...');
74+
this.outputResponse("Reconnect command detected, reconnecting device...");
6575
await this.serviceContainer.deviceService.disconnect();
66-
console.log('Device disconnected');
6776
await this.serviceContainer.deviceService.connect();
68-
console.log('Device connected');
69-
this.stream(
70-
{
71-
name: 'stdout',
72-
text: "Device Connected!"
73-
}
74-
)
77+
this.outputResponse('Device Connected!');
7578
}
76-
this.stream(
77-
{
78-
name: 'stdout',
79-
text: "Device Connect Done!"
80-
}
81-
)
82-
console.log('After reconnect check');
8379

8480
try {
8581
console.log("[Kernel] executeRequest - Checking transport");

0 commit comments

Comments
 (0)