Fix bare-host connections and input handling; add history and Ctrl+R - #170
Open
WietseWind wants to merge 6 commits into
Open
Fix bare-host connections and input handling; add history and Ctrl+R#170WietseWind wants to merge 6 commits into
WietseWind wants to merge 6 commits into
Conversation
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.
Fixes
Assume
ws://when the connection address has no protocol.wscat -c localhost:4000now works. Keep explicit protocols, paths, and queries.Fix paste at the cursor on Node.js 24, including macOS. Keep the text before
and after the cursor. Preserve Unicode and handle split UTF-8 input.
Bracketed paste also works during history search.
Make Ctrl+C clear input or history search text first. Keep the connection
open and return to an empty prompt. Ctrl+C at an empty prompt closes the
session. Cancelled text is neither sent nor saved.
Additions
~/.wscat_historyfor global npm and Bun installations.Load the last 1,000 entries. Append each command when submitted so sessions
can share the file.
--historyfor local runs and--no-historyto turn file storage off.If detection or file access fails, continue silently with history in memory.
the command. Escape selects it for editing. Ctrl+G cancels the search.
Search also works with history in memory.
Demo
Full recording: 49 seconds, 2 MB GIF (compressed from 32 MB).
Security overview
No npm packages were added or removed. No unused dependency was introduced.
The existing packages and versions are unchanged:
commanderparses options,https-proxy-agenthandles proxies,readprompts for passphrases, andwshandles WebSocket connections.
The changes use built-in Node.js modules:
os,pathstreamPassThrough.fsreadlineThese modules ship with Node.js. They need no extra npm downloads or install
scripts. Installation detection does not run npm or Bun. Reading or searching
history does not execute its text. The tests use Node's test runner and
assertions. Only tests use
child_processto start local CLI processes.0600where Unix permissions apply. Existing permissions stay unchanged. Normal
filesystem rules apply, including following symbolic links.
--no-historyfor sensitive data. Local runs need--historyto use thefile. Piped input/output and
--executedo not use it. File errors do not stopthe session.
history, but startup reads the full file. Users can trim or delete it.
ws://, which is not encrypted. Usewss://for TLS.The change does not alter TLS checks or send data to new services.
Validation
All 69 tests pass on Node.js 18.20.8 and 24.11.1. Tests cover URL handling,
paste, Unicode, saved history, Ctrl+R search, and Ctrl+C cancellation.
Installed the packed package globally. Checked bare host connections,
paste into JSON, Unicode, and pasted search text in a macOS terminal.
Tests used a local WebSocket server and temporary home directories.
Checked Ctrl+C in the global install with a real macOS terminal. Drafts,
recalled commands, and searches clear without closing the connection.
A second Ctrl+C closes the empty prompt. Cancelled text is not saved.