dsh-enter-guard: Prevent Accidental Messages by Pressing Enter Twice

Introduction

In the DeepSeek Harness (DSH) Web client, the input box sends directly with Enter by default. When writing long prompts or editing drafts, an extra press of Enter sends the entire unfinished content — wasting a conversation turn and potentially handing half-finished instructions to the agent.

DSH can be configured under Settings → General → Enter behavior: when the agent is busy, Enter either queues or steers. This setting targets only behavior in the “busy” state; accidentally pressing Enter while idle still sends immediately, with no confirmation step. Draft-related plugins in the community catalog (such as staging, scheduled sending, pre-send rewriting, etc.) also do not intercept the keyboard Enter.

The following introduces the client plugin dsh-enter-guard published by maintainer Liyu147: the first Enter only “arms” the input area and prompts that a second press is required to send; only the second Enter actually sends; pressing any other key during this period disarms it. The goal is to prevent accidents such as “half-written messages being sent by a stray Enter.”

What Is This

dsh-enter-guard is a Double-Enter send guard for DSH Web. It is categorized as a client plugin; the current package version is 0.1.0, licensed under MIT. Repository: https://github.com/Liyu147/dsh-enter-guard; Community catalog page: https://www.skillhub.cn/plugins/Liyu147/dsh-enter-guard.

The plugin does not modify draft content, does not call setDraft, and does not touch the attachment pipeline; it only listens for key presses at the DOM layer, making it a read-only interaction enhancement. Upon uninstall or failure, it should restore DSH’s native Enter behavior.

Core Behavior

The overall state machine can be summarized as:

Type text ──▶ Enter ──▶ Not sent, input area outlined, prompt "Press Enter again to send"
                     │
                     ├── Enter again ──▶ Send
                     └── Any other key ──▶ Disarm, return to normal

The main rules, consistent with the behavior table in the README, are as follows.

Case Result
First Enter (no modifier keys, not IME composition, not long-press repeat) Intercepted — input area outlined and prompt shown
Pressing Enter again while armed Passed through, sent by DSH’s native logic
Pressing any other key while armed (letters, numbers, Backspace, arrow keys, Shift, Ctrl, etc.) Disarms immediately
Draft change, IME composition start, focus loss, click outside Disarms
Ctrl/Cmd+Enter, clicking Send Sends immediately, bypassing double-Enter (a deliberately kept escape hatch)
When the / command menu or @ file menu is open Not intercepted; Enter selects a candidate
Long-pressing Enter (repeat) Ignored; does not trigger sending on its own
Empty draft (no text, no attachments) Not intercepted
About 2 seconds after arming Prompt fades out, state is retained, later Enter can still send

The README notes that a catalog scan of approximately 6084 DSH plugins found no similar Enter-intercepting plugin; nearby capabilities mostly focus on draft staging, queue enhancement, scheduled sending, or pre-send rewriting, rather than blocking the first Enter.

Installation and Activation

Not yet published to npm; it must be installed from the source directory (commands excerpted from the repository README).

git clone https://github.com/Liyu147/dsh-enter-guard.git
dsh plugin --profile web add ./dsh-enter-guard

If you already have a local checkout, you can point add at the directory path:

dsh plugin --profile web add /path/to/dsh-enter-guard

After installation you need to restart dsh web. Simply refreshing the page is not enough — the client bundle is resolved at startup.

Uninstall:

dsh plugin --profile web remove dsh-enter-guard

In the browser DevTools console you can check whether the plugin is mounted:

__dshEnterGuard.instance.inspect()
// => { version, mounted: true, armed: false, hasCard: true, everBlocked: false, ... }

hasCard: false means the composer anchor was not found; see the compatibility notes. everBlocked becomes true after the plugin actually swallows an Enter, which verifies that the key path is effective end-to-end.

Typical Usage and Self-Test Checklist

Daily writing flow: type content in the composer → first Enter shows the outline and a “press Enter again to send”-style prompt → press Enter again to send after confirming; if you accidentally press the first Enter, continue typing or press any non-Enter key to disarm.

Manual regression checks suggested by the README include:

  1. / opens the command menu → Enter should select a candidate, not enter the double-Enter flow.
  2. @ opens the file menu → Enter should insert the reference.
  3. Shift+Enter → inserts a line break, with no outline arming.
  4. Ctrl+Enter → sends immediately.
  5. Enter while the agent is busy → still queues or steers according to the global setting.
  6. Enter after pasting an image → the attachment should be sent with the message.

The development repository provides two zero-dependency Node test scripts (test_guard_enter_send_v1.js, test_client_bundle_v1.js) in the package parent directory, used for automated cases covering the state machine and the packaged bundle; they are not included in the published tarball and should be run locally on demand after checkout.

Compatibility and Known Limitations

The plugin locates elements via data attributes on the DSH Web client (dsh-client-ui-conversation), such as [data-composer-card], [data-composer-input], [data-trigger-menu], [data-composer-chip]. If DSH renames these selectors in the future, the plugin is designed to be fail safe: it becomes a no-op and restores native Enter behavior, without swallowing messages; about 5 seconds after startup, if anchors are missing, it warns in the console.

The README records that verification was performed under DSH 0.1.5-rc.3 on Windows / Chrome.

Known limitations (excerpted from the README):

  1. Only intercepts keyboard Enter; the Send button and Ctrl/Cmd+Enter always send immediately.
  2. Cannot prevent plugins that call submit() directly (e.g., some voice input auto-send).
  3. Depends on DOM anchors; not verified on mobile virtual keyboards (keydown may not fire).
  4. Assumes a single composer card (takes the first match); the standard single-session UI is unaffected.

Security and Permissions

The implementation is read-only DOM: document-level listeners for keydown / input / compositionstart / focusout / click, injecting a style block and a floating prompt div. No network requests, no localStorage / cookies, no writes to sessions or settings; the host side is a thin shell. The decision code is wrapped in try/catch; on internal errors it fails open, restoring native key behavior.

DSH plugins run within the current dsh process and the Web client context. Before installing, read the source code and the MIT license yourself to confirm they meet your security and compliance requirements; the community catalog site has no official affiliation with DeepSeek / High-Flyer and should not be treated as an official app store.

Conclusion

dsh-enter-guard closes the gap left by DSH’s lack of send confirmation in the idle state, using the lightweight rule “first Enter arms, second sends, any other key cancels”, while deliberately keeping Ctrl/Cmd+Enter and Send as explicit send paths. If you frequently write long prompts in the composer, install it into the Web profile using the commands above, restart dsh web, and use inspect() plus the six manual checks to confirm the behavior meets expectations.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye