Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BACKLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ This is the git-tracked backlog for this workstream. Keep local next steps here;
- [ ] Window-strip arrow-key navigation dispatches live select_window per keypress (valid ARIA auto-activation but can burst commands) — consider focus-only + Enter-to-activate (Wave-5 review INFO).
- [ ] Commit a refreshed docs-site screenshot of the Command Center (acceptance checklist residual NOT-MET).
- [ ] Wave-6 batch-2 review LOWs: prune command-mark seenRef on marker disposal; 4px selection-handle offset; double-tap vs touch-scroll listener ordering; thumbnail "live capture" wording; scroll-freeze anchor drift at 10k scrollback saturation; heuristic ❯/› prompt-glyph tuning; stuck suppressClickRef edge (touch tap then BT-keyboard click).
- [deps] Dependabot #39 (medium): uuid < 11.1.1 buffer bounds check in v3/v5/v6-with-buf — we only use v4(); bump uuid across lockfile at next dep pass. (2026-07-21)
- [tests] Journey suite stabilization pass: attach/type input race + launch-sheet fill timeout flake under parallel load (both pass 10/10 isolated; ~3-7% flake in full parallel runs). Consider per-test WS-connected wait helper + launch sheet readiness gate. (2026-07-21)
9 changes: 7 additions & 2 deletions apps/dashboard/src/components/TerminalView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useSettingsStore } from '@/stores/settings';

