Repository navigation
feat(web): open, edit and save files an agent names - #514
Merged
Merged
Conversation
M-Zajace
force-pushed
the
feat/file-access
branch
from
November 10, 2026 16:39
bf16b88 to
acd903a
Compare
M-Zajace
force-pushed
the
feat/file-viewer
branch
from
November 10, 2026 16:39
fa5d08c to
aaad37a
Compare
File paths in an agent's messages (inline code and Markdown links) are buttons in a thread. By default they open Canopy's file viewer: Markdown rendered or as source, other files highlighted by extension, editing in CodeMirror 6 (loaded on first edit, colours from the theme's code tokens) with an unsaved-changes badge, Mod+S, a conflict when the file changed on disk, Delete and Open in default app. The device setting "Open files in" can open them straight in the worker computer's default app instead.
The file viewer shows line numbers in a column that is never selected. Mod+A in the viewer selects only the focused file content and nothing outside it, and closing the viewer clears the selection, so the page behind it is never left selected.
"Open in default app" and the "Default app" setting asked the thread's worker to open the file, so a linked computer's file opened over there. They now apply only to files on this computer (onThisComputer); other files open in the viewer, and linked computers no longer receive OpenThreadFile.
M-Zajace
force-pushed
the
feat/file-viewer
branch
from
November 10, 2026 16:56
aaad37a to
2bffdf0
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 12, 2026
Clicking a bare name such as `violet-bg.jpg` previously tried only the thread's root and reported a missing file as deleted. Binary bytes were discarded, so images could not load even with a connected home computer. This change resolves references on the thread's home worker, including a separate worktree, and previews text and images on web and mobile. ## Behavior - Prefer explicit paths mentioned in the source item's turn, then a direct root file, then an exact basename match from a bounded, gitignore-aware listing. A unique result opens; multiple matches offer a path picker. An incomplete search never silently chooses a result. - Keep reads on the existing computer-link stream with 32 KiB frames and flow control. Preview bytes are capped at 2 MiB; oversized files have no mutation hash. Offline/transport errors remain connection errors. The gateway checks thread ownership before dispatch; workspace traversal and escaping symlinks are rejected. - Show raster images with dimensions and size. Hide binary Edit, show a relative path and home computer below the filename, and use lookup/error states in place of empty content boxes. Reload, edit and delete use the resolved path and SHA-256 conflict protection. - Mobile uses the same recognition, resolution and RPCs with existing native UI components. It supports path choices, image/text/Markdown previews, reload, copy, text editing and deletion. Failed saves and reconnects preserve edits; discarding or closing a dirty draft requires confirmation. No native code, dependencies, EAS configuration or lockfile changes. - Add gateway integration coverage through a real WorkerHost and paired gateways: nested worktree resolution, ambiguous names and selection, same-turn hints and isolation, ignored/new files, not found versus disappeared, linked text/image/other binary transfer, the 2 MiB cap, owner scoping, traversal/outside paths/escaping symlinks, workspace aliases, mutation conflicts, and offline worker/link errors. ## Validation Rebased onto `dev` at `f76cfb2a9453a26e3218c553aad8fcb37e9d55e0`. Generated contracts were regenerated to preserve the base branch's additive changes. The independent linked-bot test synchronization correction was extracted to #561; this branch contains no linked-bot test or production cache changes. - Local `bun install` and `bun run gen:check` passed. Focused `TMPDIR=/var/tmp bun test tests/integration/thread-file-previews.test.ts` passed on the final rebased head: 11 tests, 75 assertions, no failures. Web typecheck passed with zero errors/warnings; changed-file oxfmt and oxlint passed. The full `check:tmp` was intentionally not repeated locally, as requested; GitHub CI runs the full shards and required static/build checks. - Real Chromium review used a disposable paired-gateway fixture and real home WorkerHost. Confirmed bare-name nested resolution, ambiguous choices and selection, missing versus deleted after Reload, searched paths, a 320 × 180 JPG with its 977 B size, no image Edit action, and workspace-relative path plus home computer subtitles. Checked short/typical/long paths, image and picker at 1280 px and 390 px, light and dark, with no horizontal overflow or browser exceptions. The shared browser disconnected, so review continued in isolated local Chromium. Screenshots were inspected after transitions completed and with reduced motion. No browser test suite or artifacts are committed. - The browser check exposed a Svelte effect repeatedly reading the file after its own loading/path/hash updates. The effect now tracks only the viewer target and calls `load()` without tracking mutable viewer state. The repeated review passed. The final rebase leaves the reviewed file-viewer and mobile-file components unchanged. - SDK 58 fingerprints generated through `expo-updates fingerprint:generate` with `CANOPY_CHANNEL=nightly` are identical for final head and base, using the same repository path and installed dependencies: iOS `6ddec9ef559ee0095ac33e94ff9418a942053b17`; Android `5f6eae3ab278f1cd543e9ed763f923a319b65ec9`. No native code, dependencies, EAS configuration or lockfile changes. Fresh CI runs on final head `84b1a71365f817cc104d088cf7fb041100aa6686`; its result is reported independently of earlier passing runs. All disposable gateways, worker, database and web processes were stopped after review; local browser sessions were closed. ## Copy audit — docs/copy.md §8 | Before | After | Reason | | --- | --- | --- | | “This file no longer exists.” on an unresolved name | “Couldn't find {name} in this workspace.” with Reload and “Show searched paths” | Does not claim deletion without a previous read. | | Same generic missing-file claim after a previous read | “{name} is no longer at this path. Check whether it was moved or deleted.” | Reports the evidence without assuming the cause. | | No disambiguation | “Several files match this name. Choose a path to open.” | Names the condition and the next action. | | No bounded-search status | “The search reached its limit. Open a full workspace-relative path.” | Makes an incomplete search explicit. | | Empty image box | “Could not show this image. Reload to try again.” | Gives an action for image-decoder failure. | | Dropped binary bytes | “This file exceeds the 2 MB preview limit. Open a smaller file to preview it.” for truncated binaries | Explains the bounded preview. | | Filename repeated in title and subtitle | Filename; workspace-relative path and computer | Each field adds context; root paths include `./`. | | “Delete…” | “Delete file” → “Delete file?” | Concrete verb/object; confirmation names the path/computer and says it cannot be undone. | | No mobile dirty-editor flow | “Unsaved changes”, “Discard unsaved changes?”, “Discard changes” | Protects edits and states the action. | Static audit: English, sentence case, plain glossary terms, verb-led actions, confirmation verbs agree, and errors explain the event and the next action. Search diagnostics are disclosed under “Show searched paths”. Empty states are short and use the existing Reload action. Title/subtitle supply different information. Computer availability is a named dependency with reconnect/reload guidance. No humor or ornamental copy was added. States have text independent of color or icons. Visual copy audit (§8.9): short, typical and long file names/paths checked in Chromium at desktop and phone widths, in light and dark. Titles/subtitles wrap within the dialog, path choices stay compact, errors show accurate copy and searched-path disclosure, and no overlay gaps or horizontal overflow appeared. Mobile source copy uses the same shared lookup messages; no native-device visual review is claimed. Fixes: #499 Related: #514
nixuuu
added a commit
that referenced
this pull request
Nov 12, 2026
Selecting a message across a file reference used to omit the path from both clipboard text and Cite. File references and attachment previews now use selectable inline links; mentions also allow selection. A drag or a click that leaves text selected does not activate a link, while a plain click or Enter still opens the file preview. Desktop windows now provide a native context menu: Copy for selected text; native editing roles and spelling suggestions in editable fields; Copy link and Open link in browser for links. External opening validates HTTP(S) only. Existing sidebar/bot menus and sensitive values retain their local `contextmenu.preventDefault()` behavior. There is no global context-menu cancellation in the web renderer, no new IPC, and no change to sandboxing or context isolation. Fixes: #514 The file-reference buttons were introduced by #514, whose merge is currently on `dev` and has not reached `next` or `main`. Validation: - `bun install --frozen-lockfile`, `bun run gen:check`, full repository `bun run typecheck`, `bun run lint`, `bun run format:check`, and the web build passed. Web and desktop typechecks and the web build also passed after the final inline-link adjustment. - `bun test apps/desktop/test/context-menu.test.ts`: 3 tests, 27 assertions. Covers selection/composer menu roles, disabled editing actions, spelling opt-outs, and rejection of non-HTTP(S) external opening. - Real Chromium check with the production Markdown, Cite, MentionEditor and file-viewer components in a temporary harness: selection highlighting includes the long path; Ctrl+C → Ctrl+V preserves it in the composer; a saved Cite preserves the full path; mouse dragging does not open the viewer; plain click and Enter open it. File reads used a fixture response, without a gateway. Markdown file links, external links and mention labels also remain in selection/Cite and copied mention text. - Visually checked light/dark at 1280 px and 390 px, including the supplied long filename. No horizontal overflow at phone width. The browser renderer permits the normal context-menu event on message links. - The Electron binary is not installed in this checkout, so native popup interaction was not exercised; the pure menu builder is unit-tested. Full `check:tmp` was intentionally left to CI, as requested. No web UI test suite or diagnostic artifacts were added. Copy audit (docs/copy.md §8): - No menu → `Copy link` / `Open link in browser`: short imperative actions, sentence case, no trailing punctuation or new glossary terms. Native editing roles keep the operating system's conventional labels and shortcuts. - Existing `Open <path>` / `Download <name>` labels and all error/status text are unchanged. Short and long labels were checked at desktop and phone width; the file path has a visible text label and does not rely on colour or an icon.
This was referenced Nov 13, 2026
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.
Follows #499 (merged). Replaces #498, which was merged into the intermediate branch before the stack was rebased onto #513.
Summary
out/report.md,C:\work\q.sql,~/notes.txt,src/app.ts:12) and Markdown links to files ([report](out/report.md),file:///…).@codemirror/language-data, colours from the theme's--code-*tokens and palette); Unsaved changes badge in reserved space, Mod+S, close asks before discarding, conflict when the file changed on disk (Discard and reload), Delete… with confirmation, Open in default app, Copy path, Reload. Editing is off for binary, truncated and >400 KB files (BFF body limit 512 KB).@codemirror/{state,view,commands,language,language-data,search,autocomplete},@lezer/highlight.docs/ui-api.md"Pliki wątku".onThisComputer); other files open in the viewer.Verification
vite buildclean.Copy audit (docs/copy.md §8)
Edit,Save,Discard changes,Stop editing,Reload,Open in default app,Delete…,Delete file,Cancel,Keep editing,Discard and reload; tooltipOpen <path>;Copy path.Delete file?(confirm button repeats the verb:Delete file),Discard unsaved changes?(confirmDiscard changes).Unsaved changes;Opening the file…;This file is empty.;Canopy cannot show this file. Open it in its default app.;Showing the first 2 MB. Open the file in its default app to see all of it.;Files over 400 KB open read-only.This file no longer exists.,This file is outside the thread's folders, so Canopy cannot open it.,Only files can be opened, not folders.,The file changed on disk since you opened it. Reload it to see the changes.,Open the file again before changing it.,This computer is offline. Reconnect it to open files.,Update this computer to open files from Canopy.,This file is too large to save from Canopy.,No app on this computer opened the file. Copy the path instead.,The editor could not load. Reload Canopy and try again.Open files in— "Where a file path in an agent's message opens when you click it." OptionsCanopy/Default app.