Repository navigation
Description
Goal
When a write proposal targets an existing text file larger than 1 MiB, the action card says so honestly ("larger than 1 MiB, no preview") instead of showing the binary-file hint with the cap as the "previous size".
Context
Follow-up of #1550 (PR #1552): the write preview now reads at most 1 MiB. For a larger file remote_files.rs:101-106 returns (None, Some(MAX_PREVIEW_FILE_BYTES)), which ActionCard.tsx:152-153 renders through BinaryFileChangeHint (confirmDialog.binaryFileHint: "Binary file — text comparison not possible. Previous size: 1 MiB, …"). That is wrong twice: the file is not binary, and the size shown is the cap, not the real size. Spec 0020 §4.1/§4.2 point 5 describes the preview.
Requirements
- Distinguish "too large for preview" from "binary" in the proposal payload: add a boolean (e.g.
previousFileTooLarge) to the chat action-proposed payload (crates/app-logic/src/events.rs, frontend event types updated (src/api/eventPayloads.ts)) set only for the over-cap case; the binary case stays as today. - For the over-cap case,
previousFileSizeisNone; the frontend shows a new hint "File is larger than {{limit}}, no text comparison. New size: {{newSize}}." instead of the binary hint. - Add the new key to all locales (follow
docs/i18n-glossary.mdand the existing locale parity check). - Update spec 0020 §4.2 point 5 and add a changelog fragment.
Acceptance Criteria
- Target of cap + 1 bytes: payload has
previousFileContent: null,previousFileSize: null, too-large flag true. - Target of exactly the cap: content preview, flag false (unchanged).
- Real binary file (invalid UTF-8 under the cap): payload and card unchanged (binary hint with real size).
- Card for the over-cap case shows the new text and not the binary hint (component test).
- Denied proposal still reads nothing; flag false.
- Locale parity and lint pass; relevant automated tests pass.
Technical Notes
Chosen: new flag in the payload (a size value alone cannot distinguish a real 1 MiB binary from the cap). Not security-relevant: the preview goes to the UI only; filter decision unchanged. Threat model: no change expected.
Files: crates/app-logic/src/orchestration/remote_files.rs, crates/app-logic/src/orchestration/action_exec/propose.rs, crates/app-logic/src/events.rs, crates/app-logic/src/orchestration/action_exec/tests_files_and_ledger.rs, apps/smart-ssh-community/frontend/src/components/chat/ActionCard.tsx, apps/smart-ssh-community/frontend/src/api/eventPayloads.ts, apps/smart-ssh-community/frontend/apps/smart-ssh-community/frontend/src/locales, docs/specs/0020-sftp-file-transfer.md, changelog.d
Spec impact: update 0020
Open questions
- Alternative: fetch the real size via
statand show it in the hint. Not chosen: extra round trip and the size is not needed for the decision.
Activity
fix(app-logic): honest note for write preview of files over the cap (#…
smart-ssh-coder commentedon Nov 24, 2026
Implementation ready for review. PR #1563. Added previousFileTooLarge flag to the write-proposal payload; over-cap files now show a new too-large hint (all locales) instead of the binary hint. Spec 0020 and changelog updated; Rust and vitest tests added/updated, CI green on PR #1563.
smart-ssh-reviewer commentedon Nov 24, 2026
Review passed – moving on to merge. Approved. All acceptance criteria are met and backed by tests. Over-cap payload: null content, null size, flag true. At the cap: content preview, flag false. Binary under the cap: unchanged. Card: shows the new hint, not the binary hint. Denied proposal: reads nothing, flag false. Locale parity and lint pass. Both counter-proofs behave as expected: the Rust test and the component test fail without the fix and pass with it. Spec 0020 §4.2 and the changelog fragment match the code. CI is green.
fix(app-logic): honest note for write preview of files over the cap (#…
smart-ssh-coordinator commentedon Nov 24, 2026
Merged and branch deleted: PR #1563 (squash) in develop