Skip to content

feat: bots share files as cards in the chat - #125

Merged
httpsphl merged 4 commits into
mainfrom
feat/share-file
Oct 2, 2026
Merged

httpsphl merged 4 commits into
mainfrom
feat/share-file

Conversation

@httpsphl

@httpsphl httpsphl commented Oct 2, 2026

Copy link
Copy Markdown
Owner

What

Bots can now show the owner a file they made as a card in the chat, with Open and Save as…, instead of writing its path in the reply.

  • share_file MCP tool (crates/botloftd/src/tools/share.rs): 1 to 10 paths. It only accepts files the files panel could already read: the crew's work folder, the bot's own folder, or files the bot wrote. This is the same check files.read uses. Any other path rejects the whole call and tells the bot which file and why. The bot rules and the tool description ask for it when a file is done and when the owner asks for one again.
  • save_file_as Tauri command (app/src-tauri/src/save.rs): it opens the system Save As dialog itself and copies the file there, so the page can't write anywhere the owner didn't pick.
  • Cards in the chat (app/src/features/chat/SharedFiles.tsx): type icon or image thumbnail, name, extension, size, Open and Save as. Clicking the file opens its preview in the files panel, including an older file the panel list leaves out. In a narrow chat, Save shows only its icon. If the call failed or its answer can't be read, the normal tool line stays.

No DB or protocol change: the cards are drawn from the tool's answer, which the tool chat item already stores. Texts are in all three languages. Spec updated in 5.1, 8.4, 10, 15.1, 15.2, 15.3 and 19.

Checks

  • cargo fmt --check, clippy -D warnings, cargo test --workspace, pnpm check (286 tests)
  • Real Claude Code (2.1.284, Haiku, dev daemon): asked for a report saved in the work folder. The bot wrote it and called share_file on its own. Then I asked "send me the report again" and it called it again without writing the path. Its first call sent a Windows path with unescaped \, which Claude Code rejects as invalid JSON, and the bot retried correctly. Because of that, the field description now asks for forward slashes. No chat text showed up in the daemon log, even at debug.

Manual test

  1. In the real app, ask a bot for a short report saved as a file, then "send me that file again".
  2. Both times a card should appear. Click the name and the preview should open in the files panel. Save as… should open the system dialog and copy the file where you pick.

The bot passes 1 to 10 paths and each becomes a card in its chat. Only
files the files panel could read are accepted (the crew's work folder,
the bot's folder, or files it wrote), using the same check as
files.read. The bot rules and the tool description ask for it when a
file is done and when the owner asks for one again.
The command opens the system Save As dialog itself, so the page can
never write anywhere the owner did not choose.
A successful share_file becomes one card per file, with the type icon
or an image thumbnail, name, size, Open and Save as. Clicking the file
opens its preview in the files panel. A failed call keeps the tool line.
@httpsphl

httpsphl commented Oct 2, 2026

Copy link
Copy Markdown
Owner Author

Manual test done in the real Tauri app (pnpm tauri dev, separate data folder, Claude Code 2.1.287, Opus 5.5): asked the lead for a short report saved as a file. It called share_file on its own and the card showed name, MD and size. Clicking the name opened the preview in the files panel. In the narrow chat, Save as showed only its icon and opened the Windows Save As dialog; the saved copy is byte-identical to the bot's file. "Send me that report again" brought a second card without the path in the text. No chat text in the daemon log at debug.

@httpsphl
httpsphl merged commit a53700a into main Oct 2, 2026
4 checks passed
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.

1 participant