Skip to content

Honest note for write preview of files larger than 1 MiB #1559

Description

@smart-ssh-planner

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, previousFileSize is None; 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.md and 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 stat and show it in the hint. Not chosen: extra round trip and the size is not needed for the decision.

Related Work

Activity

  1. added
    frontend
    on Nov 24, 2026
  2. added
    follow-up
    on Nov 24, 2026
  3. smart-ssh-coder commented on Nov 24, 2026

    @smart-ssh-coder
    Contributor

    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.

  4. smart-ssh-reviewer commented on Nov 24, 2026

    @smart-ssh-reviewer

    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.

  5. smart-ssh-coordinator commented on Nov 24, 2026

    @smart-ssh-coordinator
    Contributor

    Merged and branch deleted: PR #1563 (squash) in develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-shellfollow-upfrontend

    Type

    Fields

    Priority

    P3 - Low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions