Skip to content

feat(attachments): attachments go where the workspace lives (whole attachments plan; SUPER-3014, SUPER-2658, SUPER-2874) - #9064

Merged
harshithmullapudi merged 21 commits into
mainfrom
fix/super-3014-local-chat-attachments
Nov 2, 2026
Merged

harshithmullapudi merged 21 commits into
mainfrom
fix/super-3014-local-chat-attachments

Conversation

@harshithmullapudi

@harshithmullapudi harshithmullapudi commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

This PR now carries the whole attachments plan

Attachments: durable for cloud sessions, local for local ones (v18). The plan's separate PRs are folded in here and closed. The checklist is in the tracking page.

Was What Commit here
#8704 + #8712 Send through storage, body buffering, scoped resolve + resolveEach, reap files with the box (seam 6) already in this branch
#8846 Host store: lastUsedAt, daily sweep, fileId index, fileId on first-prompt parts, limits in shared (seams 2, 3, 8) 9c81d7e
#8849 Claude image blocks, Codex localImage, one resolver (cache or import by fileId), name+path block, parts floor (seam 4) f68cfaa, d091944, 233498e
#8851 Desktop: parts by workspace, version gate, thumbnails from storage or host, terminal paste on the same switch, caps (seams 1, 3, 5, 7) cef20a0, 5a646e8
#8852 Mobile: cloud parts by fileId, host branch, cloud rendering, path tags as cards f32821b
#8854 Docs: a box's host-service is as new as its last boot cb1e6f2
— Fold-in fixes (floor, Files tab, leftovers, translations) 635f21d
— Merge of main (#9246, agents.ts imports) 4444ea9

Decisions made while folding in (please check)

  • Large files in a local workspace. The plan refuses anything over 25 MB in a host workspace. This PR's SUPER-3014 fix copies local files with no cap. Both are kept: a chat file up to MAX_INLINE_ATTACHMENT_BYTES (25 MB) becomes an attachment part, and a bigger local file goes through attachments.writeIntoWorktree as a path tag, so the 451 MB .dmg still works. A relay-reached host refuses files over 25 MB, as the plan says.
  • Routes: same machine → desktop main copies the files. Remote → base64 attachments.upload for parts, and base64 filesystem.writeFile into .paradev/attachments for paths; no storage. Cloud → storage, then fileId parts or materializeIntoWorkspace for paths.
  • ATTACHMENT_PARTS_MIN_HOST_VERSION = "2.0.4". 2.0.0–2.0.3 shipped without the new adapters. If this PR doesn't ship in 2.0.4, raise it before release. A local host is this build, so it always gets parts.
  • Files tab cap (25 MB) applies only to a workspace on another machine. Local drops keep no cap.
  • The parser moved to @superset/chat/core (shared by desktop and mobile) and keeps this PR's name="…" and both .paradev/.superset prefixes.

Checks on 4444ea9

  • typecheck passes in shared, chat, chat-runtime, chat-ui, host-service, trpc, cli and desktop.
  • mobile typecheck has 187 errors, all in the existing baseline. None are in the files this PR changes.
  • bun test:
    • shared 1537, chat 108, chat-runtime 440, chat-ui 75, trpc 835, i18n 169, mobile 256, desktop 9079: all pass.
    • host-service: 2710 pass, 23 fail. The same 23 fail on ae52b5f402 without these commits:
      • 22 background-naming session tests: "path traversal detected". They pass alone and depend on test order.
      • the environmental health.check sandbox test.
  • check:i18n: nothing missing in 17 locales (Ukrainian added). Biome is clean on the changed files.

Not verified / not in this PR

  • Not run in the app or on a simulator after folding in. The plan's manual matrix is still owed: local, relay-reached and cloud workspaces with Claude and Codex, desktop ↔ mobile images, and a recreated box.
  • Plan items with no code yet:
    • the durable event-log integration (waits for the store);
    • web and shared views rendering cloud parts;
    • the CLI's cloud branch (still base64 through the gate);
    • mobile's home-screen new chat (uploads to storage when you attach);
    • Sentry from the clients;
    • part images in the desktop gallery overlay.
  • resolvable.integration.ts is a manual DB test, not run in CI.

What & why

Fixes SUPER-3014. Attaching a 451MB .dmg in a local workspace failed with "files over 50MB can't be sent to a remote workspace".

This PR includes #8704 (SUPER-2658, merged in as 913077170c). #8704 sends desktop attachments through storage (createUpload → presigned PUT to R2 → attachFiles for cloud → materializeIntoWorkspace), which fixes the cloud-box ingress race. As written, it also sent local workspaces' attachments through our storage, and it refused files over 200MB.

On top of #8704:

  • A local workspace never uses storage. When useWorkspaceHostTarget says the workspace is on this machine (local or local-starting), the new Electron main route attachments.writeIntoWorktree writes every file into .superset/attachments:
    • A file with a disk path (drag, picker, Finder copy) is copied with COPYFILE_EXCL. There is no size cap, and the file never passes through renderer memory.
    • A clipboard blob (a pasted screenshot) is sent as base64 over IPC and written with wx. It is capped at MAX_ATTACHMENT_BYTES.
    • Collisions get _N suffixes, so the route never overwrites a file.
  • A host target that is still resolving refuses the send ("Workspace is not ready") instead of falling through to storage.
  • Remote and cloud workspaces keep fix(desktop,host-service): send attachments through storage, not host-service bodies #8704's storage route unchanged.
  • Review fixes:
    • The route validates every item before it writes anything, refuses UNC paths (an SMB/NTLM leak on Windows), and caps the base64 body.
    • A path-count mismatch from the host or the route now throws instead of pairing a file with "".
    • ensureWorkspaceAttachmentsDir moves to @superset/shared/workspace-attachments-dir, so the desktop and host-service share one .gitignore rule.
  • Merge conflict: cloud-workspace/reap.ts / reap.test.ts keep main's archive hook and fix(desktop,host-service): send attachments through storage, not host-service bodies #8704's detachAll + reapOrphanFiles.

After this, the only client that still sends a host workspace's files through storage is mobile (on main as well). The phone is never the host.

Against the attachments plan

The attachments plan:

  • Goal 2: "local images stay off our servers". This PR meets it for every desktop surface.
  • Seam 2: "a same-machine path import to get a local file past the inline cap" was dropped. This PR goes against that decision.

Attachment names and cards (f745e33547)

Problem: sent messages showed the sanitized disk name in a plain badge, e.g. Superset-arm64__21__1.dmg.

What changed:

  • The <attachment> tag now has an optional, escaped name="…" with the name the user attached. It is written only when that name differs from the disk name.
  • Every reader goes through attachmentDisplayName: the message row, the image fallback, the gallery and the queued-prompt label. Tags written before this fall back to the disk name.
  • Files render as the composer's card (icon, name, type). It is extracted into @superset/chat-ui/AttachmentFileCard and shared with AttachmentPills.
  • The name line drops the extension, because the type line shows it. Transcript cards size to the name (160–288px), so the message above reads Superset-arm64 (21) · DMG.

Compatibility: a desktop build without this change does not match a tag that has name=, so it shows such a message's tag as raw text. That is cosmetic only, because the agent reads the tag text either way.

Checked in the dev app:

  • Sent Superset-arm64 (21).dmg and meeting notes (final).txt. The cards read "Superset-arm64 (21)" / DMG and "meeting notes (final)" / TXT, with the full name on hover.
  • Older messages show their disk names.
  • The composer pill is unchanged apart from the extension moving to its type line.

Tests: desktop bun test 8872 pass. chat-ui tests and tsc pass. check:i18n leaves the catalogs unchanged.

Failed sends keep your files and say why (30bf515d86)

Problem: a failed chat send put the text back but dropped every attached file. A moved file showed a raw toast: ENOENT: no such file or directory, stat '…'.

What changed:

  • attachments.writeIntoWorktree now returns { ok: false, index, problem } when a source file is missing, a folder (not-a-file) or unreadable. It checks readability by opening the file, because macOS privacy denials (EPERM) only show up at open. It writes nothing in that case. A bad worktree and UNC paths still throw.
  • sendAttachmentsToWorkspace turns that result into an AttachmentSourceError.
  • The composer shows a translated message that names the file:
    • "vanishing.txt" was moved or deleted. Attach it again.
    • "My Folder" is a folder. Attach the files inside it instead.
    • Paradev doesn't have permission to read "locked.txt".
  • The composer re-adds every file except the bad one. Limit errors keep all files, so the user can remove some.
  • Translations are written for all 16 locales. check:i18n reports nothing missing.

Checked in the dev app:

  • Attached keep me.txt and vanishing.txt, deleted the second from disk, then sent. The friendly toast appeared, and the text and keep me.txt came back. Pressing Enter again sent it with no toast and no storage requests.
  • A folder and a chmod 000 file showed their messages.

Tests: route tests for each problem (nothing written), and a sendAttachmentsToWorkspace test for the error's index, name and problem. Desktop bun test 8874 pass.

How I tested it

End to end in the dev app. This was the cloud sandbox's dev stack, with the desktop restarted with RENDERER_REMOTE_DEBUG_PORT and driven over CDP.

  • Setup: created a project and a local workspace on "This device". Turned the acp-chat flag on through the renderer's PostHog client, as a setup override.
  • Journey: opened Chat and attached through the composer's real file input (DOM.setFileInputFiles):
    • a 451MB Superset-arm64 (21).dmg, the file from the report;
    • notes.txt;
    • a PNG pasted from the system clipboard with Ctrl+V.
  • Result: typed a message and pressed send.
    • No "Couldn't attach files" toast appeared, and the message rendered with the image thumbnail and both file badges.
    • A fetch recorder in the renderer saw zero createUpload / attachFiles / materializeIntoWorkspace / R2 requests.
    • The worktree's .superset/attachments holds Superset-arm64__21_.dmg and notes.txt, both byte-identical to the sources (cmp), plus image.png (64×64 PNG) and .gitignore (*). git status in the worktree is clean.
    • Claude then answered "Authentication required", because the sandbox has no Claude login. That happens after the attachments were written.

Not checked in the app:

  • The before state. I didn't run main's build to reproduce the toast.
  • Remote and cloud workspaces. The dev stack has none, so their storage route is covered by unit tests only.
  • Terminal rich input in a local workspace. It uses the same hook, but I didn't drive it.

Automated:

  • Desktop bun test: 8871 pass, 0 fail. It covers the new route tests (order, never overwrite, refuse a directory or UNC source before writing) and the new sendAttachmentsToWorkspace cases (same-machine send never touches storage and keeps the order of path, blob, path; blob cap; path-count mismatch throws).
  • packages/trpc (752 pass) and the host-service attachment + chat-v3 suites pass.
  • tsc passes in desktop, host-service and shared. Biome, check:i18n and sherif are clean.

Merge with main (71b7e89028, ae52b5f402)

71b7e89028 merges main at 9fca85d810. ae52b5f402 merges 7d6ec2de2f (#9265), with no conflicts, and formats attachmentTags.ts.

Conflicts and how they were resolved:

  • Composer.tsx: main's send path is kept (restoreDraft / prependToDraft, the hidden chatContext part, link chips). When a send fails, the composer restores the draft with only the attachments that useUploadAttachments keeps. The bad file is dropped, the other files stay, and the AttachmentSourceError message shows.
  • attachmentTags.test.ts: main's legacyPastedMessage helper and its .paradev + .superset reader test are kept, together with this PR's name= / attachmentDisplayName test. attachmentTags.ts merged cleanly: it reads both dirs and keeps the escaped name.
  • uploadPastedFiles.ts (modify/delete): it stays deleted, and nothing imports it.
  • TerminalPane.tsx: this PR's AttachmentLimitError import, plus main's LinkActionMenu.
  • chat-ui AttachmentPills.tsx: main's RevealButton and group/pill, rendered with this PR's shared AttachmentFileCard.
  • host-service chat-v3/agentImages.ts and trpc/router/attachments/attachments.ts: these use the shared ensureWorkspaceAttachmentsDir instead of main's local attachmentsDir.
  • i18n: the catalogs come from main and were regenerated. This PR's three attachment-error translations were copied back for every locale. Main added uk, so I wrote Ukrainian translations for those three strings.

.paradev change: ensureWorkspaceAttachmentsDir now writes WORKSPACE_ATTACHMENTS_GITIGNORE. The Electron route attachments.writeIntoWorktree and host materializeIntoWorkspace already build paths from WORKSPACE_ATTACHMENTS_DIR, so they now write to .paradev/attachments. The sendAttachmentsToWorkspace test fixtures now use .paradev/attachments. Readers still accept .superset/attachments. A grep of this PR's diff against main finds no new .superset/attachments. The only "*\n" left is a test assertion on the .gitignore content, the same as main's agentImages.test.ts.

Checks run on ae52b5f402:

  • bun run typecheck: desktop, host-service, shared, trpc and chat-ui all pass.
  • bun test:
    • desktop: 9074 pass, 0 fail.
    • trpc: 835 pass, 0 fail.
    • chat-ui: 75 pass, 0 fail.
    • host-service: 2714 pass, 2 fail. health.check … sandbox mode is environmental on a cloud box. pullRequests.mergePR > a failed refresh still reports the merge as done failed once in the full run (called 2 times, expected 1). It passed 3 of 3 times on its own, and this PR does not change that directory.
  • bunx biome check on the changed files: clean.
  • bun run check:i18n: 0 missing in all 17 locales.

Not checked: I did not run the app after the merge. The new failed-send path through restoreDraft is covered by typecheck only. No test drives it, and I did not use it in the app.

Summary by CodeRabbit

  • New Features

    • Upload files and clipboard attachments to local, remote, and cloud workspaces. Attachments are added to the workspace and referenced by workspace-relative paths.
    • Terminal paste and file-drop uploads now use the same attachment flow.
    • File attachments display clearer cards with filenames and file-type icons, and attachment names are preserved in chat.
  • Bug Fixes

    • Improved handling of streamed requests so upload bodies are preserved.
    • Improved feedback when attachment count or file-size limits are exceeded, or when a selected file is missing, is a folder, or cannot be read.

saddlepaddle and others added 4 commits October 20, 2026 23:44
…-service bodies (SUPER-2658)

Pasting or dropping an image into a cloud workspace failed with "Failed to
send the file to the remote workspace" (terminal) or "Couldn't attach files /
value$1 is not iterable" (chat). The desktop was shipping the bytes as a
base64 `filesystem.writeFile` body over the streaming tRPC link. tRPC answers a
streamed batch before it has read the request body, and a Vercel sandbox's
ingress treats that early response as the end of the exchange and drops the
upload still in flight — a race, not a size limit: a 500 KB body on a home
uplink loses it about half the time.

Desktop: the chat composer, the terminal rich input, and the terminal
paste/drop override now take the route every other composer already takes
(mobile, the new-workspace modal): `attachment.createUpload`, a presigned PUT
to storage, `cloudWorkspace.attachFiles` for a box, then
`attachments.materializeIntoWorkspace` on the host. The host-service request
carries ids, never bytes. `uploadPastedFiles` is replaced by
`sendAttachmentsToWorkspace` + `useSendAttachments`.

host-service: `/trpc/*` buffers the request body before handing it to tRPC so
no response can start before the request is complete; the integration test
fails without it. `materializeIntoWorkspace` and the chat image writer share
one helper that creates `.superset/attachments` with its `.gitignore`, which
the former never wrote.
…ap files with the box

First API step of the attachment plan (SUPER-2874, seam 6).

- attachment.resolve no longer signs a URL for any composer upload in the
  org. A kept (ready) file resolves only through a cloud workspace the
  caller can see. An upload still in flight (pending) stays org-wide: a
  host resolves with its owner's credential, and the sender can be a
  teammate on that host. A box still sees only its own workspace's files.
- New attachment.resolveEach returns one entry per id, with
  { fileId, missing: true } for a file that is gone or not visible, so a
  transcript can render the rest. resolve keeps its output and errors for
  released hosts.
- The archive's final reap stage (and the fallback when it cannot be
  queued) detaches and deletes the files anchored to the workspace.
The #8712 commit folded into this branch was based on a newer main that had
changed cloud-workspace.ts's imports. Keep both: listPullRequests from main,
and reapWorkspaceFiles from #8712.
…upload limits

The chat composer always shipped attachments as base64 through
filesystem.writeFile, with the 50MB/200MB caps meant for remote
workspaces. In a local workspace a disk-backed file is now copied into
.superset/attachments by the Electron main process, so no size cap
applies and the bytes never pass through renderer memory. Clipboard
blobs and remote workspaces keep the upload path and its limits.

Fixes SUPER-3014
@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

The pull request adds shared attachment sending for local and remote workspaces, updates attachment resolution and cloud-workspace cleanup, centralizes attachment-directory setup, preserves attachment display names, and buffers streamed tRPC request bodies in host-service.

Changes: Workspace attachment transfer

Layer / File(s) Summary
Local attachment API
apps/desktop/src/lib/trpc/routers/attachments/*, packages/shared/src/workspace-attachments-dir.ts, packages/host-service/src/...
The desktop router validates and writes attachments. Shared directory setup creates the attachment directory and .gitignore when needed.
Upload and materialization orchestration
apps/desktop/src/renderer/.../useSendAttachments/*, apps/desktop/src/renderer/.../sendAttachmentsToWorkspace/*
The sender writes same-machine files locally and uploads, attaches, and materializes files for remote routes. Tests cover limits, ordering, naming, failures, and returned paths.
Upload callers and attachment display
apps/desktop/src/renderer/.../TerminalPane/*, apps/desktop/src/renderer/.../ChatSession/*, packages/chat-ui/src/components/*, packages/i18n/locales/*, docs/cloud-sandbox-mismatches.md
Composer and terminal callers use the shared sender. Attachment tags preserve optional names. Transcript and prompt-input views use AttachmentFileCard. The old pasted-file utility is removed, and locale catalogs add attachment error messages.

Attachment resolution and cleanup

Layer / File(s) Summary
Resolvable attachment scope
packages/trpc/src/router/attachment/resolvable.*
resolvableFiles filters files by organization, transfer marker, workspace attachment, and caller visibility. Integration tests cover these cases.
Attachment resolve endpoints
packages/trpc/src/router/attachment/attachment.ts
resolve uses shared lookup and validates stored object size before signing. resolveEach returns an ordered result for each requested ID.
Workspace file cleanup
packages/trpc/src/router/cloud-workspace/*
Cloud-workspace deletion detaches associated files and passes them to orphan-file reaping. Tests cover cleanup and skipped cases.

Streamed tRPC request buffering

Layer / File(s) Summary
Buffer streamed request bodies
packages/host-service/src/app.ts, packages/host-service/test/integration/trpc-request-body.integration.test.ts, docs/cloud-sandbox-mismatches.md
Host-service buffers unread /trpc/* request bodies before downstream handling. The integration test checks the response after the streamed body closes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant UploadCaller
  participant useSendAttachments
  participant sendAttachmentsToWorkspace
  participant AttachmentRouter
  participant ObjectStorage
  participant HostService
  UploadCaller->>useSendAttachments: Send files
  useSendAttachments->>sendAttachmentsToWorkspace: Select route
  sendAttachmentsToWorkspace->>AttachmentRouter: Create upload target
  sendAttachmentsToWorkspace->>ObjectStorage: Upload file data
  sendAttachmentsToWorkspace->>AttachmentRouter: Attach cloud files
  sendAttachmentsToWorkspace->>HostService: Materialize workspace paths
Loading

Suggested reviewers: saddlepaddle

Merge Risk: Moderate · up to 30bf5

Resolve the request-buffering, workspace-file cleanup, and older-host attachment failures before merging. The directory, callback, and test issues also remain actionable.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 27.03% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly identifies the main attachment-routing change, although the parenthetical plan and issue list add unnecessary length.
Description check Passed The description provides detailed What & why and How I tested it sections, including scope, implementation details, automated checks, and known gaps. It does not include the template's explicit Checkl…
Full details: Description check

Explanation

The description provides detailed What & why and How I tested it sections, including scope, implementation details, automated checks, and known gaps. It does not include the template's explicit Checklist section, but the required information is mostly complete.

Full details: Docstring Coverage

Explanation

Docstring coverage is 27.03% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 37 functions across 35 files. (17 skipped: 17 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change reaches chat attachment handling in desktop workspaces.

The PR appears safe to merge, with a non-blocking improvement needed to make the copy route’s destination restriction complete.

Findings

  1. P2 Security Symlinks redirect attachment copies ▶
Fix with agent prompt
### Issue 1
apps/desktop/src/lib/trpc/routers/attachments/attachments.ts:12-18
`isWorkspaceAttachmentDestination` checks directory names, not where they point. If `.superset/attachments` is a symlink to another directory, this check passes and `copyFile` creates the attachment there. `COPYFILE_EXCL` prevents overwriting but does not prevent this redirection.

The composer checks the directory earlier, but this new main-process route does not enforce its own stated restriction. Check the real destination directory before copying and add a symlink test.

**How this was verified:** The route checks only path names before passing the unchanged destination to `copyFile`, which follows directory symlinks.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Local chat attachments with a disk path now use an Electron file copy instead of a base64 upload.

  • Disk-backed chat attachments copy directly into local workspaces.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Chat attachment] --> B{Local workspace and disk path?}
  B -->|Yes| C[Electron copy with COPYFILE_EXCL]
  B -->|No| D[Check upload limits]
  D --> E[Read and upload base64]
  C --> F{Filename exists?}
  E --> F
  F -->|Yes| G[Try a numbered filename]
  G --> B
  F -->|No| H[Return relative attachment path]
Loading

Reviews (1) · Last reviewed commit: "fix(desktop): copy local chat attachment..." · Reviewed by Greptile

Comment on lines +12 to +18
export function isWorkspaceAttachmentDestination(path: string): boolean {
const directory = dirname(path);
return (
isAbsolute(path) &&
basename(directory) === ATTACHMENTS_DIR_NAME &&
basename(dirname(directory)) === ATTACHMENTS_PARENT_NAME
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security Symlinks redirect attachment copies

isWorkspaceAttachmentDestination checks directory names, not where they point. If .superset/attachments is a symlink to another directory, this check passes and copyFile creates the attachment there. COPYFILE_EXCL prevents overwriting but does not prevent this redirection.

The composer checks the directory earlier, but this new main-process route does not enforce its own stated restriction. Check the real destination directory before copying and add a symlink test.

How this was verified: The route checks only path names before passing the unchanged destination to copyFile, which follows directory symlinks.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/lib/trpc/routers/attachments/attachments.ts
Line: 12-18

Comment:
**Symlinks redirect attachment copies**

`isWorkspaceAttachmentDestination` checks directory names, not where they point. If `.superset/attachments` is a symlink to another directory, this check passes and `copyFile` creates the attachment there. `COPYFILE_EXCL` prevents overwriting but does not prevent this redirection.

The composer checks the directory earlier, but this new main-process route does not enforce its own stated restriction. Check the real destination directory before copying and add a symlink test.

**How this was verified:** The route checks only path names before passing the unchanged destination to `copyFile`, which follows directory symlinks.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

Resolve reap.ts/reap.test.ts against main's archive hook. Port the local
copy onto sendAttachmentsToWorkspace: in a local workspace a file with a
disk path is copied into the worktree by the main process and never goes
to storage; everything else takes #8704's storage route.
@expo

expo Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Preview update published for development build eca66a32 (fingerprint e65ce637d4ee). Open the build on your phone and scan:

Update group 8717235a

harshithmullapudi and others added 10 commits November 2, 2026 20:03
…fileId on cloud copies

Part of the attachments plan (PR 3: seams 8, 2, and the fileId carry-through
of seam 3).

The host's attachment store had no retention. Nothing deletes chat.db rows
and a terminal launch has no session, so there is no session delete to hook.
Instead, metadata.json records lastUsedAt. Upload and import set it, and every
path that hands an attachment out sets it again: read, agents.run's attached
files block, and the ACP resolver. A daily sweep (not in sandboxes) removes
entries unused for ATTACHMENT_RETENTION_DAYS. An entry written before this
change is stamped, not removed. The check and the rename that takes the
entry out of the store run in the same tick, so a hand-out on this event loop
cannot land between them. The slow delete runs async, off the loop.

A box's cached copy now keeps the fileId it was imported from, in its
metadata and in a small .by-file-id index, so the adapters (next PR) can find
a cloud part's cached copy without a scan. The first prompt of a cloud launch
spreads that metadata into its parts. Without fileId, the first attachments
of a cloud session would be the one kind a reader without the box cannot
render.

MAX_INLINE_ATTACHMENT_BYTES moves to @superset/shared/attachment-limits with
MAX_THUMBNAIL_BYTES and ATTACHMENT_RETENTION_DAYS. The host and the shared
launch schema use MAX_ATTACHMENTS for their max(10).
…tachments

Part of the attachments plan (PR 4, seam 4).

The Claude SDK adapter rendered an attachment part as `[name]`, and the Codex
adapter dropped it with a notice. Only ACP resolved it. This is why desktop
chat still flattens attachments into path tags in the text.

Now all three take one resolver from the host (chat-v3/resolveAttachment.ts).
It branches on the identity the part carries. `fileId` is a cloud workspace's
storage object: served from the box's cached copy, or imported now when the
store is empty, as on a recreated box. `attachmentId` is the host store entry
itself. Each hand-out stamps lastUsedAt for the sweep. Bytes are read only for
images, since every adapter gives other files by path.

- Claude: an image goes as a base64 image block in the SDK's content-array
  form. Any other file goes as a "# Attached files" line with its name and
  path, because store files are named by id.
- Codex: an image goes as app-server's `localImage` by path. Any other file
  goes as the same text block.
- An unreadable file is named to the agent, not dropped silently.
- Resolution is chained per adapter, so prompt order holds. A text-only prompt
  with nothing queued is still pushed synchronously.

The protocol's attachment part now needs `attachmentId` or `fileId` (it
needed `attachmentId` before), so a client can send a cloud part by fileId
alone. Clients send parts only to hosts at or above
ATTACHMENT_PARTS_MIN_HOST_VERSION (1.41.0, the first release with this
change). agents.run's attached files block uses the same attachedFilesBlock,
so terminal launches also list files by name.

A failed resolve reports to Sentry. The host has no PostHog client, so the
plan's PostHog event is not sent from here.
… attachments

An attachment-only message can carry an empty text part, and the Anthropic
API rejects an empty text content block.
…floor

Desktop and mobile both decide between attachment parts and path tags from
a host's version. One function next to ATTACHMENT_PARTS_MIN_HOST_VERSION keeps
the two clients on the same rule. It coerces the version, so a canary or a
dev build of a release at or above the floor counts.
Part of the attachments plan (desktop PR: seams 1, 3, 5, 7).

Since #8704, every desktop attachment went through our storage, including
attachments for a workspace on a machine someone owns. Chat flattened them
into <attachment path> tags because two of three adapters dropped parts.
Mobile showed those tags as raw text, and desktop showed a mobile image as a
name badge.

Send (seam 1): sendAttachments picks the transfer from where the workspace
lives. A box: createUpload, presigned PUT, attachFiles; the part carries only
fileId, so it renders without the box. A host (local or relay-reached): base64
attachments.upload; the part carries only attachmentId, and the bytes never
reach our servers. A host workspace refuses a file over
MAX_INLINE_ATTACHMENT_BYTES, before anything is sent.

Composer (seam 3): sends attachment parts when the host's adapters read them.
A local host is this build. A remote host or box must report
hostReadsAttachmentParts (ATTACHMENT_PARTS_MIN_HOST_VERSION). Below the floor
it sends path tags, as before. An attachment-only message leaves out the empty
text part.

Render (seam 5): UserMessageRow renders image parts through
useAttachmentSource. A cloud part resolves through attachment.resolveEach
(batched per render) and storage; a host part through attachments.read. The
row for a message just sent is primed with the File it attached, so it does a
read of neither.

Paths (seam 7): sendAttachmentsToWorkspace, which terminal paste and drop and
the below-floor composer use, now writes base64 into the worktree for a host,
as before #8704. A box keeps storage and materialize. The Files tab and design
mode refuse a file over the inline cap before the write.
…pace lives

The clipboard paragraph described #8704's routing, which sent every non-local
host's paste through storage. A box still goes through storage; a
relay-reached machine gets base64 filesystem.writeFile again.
…parts and path tags

Part of the attachments plan (mobile PR).

Mobile uploaded every attachment to our storage when it was attached, and
then had the host import it. That also happened for a workspace on a machine
someone owns, whose bytes should never reach our servers. Mobile also showed a
desktop path tag as raw text.

- A host workspace's draft no longer uploads at attach time. At send, chat
  attachments go to the host as base64 attachments.upload (the part names
  attachmentId). Terminal attachments are written into the worktree with
  create-only base64 filesystem.writeFile. Both refuse a file over
  MAX_INLINE_ATTACHMENT_BYTES.
- A cloud chat part carries its fileId and skips importFromCloud when the box
  reads parts (hostReadsAttachmentParts). An older box still gets the copy it
  imports.
- useAttachmentFile reads a fileId part from storage (resolveEach, then a
  download into the cache), so it shows without the box. A host part still
  reads from the host.
- Path tags in a message show as file cards. parseAttachmentTags moved from
  desktop into @superset/chat/core so both clients parse them the same way.
- A send that finds an attachment that never started uploading (its draft's
  home was unknown when it was attached) starts it.
The doc assumed deployed boxes never update their host-service. They do: a
bundle release repins every live environment, every wake builds the claim from
it, and superset-boot installs the pin when its hash differs. Only a box that
never boots again keeps an old bundle. Features gate on the version a box
reports, like a remote host.
- ATTACHMENT_PARTS_MIN_HOST_VERSION is 2.0.4. 2.0.0 to 2.0.3 shipped
  without the adapters that read attachment parts, so the old 1.41.0 floor
  let those hosts receive parts they would drop.
- The Files tab caps a drop at MAX_INLINE_ATTACHMENT_BYTES only for a
  workspace on another machine. A local drop keeps no cap, as before.
- The cloud workspace attachment inputs in packages/trpc and desktop's
  thumbnail limit come from @superset/shared/attachment-limits. The values
  are the same.
- The clipboard paragraph in cloud-sandbox-mismatches covers the
  same-machine route.
- Translations for the new messages, including the Ukrainian catalog that
  main added.
…ts-9064

# Conflicts:
#	packages/host-service/src/trpc/router/agents/agents.ts
@harshithmullapudi harshithmullapudi changed the title fix(desktop): keep local-workspace attachments on the machine, with no upload cap (includes #8704) feat(attachments): attachments go where the workspace lives (whole attachments plan; SUPER-3014, SUPER-2658, SUPER-2874) Nov 2, 2026
@harshithmullapudi
harshithmullapudi merged commit 0cb6cbe into main Nov 2, 2026
24 checks passed
harshithmullapudi added a commit that referenced this pull request Nov 13, 2026
…ser (SUPER-3442)

Adding an attachment seeded an upload entry at 0% for every draft. Since
#9064, a draft for a workspace on a machine someone owns starts no upload at
attach time: its bytes go to the host at send. Nothing ever settled the
seeded entry, so the composer drew a 0% ring and kept Send disabled
("Uploading") for any photo, on any network, at any size.

Only beginUpload now creates an entry, and only for an attachment the draft
holds. A host draft has no entries, so its tray shows no ring and sends.

PostHog, mobile build 140, last 14 days: 312 of 387 attachments added were
removed again (about 4% on builds 113 and 137), and every attachments_sent
had home=cloud. No host-workspace attachment send succeeded.
harshithmullapudi added a commit that referenced this pull request Nov 13, 2026
…ser (SUPER-3442) (#9675)

Adding an attachment seeded an upload entry at 0% for every draft. Since
#9064, a draft for a workspace on a machine someone owns starts no upload at
attach time: its bytes go to the host at send. Nothing ever settled the
seeded entry, so the composer drew a 0% ring and kept Send disabled
("Uploading") for any photo, on any network, at any size.

Only beginUpload now creates an entry, and only for an attachment the draft
holds. A host draft has no entries, so its tray shows no ring and sends.

PostHog, mobile build 140, last 14 days: 312 of 387 attachments added were
removed again (about 4% on builds 113 and 137), and every attachments_sent
had home=cloud. No host-workspace attachment send succeeded.

Co-authored-by: Harshith Mullapudi <17528887+harshithmullapudi@users.noreply.github.com>

This branch was previously deployed

1 inactive deployment
preview — 4444ea92 Deployed Nov 2, 2026 by harshithmullapudi via Deploy Marketing #13600
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.

2 participants