mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
fix(web): scroll to the prompt on toolbar Enter, retire app.sendInput (#830)
submitFromToolbar() puts the CR on the FIFO, bypassing xterm scrollOnUserInput; scroll the focused pane before sending. Remove app.sendInput(), which has no production caller; update @dependency headers and test stubs. Retarget the codex predictive-echo recorders to _enqueueReliableInput. Correct the docs and the _sendInputAsync JSDoc for the session FIFO; drop stale _pendingInput stubs.
This commit is contained in:
1 parent
ddb5a647ba
commit
05fc2f990b
16 files changed
+86
-95
No files matched your search
@@ -4198,8 +4198,10 @@ class CodemanApp {
|
||||
|
||||
/**
|
||||
* Public input entry point — name/signature kept for all call sites.
|
||||
* Records the input durably, then delivers it reliably (exactly-once). Never
|
||||
* blocks the keystroke flush; never silently drops on a half-open socket.
|
||||
* Seals the session's batched keystrokes, then enqueues the input on that
|
||||
* session's FIFO, which hands it to the durable exactly-once layer
|
||||
* (_enqueueReliableInput). It can wait behind an earlier `gap` (a delayed
|
||||
* Enter); it never silently drops on a half-open socket.
|
||||
* @param {string} sessionId
|
||||
* @param {string} input
|
||||
* @param {{useMux?: boolean}} [opts] - useMux only affects the POST fallback.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
* For drag-and-drop: listens on the terminal container for file drops.
|
||||
*
|
||||
* @dependency app.js (uses global `app` for sendInput, activeSessionId, showToast)
|
||||
* @dependency app.js (uses global `app` for _sendInputAsync, _prepareExternalInput, activeSessionId, showToast)
|
||||
* @dependency panels-ui.js (provides showToast)
|
||||
*/
|
||||
|
||||
@@ -397,10 +397,9 @@ Object.assign(CodemanApp.prototype, {
|
||||
const paths = results.filter(Boolean);
|
||||
if (paths.length > 0 && options.insert !== false) {
|
||||
// Insert all paths in one shot, space-separated, in selection order, into
|
||||
// the session the batch was uploaded TO. Not sendInput(): it re-reads
|
||||
// activeSessionId, and after the awaits above that is whatever tab the
|
||||
// user switched to mid-upload, so the paths landed in the wrong session.
|
||||
// Same delivery sendInput() uses (durable queue, useMux for the POST path).
|
||||
// the session the batch was uploaded to, captured before the awaits above,
|
||||
// not the active tab the user may have switched to mid-upload.
|
||||
// Delivery uses the durable session-bound path, with useMux for the POST fallback.
|
||||
const pane = this._paneForSession?.(sessionId);
|
||||
if (pane) this._prepareExternalInput?.(pane, 'upload-insert', { flushEcho: true });
|
||||
this._sendInputAsync(sessionId, paths.join(' '), { useMux: true });
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
* @globals {class} FocusTrap
|
||||
*
|
||||
* @dependency mobile-handlers.js (MobileDetection.isTouchDevice)
|
||||
* @dependency app.js (uses global `app` for sendInput, activeSessionId, terminal)
|
||||
* @dependency app.js (uses global `app` for _enqueueInput, _sendInputAsync, _prepareExternalInput, activeSessionId, terminal)
|
||||
* @loadorder 5 of 15 — loaded after notification-manager.js, before app.js
|
||||
*/
|
||||
|
||||
|
||||
@@ -857,6 +857,12 @@ Object.assign(CodemanApp.prototype, {
|
||||
submitFromToolbar() {
|
||||
const pane = this._focusedPane();
|
||||
if (!pane?.terminal || !pane.sessionId || pane.tile?._destroyed || !this.sessions.has(pane.sessionId)) return;
|
||||
// The CR goes on the FIFO, not through xterm's triggerDataEvent(data, true),
|
||||
// so its scrollOnUserInput never runs; scroll to the prompt as it would.
|
||||
const terminal = pane.terminal;
|
||||
if (terminal.options?.scrollOnUserInput !== false && typeof terminal.scrollToBottom === 'function') {
|
||||
terminal.scrollToBottom();
|
||||
}
|
||||
this._prepareExternalInput(pane, 'submit');
|
||||
if (pane.isPrimary) this._submitMainInput(pane.sessionId);
|
||||
else this._sendInputAsync(pane.sessionId, '\r');
|
||||
@@ -7198,19 +7204,6 @@ Object.assign(CodemanApp.prototype, {
|
||||
this.showToast('Another device is setting the width — scroll sideways', 'info');
|
||||
},
|
||||
|
||||
/**
|
||||
* Send input to the active session.
|
||||
* @param {string} input - Text to send (include \r for Enter)
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async sendInput(input) {
|
||||
if (!this.activeSessionId || !input) return;
|
||||
// Route through the durable, exactly-once delivery layer (useMux for the
|
||||
// POST fallback) so voice / keyboard-accessory / paste input also survives a
|
||||
// dropped link instead of being lost in a single best-effort fetch.
|
||||
this._sendInputAsync(this.activeSessionId, input, { useMux: true });
|
||||
},
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
// Directory Input
|
||||
// ═══════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
* @globals {object} VoiceInput
|
||||
*
|
||||
* @dependency mobile-handlers.js (MobileDetection for device checks)
|
||||
* @dependency app.js (uses global `app` for sendInput, showToast, terminal focus)
|
||||
* @dependency app.js (uses global `app` for _sendInputAsync, _enqueueInput, _prepareExternalInput, showToast, terminal focus)
|
||||
* @loadorder 3 of 15 — loaded after mobile-handlers.js, before notification-manager.js
|
||||
*/
|
||||
|
||||
|
||||
Reference in new issue
Block a user