Skip to content

fix(flow-chat): attach controller files and images in peer sessions - #3833

Merged
bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:bob/fix-peer-controller-attachments
Nov 8, 2026
Merged

bobleer merged 2 commits into
openBitFun:mainfrom
bobleer:bob/fix-peer-controller-attachments

Conversation

@bobleer

@bobleer bobleer commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Peer Device sessions could not reference files from the controller device, and dragging an image into a remote-controlled session did nothing but show "A peer-device session cannot reference files from the controller device." Both come from the same gate: resolveExternalFileIntakeAvailability rejected every controller path outside local execution, and desktop native drops only carry paths, so dropped images were rejected too (pasted images worked because they carry pixels).

This makes controller attachments work in peer and remote sessions the way they do locally:

  • Controller-local IO. Dropped/pasted files are read through the controller's own Tauri host with the local-provider marker (remoteConnectionId: ''), never through the rendered peer transport. The Linux clipboard fallbacks now read the controller clipboard instead of being proxied to the peer.
  • Images (png/jpg/gif/webp) become inline image contexts, which every execution host already accepts (inline or via upload_image_contexts). Works for Peer Device, remote workspace, and detached dispatch.
  • Other files are staged with the existing chunked, SHA-256-verified workspace_file_upload under openbitfun://runtime/<workspaceId>/attachments/<id>/<name>: host-owned runtime storage outside the repo that agent tools already resolve. The prompt references that host path, never a controller path.
  • Capability negotiation. New runtime_attachment_upload_v1 peer capability (Desktop + CLI). The upload service creates the runtime-owned parent for attachment URIs, confined to the runtime root.
  • Loud degradation. Older peers (images still work), folders, files over 32 MB, upload failures, sessions without a workspace, and non-image files on detached dispatch each get an explicit message; there is no path-reference fallback.

Related gaps closed in the same pass (same root cause: a controller path or clipboard sent to the rendered peer):

  • Files panel drop / OS-clipboard paste in Peer Device Mode used paste_files / SSH upload with controller paths, so the peer resolved them against its own disk, and paste read the peer's clipboard. They now upload controller bytes with workspace_file_upload (local-paste name (1) naming, never replacing a file, 64 MB per file, cancellable). Folders are refused explicitly because the controller explorer listing filters hidden/ignored entries and would copy an incomplete tree; a cut clipboard behaves as a copy (the controller source is never deleted).
  • Partial drop failures in the Files panel are now reported instead of dropped silently.
  • .bfminiapp import (drag or picker) is refused while a peer is rendered instead of sending a controller path to the peer.
  • Controller IO and the upload client live in infrastructure/files/controllerFiles.ts, shared by the composer and Files panel.

Fixes #

Type and Areas

Type: bug fix / UI/UX

Areas: web UI (flow chat composer, Files panel, MiniApp import, peer device), Rust core (workspace upload service), stable contracts (peer host capabilities), locales, docs

Motivation / Impact

Remote-controlled sessions behaved differently from local ones: users could not drag or paste files or images from the device in front of them. After this change, dropping or pasting controller images and files into a Peer Device or remote workspace session attaches them as it does locally.

Remote scenarios:

  • Peer Device: images inline; files staged on the peer when it advertises runtime_attachment_upload_v1, explicit "update the peer device" reply otherwise.
  • Remote workspace (opened by this desktop): images inline; files staged in the local runtime root for that workspace. workspace_file_upload requires being signed in, so unsigned users get an explicit upload error for non-image files.
  • Detached dispatch: images inline; non-image files keep the explicit unsupported reply.
  • Remote control (mobile / IM bots): unaffected.

Upgrade compatibility: new capability key is additive; a missing key resolves to unsupported on the controller. No persisted shapes change.

Verification

  • cargo test --locked -p openbitfun-product-domains --lib remote_surface::capabilities: 3 passed
  • cargo test --locked -p openbitfun-core --no-default-features --features remote-connect --lib service::filesystem::upload: 3 passed (incl. new attachment-URI guard)
  • pnpm --dir src/web-ui run test:run src/flow_chat/utils/externalFileIntake.test.ts src/flow_chat/utils/controllerFileTransfer.test.ts src/flow_chat/utils/imagePayload.test.ts src/infrastructure/peer-device/PeerConnectionManager.test.ts src/infrastructure/api/generated/remoteSurface.test.ts: all passed
  • pnpm --dir src/web-ui run test:run (full suite): 1229/1229 files passed, incl. new workspaceFileTransfer.peer.test.ts
  • npx tsc --noEmit (web-ui): clean; eslint on changed files: clean
  • pnpm run check:repo-hygiene: passed
  • pnpm run i18n:audit: passed, 0 warnings
  • pnpm run capabilities:check: verified
  • pnpm run fmt:rs

Not yet exercised end-to-end between two real devices; remote behavior above is covered by unit tests only.

Reviewer Notes

  • Peer-device README gains invariant 22 describing the controller-attachment contract.
  • Staged attachments are not garbage-collected yet; they live in the host runtime root per workspace.
  • Peer folder upload and peer MiniApp package import are deliberately refused rather than half-supported; both need a complete controller-side listing / byte transport to do correctly.

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

Peer Device, remote workspace and detached sessions rejected every file
dropped or pasted from the controller, and desktop drops only carry
paths, so dragged images failed the same way.

- Read controller files through the controller's own Tauri host (local
  provider marker), never through the rendered peer transport. The
  Linux clipboard fallbacks now read the controller clipboard too.
- Send supported images as inline image contexts, which every
  execution host already accepts.
- Stage other files with workspace_file_upload under
  openbitfun://runtime/<workspaceId>/attachments/<id>/, which agent
  tools on the host resolve. Gated by the new negotiated
  runtime_attachment_upload_v1 capability; older peers, folders and
  oversize files get an explicit message.
- The upload service creates the runtime-owned parent for attachment
  URIs, confined to the runtime root.
…aces

Follow-up for controller attachments in Peer Device Mode:

- Fix the ChatInputImageIntake source contract: the WebKitGTK paste
  fallback now reads the controller clipboard, not the rendered device.
- Move controller-local IO and the workspace_file_upload client into
  infrastructure/files/controllerFiles so the composer and Files panel
  share one implementation.
- Files panel drop and OS-clipboard paste in Peer Device Mode published
  controller paths to the peer (paste_files / SSH upload) and read the
  peer clipboard. They now upload controller bytes with
  workspace_file_upload, using local-paste "name (1)" naming and never
  replacing a file. Folders are refused explicitly because the
  controller explorer listing filters entries; a cut behaves as a copy.
- Report partial drop failures in the Files panel instead of dropping
  them silently.
- Refuse .bfminiapp imports from controller paths while a peer is
  rendered instead of sending the path to the peer.
- Give composer files without a session workspace their own message
  instead of the peer-update hint.
@bobleer
bobleer merged commit fcf05dd into openBitFun:main Nov 8, 2026
12 checks passed
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