Skip to content

app-shell sftp: split commands/sftp.rs into one file per command group #844

Open

Description

@smart-ssh-planner

Goal

Each group of file-browser commands lives in its own file, so a change to, say, chmod no longer means loading a 3,400-line file.

Context

crates/app-shell/src/commands/sftp.rs has 3,449 lines (~2,660 production lines before the tests at :2666, plus 4,500 lines of tests in commands/sftp/*_tests.rs), 32 Tauri commands and 99 functions, each command with *_impl/*_reporting/*_recursive variants. Sub-modules already exist: commands/sftp/transfer.rs, commands/sftp/folder_upload.rs, and test modules revocation_tests.rs, size_limit_tests.rs, local_path_tests.rs (declared at :51–72); inline test modules rename_overwrite_tests (:2667), sftp_mutation_tests (:2744), edit_session_tests (:3348).

Command groups (line numbers on develop):

  • list/stat/exists: sftp_list :75, sftp_start_directory :97, session_is_root :112, list_impl :123, sftp_exists :1254, exists_impl :1271, sftp_stat :1294;
  • download: download_one_file :162, sftp_download :194, download_impl :214, pick_folder_dialog :304/:324, default_downloads_dir :337, download_recursive :360, download_entry_to :433, sftp_download_default :486, sftp_download_dir :522, sftp_cancel_transfer :560;
  • upload and clipboard: sftp_upload :579, pick_upload_files :654, claim_dropped_paths :712, clipboard_has_files :739, clipboard_write_text :755, ClipboardPasteDialogTexts :769, paste_dialog_message :781, claim_clipboard_files :840, upload_impl :906;
  • delete: walk_dirs_and_count_files :940, EntryRows :965, sftp_delete_preview :1059, delete_preview_impl :1076, sftp_delete :1114, delete_impl* :1136–1186, delete_recursive :1187;
  • permissions: sftp_chmod :1323, chmod_impl* :1357–1423, recursive_entry_mode :1424, chmod_recursive :1441, sftp_chown :1513, chown_impl*, resolve_chown_ids :1574, chown_target :1656, chown_recursive :1677;
  • rename/mkdir/create: rename_replacing :1741, sftp_rename :1771, sftp_mkdir :1813, mkdir_impl :1830, create_file_impl :1848, sftp_create_file :1875;
  • copy content: too_large_for_clipboard :1910, sftp_read_text :1932, read_text_impl :1949, CopyContentProgress/CopyContentJobs :2010–2057, sftp_copy_content :2060, sftp_cancel_copy_content :2101, copy_content_* :2109–2186, sftp_copy_file :2189, read_local_text_preview :2261;
  • edit session: sftp_open_for_editing :2378, open_for_editing_impl :2415, local_file_mtime :2487, in_app_edit_copy :2532, read_edit_copy_text :2593, write_edit_copy_text :2610, close_edit_session* :2630–2665.

Requirements

  • commands/sftp.rs becomes commands/sftp/mod.rs (shared imports, re-exports of all #[tauri::command] functions so lib.rs's generate_handler! paths keep working) plus commands/sftp/{list.rs, download.rs, upload_clipboard.rs, delete.rs, permissions.rs, rename_mkdir.rs, copy_content.rs, edit_session.rs}.
  • Inline test modules move next to their code (rename_overwrite_tests → with rename_mkdir.rs, edit_session_tests → with edit_session.rs, sftp_mutation_tests → split by the function they test, or kept as sftp/tests_mutation.rs).
  • No logic change; no moving of code to app-logic in this issue (separate issue).

Acceptance Criteria

  • crates/app-shell/src/commands/sftp.rs no longer exists; the listed files exist under commands/sftp/.
  • Every file under crates/app-shell/src/commands/sftp/ has a production part below 800 lines.
  • npm run check-commands (frontend) and cargo build --workspace pass without changing any command name.
  • Test count per binary unchanged, all pass.
  • Gate green.

Technical Notes

  • The file browser can run on an elevated (sudo) SFTP channel. BrowserChannel, BrowserAccess and ElevatedSftpRegistry stay private to app-shell exactly as today (docs/architecture.md, "Eine Ausnahme … der erhöhte SFTP-Kanal"); do not widen any visibility while moving.
  • The recursive delete uses lstat to never follow a symlink into another tree (Spec 0054); keep the code byte-identical apart from module paths.
  • Restructuring only: behaviour, error codes, emitted events, log fields and messages stay identical. Fix nothing on the way; a bug you find goes into its own issue (mention it in the PR).
  • Tests: cargo test --workspace -- --list before and after; the number of tests per test binary does not decrease, and the same tests pass. Tests may move with the code they test (<module>/tests.rs or <module>/tests_<topic>.rs; no new *_tests.rs names).
  • Public items used from outside the crate keep their paths (re-export if an item moves); check with grep -rn over the workspace.
  • New code comments in English; existing German comments may move unchanged.
  • Update docs/architecture.md (module table "Ausnahmen von der Regel (A4)" and the list of app-shell modules) when a module moves between app-shell and app-logic.
  • Gate: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace, cargo build --workspace (the last one catches production calls into test-support-only items).

Spec impact: none

Related Work

Activity

  1. added this to the 0.8.0 milestone on Oct 26, 2026
  2. 21 remaining items

  3. marked this as blocking 15 issues on Oct 26, 2026
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

    Type

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions