Enter Newline Plugin: Enter Inserts Newline, Ctrl/Cmd+Enter Sends

Introduction

DeepSeek Harness (DSH) sends the draft by default when Enter is pressed, which makes it easy to accidentally send a message when frequently switching input modes during long conversations. The Enter Newline plugin takes over the send key in the input box, remapping Enter to insert a newline by default, and delegates sending to Ctrl/Cmd+Enter (interject) and Shift+Enter (queue).

The plugin does not replace the input box, does not read or write draft content, and does not directly invoke the send button. It simply replays key events as gestures the composer already recognizes, so attachments, quotes, command chips, undo history, and IME composition states all follow DSH’s original implementation.

Plugin Overview

Maintained by Librorum545 and classified as a client-side plugin, the core consists of two global configuration presets:

  • Plugin configuration (default): Enter inserts a newline, Ctrl/Cmd+Enter sends as interject, and Shift+Enter sends as queue. Each of the three keys can be individually reassigned to “newline / interject send / queue send” on a dedicated settings page. On save, the plugin validates that “at least one key is mapped to newline and at least one key is mapped to send.”
  • Default configuration: Hot-disables the plugin; all three keys are handed back to DSH, and the plugin stops intercepting key events entirely.

Switching between the two configurations takes effect immediately and is written to disk — no save or restart required.

Installation & Activation

Install via npm:

dsh plugin --profile web add dsh-enter-newline

Install from GitHub source (pinning a commit is recommended):

dsh plugin --profile web add github:Librorum545/Enter_Newline#<commit>

On the desktop client, enter dsh-enter-newline in the install field under Settings → Plugins. The first installation (adding a new Host plugin entry) requires a desktop client restart; subsequent client.js updates do not require a restart — DSH 0.2.x’s client-hmr will hot-load the change.

Requires DSH >=0.2.2-rc.5 <0.3.0-0.

Typical Usage

After installation, a new settings page titled “Enter Newline” appears in DSH settings (immediately after General). The top of the page displays the currently active key mapping, and below are two configuration cards:

  • Default configuration: Hot-disables the plugin and returns all keys to DSH.
  • Plugin configuration: Customize the mapping for all three keys; changes take effect immediately upon saving.

Under the Plugin configuration, each key’s dropdown allows selecting “newline / interject send / queue send.” Clicking “Restore Plugin Preset” resets to the default mapping in one click.

Implementation Details

The plugin intercepts the three Enter combinations at the browser window capture phase and replays them as gestures the composer already recognizes, according to the active configuration and mapping:

  • Newline: Replays a Shift+Enter keydown; the composer’s Lexical keymap inserts a newline node.
  • Interject / Queue: Replays a plain Enter or Ctrl+Enter keydown. The plugin reads DSH’s current “Enter when busy” setting (busyEnter in ui-conversation) and picks the appropriate gesture accordingly, ensuring the “interject/queue” semantics are not affected by user setting changes.
  • Default configuration: No events are replayed.

The plugin does not directly invoke the send button, nor does it read or write draft content. Attachments, quotes, command chips, undo history, and IME composition states all follow the original implementation.

IME Safety

DSH’s keymap has a 10 ms composition-check window after compositionend (Safari dispatches the closing keydown after compositionend). The plugin listens for composition events and, within this 12 ms window, defers “send-type” replays until the window ends before dispatching; newline replays are unaffected. This ensures that pressing send immediately after confirming a Chinese IME candidate does not lose the keypress, and a send cancelled by Esc will not be dispatched.

Completion Menu Three-State Handling

The plugin only checks for a visible [data-trigger-menu] (and the legacy [data-composer-overlay] [role="listbox"]) inside [data-composer-card]:

  • If a highlighted candidate exists, Enter is consumed by menu selection.
  • If the menu is visible but no candidate is highlighted, DSH would interpret Enter as submit — the plugin swallows it (no send, no newline).
  • Only when no menu is present does the plugin execute the mapped action.

