Repository navigation
Inbox: code files as attachments, and project_path on the plannotator_inbox tool - #1826
Merged
Merged
Conversation
…_inbox tool - Source code and scripts (the code-file set, CODE_FILE_REGEX, now also .mjs/.cjs/.mts/.cts) attach as kind "code": refused when the bytes are not UTF-8 text, shown read-only as one highlighted code block in the window and the phone surface; annotations on them are refused. - plannotator_inbox takes an optional project_path (the repository or folder a call is about). Connections resolve it against the working folder and refuse a path that is not an existing folder before the Inbox is reached (the mod, Pi and OpenCode).
…e .env family - codeDocumentBlocks highlights only up to CODE_HIGHLIGHT_MAX_CHARS (100,000): Shiki is one synchronous pass, which froze the window on a large file. Above it the block has no language (one plain text node). - inboxAttachmentNameRefusal refuses any .env.* name outside the annotatable doc set (.env.ts, .env.local.sh); .env.example stays. - The binary refusal reads "not UTF-8 text (binary or another encoding)".
backnotprop
force-pushed
the
fix/inbox-code-attachments-project-path
branch
from
October 10, 2026 22:21
596c06c to
27471e2
Compare
1 task
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.
Two fixes to obvious Inbox attachment problems. Out of scope, because each needs a decision: inline images, a lightbox, PDFs, a size cap, Show in Finder, and attaching any file type.
1. Code and script files as attachments (kind
code)recordInboxAttachmentsrefused every file outside annotate's annotatable set, so an agent could not attach the script it ran (.ts,.mjs,.sh,.py,.swift, ...).Accepted set. The set comes from the existing code-file list,
CODE_FILE_REGEXinpackages/core/code-file.ts. Annotate's code-file links already use it. I widened that list by.mjs,.cjs,.mtsand.cts([cm]?[jt]s|[jt]sx). As a side effect, markdown links to those files now count as code-file links in plan review and annotate too. The extensionless names come from the same list:Makefile,Dockerfile,Rakefile,Gemfile,Procfile,Vagrantfile,Brewfile,Justfile. A name that both sets know (.json,.yaml,.toml,.ini,.xml) keeps the kindtext.Refusals. Every existing refusal still applies:
.env, by the named path and by its target (aload.shsymlink to.envis refused). New: any other.env.name outside the annotatable doc set is refused too, so.env.tsand.env.local.shcannot slip in as code;.env.examplestays acceptedNew: a code file whose bytes are not UTF-8, or contain a NUL byte, is refused with
validation_error: attachments[i]: <name>: not UTF-8 text (binary or another encoding).. This check usesisInboxTextBytesin core and applies to code files only, so text, markdown and HTML attachments behave exactly as before.Rendering. A code file renders as one code block, highlighted by Plannotator's existing Shiki fence highlighting:
codeDocumentBlocksbuilds the block. It never uses the markdown pipeline, so a#comment in shell or Python does not become a heading.CODE_HIGHLIGHT_MAX_CHARS(100,000 characters). Shiki makes one synchronous pass over the file, and a large file froze the window (measured: 300 KB of JS took 4 s, a 1.6 MB minified bundle 163 s). A larger file renders as one plain text node.codeLanguageOfpicks the language: the file's extension, with a few names mapped (Makefile→make,.h→c, ...). A grammar Shiki does not know stays plain text.Read-only. You cannot comment on a code file. The text viewer's selection annotation does not work on a code block: the only option would be a whole-block comment, which would quote the entire file into the reply. So:
readOnlyto theViewer;SurfaceDocument) is read-only for code too;store.saveAnnotationrefuses an annotation on a code attachment with422 validation_error.Serving. Unchanged: by id only,
text/plain, CSPsandbox, nosniff. The sent-version blob and "changed since sent" work as for every other kind.Labels and agent docs.
send_messageattachments description lists source code and scripts.plannotator inbox --helpguide, the attachments line names example code files. Its test checks each one against the Inbox's own name rule and kind.iPhone contract.
adr/implementation/inbox-mobile.mddoes not list attachment kinds. It says only that "every attachment kind is text", which still holds.codeis an additive kind: the app (now in the Workspaces repo) should show any kind it does not know as text. I did not edit the contract doc.2. Optional
project_pathon theplannotator_inboxtoolEvery connection filled
project_pathwith the session's working folder and kept the field out of the schema. An agent working in a subfolder that is not a git repo (a meeting-notes folder, for example) therefore filed threads under that folder, and relative attachment paths resolved against it.Schema. The shared contract (
packages/shared/inbox/connection.ts) now offers an optionalproject_pathin the agent's schema, described as "The repository or folder this is about; defaults to your working folder." The other filled fields (agent_session,agent_host,agent_name) stay hidden. The mod's byte-for-byte copy (apps/hook/hooks/mod/inbox-contract.ts) is updated, andinbox-contract.test.tspasses.Shape check.
inboxToolCallrefuses a value that is not a string, is empty, contains a control character or line break, or is longer than 4096 characters. It returns a valid value asprojectPath;argumentsstill holds the working folder.Resolution. Each connection resolves the path against the working folder (an absolute path is used as given) to an existing folder's real path, then passes that path in place of the cwd:
inboxProjectDirinagent-link.ts.INBOX_PROJECT_DIR_SCRIPT, which runscdwithCDPATH=and./before a relative name, thenpwd -P.A path that is not an existing folder is refused before the Inbox is reached or started. Without
project_path, behavior is unchanged.Server side. The Inbox still resolves
project_pathto the git toplevel or the folder. Relative attachments now resolve against the folder the agent named, because the server already uses an absoluteproject_pathas the base.No new exposure. Any MCP client could already pass any
project_pathto/mcp.Version skew. None:
project_pathis an existing MCP argument on every Inbox that has the tool, so an older Inbox takes it as is. The tool list is part of the prompt prefix, so the new schema applies from the next session only, as documented.Docs. The help guide's line about filled fields now says an agent can pass
project_pathto override the working folder.Docs
AGENTS.md: the Inbox "Attachments and annotation" section (the code kind, the binary refusal, the read-only viewer), "Agent connections" (the optionalproject_path) and the mod's Inbox paragraph.apps/marketing/src/content/docs/reference/inbox.md: one line on file types, one line onproject_path.Tests
packages/core/inbox-attachments.test.ts(new): kinds, refusals, the label,isInboxTextBytes.code-file.test.tsadds.mjs,.cjs,.mtsand.cts.packages/shared/inbox/attachments.test.ts(new):.sh,.ts,.swift,.mjsandMakefileare recorded ascodewith their blobs. Binary content (ELF bytes, Latin-1 bytes) is refused and no blob is written..envis refused by name and through a symlink with a code name. A path outside the project is refused.packages/server/inbox-attachments.test.ts: a script is served withtext/plain,sandboxand nosniff, its view carries the text, and an annotation on it gets422. Binary content getsvalidation_errorover MCP.packages/inbox/codeAttachment.test.tsx(new DOM test, added to the DOM allowlist intest.yml): the pane renders onelanguage-shcode block with no heading and no toolstrip; the tile reads "Code (.sh)".packages/shared/inbox/connection.test.ts(new):project_pathis in the schema and optional while the other filled fields stay hidden; the working folder is still filled without it; malformed values are refused.packages/server/inbox-agent-project-path.test.ts(new): the Pi/OpenCode connection against a real in-process Inbox.project_pathfiles the thread under that project, and relative attachments resolve against it.apps/hook/hooks/mod/inbox.test.ts: the same pass-through and refusal through the mod against a real Inbox. After the refusal, the registry still names the dead Inbox, so nothing started it.apps/hook/tests/register.test.ts.Results:
bun run typecheck(includingapps/hook/hooks/mod/tsconfig.json): passes.bun test apps/hook/hooks/mod/: 157 pass.packages/server/inbox*,packages/shared/inbox,packages/core,apps/hook/server/inbox*: 493 pass.packages/ui,packages/inbox,packages/editor,packages/core: pass.apps/opencode-plugin/inbox.test.tsandapps/pi-extension/inbox.test.ts(real Pi, scripted model): 7 pass, 1 skip (the old-CLI floor test).DOM_TESTS=1.apps/hook/tests/register.test.ts(scripts/test-claude-code-mod.sh, which runsclaude plugin test). It would read the real~/.claude, and CI does not run it either.