mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-20 04:59:34 +01:00
fix(mobile): Send on Enter fourth review fixes
- selectSession restores the CJK draft after _activateFileBrowserSession, which test/file-browser-search.test.ts pins right after the activeSessionId assignment. - A lone digit while the session has a pending permission_prompt or elicitation_dialog goes out without the delayed Enter: the dialog acts on the digit, and the Enter would confirm whatever comes next. Same rule as the Approvals Inbox and the Discord bridge. - Changeset mentions the toolbar Enter sending the CJK field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
80d719df5f
commit
b5ad7afebe
6 files changed
+79
-6
No files matched your search
@@ -107,8 +107,10 @@ describe('a held draft survives a reload of the same session', () => {
|
||||
});
|
||||
|
||||
it('selectSession restores the draft of the session it lands on', () => {
|
||||
// After _activateFileBrowserSession: test/file-browser-search.test.ts pins
|
||||
// that call as the line right after the activeSessionId assignment.
|
||||
expect(read('app.js')).toContain(
|
||||
"this.activeSessionId = sessionId;\n if (typeof CjkInput !== 'undefined') CjkInput.restoreDraft?.(sessionId);"
|
||||
"this.activeSessionId = sessionId;\n this._activateFileBrowserSession?.(sessionId);\n if (typeof CjkInput !== 'undefined') CjkInput.restoreDraft?.(sessionId);"
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -606,6 +606,64 @@ describe('Send on Enter: a held answer goes out with Enter as its own write', ()
|
||||
}
|
||||
});
|
||||
|
||||
it('sends a lone digit without Enter while a permission or question dialog waits', () => {
|
||||
// The dialog acts on the digit keypress itself; an Enter 120 ms later would
|
||||
// confirm whatever the CLI shows next (a second permission prompt, unseen).
|
||||
// Same rule as the Approvals Inbox and the Discord bridge (awaitingChoice).
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
for (const hook of ['permission_prompt', 'elicitation_dialog']) {
|
||||
const { app, composed } = promptApp();
|
||||
const writes: Array<[string, string, unknown]> = [];
|
||||
(app as unknown as { _sendInputAsync: unknown })._sendInputAsync = (
|
||||
id: string,
|
||||
input: string,
|
||||
opts?: unknown
|
||||
) => writes.push([id, input, opts]);
|
||||
(app as unknown as { pendingHooks: Map<string, Set<string>> }).pendingHooks = new Map([
|
||||
['session-a', new Set([hook])],
|
||||
]);
|
||||
expect(app._sendCjkPrompt('2')).toBe(true);
|
||||
vi.advanceTimersByTime(500);
|
||||
expect(writes).toEqual([['session-a', '2', undefined]]);
|
||||
composed.mockRestore();
|
||||
}
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it('keeps the delayed Enter for a digit when only an idle prompt is pending, or for a letter in a dialog', () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
const cases: Array<[string, string]> = [
|
||||
['idle_prompt', '1'],
|
||||
['permission_prompt', 'y'],
|
||||
];
|
||||
for (const [hook, text] of cases) {
|
||||
const { app, composed } = promptApp();
|
||||
const writes: Array<[string, string, unknown]> = [];
|
||||
(app as unknown as { _sendInputAsync: unknown })._sendInputAsync = (
|
||||
id: string,
|
||||
input: string,
|
||||
opts?: unknown
|
||||
) => writes.push([id, input, opts]);
|
||||
(app as unknown as { pendingHooks: Map<string, Set<string>> }).pendingHooks = new Map([
|
||||
['session-a', new Set([hook])],
|
||||
]);
|
||||
expect(app._sendCjkPrompt(text)).toBe(true);
|
||||
vi.advanceTimersByTime(120);
|
||||
expect(writes).toEqual([
|
||||
['session-a', text, undefined],
|
||||
['session-a', '\r', { useMux: true }],
|
||||
]);
|
||||
composed.mockRestore();
|
||||
}
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it('pastes even a short word: only one character is typed', () => {
|
||||
const { app, composed } = promptApp();
|
||||
expect(app._sendCjkPrompt('yes')).toBe(true);
|
||||
|
||||
Reference in new issue
Block a user