A visible listbox elsewhere on the page does not disable the three keys in the current input box.

Anchor Failure Fail-Safe

If a DSH revision causes [data-composer-input] to no longer exist, the plugin logs a one-time warning and swallows send-type Enter (including Ctrl/Cmd+Enter) within the input card, while Shift+Enter is still handled by the host for newline. The design philosophy is: “prefer Enter doing nothing over sending a half-finished draft.”

All Composer Surfaces

The main input box and sub-agent sessions in the right sidebar are treated identically. Only the front-end key mapping is changed; the Host’s delivery semantics remain unaltered.

When dsh-better-sidebar is installed, the settings page displays (read-only) the sidebar’s current send key and provides a “Follow This Plugin’s Mapping” toggle. When enabled, this plugin’s Enter semantics are projected into the sidebar’s own settings (Enter newline → sidebar switches to Ctrl/Cmd+Enter for sending). Everything goes through the sidebar’s own key implementation — no key hijacking, no input box replacement.

Observability & Migration

The plugin exposes a diagnostics entry point:

window.__dshEnterNewline.getStatus()      // current state snapshot
window.__dshEnterNewline.getBindings()    // current three-key mapping
window.__dshEnterNewline.inspect()        // formatted JSON of the snapshot

The settings page provides a “Copy Diagnostics” button for one-click snapshot copying when filing an issue. Configuration supports JSON export/import; mappings are stored in the browser locally (localStorage keys composer-enter-newline:bindings:v1 and composer-enter-newline:preset).

Hot Reload

This plugin has only a browser-side component. DSH’s client-hmr polls each loaded plugin’s client.js every 500 ms by default; upon detecting a file change it publishes a new artifact revision and notifies the page via SSE. After the page receives the rebuilt event, it reloads the plugin. When installed via link:, saving a modified client.js means the current page picks up the new code in about half a second — no disable/re-enable cycle needed, and no restart required.

Slash Command Handling

/ commands do not all execute on Enter. DSH categorizes them into four types, plus a “not a command at all” case:

Command Type Example Result of pressing Enter
Client action (no args) /file Executes immediately: strips /file from the draft, opens the file picker, no model turn is generated
Opens a selector /model Opens a selector overlay, no execution; takes effect only after a selection is made
Host bare command (no args) /compact Executes immediately (run by DSH within the session), no model turn is generated
Command requiring arguments /goal, /feedback Does not execute: /goal becomes a command chip (data-phase="claimed"); executes only after arguments are completed and submitted
Unregistered name /zzz Matches no command; sent as a plain text message to the model

Only a / at the beginning of a line counts as a command; /xxx appearing mid-line is plain text. Commands that require arguments become chips as soon as a space is pressed. Once a chip is formed, Enter under this plugin’s configuration still inserts a newline — use Ctrl/Cmd+Enter or the send button to submit the command.

When switched to the “Default configuration,” all of the above behaviors are determined entirely by DSH, and the plugin does not intervene.

Use Cases

Ideal for users who want Enter to insert a newline and prefer sending via a modifier key combination — especially when frequently composing multi-line drafts and wanting to avoid accidental sends. The plugin runs with the current DSH process’s permissions; it is recommended to review the source code and license before installing.

Disabling & Removal

  • Temporary disable: Switch to “Default configuration” on the settings page. All three keys immediately revert to native behavior — no restart needed.
  • Full removal: Disable or remove this plugin from the Plugins panel. Disabling immediately removes the key interception and the settings page; re-enabling reloads the browser-side component.

Ecosystem Context

DSH’s philosophy is “everything is a plugin.” The community directory is an independent site with no official affiliation to DeepSeek / High-Flyer. The Enter Newline plugin described in this article is maintained by the community. Details are available on the community directory:
- Community directory page: https://www.skillhub.cn/plugins/Librorum545/Enter_Newline
- GitHub repository: https://github.com/Librorum545/Enter_Newline

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

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

Xiaoye