fix(input): count code points when clearing prompts

This commit is contained in:
DodgyBadger
2026-09-20 07:18:49 +00:00
parent 0761de3dae
commit a220c28a14
4 changed files with 20 additions and 8 deletions
+11
View File
@@ -152,6 +152,17 @@ describe('mobile prompt composer', () => {
expect(app._flushedTexts.has('session-1')).toBe(false);
});
it('uses Unicode code points when erasing flushed text', () => {
const { app, bar, document } = loadComposer();
app._flushedOffsets.set('session-1', 3);
app._flushedTexts.set('session-1', 'a😀');
bar.composePrompt();
expect(textarea(document).value).toBe('a😀');
expect(app._sendInputAsync).toHaveBeenCalledWith('session-1', '\x7f'.repeat(2), { useMux: true });
});
it('closes on tab switch and keeps drafts isolated by session', () => {
const { app, bar, document } = loadComposer();
const composeButton = mountComposeButton(bar, document);
+3 -3
View File
@@ -200,12 +200,12 @@ describe('mobile filesystem picker actions', () => {
_pendingInput: 'pending text',
_localEchoEnabled: true,
_localEchoOverlay: {
getFlushed: () => ({ count: 4, text: 'sent' }),
getFlushed: () => ({ count: 4, text: 'a😀b' }),
clear,
suppressBufferDetection,
},
_flushedOffsets: new Map([['session-1', 4]]),
_flushedTexts: new Map([['session-1', 'sent']]),
_flushedTexts: new Map([['session-1', 'a😀b']]),
sendInput,
showToast,
terminal: { focus },
@@ -216,7 +216,7 @@ describe('mobile filesystem picker actions', () => {
expect(app._pendingInput).toBe('');
expect(clear).toHaveBeenCalledOnce();
expect(suppressBufferDetection).toHaveBeenCalledOnce();
expect(sendInput).toHaveBeenCalledWith('\x7f'.repeat(4));
expect(sendInput).toHaveBeenCalledWith('\x7f'.repeat(3));
expect(sendInput).not.toHaveBeenCalledWith('/clear');
expect(app._flushedOffsets.size).toBe(0);
expect(app._flushedTexts.size).toBe(0);