fix(coding-agent): keep custom-editor Enter submissions from being dropped - #908
fix(coding-agent): keep custom-editor Enter submissions from being dropped#908Tinycute00 wants to merge 1 commit into
Conversation
…opped The custom-editor submit bridge in setCustomEditorComponent() expanded the submission via expandEditorSubmission(), which prefers the editor's live getExpandedText() over the passed text. pi-tui's Editor.submitValue() clears the editor state and paste registry BEFORE invoking onSubmit, so any custom editor implementing getExpandedText() (e.g. pi-voice-stt's wrapper around the pi-tui Editor) was re-read as "" and the submission was silently discarded: Enter cleared the prompt and nothing was sent. Add expandSubmittedText() — paste-marker expansion against the passed, authoritative text with no live editor re-read — and use it at the submit call site. The live-draft read path (getExpandedEditorText) keeps the existing getExpandedText() preference.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4bf8bbd3d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -0,0 +1,48 @@ | |||
| import type { EditorComponent, EditorPasteState } from "@earendil-works/pi-tui"; | |||
There was a problem hiding this comment.
Move the regression into the designated regression suite
This file specifically covers the dropped custom-editor submission regression, but it is added at the test root rather than under test/suite/regressions/, splitting related coverage from the existing editor-paste regression tests and violating the repository's required placement. Move these cases into a suitably named regression file in that directory, preferably alongside 0000-editor-paste-submit.test.ts.
AGENTS.md reference: packages/coding-agent/test/AGENTS.md:L40-L40
Useful? React with 👍 / 👎.
| export function expandSubmittedText(editor: EditorComponent, text: string): string { | ||
| const pasteState = editor.getPasteState?.(); | ||
| return pasteState ? expandPasteMarkers(text, pasteState) : text; |
There was a problem hiding this comment.
Preserve submit-time expansion for uncleared custom editors
When a custom EditorComponent invokes onSubmit before clearing its draft and relies on the optional getExpandedText() method to turn its own markers into submitted content, this helper now ignores that valid expanded value and forwards the raw callback text unless the component also exposes pi-tui paste state. The previous bridge supported this extension pattern, so such editors will silently submit marker placeholders after this change; use the passed text only when the live expanded read shows that the editor has already been cleared rather than unconditionally bypassing getExpandedText().
Useful? React with 👍 / 👎.
| @@ -1,5 +1,25 @@ | |||
| # changes | |||
|
|
|||
| ## Custom-editor Enter submissions are no longer dropped (2026-08-16) | |||
There was a problem hiding this comment.
Mirror the behavior change in the root change record
This new fork-visible behavior is recorded only in the nested interactive changes.md; packages/coding-agent/src/changes.md has no corresponding custom-editor submission entry. The package requires the root and nested change records to remain aligned, so upstream-sync and fork-behavior audits using the root record will miss this fix unless a matching entry is added in the same increment.
AGENTS.md reference: packages/coding-agent/AGENTS.md:L81-L81
Useful? React with 👍 / 👎.
Symptom
With a custom editor component installed via
ctx.ui.setEditorComponent()(e.g. thepi-voice-sttdictation extension), pressing Enter clears the prompt but the message is never sent — no user message, no model activity, no error. With such an extension installed, the TUI cannot submit any user input at all, including normally typed text.Root cause
setCustomEditorComponent()wires the custom editor's submit throughexpandEditorSubmission(newEditor, text):expandEditorSubmission()preferseditor.getExpandedText()over the passed text. But pi-tui'sEditor.submitValue()clears the editor state and paste registry before invokingonSubmit:So for any custom editor that implements
getExpandedText()— a thin wrapper delegating to a pi-tuiEditor, which is exactly what pi-voice-stt does — the bridge re-reads the already-cleared editor, gets"", anddefaultEditor.onSubmit("")returns early on the empty-text guard. Because the editor was cleared, to the user it looks like "Enter did nothing".Fix
Add
expandSubmittedText()next toexpandEditorSubmission()and use it at the submit call site only. It expands paste markers against the passed (authoritative) text and never re-reads the editor. The live-draft read path (getExpandedEditorText()) keeps the existinggetExpandedText()preference, so draft-read behavior is unchanged.changes.mdentry included per the fork contract.Reproduction (before this patch)
Editorand exposesgetExpandedText()(pi-voice-stt).Verified end-to-end on a real TUI (omo, senpi engine 2026.8.12-4, Linux, xterm-256color) with pi-voice-stt installed:
ctrl+r→ record →ctrl+r→ transcript inserted into prompt → Enter → message sent, model responded.Tests
packages/coding-agent/test/editor-paste-transfer.test.ts(4 tests, deterministic, offline):expandEditorSubmission()(live draft reads) still prefersgetExpandedText().Summary by cubic
Prevents custom-editor Enter submissions from being dropped by expanding paste markers against the submitted text at submit time. Previously, with editors implementing getExpandedText (e.g.,
pi-voice-sttwrapping@earendil-works/pi-tui), Enter cleared the prompt but sent nothing; now Enter sends the message, and live draft reads remain unchanged.interactive-mode.tsto useexpandSubmittedText(...); keepexpandEditorSubmission(...)for live draft reads.packages/coding-agent/test/editor-paste-transfer.test.tsfor submit-time behavior and paste expansion.interactive-mode.ts; new export added ineditor-paste-transfer.ts(low risk).Written for commit b4bf8bb. Summary will update on new commits.