feat(cmdsender): file upload support for BLOCK params and Send Raw File#3375
Open
ryanmelt-agent wants to merge 2 commits into
Open
feat(cmdsender): file upload support for BLOCK params and Send Raw File#3375ryanmelt-agent wants to merge 2 commits into
ryanmelt-agent wants to merge 2 commits into
Conversation
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>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
|
@ryanmelt-agent The newly created "opens the Send Raw File dialog and lists interfaces" Playwright test fails on this branch in CI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Resolves #59 by adding two upload affordances to the Command Sender:
Upload Dataentry alongsideDetails. Selecting it opens a hidden file input; the file is read withFileReader.readAsArrayBuffer, the bytes are encoded as0x<HEX>, and the value is written back into the row. The existingconvertToValueBLOCK branch already turns that hex string into thejson_class: 'String'payload the API expects.Send Rawdialog inCommandSender.vue. The menu now fetchesget_interface_names, presents the dialog with the existing interface picker + file input, reads the chosen file, and POSTs tosend_raw(interface_name, jstr). Status feedback flows through the existing status pipeline.Upload Datais only offered for BLOCK parameters, so other rows behave exactly as before. No new dependencies. The reading code reuses the sameUint8Array/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 viafilechooser, and asserts the field becomes0xDEADBEEF. 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 checksRaw command not sentstatus.pnpm lint --max-warnings 0passes for bothopenc3-cosmos-tool-cmdsenderandopenc3-vue-common.Fixes #59
🤖 Generated with Claude Code