Skip to content

fix(mobile): recover terminal input lease on attach and preserve picked file names #32985

Closed

Description

@zhangxaochen

Problem

When attaching files from the mobile terminal command bar via long-press on the attach button (pickImage('files')):

  1. Attach failed (reconnecting) in Terminal view after backgrounding/picker freeze:

    • While the Android file picker (PickActivity) is open or the phone briefly backgrounds/freezes the WebView, the WebSocket reconnects and clears nativeChatInputLeaseReadyRef (leaseReady = false).
    • When the previous terminal.subscribe stream ends (unsubscribeTerminal), useMobileSessionTerminalSubscriptionFoundation only increments coveredStreamRevision when showNativeChatRef.current is true.
    • In pure Terminal view (showNativeChat === false), neither coveredStreamRevision nor leaseReady changes on stream teardown, and ensureSessionTabs() on reconnect skips re-applying the tab snapshot when (publicationEpoch, version) is unchanged on the host.
    • As a result, terminal.subscribe remains permanently unsubscribed and useMobileAttachmentInputLeaseGate times out after 3000ms with Attach failed (reconnecting).
  2. Original filename and extension are lost on terminal file upload:

    • saveClipboardImageBufferAsTempFile hardcodes the temporary filename on the host as orca-paste-${Date.now()}-${randomUUID()}.png, renaming any non-image file (e.g. .txt, .pdf, .json) to .png.
    • mobile/src/session/mobile-image-source-picker.ts (pickFromFiles) restricts DocumentPicker.getDocumentAsync to type: 'image/*' instead of type: '*/*', and media-picker.web.ts (readPicked) does not forward the picked file's name from verbs.nameMedia.

Expected Behavior

  1. Automatically recover the active terminal subscription and input lease when a stream is torn down in Terminal view (showNativeChat === false), on WebSocket reconnect, and when useMobileAttachmentInputLeaseGate detects an unready lease on a connected terminal tab.
  2. Preserve the sanitized original filename and extension when saving mobile terminal file attachments to a host temporary file, and allow pickFromFiles to select any file type (*/*).

Activity

  1. AmethystLiang commented on Oct 25, 2026

    @AmethystLiang
    Contributor

    looking into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions