Skip to content

feat(cli): give the /btw panel a dedicated input editor - #3640

Closed
liukx0205 wants to merge 1 commit into
feat/btw-image-supportfrom
feat/btw-panel-input
Closed

feat(cli): give the /btw panel a dedicated input editor#3640
liukx0205 wants to merge 1 commit into
feat/btw-image-supportfrom
feat/btw-panel-input

Conversation

@liukx0205

Copy link
Copy Markdown
Collaborator

Related Issue

Stacks on #3619 (which stacks on #3613). This PR is the follow-up that gives the /btw panel its own input box; base is set to feat/btw-image-support because the media path added there (prepareBtwPrompt / trackBtwDispatch, plus the daemon-side ReadMediaFile whitelist) is exactly what the dedicated editor reuses for pasted images.

Problem

The /btw panel had no input of its own: it visually borrowed the main editor (connectedAbove stitching) and intercepted the main send path (sendUserInput) to reroute keystrokes to the side agent. That coupling meant the panel inherited every main-input semantic (queue, steer, bash mode, …) through a fragile interception layer, and pasted images only worked because the shared editor happened to write into the same buffer.

What changed

Design decisions

  • Stacking: branched from feat/btw-image-support (feat(cli): send pasted images to the /btw side agent #3619) and based this PR on it. The dedicated editor's image support is a thin reuse of feat(cli): send pasted images to the /btw side agent #3619's prepareBtwPrompt (placeholder → imageStore → daemon file-ref parts at submit); going self-contained would mean duplicating that media chain.
  • Layout: kept the existing visual structure with the smallest UX delta. The panel stays where it is; the new editor mounts inside btwPanelContainer directly under the panel with connectedAbove = true, so the panel stitches onto its own editor exactly the way it used to stitch onto the main one. The main editor simply reverts to its plain rounded top border — input and visuals are now fully decoupled.
  • Capability trim: the panel's editor is the same CustomEditor class as the main input, but wired with only what a side panel needs:
    • Kept: plain text submit, clipboard image/video paste (same imageStore placeholder → ingestion → prepareBtwPrompt expansion path as the main editor), inline-skill token extraction on submit (existing follow-up behavior), Esc close, ↑↓ panel scroll, Ctrl+C cancel/close.
    • Dropped: no QueuePane/queueing, no Ctrl+S steer, no bash mode (new disableBashMode option on CustomEditor — a leading ! stays literal text), no slash-command/@-mention autocomplete provider, no Ctrl+B/T/P/N bindings, no input history. Placeholder hint stays in the panel body ("Ready for a side question…") and the border hint ("Esc close · ↑↓ scroll") rather than inventing an editor placeholder concept.
  • Focus: opening the panel focuses its editor; Esc/close (including clear() on session reset) returns focus to the main editor.

By file

  • components/editor/custom-editor.ts — new disableBashMode option guarding both !-mode entry paths (typed and pasted).
  • controllers/btw-panel.tsopen() now constructs and wires a dedicated CustomEditor; sendUserInput interception is deleted, replaced by the editor's own onSubmit (busy → restore draft + transient notice; idle → panel.submit with inline-skill extraction); mount/close/clear manage the editor and focus.
  • controllers/editor-keyboard.tshandleClipboardImagePaste became public pasteClipboardImage(target) so both editors share one paste/ingestion path and one imageStore.
  • kimi-tui.ts — removed the two btwPanelController.sendUserInput interception calls from sendNormalUserInput / sendInlineSkillUserInput; added pasteImageIntoEditor (BtwPanelHost) delegating to the shared paste path.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Sep 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9818178

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@9818178
npx https://pkg.pr.new/@moonshot-ai/kimi-code@9818178

commit: 9818178

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9818178f28

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// used to when it doubled as the panel's input.
editor.connectedAbove = true;
this.host.state.btwPanelContainer.addChild(editor);
this.host.state.ui.setFocus(editor);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore focus to the /btw editor after modal dialogs

When /btw is opened while the main agent is still running and that agent raises an approval or question dialog, closing the dialog calls KimiTUI.restoreEditor(), which always focuses state.editor (kimi-tui.ts:3764-3768) instead of this dedicated editor. The panel remains visible, but subsequent typing and Enter now go through the main send path because this commit also removed the old /btw interception, so the user's intended follow-up can be queued or sent to the wrong agent. Modal restoration needs to return focus to the active panel editor when one exists.

Useful? React with 👍 / 👎.

@liukx0205

Copy link
Copy Markdown
Collaborator Author

Closing: product focus moved to the desktop /btw panel (kimi-code-app). The TUI-side dedicated input may be revisited later.

@liukx0205 liukx0205 closed this Sep 8, 2026
@liukx0205

Copy link
Copy Markdown
Collaborator Author

Closing: product focus moved to the desktop /btw panel (kimi-code-app). The TUI-side dedicated input may be revisited later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant