Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3394,7 +3394,10 @@ Begin by analyzing the query and planning your research approach.`;
console.log(chalk.dim('\nGoodbye!'));
};

if (!useInkUi) {
// Skip readline creation for non-interactive mode
const isNonInteractive = Boolean(options.prompt);

if (!useInkUi && !isNonInteractive) {
// Enable bracketed paste mode for better paste detection
enableBracketedPaste();

Expand Down Expand Up @@ -3448,7 +3451,7 @@ Begin by analyzing the query and planning your research approach.`;
rl.on('error', (err) => {
logger.error(`Readline error: ${err.message}`, err);
});
} else {
} else if (useInkUi) {
exitApp = () => {
inkController?.requestExit();
};
Expand Down
26 changes: 23 additions & 3 deletions src/orchestrate/ipc/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,33 @@ export class IPCClient extends EventEmitter {

/**
* Disconnect from the server.
* Waits for pending writes to complete before closing the socket.
*/
async disconnect(): Promise<void> {
if (this.socket) {
this.socket.destroy();
this.socket = null;
if (!this.socket) {
this.connected = false;
return;
}

const socket = this.socket;
this.socket = null;
this.connected = false;

// Wait for pending writes to drain, then close gracefully
await new Promise<void>((resolve) => {
const timeout = setTimeout(() => {
socket.destroy();
resolve();
}, 1000); // Timeout after 1 second

socket.once('close', () => {
clearTimeout(timeout);
resolve();
});

// End gracefully - allows pending writes to complete
socket.end();
});
}

/**
Expand Down