- Notifications
You must be signed in to change notification settings - Fork 15
made command-text clear after submitting #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
made the command-text clear after submitting
WalkthroughThe changes update the frontend's command input behavior and synchronize the embedded HTML data in the backend. The frontend now clears the command input field after sending a command via websocket. Correspondingly, the backend's embedded HTML byte array and its size constant have been updated to reflect the new HTML content. No other logic or public interface changes are present. Changes
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/WebSerialWebPage.h (1)
5-83: Improve maintainability of embedded HTML.
Embedding the full gzipped HTML by hand is fragile. To keep the header in sync withfrontend/index.html, you could:
- Add a build script (Makefile, Python, etc.) that gzips and converts
index.htmlinto this byte array automatically.- Optionally include a verification step that decompresses the PROGMEM data and diffs it against the source HTML to catch mismatches early.
Let me know if you’d like assistance generating the embedding script.
frontend/index.html (1)
296-298: Enhance input handling after send.
To further streamline command entry and avoid accidental whitespace:-function sendCommand() { - const input = document.getElementById("command-text"); - websocket.send(input.value); - input.value = ""; -} +function sendCommand() { + const input = document.getElementById("command-text"); + const cmd = input.value.trim(); + if (cmd) { + websocket.send(cmd); + input.value = ""; + input.focus(); + } +}This trims leading/trailing spaces and returns focus to the text field for rapid successive commands.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
frontend/index.html(1 hunks)src/WebSerialWebPage.h(1 hunks)
🔇 Additional comments (1)
frontend/index.html (1)
296-298: Clear input field after sending command.
The updatedsendCommandfunction now retrieves the input element, sends its current value, and then resets it—clearly improving the UX by readying the field for the next entry.
| #ifndef _webserial_webapge_h | ||
| #define _webserial_webpage_h | ||
| const uint32_t WEBSERIAL_HTML_SIZE = 2322; | ||
| const uint32_t WEBSERIAL_HTML_SIZE = 2329; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Automate HTML size constant.
Maintaining a manual WEBSERIAL_HTML_SIZE is error-prone and can easily drift out of sync with the actual array length. Consider computing it at compile time, for example:
const uint32_t WEBSERIAL_HTML_SIZE = sizeof(WEBSERIAL_HTML);Or add a static_assert to validate the size matches the array:
static_assert(WEBSERIAL_HTML_SIZE == sizeof(WEBSERIAL_HTML), "HTML size mismatch");
just changed index.html in frontend and WebSerialWebPage.h in src
Summary by CodeRabbit
New Features
Bug Fixes