d7d3c8409dabc1d2b30ac02ffce151fd36e2d030
1 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
c0eaafaf29 |
fix(mobile): isPassthroughMode falls back to TaskChatPanel when snapshot is missing (closes #1031) (#1034)
* fix(mobile): passthrough TUI rendering + touch-scroll Two related mobile-UI fixes for cli_passthrough sessions, both filed in #1031. 1. task-center-panel.tsx: align isPassthroughMode with the rest of the codebase by checking session.is_passthrough first. The memo previously only consulted agent_profile_snapshot.cli_passthrough, which can be undefined in the Redux store on re-mount (the snapshot isn't always present on the leaner session-list responses). When that happened on mobile, the chat panel rendered the persisted- messages TaskChatPanel fallback instead of the live PassthroughTerminal. Desktop was immune because dockview-desktop-layout.tsx already uses the session.is_passthrough field directly. is_passthrough is the source of truth used by manager_startup.go's StartAgentProcess routing — keeping the frontend consistent with that invariant. 2. passthrough-terminal.tsx: wire touch-drag scrolling on the xterm viewport. xterm.js handles mouse wheel natively but not touch gestures, so swiping inside the terminal on mobile bubbled up and scrolled the page instead of the terminal scrollback — effectively making everything that scrolled off-screen unreachable on mobile. The new hook attaches touchstart/touchmove/touchend handlers that map vertical drag delta to term.scrollLines(), gated on (pointer: coarse) so desktop xterm behaviour stays identical. Row-height comes from xterm's internal render dimensions with a measured fallback (xterm 5.x layout) and a 16px constant fallback if both fail. Closes #1031 * fix(mobile): also fix useSessionLayoutState's isPassthroughMode + tighten touch-handling Three follow-on fixes after Dan's mobile QA surfaced more cases: 1. apps/web/hooks/use-session-layout-state.ts — the mobile layout actually uses THIS hook's isPassthroughMode memo (not the one in task-center-panel.tsx that I previously fixed). It had the identical snapshot-only bug. Aligned with the same is_passthrough-first priority. 2. apps/web/components/task/passthrough-terminal.tsx — always preventDefault on touchmove (was only doing so when the row-delta calculation rounded to non-zero, so sub-row drags slipped through to parent scroll). Added touch-action: none + overscroll-behavior: contain inline on the terminal element so the browser never claims the gesture. 3. apps/web/app/globals.css — overscroll-behavior: none on body to block pull-to-refresh. iOS Safari ignores this in some configurations but blocking it where possible reduces the page-reload race that was triggering the stuck-on-loading-messages state. * fix(mobile): trim PR to minimum required changes After QA showed the user-visible mobile bug is fully addressed by the useSessionLayoutState memo fix alone, revert the parallel changes to the desktop hook (task-center-panel.tsx's useSessionApprove) and the body-level overscroll-behavior — neither was required for the reported bug, and Dan asked for the smallest possible diff. Remaining changes: - apps/web/hooks/use-session-layout-state.ts — actual mobile fix - apps/web/components/task/passthrough-terminal.tsx — touch-scroll feature * fix(mobile): tighten isPassthroughMode + drop terminal touch-scroll from this PR Adversarial-review feedback applied: - Change `is_passthrough === true` to `!== undefined` so an explicit server-side false isn't overridden by a stale snapshot. - Comment now cites the specific WS handler quirk in ws/handlers/agent-session.ts where snapshot writes are truthy-guarded but is_passthrough writes are !== undefined-guarded — that's the concrete path where partial events land one without the other. Dropped: the useMobileTouchScroll hook. Terminal scroll on mobile is a separate feature that deserves its own discussion (xterm renders the canvas above the scrollable viewport so native scroll doesn't reach the viewport; the right fix likely lives in xterm itself or a small event-redirect addon). Keeping this PR scoped to the rendering bug. * fix(mobile): add minimal touch-scroll fallback for xterm viewport xterm.js renders .xterm-screen (canvas) above .xterm-viewport, so iOS / Android native scroll on the viewport never sees the touches and the terminal is unscrollable on mobile. useTouchScrollFallback wires touchstart/touchmove/touchend to Terminal.scrollLines via an accumulated fractional-row delta. No inertia — the proper fix is upstream in xterm-js. Gated on (pointer: coarse) so desktop xterm behaviour is unchanged. Sets touch-action: none + overscroll-behavior: contain inline on the terminal element so the browser doesn't claim the gesture for pull-to-refresh. * fix(mobile): inertia decay on touch-scroll release for native-scroll feel * fix(mobile): address adversarial review of touch-scroll hook - Read xterm from ref inside each handler so renderer recreate doesn't strand the handlers on a stale Terminal instance (React refs are stable so dep array doesn't catch .current swaps). - Drop the internal _core._renderService private-API path for row height in favor of public term.rows + measured element height. The internal path was API-unstable across xterm majors. - Velocity window 80ms → 50ms so a direction reversal at the tail of the gesture is the release velocity, not averaged against the early motion. - Reset pendingRows fractional accumulator on direction reversal — was causing perceptible stickiness when reversing from slow-up to fast-down. - Style restoration now uses removeProperty when the inline style was never set, rather than leaking an empty string in its place. * fix(mobile): revert touch-scroll hook from this PR — separate concern After several iterations the touch-scroll fallback kept surfacing new issues (iOS pull-to-refresh leaking through preventDefault, scroll direction reversal edge cases) that suggest a more involved upstream discussion is needed about whether to ship a workaround in PassthroughTerminal at all vs fixing xterm.js's mobile story upstream. Splitting that work out so this PR can land the rendering bug fix cleanly. Will file a separate issue for the touch-scroll work with the diagnosis + alternatives we explored. * fix(mobile): honor is_passthrough when snapshot missing --------- Co-authored-by: Carlos Florêncio <carlosmflorencio@gmail.com> |