Compare commits

...
Author SHA1 Message Date
Codeman maintainer cf3183abf7 chore: version packages
Release 1.16.6: phone overview started/idle stamps, plus fixes for the
selection-dialog keyboard lockout, the accessory bar arrows bypassing the
local-echo overlay, and recovered sessions being restamped as newly created
on every server restart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 23:14:57 +02:00
13 changed files with 446 additions and 27 deletions
+14
View File
@@ -1,5 +1,19 @@
# aicodeman
## 1.16.6
### Patch Changes
- Phone home screen now shows session ages, plus three mobile input fixes.
**Phone overview: started / how long stamps.** Every live session row on the "C" home screen carries a third line: when the session first started, and how long it has been in the state it is in ("started 3d ago · idle 12m"). Idle, waiting, error and ended states measure from the pane's last output, which for a Claude pane sitting at its composer is exactly when the turn ended; a WORKING session measures from its last Enter instead, because a running pane repaints about once a second and would otherwise report every turn as 0m. A 20s clock rewrites the values in place rather than re-rendering, so no row's blink or pulse restarts.
**Fix: a recovered session was restamped as new on every restart.** Boot recovery never passed `createdAt`, so each server start reset it to `Date.now()` and a week-old pane reported "created 2m ago" (and sorted as the newest thing in the unified session list). It now comes from the tmux session's own birth time, which mux-sessions.json already carried. The desktop home rail's "created" stamp is fixed by the same change.
**Fix: a selection dialog locked the on-screen keyboard out of the terminal (regression in 1.16.5).** The check that decides whether a tap belongs to the TUI scanned the whole viewport for a numbered menu, so while a Claude question or permission dialog was on screen EVERY tap in the terminal counted as actionable and blurred the input. The keyboard could not be opened at all until the dialog was answered, which left tapping an option, the one gesture that commits an answer, as the only interaction a phone had. The menu test is now row-local: the dialog's own rows still report the tap and keep the keyboard down, while the question title, the transcript and blank space summon the keyboard so a digit can be typed at the dialog instead of aimed at it.
**Fix: the accessory bar's arrow keys bypassed the local-echo overlay.** On a phone the text you type is buffered in the browser and has never reached the PTY, so an arrow tapped on the bar arrived at a composer the CLI still considered empty: Up recalled a history entry into it while the overlay went on painting the draft over the same row and still believed it was pending, and the next Enter submitted the two mixed together. The four arrows now flush the draft first and hand the session to plain PTY echo, the same contract a nav key typed on a hardware keyboard has had since #218. The CLI stashes the flushed draft, so Down brings it back. Tab now shares that one flush helper instead of its own copy.
## 1.16.5
### Patch Changes
+1 -1
View File
@@ -74,7 +74,7 @@ When user says "COM":
CI runs `npm run check:lockfile` on every push/PR, so lockfile drift fails the build even if the `version-packages` script is bypassed.
**Version**: 1.16.5 (must match `package.json`)
**Version**: 1.16.6 (must match `package.json`)
## Project Overview
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "aicodeman",
"version": "1.16.5",
"version": "1.16.6",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "aicodeman",
"version": "1.16.5",
"version": "1.16.6",
"hasInstallScript": true,
"license": "MIT",
"workspaces": [
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "aicodeman",
"version": "1.16.5",
"version": "1.16.6",
"description": "Mission control for AI coding agents - run 20 autonomous agents with real-time monitoring and session persistence",
"type": "module",
"main": "dist/index.js",
+6 -1
View File
@@ -591,7 +591,12 @@ export class Session extends EventEmitter {
this.mode = config.mode || 'claude';
this._name = config.name || '';
this._resumeSessionId = config.resumeSessionId;
this._lastActivityAt = this.createdAt;
// NOW, not `createdAt`: recovery passes the ORIGINAL creation time of a
// days-old tmux session, and seeding last-activity from it would report a
// freshly re-attached pane as having been silent for days, which the idle
// confirmation reads as "already quiet" and the home screens print as its
// idle duration. For a genuinely new session the two are the same instant.
this._lastActivityAt = Date.now();
// Set claudeSessionId — when resuming, the Claude conversation ID is the resumed one.
this._claudeSessionId = config.resumeSessionId || this.id;
// Restored from state.json on boot recovery. start() resets _claudeSessionId
+52 -21
View File
@@ -729,16 +729,16 @@ const KeyboardAccessoryBar = {
this.toggleCtrl();
break;
case 'scroll-up':
this.sendKey('\x1b[A');
this.sendNavKey('\x1b[A');
break;
case 'scroll-down':
this.sendKey('\x1b[B');
this.sendNavKey('\x1b[B');
break;
case 'arrow-left':
this.sendKey('\x1b[D');
this.sendNavKey('\x1b[D');
break;
case 'arrow-right':
this.sendKey('\x1b[C');
this.sendNavKey('\x1b[C');
break;
case 'esc':
this.sendKey('\x1b');
@@ -746,26 +746,12 @@ const KeyboardAccessoryBar = {
case 'opt-enter':
this.sendKey('\x1b\r');
break;
case 'tab': {
case 'tab':
// Tab means "complete what I just typed", but with local echo the typed
// text is still buffered in the overlay and has never reached the PTY —
// a bare \t would ask the CLI to complete an empty composer. Flush the
// pending text first (same steps as the Shift+Enter branch in
// terminal-ui.js), then send \t after the sendCommand settle delay.
const overlay = app._localEchoOverlay;
const pending = (app._localEchoEnabled && overlay?.pendingText) || '';
if (pending) {
overlay.clear();
overlay.suppressBufferDetection?.();
app._flushedOffsets?.delete(app.activeSessionId);
app._flushedTexts?.delete(app.activeSessionId);
app.sendInput(pending);
setTimeout(() => this.sendKey('\t'), 120);
} else {
this.sendKey('\t');
}
// a bare \t would ask the CLI to complete an empty composer.
this.flushPendingThen(() => this.sendKey('\t'));
break;
}
case 'shift-tab':
this.sendKey('\x1b[Z');
break;
@@ -860,6 +846,51 @@ const KeyboardAccessoryBar = {
setTimeout(() => app.sendInput('\r'), 120);
},
/**
* Flush whatever the local-echo overlay is still holding, THEN run `after()`.
*
* On a phone the characters you type sit in the overlay and have never
* reached the PTY, so any key that acts on "what I just typed" has to push
* that text out first or the CLI acts on an empty composer. Mirrors the
* flush the typed path performs in terminal-ui.js's onData; the 120ms is the
* same settle delay sendCommand uses, so the text lands before the key.
*/
flushPendingThen(after) {
const overlay = app._localEchoOverlay;
const pending = (app._localEchoEnabled && overlay?.pendingText) || '';
if (!pending) {
after();
return;
}
overlay.clear();
overlay.suppressBufferDetection?.();
app._flushedOffsets?.delete(app.activeSessionId);
app._flushedTexts?.delete(app.activeSessionId);
app.sendInput(pending);
setTimeout(after, 120);
},
/**
* A composer nav key (the four arrows) from the bar, under the SAME contract
* as pressing one on a hardware keyboard (the `isComposerNavKey` branch of
* terminal-ui.js's onData): flush the unsent draft so the key edits the real
* composer, then hand the session to plain PTY echo until Enter or Ctrl+C,
* because after a nav key the cursor can sit mid-text where the overlay's
* append-only buffering cannot track edits (issue #218).
*
* Without the flush the arrow reached a composer the CLI still saw as EMPTY:
* Up recalled a history entry into it while the overlay went on painting the
* draft over the same row and still believed it was pending. The draft was
* then submitted on top of the recalled text, and history recall looked
* broken because what came back was never what the row showed.
*/
sendNavKey(sequence) {
if (!app.activeSessionId) return;
if (!app._echoPassthroughSessions) app._echoPassthroughSessions = new Set();
app._echoPassthroughSessions.add(app.activeSessionId);
this.flushPendingThen(() => this.sendKey(sequence));
},
/** Send a special key (arrow, escape, etc.) directly to the PTY.
* Bypasses tmux send-keys -l (literal mode) since escape sequences
* must be written raw to be interpreted as key presses by Ink. */
+160
View File
@@ -14,12 +14,19 @@
* only this module removes it, so desktop (which never loads mobile.css) cannot
* render an unstyled overview even if a class rule leaked.
*
* Each live row also carries when the session FIRST started and how long it has
* been in the state it is in ("started 3d ago · idle 12m"). Both go stale on
* their own (a sitting session emits no event), so a slow clock rewrites them
* IN PLACE from the epoch ms parked on the elements, never by re-rendering,
* which would restart every row's blink and pulse.
*
* Everything renders from state the page already holds (`this.sessions`,
* `this.cases`, `this.pendingHooks`) — no endpoint, no SSE event, no schema.
* `buildMobileOverviewModel()` is pure and unit-tested (test/mobile-overview.test.ts).
*
* @mixin Extends CodemanApp.prototype via Object.assign
* @dependency app.js (this.sessions, this.cases, this.pendingHooks, selectSession, run)
* @dependency ralph-panel.js (formatRelativeTime, the app's one relative-time formatter)
* @dependency mobile-handlers.js (MobileDetection)
* @dependency session-ui.js (selectQuickStartCase for "New session here")
* @loadorder 12.55 of 16, after webview-tabs.js, before entrance-animations.js
@@ -64,6 +71,23 @@ const MOBILE_OVERVIEW_PILL_LABEL = {
done: 'done',
};
/**
* Label for the "how long has it been like this" stamp, per state. The pill
* already names the state, so this word is there to say what the duration next
* to it is measuring.
*/
const MOBILE_OVERVIEW_SINCE_LABEL = {
needs: 'waiting',
waiting: 'waiting',
error: 'failed',
working: 'working',
idle: 'idle',
done: 'ended',
};
/** How often the age stamps are rewritten in place while the home screen is up. */
const MOBILE_OVERVIEW_CLOCK_MS = 20000;
Object.assign(CodemanApp.prototype, {
// ═══════════════════════════════════════════════════════════════
// Model (pure)
@@ -87,6 +111,29 @@ Object.assign(CodemanApp.prototype, {
return 'idle';
},
/**
* Anchor + label for the row's second stamp: how long the session has been in
* the state it is in.
*
* For everything that is NOT working that anchor is `lastActivityAt`, the last
* byte the pane printed: a Claude pane sitting at its composer prints nothing,
* so the end of the last turn is exactly when the session went quiet.
*
* A WORKING pane is the opposite: it repaints about once a second, so its
* last-activity stamp is always "now" and would report every running turn as
* 0m. The turn's own start is the pane's last Enter (`lastSubmitAt`), which is
* persisted server-side and therefore survives a Codeman restart. A session
* that has never submitted has no anchor at all, and gets no stamp rather than
* a made-up one.
*
* @returns {{key: string, at: number}|null}
*/
_mobileOverviewSince(state, session) {
const at = state === 'working' ? Number(session.lastSubmitAt) || 0 : Number(session.lastActivityAt) || 0;
if (!at) return null;
return { key: MOBILE_OVERVIEW_SINCE_LABEL[state] || state, at };
},
/**
* Longest-prefix match of a workingDir against the case list, so a session
* started in a subdirectory still belongs to its case. Mirrors the matching in
@@ -137,6 +184,10 @@ Object.assign(CodemanApp.prototype, {
dir: this._shortenHomePath ? this._shortenHomePath(session.workingDir) : session.workingDir || '',
state,
pill: MOBILE_OVERVIEW_PILL_LABEL[state] || state,
// Epoch ms, straight off the session payload; formatting happens at
// render time so the clock can redo it without a re-render.
createdAt: Number(session.createdAt) || 0,
since: this._mobileOverviewSince(state, session),
orderIndex: orderIndex === -1 ? Number.MAX_SAFE_INTEGER : orderIndex,
};
});
@@ -224,6 +275,7 @@ Object.assign(CodemanApp.prototype, {
const el = document.getElementById('mobileOverview');
if (!el) return;
this._closeMobileOverviewRunMenu();
this._stopMobileOverviewClock();
el.classList.remove('visible');
el.hidden = true;
},
@@ -380,6 +432,8 @@ Object.assign(CodemanApp.prototype, {
this._mobileOverviewHistory ? 'No past conversations yet' : 'Loading…'
)
);
this._startMobileOverviewClock();
},
/**
@@ -623,6 +677,8 @@ Object.assign(CodemanApp.prototype, {
line2.textContent = row.mode + (row.dir ? ' · ' + row.dir : '');
body.appendChild(line2);
body.appendChild(this._buildMobileOverviewMeta(row));
item.appendChild(body);
const pill = document.createElement('span');
@@ -654,6 +710,110 @@ Object.assign(CodemanApp.prototype, {
return item;
},
// ═══════════════════════════════════════════════════════════════
// Age stamps: started / how long in this state
// ═══════════════════════════════════════════════════════════════
/**
* The "started 3d ago · idle 12m" line under a session row. Both stamps keep
* their raw epoch ms on the element (`data-mo-ts`) so `_tickMobileOverviewTimes()`
* can rewrite the text without rebuilding the row (a re-render would restart
* the blink on every waiting row and the pulse on every working one).
*/
_buildMobileOverviewMeta(row) {
const meta = document.createElement('span');
meta.className = 'mobile-overview-row-meta';
// Relative times are generated text, and "started"/"idle" here are the same
// generic words that mean something else on other surfaces.
meta.setAttribute('data-i18n-skip', '');
meta.appendChild(this._buildMobileOverviewStamp('started', row.createdAt, 'ago', 'mobile-overview-meta-started'));
if (row.since) {
const sep = document.createElement('span');
sep.className = 'mobile-overview-meta-sep';
sep.setAttribute('aria-hidden', 'true');
sep.textContent = '·';
meta.appendChild(sep);
meta.appendChild(
this._buildMobileOverviewStamp(row.since.key, row.since.at, 'for', 'mobile-overview-meta-since')
);
}
return meta;
},
/** One labelled stamp: a dim key, the value, the full date in the title. */
_buildMobileOverviewStamp(key, timestamp, format, className) {
const wrap = document.createElement('span');
wrap.className = 'mobile-overview-meta-item ' + className;
const label = document.createElement('span');
label.className = 'mobile-overview-meta-key';
label.textContent = key;
wrap.appendChild(label);
const value = document.createElement('span');
value.dataset.moTs = String(timestamp || 0);
value.dataset.moFmt = format;
value.textContent = this._mobileOverviewStampText(timestamp, format);
wrap.appendChild(value);
if (timestamp) wrap.title = `${key}: ${new Date(timestamp).toLocaleString()}`;
return wrap;
},
/**
* 'ago' points at a moment ("3d ago", the app's one relative formatter);
* 'for' measures a span from it to now ("12m"), which is what a duration
* beside a state word wants to read as.
*/
_mobileOverviewStampText(timestamp, format) {
if (!timestamp) return '—';
if (format === 'ago') {
return (this.formatRelativeTime && this.formatRelativeTime(timestamp)) || '—';
}
const ms = Date.now() - timestamp;
if (ms < 60000) return '<1m';
const mins = Math.floor(ms / 60000);
if (mins < 60) return `${mins}m`;
const hours = Math.floor(mins / 60);
if (hours < 24) return mins % 60 ? `${hours}h ${mins % 60}m` : `${hours}h`;
const days = Math.floor(hours / 24);
return hours % 24 ? `${days}d ${hours % 24}h` : `${days}d`;
},
/**
* Rewrites the stamps in place every `MOBILE_OVERVIEW_CLOCK_MS`. A sitting
* session emits nothing, so without this its "idle 2m" would still read 2m an
* hour later, the one number on the screen that has to move on its own.
*/
_startMobileOverviewClock() {
if (this._mobileOverviewClock) return;
this._mobileOverviewClock = setInterval(() => {
if (!this.isMobileOverviewVisible()) {
this._stopMobileOverviewClock();
return;
}
this._tickMobileOverviewTimes();
}, MOBILE_OVERVIEW_CLOCK_MS);
},
_stopMobileOverviewClock() {
if (!this._mobileOverviewClock) return;
clearInterval(this._mobileOverviewClock);
this._mobileOverviewClock = null;
},
_tickMobileOverviewTimes() {
const el = document.getElementById('mobileOverview');
if (!el) return;
for (const node of el.querySelectorAll('[data-mo-ts]')) {
const text = this._mobileOverviewStampText(Number(node.dataset.moTs) || 0, node.dataset.moFmt);
if (node.textContent !== text) node.textContent = text;
}
},
/** The session's pending approval, when the strip should render (dialogs only). */
_pendingApprovalForSession(sessionId) {
if (!this.approvals || !this.approvalsInboxEnabled || !this.approvalsInboxEnabled()) return null;
+40
View File
@@ -2720,6 +2720,46 @@ html.mobile-init .file-browser-panel {
text-overflow: ellipsis;
}
/* Third line of the row body: "STARTED 3d ago · IDLE 12m". Monospace so the
numbers stay put as the clock rewrites them every 20s, and dimmer than the
path above it: it answers a question you only ask on purpose. */
.mobile-overview-row-meta {
display: flex;
align-items: center;
gap: 0.3rem;
min-width: 0;
font-family: var(--font-mono, monospace);
font-size: 0.63rem;
color: var(--text-muted);
white-space: nowrap;
overflow: hidden;
}
.mobile-overview-meta-item {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
}
.mobile-overview-meta-key {
margin-right: 0.3rem;
opacity: 0.6;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.mobile-overview-meta-sep {
opacity: 0.45;
}
/* The freshest signal on the row: while a session is actually running, how
long the current turn has been going is the number the eye should land on.
Same treatment the desktop rail gives its "active" stamp. */
.mobile-overview-row--working .mobile-overview-meta-since {
color: var(--green);
opacity: 0.95;
}
.mobile-overview-dot {
flex-shrink: 0;
width: 9px;
+12 -1
View File
@@ -3641,9 +3641,20 @@ Object.assign(CodemanApp.prototype, {
// the affordance above; there is deliberately no verb literal here, because
// the verb is randomised per build.
// A visible selection dialog makes its OWN rows actionable, not the whole
// screen. Two viewport-wide `some()` tests used to be the entire answer, so
// while a Claude question or permission dialog was up EVERY tap in the
// terminal (inert transcript, the question title, blank rows) came back
// actionable, and the caller blurred on each one. The on-screen keyboard
// could then not be opened at all until the dialog was answered, which left
// tapping an option row as the only interaction available: the one that
// commits an answer. Requiring the TAPPED line to be a numbered row keeps
// the dialog's own rows behaving as before (report the tap, keep the
// keyboard down) while any other row can still summon the keyboard, which
// is how a digit gets typed at a dialog instead of aimed at it.
const hasMenuPrompt = lines.some((line) => /^\s*[❯›]\s+\d+[.)]\s/.test(line));
const hasMenuChoice = lines.some((line) => /^\s+\d+[.)]\s/.test(line));
return hasMenuPrompt && hasMenuChoice;
return hasMenuPrompt && hasMenuChoice && /^\s*(?:[❯›]\s*)?\d+[.)]\s/.test(tappedLine);
},
_focusMobileTerminalInput() {
+6
View File
@@ -2619,6 +2619,12 @@ export class WebServer extends EventEmitter {
workingDir: muxSession.workingDir,
mode: muxSession.mode,
name: sessionName,
// When the session FIRST started, not when this server booted.
// Without it every recovered session was restamped `Date.now()` on
// each restart, so a week-old pane read as "created 2m ago" on the
// home screens (and sorted as the newest thing in the unified list).
// mux-sessions.json carries the tmux session's own birth time.
createdAt: muxSession.createdAt || savedState?.createdAt,
mux: this.mux,
useMux: true,
muxSession: muxSession, // Pass the existing session so startInteractive() can attach to it
+54
View File
@@ -211,6 +211,60 @@ describe('mobile overview model', () => {
expect(empty).toMatchObject({ needsYou: [], current: [], past: [], sessionCount: 0 });
});
it('anchors the "how long" stamp on last activity, and on the last Enter while working', () => {
const app = loadOverviewApp();
const now = Date.now();
const model = app.buildMobileOverviewModel({
sessions: [
// A working pane repaints about once a second, so lastActivityAt is
// always "now" and would report every running turn as 0m. The turn's
// own start is the last Enter.
session({
id: 'w',
status: 'busy',
createdAt: now - 7200_000,
lastActivityAt: now,
lastSubmitAt: now - 300_000,
}),
// A quiet pane prints nothing, so its last byte IS when it went idle.
session({ id: 'i', status: 'idle', createdAt: now - 7200_000, lastActivityAt: now - 900_000 }),
],
cases: CASES,
});
const rows = Object.fromEntries(model.current.map((r: any) => [r.id, r]));
expect(rows.w.since).toEqual({ key: 'working', at: now - 300_000 });
expect(rows.i.since).toEqual({ key: 'idle', at: now - 900_000 });
expect(rows.i.createdAt).toBe(now - 7200_000);
});
it('leaves the stamp off rather than inventing an anchor', () => {
const app = loadOverviewApp();
const model = app.buildMobileOverviewModel({
// A session that has never submitted has no turn start to measure from.
sessions: [session({ id: 'w', status: 'busy', lastActivityAt: Date.now() })],
cases: CASES,
});
expect(model.current[0].since).toBeNull();
expect(model.current[0].createdAt).toBe(0);
});
it('formats a moment as "ago" and a span as a bare duration', () => {
const app = loadOverviewApp();
app.formatRelativeTime = () => '3d ago';
const now = Date.now();
expect(app._mobileOverviewStampText(now - 86_400_000, 'ago')).toBe('3d ago');
expect(app._mobileOverviewStampText(now - 20_000, 'for')).toBe('<1m');
expect(app._mobileOverviewStampText(now - 12 * 60_000, 'for')).toBe('12m');
expect(app._mobileOverviewStampText(now - 125 * 60_000, 'for')).toBe('2h 5m');
expect(app._mobileOverviewStampText(now - 3 * 3600_000, 'for')).toBe('3h');
expect(app._mobileOverviewStampText(now - 50 * 3600_000, 'for')).toBe('2d 2h');
// No anchor renders as a dash, never as "56 years ago" off epoch 0.
expect(app._mobileOverviewStampText(0, 'for')).toBe('—');
expect(app._mobileOverviewStampText(0, 'ago')).toBe('—');
});
it('no longer builds a spaces section', () => {
const app = loadOverviewApp();
const model = app.buildMobileOverviewModel({ sessions: [session({ id: 'a' })], cases: CASES });
+67
View File
@@ -573,3 +573,70 @@ describe('armed styling survives the light-skin overrides', () => {
);
});
});
describe('composer nav keys from the bar', () => {
/** loadBar()'s app stub plus the local-echo state the flush path reads. */
function barWithDraft(draft: string) {
const loaded = loadBar('claude');
const overlay = {
pendingText: draft,
clear: vi.fn(() => {
overlay.pendingText = '';
}),
suppressBufferDetection: vi.fn(),
};
const app = loaded.app as unknown as Record<string, unknown>;
app._localEchoEnabled = true;
app._localEchoOverlay = overlay;
app.sendInput = vi.fn();
app._flushedOffsets = new Map([['session-1', 3]]);
app._flushedTexts = new Map([['session-1', 'dra']]);
return { ...loaded, app, overlay };
}
const sentKeys = (fetchMock: { mock: { calls: unknown[][] } }) =>
fetchMock.mock.calls.map((call) => JSON.parse((call[1] as { body: string }).body).input);
it('flushes the unsent draft before sending the arrow', () => {
// On a phone the typed text lives in the overlay and has NEVER reached the
// PTY, so an arrow sent on its own arrives at a composer the CLI still
// considers empty: Up recalls a history entry into it while the overlay
// goes on painting the draft over the same row and still believes it is
// pending. Flushing first is also what makes the draft recoverable: the
// CLI stashes the live composer and hands it back on Down.
const { bar, app, overlay, fetchMock } = barWithDraft('draft I typed');
bar.handleAction('scroll-up');
expect(app.sendInput).toHaveBeenCalledWith('draft I typed');
expect(sentKeys(fetchMock)).toEqual(['\x1b[A']);
expect(overlay.pendingText).toBe('');
expect(overlay.suppressBufferDetection).toHaveBeenCalled();
// The overlay's bookkeeping for this session has to go with it.
expect((app._flushedOffsets as Map<string, number>).has('session-1')).toBe(false);
expect((app._flushedTexts as Map<string, string>).has('session-1')).toBe(false);
});
it('hands the session to plain PTY echo, like a typed nav key does', () => {
// After a nav key the real cursor can sit mid-text, where the overlay's
// append-only buffering cannot track edits (issue #218). terminal-ui.js's
// onData branch does exactly this for a nav key typed on a keyboard.
const { bar, app } = barWithDraft('');
bar.handleAction('arrow-left');
expect([...(app._echoPassthroughSessions as Set<string>)]).toEqual(['session-1']);
});
it('sends all four arrows and skips the flush when there is no draft', () => {
const { bar, app, fetchMock } = barWithDraft('');
bar.handleAction('scroll-up');
bar.handleAction('scroll-down');
bar.handleAction('arrow-left');
bar.handleAction('arrow-right');
expect(sentKeys(fetchMock)).toEqual(['\x1b[A', '\x1b[B', '\x1b[D', '\x1b[C']);
expect(app.sendInput).not.toHaveBeenCalled();
});
});
+31
View File
@@ -166,6 +166,37 @@ describe('terminal touch tap mouse guard', () => {
expect(app._classifyMobileTerminalTap(9, 49)).toBe('content');
});
it('keeps the keyboard reachable while a selection dialog is on screen', () => {
// The lock this pins: a visible dialog used to make EVERY row of the
// terminal "actionable" (both menu tests scanned the whole viewport), so
// every tap blurred and the on-screen keyboard could not be opened until
// the dialog was answered, leaving tapping an option (the one gesture that
// commits an answer) as the only thing a phone could do.
const { app, setActiveElement } = loadTerminalUiHarness();
app.activeSessionId = 'sess-1';
app.sessions = new Map([['sess-1', { mode: 'claude' }]]);
app.terminal = createTerminalGrid(
['Do you want to proceed?', '', '❯ 1. Yes', ' 2. No, tell Claude what to do', '', ''],
2
);
app._sendInputAsync = vi.fn();
setActiveElement(null);
// The dialog's own rows stay TUI-owned: report the tap, keep the keyboard down.
expect(app._isActionableMobileTerminalTap(9, 33)).toBe(true); // ❯ 1. Yes
expect(app._isActionableMobileTerminalTap(9, 49)).toBe(true); // 2. No, …
// Everything else is inert, and must still be able to summon the keyboard.
expect(app._isActionableMobileTerminalTap(9, 1)).toBe(false); // question title
expect(app._isActionableMobileTerminalTap(9, 65)).toBe(false); // blank row
app._handleMobileTerminalTap({ clientX: 9, clientY: 1 }, false);
expect(app.terminal.focus).toHaveBeenCalledOnce();
app.terminal.focus.mockClear();
app._handleMobileTerminalTap({ clientX: 9, clientY: 33 }, false);
expect(app.terminal.focus).not.toHaveBeenCalled();
});
it('collapses TUI readback content without opening or retaining the keyboard', () => {
const { app, setActiveElement } = loadTerminalUiHarness();
app.activeSessionId = 'sess-1';