From 2f90f4b60cd50f7e9649daaf8e76a120e608cff6 Mon Sep 17 00:00:00 2001 From: Christophe Besson Date: Thu, 15 Oct 2026 09:57:18 +0200 Subject: feat(cli): /put and /get in the interactive chat /put FILE sends one local file, relative to the current directory or absolute, into the chat's folder, then posts the application's attachment message naming it ({"text": "", "attachment": {filename, size, type}}), so the page shows it as its paperclip's. /get NAME saves a file of that folder, named from it, into the current directory, never over a file already there. The chat's folder is the page's rule: the operator's choice while its root is writable and present, else the first such root; a chat_directory_ack moves it. A line above the one written in shows the transfer's progress. Attachment messages, from the page or from /put, read as [file: name, size] in the room and in `chat`, and as an `attachment` field with --json. Co-Authored-By: Claude Opus 5.5 --- packages/meshbay-cli/src/meshbay_cli/commands/chat.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'packages/meshbay-cli/src/meshbay_cli/commands/chat.py') diff --git a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py index d650af3..e410a6a 100644 --- a/packages/meshbay-cli/src/meshbay_cli/commands/chat.py +++ b/packages/meshbay-cli/src/meshbay_cli/commands/chat.py @@ -28,7 +28,7 @@ from ..client.groups import my_groups, open_group from ..client.paths import group_arg, handle, resolve_group from ..client.roster import RosterCheck from ..errors import NODE, USAGE, CliError -from ..output import date, err, safe, sentence +from ..output import date, err, human_size, safe, sentence from .context import Context HELP = ("chat: alone, interactively; with a group, its last 10 messages (-N for N), " @@ -147,6 +147,10 @@ def print_message(m, *, flush: bool = False) -> None: print(f"{head}[this message cannot be read: {m.unreadable}]", flush=flush) return lines = safe_lines(m.text) + if m.attachment: + file_line = (f"[file: {safe(m.attachment['filename'])}, " + f"{human_size(m.attachment['size'])}]") + lines = [file_line] if lines == [""] else [file_line, *lines] print(head + lines[0]) for line in lines[1:]: print(" " * len(head) + line) @@ -158,7 +162,8 @@ def print_message(m, *, flush: bool = False) -> None: def as_json(m) -> dict: return {"id": m.id, "timestamp": m.timestamp, "sender": m.sender, "text": m.text, - "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {})} + "trust": m.trust, **({"unreadable": m.unreadable} if m.unreadable else {}), + **({"attachment": m.attachment} if m.attachment else {})} class Follower: -- cgit v1.2.3