Skip to content

Commit c954619

Browse files
committed
fix: route hook output through promptNotify to avoid composer interleaving
Hook execution callbacks wrote directly to process.stdout/stderr which interleaved with readline rendering. Route through promptNotify so hook output displays cleanly above the active composer.
1 parent 9c59262 commit c954619

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/core/agent.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { LLMProvider } from '../providers/LLMProvider.js';
2020
import { ProviderNotConfiguredError } from '../providers/ProviderFactory.js';
2121
import {
2222
getPromptBlockWidth,
23+
promptNotify,
2324
readInstruction,
2425
safeEmitKeypressEvents
2526
} from '../ui/inputPrompt.js';
@@ -274,16 +275,13 @@ export class AutohandAgent {
274275
if (runtime.isRpcMode) {
275276
return;
276277
}
277-
// Display hook output to console (only if not a JSON control flow response)
278-
// Write text THEN newline separately to prevent ANSI reset codes
279-
// from being written after \n (which corrupts the next line for readline)
278+
// Route hook output through promptNotify so it renders above the
279+
// active composer instead of interleaving with readline output.
280280
if (result.stdout && !result.response) {
281-
const msg = chalk.dim(`[hook:${result.hook.event}] ${result.stdout}`);
282-
process.stdout.write(msg + '\n');
281+
promptNotify(chalk.dim(`[hook:${result.hook.event}] ${result.stdout}`));
283282
}
284283
if (result.stderr && !result.blockingError) {
285-
const msg = chalk.yellow(`[hook:${result.hook.event}] ${result.stderr}`);
286-
process.stderr.write(msg + '\n');
284+
promptNotify(chalk.yellow(`[hook:${result.hook.event}] ${result.stderr}`));
287285
}
288286
}
289287
});

0 commit comments

Comments
 (0)