interface TerminalViewProps {
sessionId: string;
historySessionId?: string;
hostId?: string;
paneId?: string;
className?: string;
Expand All @@ -39,6 +40,7 @@ export type { TerminalController } from '@/components/terminal/types';

export function TerminalView({
sessionId,
historySessionId = sessionId,
hostId,
paneId,
className,
Expand Down Expand Up @@ -206,6 +208,7 @@ export function TerminalView({
onOutputStart: handleOutputStart,
onOutputWritten: handleTerminalOutputWritten,
});
const terminalWritable = status === 'connected' && !readOnly;
controllerReadOnlyRef.current = readOnly;
const dispatchStickyCtrl = useCallback((event: StickyCtrlEvent) => {
const nextMode = reduceStickyCtrl(stickyCtrlModeRef.current, event);
Expand Down Expand Up @@ -234,8 +237,10 @@ export function TerminalView({
terminalRef,
fontSize: terminalFontSize,
onFontSizeChange: setTerminalFontSize,
cursorEnabled: status === 'connected' && !readOnly,
cursorEnabled: terminalWritable,
onCursorInput: sendInput,
writable: terminalWritable,
onScrollInput: sendInput,
onHorizontalSwipe: (direction) => {
termRef.current?.dispatchEvent(new CustomEvent('terminal-window-swipe', {
bubbles: true,
Expand Down Expand Up @@ -380,7 +385,7 @@ export function TerminalView({
search={searchControls}
/>
<ScrollbackPager
sessionId={sessionId}
sessionId={historySessionId}
open={historyOpen}
onClose={() => setHistoryOpen(false)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function PersistentTerminalHost() {
(state) => state.terminalWarmTimeoutMinutes ?? DEFAULT_TERMINAL_WARM_TIMEOUT_MINUTES
);
const attachmentDescriptor = snapshot.attachmentDescriptor ?? snapshot.descriptor;
const selectedSessionId = snapshot.descriptor?.sessionId;
const terminalContext = attachmentDescriptor
? {
descriptorKey: snapshot.descriptorKey!,
Expand Down Expand Up @@ -167,11 +168,12 @@ export function PersistentTerminalHost() {
return (
<>
<div ref={parkingRef} hidden aria-hidden="true" data-terminal-parking />
{portalNode && attachmentDescriptor && createPortal(
{portalNode && attachmentDescriptor && selectedSessionId && createPortal(
<TerminalGridContext.Provider value={terminalContext}>
<TerminalView
key={snapshot.descriptorKey}
sessionId={attachmentDescriptor.sessionId}
historySessionId={selectedSessionId}
hostId={attachmentDescriptor.hostId}
paneId={attachmentDescriptor.paneId}
autoAttach={attachmentDescriptor.autoAttach}
Expand Down
134 changes: 133 additions & 1 deletion apps/dashboard/src/hooks/useTerminalTouchScroll.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import type { XTerminal } from '@/components/terminal/types';
import {
buildSgrWheelReports,
calculatePinchFontSize,
dispatchTerminalTouchScroll,
mapScrollLinesToWheelReports,
resolveTerminalHorizontalSwipe,
resolveTouchCell,
synthesizeCursorDragInput,
} from './useTerminalTouchScroll';

function terminalForScroll(
bufferType: 'normal' | 'alternate',
mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any'
): XTerminal {
return {
buffer: { active: { type: bufferType } },
modes: { mouseTrackingMode },
scrollLines: vi.fn(),
} as unknown as XTerminal;
}

describe('terminal pinch font sizing', () => {
it('scales from the gesture origin and clamps to the configured range', () => {
expect(calculatePinchFontSize(14, 100, 115)).toBe(16);
Expand Down Expand Up @@ -46,3 +62,119 @@ describe('terminal cursor drag synthesis', () => {
expect(accelerated.sentY).toBe(36);
});
});

describe('terminal touch wheel synthesis', () => {
it('maps signed line deltas to five-line wheel reports with a remainder', () => {
expect(mapScrollLinesToWheelReports(-2)).toEqual({ reportDelta: 0, remainder: -2 });
expect(mapScrollLinesToWheelReports(-3, -2)).toEqual({
reportDelta: -1,
remainder: 0,
});
expect(mapScrollLinesToWheelReports(11)).toEqual({ reportDelta: 2, remainder: 1 });
});

it('builds repeated SGR wheel-up and wheel-down reports at the touch cell', () => {
expect(buildSgrWheelReports(-2, 12, 7)).toBe(
'\x1b[<64;12;7M\x1b[<64;12;7M'
);
expect(buildSgrWheelReports(1, 3, 4)).toBe('\x1b[<65;3;4M');
expect(buildSgrWheelReports(0, 3, 4)).toBe('');
});

it('derives one-based touch cells and clamps them to the terminal grid', () => {
const rect = { left: 100, top: 50 };
expect(resolveTouchCell(124, 90, rect, 8, 20, 80, 24)).toEqual({
column: 4,
row: 3,
});
expect(resolveTouchCell(20, 10, rect, 8, 20, 80, 24)).toEqual({
column: 1,
row: 1,
});
expect(resolveTouchCell(2_000, 2_000, rect, 8, 20, 80, 24)).toEqual({
column: 80,
row: 24,
});
});
});

describe('terminal touch scroll dispatch', () => {
it('keeps normal-buffer scrolling in xterm', () => {
const terminal = terminalForScroll('normal', 'none');
const onInput = vi.fn();

expect(dispatchTerminalTouchScroll({
terminal,
lineDelta: -4,
wheelRemainder: 0,
column: 2,
row: 3,
writable: true,
onInput,
})).toBe(0);
expect(terminal.scrollLines).toHaveBeenCalledWith(-4);
expect(onInput).not.toHaveBeenCalled();
});

it('sends SGR reports for a writable alternate buffer with mouse tracking', () => {
const terminal = terminalForScroll('alternate', 'drag');
const onInput = vi.fn();
const remainder = dispatchTerminalTouchScroll({
terminal,
lineDelta: -3,
wheelRemainder: 0,
column: 12,
row: 7,
writable: true,
onInput,
});

expect(dispatchTerminalTouchScroll({
terminal,
lineDelta: -2,
wheelRemainder: remainder,
column: 12,
row: 7,
writable: true,
onInput,
})).toBe(0);
expect(terminal.scrollLines).not.toHaveBeenCalled();
expect(onInput).toHaveBeenCalledOnce();
expect(onInput).toHaveBeenCalledWith('\x1b[<64;12;7M');
});

it('falls back to xterm scrolling when the alternate buffer has no mouse tracking', () => {
const terminal = terminalForScroll('alternate', 'none');
const onInput = vi.fn();

dispatchTerminalTouchScroll({
terminal,
lineDelta: 6,
wheelRemainder: 0,
column: 2,
row: 3,
writable: true,
onInput,
});

expect(terminal.scrollLines).toHaveBeenCalledWith(6);
expect(onInput).not.toHaveBeenCalled();
});

it('does nothing for a read-only or disconnected mouse-tracked alternate buffer', () => {
const terminal = terminalForScroll('alternate', 'drag');
const onInput = vi.fn();

expect(dispatchTerminalTouchScroll({
terminal,
lineDelta: -5,
wheelRemainder: 0,
column: 2,
row: 3,
writable: false,
onInput,
})).toBe(0);
expect(terminal.scrollLines).not.toHaveBeenCalled();
expect(onInput).not.toHaveBeenCalled();
});
});
Loading
Loading