Repository navigation
Description
The host splits a large message into pieces (MessageParts, Sources/AgentTermHost/HostServer.swift:1911) and the client joins them (Sources/AgentTermClient/AgentTermConnection.swift:267). The other way nothing is split or bounded: AgentTermConnection.send (AgentTermConnection.swift:146-152, transmit at 242-246) sends each message as one text frame, and the host's WebSocket takes at most 4 MB (webSocket.maximumMessageSize = 4 * 1024 * 1024, HostServer.swift:1756).
What happens.
- On the iPhone, or on a Mac showing another Mac: a text file of 5 to 20 MB is opened with "Open Anyway" (
FileContent.largestOpenedAnyway,Sources/AgentTermProtocol/Workspace.swift:789), edited and saved.writeFile(path, text)goes as one frame (iOS/AgentTerm/PhoneModel.swift:2279,Sources/AgentTermMac/FilesModel.swift:414). The connection drops, nothing is saved and no reason is given (principle 3). browserReply(.image(png:)), the picture an agent asked of a page (Sources/AgentTermMac/BrowserAgent.swift:543,BrowserDevTools.swift:526): a whole page or a large viewport in base64 can pass 4 MB. OnlybrowserFrameis capped (PagePicture.mostBytes).
Found by reading the code in the review of 2026-11-22, at commit 968516d; not reproduced yet. A second reading confirmed that the client sends one frame and that the host's limit is 4 MB. That a frame over the limit closes the connection is taken from the comment at Sources/AgentTermProtocol/PagePicture.swift:16-18, not tried.
A way to fix it, not decided: split in AgentTermConnection.send as the host does and join on the host, or refuse a message that is too large in words before it is sent. Which of the two is a design choice (a change to the protocol): the owner's.
- Reproduced: a test that sends a
writeFileover 4 MB to a host of its own and fails because the file is not written, seen failing - Fixed at its root, the test passing, the layers of rule 2 run, committed, CI green
Decided by the owner on 2026-11-23: a client's large messages are split and joined, as the host's are.
Definition of done
- Decided by the owner first: client messages split and joined, or refused in words above a size.
- A test (
AgentTermHostTests, a host with a state folder and a port of its own) that saves a text of more than 4 MB throughAgentTermConnectionand fails because the connection closes, seen failing, then passing and kept; one for a browser picture's answer of that size. - A file the apps let the user open and edit can be saved from the iPhone and from another Mac, or the user is told at once, in the top banner of both apps, why not and what to do; the connection is never lost over the size of a message.
- The words are in
AgentTermProtocol(principle 9); the protocol's number is raised if a message changes or pieces are added the other way (principle 6). docs/DESIGN.md(Protocol) says how large messages go both ways; a case indocs/TESTING.mdnamed by the test.swift build,swift test,scripts/test-mac.sh,scripts/test-ios.sh "iPhone Air",scripts/test-both.sh "iPhone Air".make formatandmake lint, committed on the milestone's branch and pushed, CI on the branch green.
Tiếng Việt
Đây là bản dịch của phần tiếng Anh ở trên; các ô đánh dấu chỉ có ở phần tiếng Anh.
Host chia một message lớn thành nhiều phần (MessageParts, Sources/AgentTermHost/HostServer.swift:1911) và client ghép lại (Sources/AgentTermClient/AgentTermConnection.swift:267). Chiều ngược lại không có gì được chia hay giới hạn: AgentTermConnection.send (AgentTermConnection.swift:146-152, transmit ở 242-246) gửi mỗi message thành một text frame, và WebSocket của host nhận tối đa 4 MB (webSocket.maximumMessageSize = 4 * 1024 * 1024, HostServer.swift:1756).
Điều xảy ra.
- Trên iPhone, hoặc trên một Mac đang xem Mac khác: một file text 5 đến 20 MB được mở bằng "Open Anyway" (
FileContent.largestOpenedAnyway,Sources/AgentTermProtocol/Workspace.swift:789), sửa rồi lưu.writeFile(path, text)đi thành một frame (iOS/AgentTerm/PhoneModel.swift:2279,Sources/AgentTermMac/FilesModel.swift:414). Kết nối rớt, không có gì được lưu và không có lý do nào được nêu (nguyên tắc 3). browserReply(.image(png:)), ảnh agent xin của một trang (Sources/AgentTermMac/BrowserAgent.swift:543,BrowserDevTools.swift:526): cả trang hoặc một viewport lớn ở dạng base64 có thể vượt 4 MB. ChỉbrowserFrameđược giới hạn (PagePicture.mostBytes).
Tìm thấy khi đọc code trong đợt rà soát ngày 2026-11-22, tại commit 968516d; chưa tái hiện. Lần đọc thứ hai xác nhận client gửi một frame và giới hạn của host là 4 MB. Việc một frame vượt giới hạn làm đóng kết nối là theo comment ở Sources/AgentTermProtocol/PagePicture.swift:16-18, chưa thử.
Một cách sửa, chưa quyết định: chia trong AgentTermConnection.send như host làm và ghép ở host, hoặc từ chối bằng lời một message quá lớn trước khi gửi. Chọn cách nào là quyết định thiết kế (thay đổi protocol): của owner.
- Tái hiện: một test gửi
writeFilehơn 4 MB tới một host riêng của nó và fail vì file không được ghi, đã thấy fail - Sửa tận gốc, test pass, chạy các tầng của rule 2, commit, CI xanh
Đã quyết bởi owner ngày 2026-11-23: tin lớn của client được chia nhỏ rồi ghép lại, giống cách host đang làm với tin của mình.
Định nghĩa hoàn thành
- Owner quyết định trước: message của client được chia và ghép, hay bị từ chối bằng lời khi vượt một kích thước.
- Một test (
AgentTermHostTests, host có state folder và port riêng) lưu một text hơn 4 MB quaAgentTermConnectionvà fail vì kết nối đóng, đã thấy fail, rồi pass và được giữ lại; một test cho câu trả lời ảnh browser cỡ đó. - File mà app cho user mở và sửa thì lưu được từ iPhone và từ Mac khác, hoặc user được báo ngay, ở banner trên cùng của cả hai app, vì sao không và phải làm gì; kết nối không bao giờ mất vì kích thước của một message.
- Câu chữ nằm trong
AgentTermProtocol(nguyên tắc 9); số của protocol được tăng nếu một message thay đổi hoặc thêm việc chia phần ở chiều ngược lại (nguyên tắc 6). docs/DESIGN.md(Protocol) nói message lớn đi thế nào ở cả hai chiều; một case trongdocs/TESTING.mdđược test nêu tên.swift build,swift test,scripts/test-mac.sh,scripts/test-ios.sh "iPhone Air",scripts/test-both.sh "iPhone Air".make formatvàmake lint, commit trên nhánh của milestone và push, CI trên nhánh xanh.
Activity
manhpham90vn commentedon Nov 23, 2026
Reproduced on 2026-11-23, on
milestone-0.15.1:Reproduced on 2026-11-23, on
milestone-0.15.1at e5c1bd8, byReviewCoreLargeFrameTests.testSavingAFileLargerThanAFrameIsDoneOrRefusedInWordsinTests/AgentTermHostTests/ReviewCoreLargeFrameTests.swift(new, not committed).A host of the test's own and the apps' own client (
AgentTermConnection); a file of 6 bytes in a folder of the test's;writeFile(path:text:)with a text of 5 MB.swift test --filter ReviewCoreLargeFrameTests:What it proves: a message of a client over 4 MB closes the connection (in 0.09 s here), nothing is saved and no
erroris sent. Not tried: what each app then shows (the Mac app on another Mac, the iPhone), and the browser'sbrowserReply(.image)of a large picture, which goes the same way by reading.The failing test, kept out of the branch while the issue is not done (it would make CI red), to be put back with the fix (
Tests/AgentTermHostTests/ReviewCoreSupport.swiftis on the branch):ReviewCoreLargeFrameTests.swiftfix: a client's large messages go in pieces, and a client that does n…
manhpham90vn commentedon Nov 23, 2026
Fixed in 753bd75, as the owner decided: a client's message larger than 256 KB goes in pieces (
MessageParts, binary frames numbered by the client) and the host joins them, up toMessageParts.largestFromAClient(64 MB); one larger is answered withmessage too large, said in both apps asHostErrorWords.tooLarge, and the connection goes on. Protocol 41. REMOTE-34 (LargeMessagesTests): saving 6 MB of text, a browser picture's answer of 5 MB, and a message over 64 MB each closed the connection without a reason before the fix (seen with the client's splitting turned off), and pass.docs/DESIGN.md(Protocol) says it.Run on
milestone-0.15.1, 2026-11-23:swift build,swift test,scripts/test-mac.shin full,scripts/test-ios.sh "iPhone Air"andscripts/test-both.sh "iPhone Air"passing on 022aa66;make lint; CI on the branch green (run 45152397234).The save from a real iPhone is in the milestone's pull request (#326). Done in full: closed.