fix(desktop): restore file.attach client upload path (Phase 2b companion to #142)#144
Merged
Merged
Conversation
Companion to PR #142 (backend handler + contract 2). The client half of dbbd1d4 was reverted by the same blocked-upstream-sync split-brain: on main the attachment-sync path only handled images (image.attach), so non-image @file: refs to a remote gateway resolved to a client-disk path the gateway couldn't see ("path outside the allowed workspace"). Restores the generalized attachment sync (use-prompt-actions.ts): - syncImageAttachmentsForSubmit -> syncAttachmentsForSubmit: images still use image.attach / image.attach_bytes; non-image files now use the file.attach RPC (upload bytes on remote, pass path locally). Adds readFileDataUrlForAttach + the image-bytes helpers that were also clobbered. - rewriteOptimistic refreshes the optimistic message after refs resolve. Merged against current main (not a blind take-theirs): kept the Phase 2b sender_device on prompt.submit; the "remote" test is `$connection.mode === 'remote' || activeBackendIsRemote()` so it fires for BOTH whole-app remote mode AND a Phase 2b dialed-endpoint session; rewriteOptimistic carries the same interrupted:false fresh-turn invariant as seedOptimistic. Fixes the 2 file.attach client tests (remote upload, local passthrough) and the interrupted-flag test. One pre-existing failure remains in this file (sleep/wake "session not found" resume-retry) — it fails identically on clean origin/main, is unrelated to attachments, and is filed separately. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🔎 Lint report:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Companion to #142 (backend
file.attachhandler + contract 2). The client half ofdbbd1d4d0was reverted by the same blocked-upstream-sync split-brain: on main the attachment-sync path only handled images, so a non-image@file:ref sent to a remote gateway resolved to a client-disk path the gateway can't see ("path outside the allowed workspace"). This restores the client upload path so remote sessions (the Phase 2b cross-device feature) can actually attach files.What changed
apps/desktop/src/app/session/hooks/use-prompt-actions.ts:syncImageAttachmentsForSubmit→syncAttachmentsForSubmit: images keepimage.attach/image.attach_bytes; non-image files now use thefile.attachRPC (upload bytes when remote, pass the path locally). RestoresreadFileDataUrlForAttach+ the image-bytes helpers that were also clobbered.rewriteOptimisticrefreshes the optimistic message after refs resolve.sender_deviceonprompt.submit; the remote check is$connection.get()?.mode === 'remote' || activeBackendIsRemote()so it fires for both whole-app remote mode AND a Phase 2b dialed-endpoint session;rewriteOptimisticcarries the sameinterrupted: falsefresh-turn invariant asseedOptimistic.How to review
syncAttachmentsForSubmit— the image branch is behavior-identical to before; the newfilebranch is the restored feature.remotecondition + therewriteOptimisticinterrupt reset (the two main-divergence merge points).Evidence
uploads file bytes via file.attach on a remote gatewayandpasses the path directly via file.attach in local modenow pass;clears a leftover interrupted flag on a fresh submitpasses.Verification
tsc -b0 errors.vitest use-prompt-actions.test.tsx— 15/16 pass. Fullvitest src— 469 passed / 7 failed; all 7 are pre-existing on cleanorigin/main(the 6 in untouched files + the 1 below).Risks / gaps
sleep/wake "session not found" resume-retry. It fails identically on cleanorigin/main, is unrelated to attachments (the resume-retry escape hatch returnsok:false), and is filed separately as a pre-existing-failure investigation (possibly another clobbered half of the upstream-sync split-brain).use-gateway-boottest failures persist on main (remote reconnect escape hatch) — pre-existing, flagged for a separate look (possible fallout from feat(desktop): attach to sessions on other devices — Live section + remote dial (Phase 2b/2) #139's prune keep-set); not touched here.F-003-multi-participant-channels.Collaborators