mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-20 04:59:34 +01:00
fix(mobile): the clear-line key discards a Send on Enter draft
clear({ discard: true }) skips the owner stash, drops any older stash of
the owner and keeps the owner; clearTerminalInput() (the keyboard bar's
clear-line key) uses it, so a cleared draft does not come back on a
same-tab reload or a switch back. @fileoverview gains a Send on Enter
section.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
673a656538
commit
387cb830f4
3 files changed
+64
-10
No files matched your search
@@ -7,6 +7,21 @@
|
||||
* While this textarea has focus, window.cjkActive = true blocks xterm's onData.
|
||||
* Arrow keys and function keys are forwarded to PTY directly.
|
||||
*
|
||||
* ## Send on Enter (setting cjkInputHoldUntilEnter)
|
||||
*
|
||||
* The live mode above streams typed text to the PTY after a short debounce.
|
||||
* With Send on Enter on, the field is a chat box instead: _flush() holds the
|
||||
* text, and only Enter sends it, through the sendPrompt callback
|
||||
* (terminal-ui.js _sendCjkPrompt: a single character is typed, anything longer
|
||||
* goes as the composer's bracketed paste, Enter is always its own later write,
|
||||
* and a lone digit at a pending dialog goes without it). Shift+Enter is a
|
||||
* newline, Esc clears, Backspace and the arrows reach the PTY only from an
|
||||
* empty field, and so do the Ctrl shortcuts. Autocorrect is on. A held draft
|
||||
* belongs to one session (_owner): clear() stashes it under that session and
|
||||
* restoreDraft() brings it back when the session is shown again, except a
|
||||
* clear({ discard: true }) (the keyboard bar's clear-line key), which throws
|
||||
* it away.
|
||||
*
|
||||
* ## Android IME challenge
|
||||
*
|
||||
* Android virtual keyboards (WeChat, Sogou, Gboard in Chinese mode) use
|
||||
@@ -621,17 +636,24 @@ const CjkInput = (() => {
|
||||
* can't flush into the wrong session). Restores the phantom so backspace
|
||||
* forwarding keeps working — unlike a raw `textarea.value = ''`.
|
||||
*/
|
||||
clear() {
|
||||
clear({ discard = false } = {}) {
|
||||
if (!_initialized || !_textarea) return;
|
||||
_t('clear (external)');
|
||||
// Send-on-Enter: a held draft is stashed for the session it was typed
|
||||
// for, whichever path got here. discardDraft() drops the owner of a
|
||||
// removed session, so its text is not stashed again.
|
||||
if (_hold && _owner) {
|
||||
const draft = _strip(_textarea.value);
|
||||
if (draft.trim()) _drafts.set(_owner, draft);
|
||||
_t(`clear (external)${discard ? ' discard' : ''}`);
|
||||
if (discard) {
|
||||
// The user threw the text away (the keyboard bar's clear-line key):
|
||||
// nothing is stashed, any older stash of this session goes too, and the
|
||||
// field keeps its owner, since the session shown has not changed.
|
||||
if (_owner) _drafts.delete(_owner);
|
||||
} else {
|
||||
// Send-on-Enter: a held draft is stashed for the session it was typed
|
||||
// for, whichever path got here. discardDraft() drops the owner of a
|
||||
// removed session, so its text is not stashed again.
|
||||
if (_hold && _owner) {
|
||||
const draft = _strip(_textarea.value);
|
||||
if (draft.trim()) _drafts.set(_owner, draft);
|
||||
}
|
||||
_owner = null;
|
||||
}
|
||||
_owner = null;
|
||||
_cancelDebouncedFlush();
|
||||
clearTimeout(_compositionFlushTimer);
|
||||
_compositionFlushTimer = null;
|
||||
|
||||
@@ -5134,7 +5134,9 @@ Object.assign(CodemanApp.prototype, {
|
||||
clearTerminalInput() {
|
||||
if (!this.activeSessionId) return;
|
||||
|
||||
if (typeof CjkInput !== 'undefined') CjkInput.clear();
|
||||
// discard: the line is thrown away, so a Send on Enter draft must not be
|
||||
// stashed and come back on the next visit to this session.
|
||||
if (typeof CjkInput !== 'undefined') CjkInput.clear({ discard: true });
|
||||
// A tile or Pane B holds the keyboard: its TUI owns the editable buffer
|
||||
// (no local-echo overlay there), so kill the line in that pane's session,
|
||||
// never in the parked main pane's.
|
||||
|
||||
Reference in new issue
Block a user