Skip to content

Offer Enter or Shift+Enter to send from Settings (#3114) - #3168

Merged
Birfy merged 2 commits into
mainfrom
feat/3114-send-key
Nov 18, 2026
Merged

Birfy merged 2 commits into
mainfrom
feat/3114-send-key

Conversation

@Birfy

@Birfy Birfy commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #3167
Part of #3114 (the umbrella stays open — this slice closes its own issue).

Owner: Dev
Reviewer: Reviewer
Written-by: Dev
Tier: T1 — the tier the enqueue-guard computed from this diff

What changed

  • Settings → General → Shortcuts (core/src/client/settings.js): a writable window gets a two-button picker, Enter to send (the default, keeping the shell's habit) or Shift+Enter to send; the other key starts a new line. The choice is written to this window's localStorage (flybot-send-key), not to team state, so there is no host field and no cross-device sync. A read-only window draws one text row naming the choice instead of a picker.
  • Composer (core/src/client/composer.js): SEND_KEYS/normalizeSendKey/readSendKey/writeSendKey, the pure shouldSendOnKey/shouldBreakOnKey predicates (IME composition, the legacy keyCode 229, and Ctrl/Cmd/Alt pass through), findSendButton (marker first, then the Send label, excluding dictate/mic/voice/add/plus/stop), insertComposerNewline (value field splice; the Lexical contenteditable takes insertLineBreak → insertParagraph → insertText), and installSendShortcut, one capture-phase window listener mounted by ComposerVoice. Shift+Enter clicks the card's own Send button; Enter inserts the break; a disabled or absent Send (a running turn's Stop, a read-only composer) leaves the key to the shell.
  • i18n (core/src/client/i18n.js): five zh keys (Shortcuts, Send shortcut, Enter to send, Shift+Enter to send, and the sentence under the row).
  • Tests (core/test/settings-readonly-pages.test.js, on the existing harness — no new test file): the localStorage stub becomes a writable Map, the virtual entry exports the three composer functions, and five cases are added — two Settings cases (writable picker + stored choice, read-only text) and three composer cases (Shift+Enter sends and Enter breaks; Enter-to-send leaves the key alone; a missing/disabled Send or a locked field is left alone). The writable-control count goes 6 → 7.
  • Docs/changelog: one line in docs/subsystems/core-client.md (the composer's own page) and changelog.d/3114-send-key.added.md.

Not in this cut: light/dark/auto/system mode (the shell's theme service owns data-ds-dark-theme), the Grove palette / --bt-selected, language, folding, Channels, and persisting the key through the host (core/src/host/channel.js is a T3 path and setPrefs silently drops unknown fields). patches/ds-bot/topics.json is untouched (no new source file).

Verification at the tip

Tip SHA: bc469a433c794c97e6e1540fd01981f2653b8380
Base: 483fb8fe2696b4e79735a505af77a878ce705423 (live origin/main when the branch was cut; main was still that sha when the branch was pushed)

Ran:

  • cd core && node --import ./test/harness-resolve.mjs --test test/settings-readonly-pages.test.js before the implementation (test changes only) → # tests 10 / # pass 7 / # fail 3, red on General keeps its four switches beside the send-key picker (6 !== 7), the choice has its own section, and the page still names the setting.
  • The same command after the implementation → # tests 13 / # pass 13 / # fail 0.
  • cd core && node scripts/build-client.mjs then node core/scripts/build-client.mjs --check → exit 0 (core/client.js 24122 → 24252 lines, +130).
  • node scripts/ds-bot-patches.mjs generate → wrote files/ (429 files) + 10 patches, exactly the 5 expected generated paths changed; node scripts/ds-bot-patches.mjs check → ok 10 patches apply cleanly in order · ok core/ equals ds-bot/ + patches/ds-bot/; node scripts/ds-bot-patches.mjs canonical → ok patches/ds-bot/ is what generate writes (generate is a no-op). This machine has no git in PATH; the repo's own gates ran with the bundled git 2.53.0 at /data/dsh/bot/workspace/tools/git (bin + GIT_EXEC_PATH), and canonical was green here, not deferred to the tip CI.
  • TZ=UTC TMPDIR=/data/flybot-tmp npm run verify → exit 0 (core 3309 tests: 3308 pass, 1 skipped; every plugin suite, core lint with 89 warnings / 0 errors, arch-docs OK on 12 files, both -checks, canonical, and the interop/live-e2e suites green).
  • Focused regression: settings-polish, settings-page-keys, client-bundle, composer-send-readonly, i18n, i18n-missing-entries → 38/38.

Not run (and why):

  • A real-browser click-through of the composer path. The unit cases drive the real components through the existing esbuild/vm harness, but the card there is a mock, so the hand-check list for this PR is: in a real composer card, [data-composer-card] must yield the Send button by aria-label/title/textContent; pressing Shift+Enter with Shift+Enter to send chosen must actually send; pressing Enter must insert a line break. That structure assumption is not covered by a unit test, so a break there shows up as a silent non-send, not an error.
  • The smoke bench (core/dev/bench.sh): no host, index.js or turn-pipeline change.

Checkpoint

{
"pr": 3168,
"claim": "Dev",
"issue": 3167,
"summary": "General → Shortcuts now offers Enter to send (the default) or Shift+Enter to send, stored for this window only. The composer reads that choice at each key press: Shift+Enter presses the card's own Send button, Enter inserts a line break, and a disabled or missing Send falls back to the shell. A read-only window names the choice instead of drawing a picker, and the five zh keys cover the new copy. The suite adds three UI cases and three composer cases to the existing Settings harness, 13/13 after the implementation (10/7/3 red first).",
"files": [
"core/src/client/composer.js",
"core/src/client/settings.js",
"core/src/client/i18n.js",
"core/test/settings-readonly-pages.test.js",
"docs/subsystems/core-client.md",
"changelog.d/3114-send-key.added.md",
"core/client.js",
"patches/ds-bot/0001-core-fixes.patch",
"patches/ds-bot/0008-client-bundle.patch",
"patches/ds-bot/0012-room-membership.patch",
"patches/ds-bot/0014-flybot-branding.patch",
"patches/ds-bot/files/test/settings-readonly-pages.test.js"
],
"checks": { "ran": "TZ=UTC TMPDIR=/data/flybot-tmp npm run verify", "result": "green", "at": "bc469a433c794c97e6e1540fd01981f2653b8380" },
"next": "none — ready for review"
}

The cases drive the General page main has today: the writable page draws six
controls and no Shortcuts section, and the read-only page never names the
send key. They fail until composer.js carries the choice and settings.js
draws it.

Part of #3114 (the umbrella stays open — this slice closes its own issue).
General → Shortcuts picks which key sends: Enter keeps the shell's habit,
Shift+Enter flips it so Enter starts a new line. The choice is this window's
own (localStorage) — no host field, no cross-device sync — and the composer
presses the card's own Send button or inserts the line break in a capture
listener. A read-only window names the choice instead of drawing a picker.

Fixes #3167
Part of #3114 (the umbrella stays open — this slice closes its own issue).
@Birfy Birfy added the agent-pr Pull request opened by an agent label Nov 18, 2026
@Birfy Birfy self-assigned this Nov 18, 2026
@Birfy

Birfy commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

Verdict: PASS at bc469a4
Written-by: Reviewer
Attestation: bc469a4 role=Reviewer

Ran at this tip:

$ cd core && node --import ./test/harness-resolve.mjs --test test/settings-readonly-pages.test.js
# tests 13  # pass 13  # fail 0
$ for t in settings-polish settings-page-keys client-bundle composer-send-readonly i18n i18n-missing-entries; do node --import ./test/harness-resolve.mjs --test test/$t.test.js; done
# tests 38  # pass 38  # fail 0
$ cp base_settings.js core/src/client/settings.js && node --import ./test/harness-resolve.mjs --test test/settings-readonly-pages.test.js
# tests 13  # pass 10  # fail 3
$ node core/scripts/build-client.mjs --check; echo $?; node scripts/ds-bot-patches.mjs check; node scripts/ds-bot-patches.mjs canonical
# 0 / ok 10 patches apply cleanly in order / ok patches/ds-bot/ is what generate writes (generate is a no-op)

Read at 2026-11-18T13:40Z on the tip tarball bc469a4 (base 483fb8f = live main).

Red first. Reverting only core/src/client/settings.js to the base blob takes the suite to 10/7/3, and the three reds are the three the erratum names: a writable window keeps every page as it is today (#2474) on General keeps its four switches beside the send-key picker (6 !== 7), General offers Enter or Shift+Enter to send… on the choice has its own section, a read-only window names the send shortcut… on the page still names the setting. Reverting all three sources crashes the harness at the missing installSendShortcut/shouldBreakOnKey/shouldSendOnKey export — i.e. the reds are the change, not the environment.

Range. /pulls/3168/files = 12 files; handwritten (excluding core/client.js and patches/**) +275/−3 = 278 (composer +117, settings +20, i18n +5, test +131/−3, docs +1, changelog +1); generated core/client.js +130/−0 (24122 → 24252, installSendShortcut and flybot-send-key present in the bundle). No .github/**, no policy/**, no core/src/host/**, no core/src/shared/**.

Behaviour against the anchors. settings.js: import is SEND_KEYS, readSendKey, writeSendKey from composer; state sits after [custom, setCustom]; the writable Shortcuts SetSection lands after the accent block's closing input type="color" line and before the // One switch for every system notification (#353) comment, so that comment still belongs to Notifications; the read-only branch draws one Send shortcut row and no picker; the picker is Segmented with label: t('Send shortcut'), which motion.js:147 renders as role=group aria-label. composer.js: SEND_KEYS/normalizeSendKey/readSendKey/writeSendKey/shouldSendOnKey/shouldBreakOnKey/installSendShortcut all exported; plainEnter bails on metaKey|ctrlKey|altKey and on isComposing/nativeEvent.isComposing/keyCode 229/which 229; listener is addEventListener('keydown', onKey, true) mounted once per composer and reads the key at each press; the Send button is looked up only inside field.closest('[data-composer-card]') and a disabled/absent Send falls through to the shell. i18n.js: exactly 5 zh keys added; docs one line.

Tests. The localStorage stub is a writable Map; the virtual entry and the destructure both gain installSendShortcut/shouldBreakOnKey/shouldSendOnKey. The only edit to an existing case is counts(general) 6 → 7 plus one new assertion that the Send shortcut Segmented is drawn — the count moves because isControl counts the new widget, not because a judgement was relaxed; the other existing cases are untouched.

Gates. build-client --check exit 0, ds-bot-patches check ok (10 patches apply cleanly, core/ equals ds-bot/ + patches), ds-bot-patches canonical ok on this machine (git 2.53.0), matching the PR body's Ran: — nothing deferred to CI.

CI on the tip. 19 check-runs, all terminal, none failing (tests-ok, package, the five plugin jobs, merge-gate, enqueue-guard, judge, agent-audience, policy-sign all success; two cancelled runs are the superseded duplicates of judge/agent-audience, each of which also has a success; live and window check skipped by design).

Not covered, and it is the hand-check item. The unit card is a mock, so "a real [data-composer-card] yields the Send button and Shift+Enter actually sends" is not asserted; a break there is a silent non-send, not an error. Belt-and-braces for whoever clicks it before/after merge.

@Birfy
Birfy added this pull request to the merge queue Nov 18, 2026
@github-actions github-actions Bot added the pass label Nov 18, 2026
Merged via the queue into main with commit 8b9e249 Nov 18, 2026
17 of 19 checks passed
@Birfy
Birfy deleted the feat/3114-send-key branch November 18, 2026 13:39
@github-actions github-actions Bot removed the agent-pr Pull request opened by an agent label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#3114] 发送快捷键:General 里选 Enter 还是 Shift+Enter 发送

1 participant