Skip to content

fix(android): reject stale shell backlog + always-visible keyboard toggle#178

Open
wahaj4311 wants to merge 1 commit into
dnakov:mainfrom
wahaj4311:fix/android-terminal-keyboard-and-replay
Open

fix(android): reject stale shell backlog + always-visible keyboard toggle#178
wahaj4311 wants to merge 1 commit into
dnakov:mainfrom
wahaj4311:fix/android-terminal-keyboard-and-replay

Conversation

@wahaj4311

Copy link
Copy Markdown

Summary

  1. Terminal breakage on reconnect (`v1-Backend: terminal JSON-RPC stream closed`): the shared `remote_alleycat` read loop was accepting replayed backlog frames from a prior killed shell session while its own `shell_session_id` was still `None`. A stale `shell/exit` in the ring then broke the loop before `initialize` returned. Guard by treating an unset expected id as reject-until-spawned instead of accept-all.
  2. Keyboard never appearing on Android: `onSingleTapConfirmed` returned false when `terminalRenderer` was null, so tapping the black surface during startup never called `showIme()`. Users had no other way to summon the IME. Fix by popping the IME on every confirmed tap, and add an `Icons.Outlined.Keyboard` `IconButton` in the terminal header wired to a new file-local `showTerminalKeyboard()` helper (via a `WeakReference` to the active `GhosttyAndroidSurfaceView`).

Pairs with dnakov/alleycat#PR (server-side session-replay fix for the shell agent). Either patch alone fixes the reconnect breakage; both together are the belt-and-suspenders.

Test plan

  • Reject-on-null-session verified: Android app opens terminal, backgrounds, reconnects — every attach is Fresh with the server-side fix and no stale exit interrupts `initialize`.
  • Manual: tap black viewport during startup — keyboard appears.
  • Manual: tap the new keyboard icon in the terminal header — keyboard appears.
  • Manual: reconnect after wifi flip — keyboard button still summons IME.

…ggle

Terminal was broken on every reconnect with 'v1-Backend: terminal
JSON-RPC stream closed' and the on-screen keyboard could not be
summoned by tapping the viewport.

Two fixes:

1. shared/remote_alleycat: reject replayed backlog frames from a prior
   killed shell session until our own shell/spawn returns and sets the
   expected session id. Otherwise a stale shell/exit in the ring breaks
   the read loop before initialize returns.

2. android/GhosttySurfaceView + TerminalScreen: pop the IME on every
   confirmed tap (previously the tap handler bailed out when the
   renderer was still binding), and add an explicit keyboard IconButton
   to the terminal header for reconnects/edge cases where focus is not
   restored to the SurfaceView.
cad0p added a commit to cad0p/litter that referenced this pull request Jul 9, 2026
The com.apple.developer.carplay-voice-based-conversation entitlement
requires special Apple approval and is not available via the public App
Store Connect API capability list. Forks without that approval cannot
build a TestFlight IPA. Remove it — CarPlay is not needed to test the
terminal stale-backlog fix (PR dnakov#178).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant