Skip to content

feat(cmdsender): file upload support for BLOCK params and Send Raw File#3375

Open
ryanmelt-agent wants to merge 2 commits into
OpenC3:mainfrom
ryanmelt-agent:feature/ope-21-cmdsender-file-uploads
Open

feat(cmdsender): file upload support for BLOCK params and Send Raw File#3375
ryanmelt-agent wants to merge 2 commits into
OpenC3:mainfrom
ryanmelt-agent:feature/ope-21-cmdsender-file-uploads

Conversation

@ryanmelt-agent
Copy link
Copy Markdown

Summary

Resolves #59 by adding two upload affordances to the Command Sender:

  • BLOCK parameter Upload Data right-click menu. In the Command Editor parameter table, right-clicking a row whose parameter is BLOCK now adds an Upload Data entry alongside Details. Selecting it opens a hidden file input; the file is read with FileReader.readAsArrayBuffer, the bytes are encoded as 0x<HEX>, and the value is written back into the row. The existing convertToValue BLOCK branch already turns that hex string into the json_class: 'String' payload the API expects.
  • File > Send Raw File menu option. Wires up the previously stubbed Send Raw dialog in CommandSender.vue. The menu now fetches get_interface_names, presents the dialog with the existing interface picker + file input, reads the chosen file, and POSTs to send_raw(interface_name, jstr). Status feedback flows through the existing status pipeline.

Upload Data is only offered for BLOCK parameters, so other rows behave exactly as before. No new dependencies. The reading code reuses the same Uint8Array / json_class: 'String' shape the rest of the tool uses for BLOCK data and matches the original draft that the file already shipped commented-out.

Test plan

A new parallel Playwright test (playwright/tests/command-sender.p.spec.ts) covers both features against the existing INST demo target:

  • uploads data into a BLOCK parameter via right-click — selects INST MEMLOAD, right-clicks the DATA BLOCK row, supplies a 4-byte payload via filechooser, and asserts the field becomes 0xDEADBEEF. Then checks that INST COLLECT's non-BLOCK DURATION row does not show the new menu entry.
  • opens the Send Raw File dialog and lists interfaces — opens File > Send Raw File, asserts the dialog appears with the file input, cancels, and checks Raw command not sent status.
  • pnpm lint --max-warnings 0 passes for both openc3-cosmos-tool-cmdsender and openc3-vue-common.

Fixes #59

🤖 Generated with Claude Code

Adds two CmdSender enhancements requested in OpenC3#59:

- Right-clicking a BLOCK parameter row in the Command Editor now offers
  an "Upload Data" entry. Selecting it opens a file picker, reads the
  file as bytes, and fills the parameter with the matching 0x... hex
  string that convertToValue already understands for BLOCK fields.
- The previously stubbed "Send Raw File" menu option under File is now
  wired up: it fetches the available interfaces, prompts for an
  interface and file, and ships the bytes via OpenC3Api.send_raw.

Includes a parallel Playwright test covering the BLOCK upload path
against INST MEMLOAD and the Send Raw dialog open/cancel flow.

Fixes OpenC3#59

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Replace FileReader + index-style for loops in the new BLOCK upload and
Send Raw File paths with Blob#arrayBuffer() and for-of iteration, and
drop the obsolete `self = this` aliasing in favor of `async sendRawCmd`.

- CommandEditor.onBlockUploadFile is now async and reads the file via
  await file.arrayBuffer(); the hex encode loop uses for-of.
- CommandSender.setupRawCmd builds the interface list via Array#map.
- CommandSender.sendRawCmd is now async, reads the file via
  Blob#arrayBuffer(), and calls send_raw inline; the helper onLoad and
  the FileReader pattern are removed entirely.

Behavior is unchanged; only fixes the 6 SonarQube findings
(javascript:S4138, javascript:S7740, javascript:S7756).

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@sonarqubecloud
Copy link
Copy Markdown

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.82%. Comparing base (a5e2697) to head (f12f03b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3375      +/-   ##
==========================================
- Coverage   78.86%   78.82%   -0.05%     
==========================================
  Files         687      687              
  Lines       57266    57264       -2     
  Branches      728      728              
==========================================
- Hits        45164    45137      -27     
- Misses      12024    12049      +25     
  Partials       78       78              
Flag Coverage Δ
python 80.03% <ø> (-0.01%) ⬇️
ruby-api 81.80% <ø> (-0.55%) ⬇️
ruby-backend 82.26% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@EmilyRagan
Copy link
Copy Markdown
Contributor

@ryanmelt-agent The newly created "opens the Send Raw File dialog and lists interfaces" Playwright test fails on this branch in CI

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CmdSender support file uploads

3 participants