Skip to content

Save a file a task made to Downloads when it is clicked - #72

Open
abhishek-anand wants to merge 6 commits into
mainfrom
fix/outputs-to-downloads
Open

abhishek-anand wants to merge 6 commits into
mainfrom
fix/outputs-to-downloads

Conversation

@abhishek-anand

Copy link
Copy Markdown
Collaborator

Asked for code as a zip, the assistant made one but there was no way to get it: a click on an outputs link opened a hidden copy, and the assistant cannot write to the owner's Mac.

  • Clicking a file in the outputs folder now copies it to ~/Downloads like a browser download. It then opens there, or is shown in Finder when it could run or is an archive. The copy comes from Open a file a task made from the link in its answer #69's no-follow snapshot and is never executable.
  • Clicking the same file again finds the copy saved before. A different file with that name gets name (2).ext, and the file already there is left alone.
  • The app says "Saved to Downloads: name".
  • The instructions tell the assistant to link the files it saves in the outputs folder, since a click saves them to Downloads.
  • The room test sizes its small room from the instructions, the same change as in Write code with file tools in the sandbox, and check it in the sandbox's browser #70, so either can merge first.

Tests: gateway test updated (save, reuse, numbered name, never executable); full suite 1272 passing.

Clicked, a file in the outputs folder is copied to Downloads like a browser download, then opened there, or
shown in Finder when it could run or is an archive. The same file clicked again finds the copy saved before; a
different file of that name gets a numbered name. The answer can link it, and the app says where it went.
Copilot AI balanced review requested due to automatic review settings December 2, 2026 07:09
Comment thread coderunner/files/attached.py Fixed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Concurrent requests can reuse incomplete or incorrect downloads, and byte-identical executable files can be reused without enforcing the non-executable guarantee.

2 open issues
What changed in this PR

Makes task-generated files accessible by saving clicked output links to Downloads before opening or revealing them.

Changes:

  • Adds download copying, reuse, and numbered filenames for collisions.
  • Shows a save notification and tells the assistant to link generated files.
  • Updates gateway coverage and makes the room test adapt to instruction length.
File Description
tests/​test_parallel.py Sizes the test room from instructions.
tests/​test_gateway.py Checks saving, reuse, collisions, and permissions.
coderunner/​server/​web/​app/​app.js Displays the Downloads notification.
coderunner/​server/​gateway.py Saves outputs before opening and returns the saved path.
coderunner/​files/​attached.py Adds Downloads copying and filename selection.
coderunner/​agent/​loop.py Instructs the assistant to link downloadable outputs.

Review effort: Balanced

Comment thread coderunner/files/attached.py Outdated
Comment on lines +275 to +276
with open(target, "xb") as out, open(copy, "rb") as src:
shutil.copyfileobj(src, out)
Comment thread coderunner/files/attached.py Outdated
target = folder / (copy.name if n == 1 else f"{stem} ({n}){suffix}")
if target.is_symlink():
continue
if target.is_file() and filecmp.cmp(copy, target, shallow=False):
… never hand back an executable copy

The file is copied to a hidden temp file in Downloads first and then linked to its
name without overwriting, so a failed copy leaves nothing behind. A same-name file
with the same bytes is reused only if it is not executable.
mkagenius
mkagenius previously approved these changes Dec 3, 2026
…t be read, and name the saved file when nothing can open it

The name is given only by a hard link of the whole copy, so no empty placeholder
is ever left in Downloads; a disk without hard links gets a plain error. When the
link loses to another click that saved the same bytes, that file is reused. A
same-name file that cannot be read counts as someone else's. A missing opener or
one that hangs is treated as a failed open, so the reply still says where the
file was saved.
Comment thread tests/test_attached.py Fixed
Comment thread tests/test_attached.py Fixed
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.

4 participants