mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-23 22:29:33 +01:00
Merge #820: Send on Enter for the pinned CJK input field
A per-device mode for the pinned CJK field on phones: a typed answer stays in the field while the terminal scrolls and goes out only on Enter.
This commit is contained in:
commit
6222444e82
20 files changed
+1725
-42
No files matched your search
@@ -145,6 +145,28 @@ describe('terminal touch tap mouse guard', () => {
|
||||
expect(app._isMobileTerminalInputFocused()).toBe(true);
|
||||
});
|
||||
|
||||
it('a content touchstart blurs xterm input but leaves the pinned CJK field focused', () => {
|
||||
const { app, setActiveElement } = loadTerminalUiHarness();
|
||||
setActiveElement({ id: '', classList: { contains: (c: string) => c === 'xterm-helper-textarea' } });
|
||||
expect(app._contentTouchStartBlurs()).toBe(true);
|
||||
// A swipe that starts on the live screen must not close the keyboard the field owns.
|
||||
setActiveElement({ id: 'cjkInput', classList: { contains: () => false } });
|
||||
expect(app._contentTouchStartBlurs()).toBe(false);
|
||||
setActiveElement(null);
|
||||
expect(app._contentTouchStartBlurs()).toBe(true);
|
||||
});
|
||||
|
||||
it('the content touchstart only blurs through _contentTouchStartBlurs()', () => {
|
||||
// The touchstart listener lives in initTerminal, which this harness does not run,
|
||||
// so pin its one line: an unconditional blur there closes the pinned field's
|
||||
// keyboard on every swipe that starts on the live screen.
|
||||
const code = readFileSync(resolve(import.meta.dirname, '../src/web/public/terminal-ui.js'), 'utf8');
|
||||
const branch = code.slice(code.indexOf("if (touchStartIntent === 'content') {"));
|
||||
const body = branch.slice(0, branch.indexOf('// Hold still and this press becomes a text selection.'));
|
||||
expect(body).toContain('if (this._contentTouchStartBlurs()) this._blurMobileTerminalInput();');
|
||||
expect(body.match(/_blurMobileTerminalInput\(\)/g)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('routes a readback row to the TUI while keeping the prompt row as keyboard input', () => {
|
||||
const { app } = loadTerminalUiHarness();
|
||||
app.activeSessionId = 'sess-1';
|
||||
@@ -973,9 +995,27 @@ describe('terminal link tap', () => {
|
||||
app._isOutsideWorktreePath = () => false;
|
||||
windowRef.open = vi.fn();
|
||||
app.registerFilePathLinkProvider();
|
||||
return { app, windowRef, sent };
|
||||
return { app, windowRef, sent, setActiveElement: harness.setActiveElement };
|
||||
}
|
||||
|
||||
it('a link tap closes the keyboard of the pinned CJK field, which touchstart left focused', () => {
|
||||
const line = 'Login at https://claude.ai/oauth/authorize?code=true&client_id=abc to finish';
|
||||
const { app, setActiveElement } = linkHarness([line, '', '❯ ']);
|
||||
const cjk = { id: 'cjkInput', classList: { contains: () => false }, blur: vi.fn() };
|
||||
setActiveElement(cjk);
|
||||
expect(app._handleMobileTerminalTap(at(line.indexOf('https')), false, 'content')).toBe('link');
|
||||
expect(cjk.blur).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('a link tap leaves focus alone otherwise (touchstart already blurred xterm input)', () => {
|
||||
const line = 'Login at https://claude.ai/oauth/authorize?code=true&client_id=abc to finish';
|
||||
const { app, setActiveElement } = linkHarness([line, '', '❯ ']);
|
||||
const other = { id: '', classList: { contains: () => false }, blur: vi.fn() };
|
||||
setActiveElement(other);
|
||||
expect(app._handleMobileTerminalTap(at(line.indexOf('https')), false, 'content')).toBe('link');
|
||||
expect(other.blur).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('opens a URL under the finger in a new tab', () => {
|
||||
const line = 'Login at https://claude.ai/oauth/authorize?code=true&client_id=abc to finish';
|
||||
const { app, windowRef } = linkHarness([line, '', '❯ ']);
|
||||
|
||||
Reference in new issue
Block a user