Repository navigation
fix(bots): send attachments only with their original message - #581
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 12, 2026 17:08
Extract attachment input assembly and capability validation from the harness runner. Apply the spacing rule to the changed attachment code and regression tests.
This was referenced Nov 12, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Describe default-on Web access and Files, per-conversation workspaces, bounded downloads and outgoing attachments before changing runtime behavior. The Polish design covers SSRF/DNS rebinding, path traversal and symlinks, disk exhaustion, cross-conversation exfiltration, owner scoping and gateway approvals. This is the bottom layer of the five-stage stack. Keep every layer draft until the complete implementation and verification are finished; do not merge individual layers. Validation: read architecture, bot/harness, worker and connector documentation and the existing #469/#581 attachment behavior. `bun install --frozen-lockfile`, `bun run format` and `git diff --check` passed. No runtime changes or local integration/browser tests in this layer. CI runs required checks. Copy audit §8: no UI copy changed.
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Bots can use Claude WebSearch/WebFetch, Codex native live web search and Grok web_search/web_fetch while local tools remain disabled. Add the owner-controlled, default-on webAccess setting to the existing JSON configuration, preserve explicit false across unrelated saves, and require worker capability bot_web_v1. No database migration is needed. Every adapter receives the resolved permission; changing it rebuilds the hidden session. Tool-free handoffs keep web access disabled. Add provider schema-capture coverage for both toggle states and gateway settings persistence coverage, using only local fixtures. Grok's MCP search_tool is not confused with native web search. Validation: on the authorized review host, gen:check, typecheck, lint, format:check and the web build passed. Official Claude, Codex and Grok CLIs captured their tool schemas against local inference fixtures: both Web access states passed for every provider (8 isolation tests). Gateway settings persistence (6 tests) and harness integration (24 tests) passed. No real provider APIs or external test URLs were called. CI is green for this layer. Copy audit §8: the new update-worker error names the missing capability and tells the user to update or choose another worker. No settings UI is added until the final layer; prompt text is model-facing. Related: #469, #581
nixuuu
added a commit
that referenced
this pull request
Nov 13, 2026
Bots can download public HTTP(S) files into their conversation workspace and send generated/downloaded files as ordinary Canopy attachments. download_file and send_attachment are gated by current Files permission, owner, worker, active turn and gateway approval policy. A new bot_outgoing_files_v1 capability prevents dispatch to older workers; protobuf extensions are additive and no migration is needed. Downloads block private/loopback/link-local/metadata/reserved addresses after DNS and on every redirect, pin the checked literal IP and preserve HTTPS hostname verification. Limits: 50 MiB, five redirects, 60 seconds total, 10 seconds idle; Content-Length and streamed bytes are checked separately. No credentials, cookies, inherited proxy, execution or unpacking. Files is the download permission, independent of native Web access. Outgoing transfers use bounded chunks and an immutable worker snapshot with SHA-256. Existing gateway attachment validation/storage, message, audit and durable tool result commit in the fenced/idempotent action. Replayed call IDs return the stored result; revoked Files and stopped/foreign turns cannot publish. Existing web/desktop/mobile APIs and attachment renderers provide download and supported previews. This repository has MCP connector accounts, but no automatic Telegram/Slack chat delivery adapters; external delivery needs its separately granted connector tool. Fourth draft layer of stack #598. Do not merge separately. Validation: authorized review-host checks passed: gen:check, typecheck, lint, format:check and web build. All download security tests passed (3 tests): SSRF private/reserved ranges, redirects, DNS pinning/rebinding, declared/streamed size, DNS/body timeouts and MIME. All gateway↔worker outgoing-file tests passed (6 tests): every provider, attachment retrieval, replay without duplicate delivery/audit, owner refusal through core/storage, completed turns, approval refusal, Files revocation and restarts. Local HTTP/inference fixtures only. The final UI layer was reviewed in one Chromium session at desktop/phone widths, light/dark, including actual Markdown/image previews and downloads. Copy audit §8: errors name public-URL, size, timeout or permission failures with a recovery action. Tool descriptions distinguish downloading from sending and Canopy delivery from connector delivery. Prompt states files/web boundaries, retention and limits. No new UI controls in this layer; final-layer visual verification passed. Related: #469, #581
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.
Change
A file sent once could be presented to the bot again when its hidden harness session was rebuilt. The gateway collected historical attachments into
historyAttachments, and the worker flattened them into the newest native user input. The generic “Canopy attached files” note did not distinguish the original message. This originated in #449; #469 extended the same path to other file types.Send file bytes only with their original message, for both resumed and rebuilt Claude, Codex and Grok sessions. Historical messages retain dated, forwardable references and explicitly say they are earlier attachments. The current message is supplied once, separately from history. Workers ignore the legacy historical binary field, and the session context key changes once to discard previously mixed attachment context.
The server already clears the sent draft revision atomically with message acceptance and attachment binding. A separate race in the shared web/desktop/mobile synchronizer allowed a draft read started before acknowledgement to restore the old client draft afterward. Ignore stale reads and reload the current revision after clearing. Newer device edits, failed-send drafts and idempotency remain preserved.
Connector accounts expose MCP tools; there is no automatic inbound Slack/thread-file ingestion path in this flow. Owner/conversation checks and attachment forwarding authorization remain in the gateway.
Verification
bun install --frozen-lockfile, targeted spacing autofix and formatting, fullbun run lint,git diff --check, and the Angular commit-message hook passed.check:tmprun passed: 44 tests, 371 assertions across bot composer, bot files, harness context, harness durability/restarts and worker attachment compatibility. No files remained in the temporary directory.Mobile is affected only through shared TypeScript. No native configuration, dependencies, assets, lockfiles or fingerprint inputs were changed; fingerprints were not recalculated locally. No UI markup or UI text changed; copy audit §8 is not applicable to the model-facing provenance notes. Polish bot docs describe the resulting behavior.
Fixes: #449
Related: #469