Skip to content

Save As to this computer or the board, in VS Code and the browser - #91

Merged
bdbarnett merged 2 commits into
mainfrom
save-as
Oct 8, 2026
Merged

bdbarnett merged 2 commits into
mainfrom
save-as

Conversation

@bdbarnett

Copy link
Copy Markdown
Collaborator

Save As now offers both destinations: this computer and the board.

What you can do. With a file open in the editor, Save As asks where to put it, This computer or Board (the board only while one is connected). It starts on the side the file came from. The path starts as that side's list folder plus the file's name, so you can browse to a folder in the File Transfer panel and Save As lands there; you can edit it. An existing file is replaced only after you say so. The folder has to exist, because the board's write doesn't create folders, so a missing one is reported and nothing is written. Afterwards the editor follows the copy: its tab, side and path change, the next Save goes there, and the original is left as it was. The destination list redraws so the new file shows.

VS Code. A new command, mpftp: Save As…, sits in the editor title bar (save-as icon) and the editor's right-click menu, for any file, local or a board file's temp copy. It asks the side with a QuickPick and the path with an InputBox. For a board file, Save As to the board moves the temp mapping to the new board path. Save As to this computer makes it a plain local file that no longer pushes to the board. VS Code's own Save As is unchanged. The path rules and the rebinding are in extension/src/saveAs.ts, which doesn't use the VS Code API, so npm test (node:test) covers them. CI now runs that step too.

Browser (python -m mpftp). There's a Save As button beside Save (Ctrl+Shift+S). Its dialog is styled like the others and uses the theme variables. panel.py's new saveFileAs message makes the same checks as the extension. The page passes the lists' folders through from the panel's state. A smaller fix while there: the page's Ctrl+S handler now skips keys the editor has already handled, so Ctrl+S in the editor saves once rather than twice.

Tested

  • cli/tests/test_panel.py: 8 new Save As cases (other board folder, relative paths, replace/cancel, same file, missing folder, folder as target, between sides, disconnected).
  • extension: npm test, 7 cases for path resolution and temp-mapping rebinding. A planted fault (the old mapping not removed) fails 2 of them.
  • In Chromium with Playwright against an ESP32-P4 board over USB serial:
    • Board file to another board folder: the new file's board hash matches the editor, the original is unchanged, the board list shows the copy, and the next Save goes to the copy.
    • Local file to the board.
    • Board file to this computer: the next Save stays local.
    • Replacing an existing file asks first. Cancel keeps the file; Replace writes it.
    • Saving into a missing board folder reports it and writes nothing.
  • The VSIX packages and includes the command.

Not tested: the VS Code command in a real VS Code window: the QuickPick and InputBox, the tab swap (revert and close the old editor, open the copy in the same column), and the title-bar and context-menu entries.

The editor's file can be saved under a new name or folder on either side.
The path starts in the folder that side's list is showing; an existing
file is replaced only after asking; a missing folder is reported. The
editor then follows the copy, so the next Save goes there.

VS Code: mpftp: Save As... in the editor title bar and context menu. A
board file's temp mapping moves to the new board path, or ends when the
copy is saved to this computer. Its path rules live in saveAs.ts with
node:test unit tests, now run in CI.

Browser: a Save As button (Ctrl+Shift+S) and dialog; panel.py's
save_file_as mirrors the extension's checks.
# Conflicts:
#	cli/src/mpftp/webui/app.css
@bdbarnett
bdbarnett merged commit 982a904 into main Oct 8, 2026
4 checks passed
@bdbarnett
bdbarnett deleted the save-as branch October 8, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant