feat(core): track shell cursor visibility in output events

This commit is contained in:
Keith Guerin
2026-03-27 20:58:51 -07:00
parent 317c13f846
commit 5a39e69164
3 changed files with 19 additions and 5 deletions
@@ -36,6 +36,7 @@ export type ExecutionOutputEvent =
| {
type: 'data';
chunk: string | AnsiOutput;
isCursorHidden?: boolean;
}
| {
type: 'binary_detected';
@@ -299,10 +299,12 @@ describe('ShellExecutionService', () => {
expect(result.output.trim()).toBe('file1.txt');
expect(handle.pid).toBe(12345);
expect(onOutputEventMock).toHaveBeenCalledWith({
type: 'data',
chunk: createExpectedAnsiOutput('file1.txt'),
});
expect(onOutputEventMock).toHaveBeenCalledWith(
expect.objectContaining({
type: 'data',
chunk: createExpectedAnsiOutput('file1.txt'),
}),
);
});
it('should strip ANSI color codes from output', async () => {
@@ -952,9 +952,13 @@ export class ShellExecutionService {
if (output !== finalOutput) {
output = finalOutput;
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-type-assertion
const isCursorHidden = (headlessTerminal as any)._core?.coreService
?.isCursorHidden as boolean | undefined;
const event: ShellOutputEvent = {
type: 'data',
chunk: finalOutput,
isCursorHidden,
};
onOutputEvent(event);
ExecutionLifecycleService.emitEvent(ptyPid, event);
@@ -1303,7 +1307,14 @@ export class ShellExecutionService {
startLine,
endLine,
);
const event: ShellOutputEvent = { type: 'data', chunk: bufferData };
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-type-assertion
const isCursorHidden = (activePty.headlessTerminal as any)._core
?.coreService?.isCursorHidden as boolean | undefined;
const event: ShellOutputEvent = {
type: 'data',
chunk: bufferData,
isCursorHidden,
};
ExecutionLifecycleService.emitEvent(pid, event);
}
}