Repository navigation
[Idea] Public composer-keymap & sent-message-history APIs for plugins (use case: shell-style ↑ history recall) #11194
Chaiyahang
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
English below / 中文在后。
Summary
I'd like to build a plugin (
dsh-command-history) that gives the Web GUI composer a shell-style input history recall: press↑in an empty composer to refill the previous message you sent,↓to go forward — exactly like a terminal.While prototyping against
0.2.1-rc.x, I found the write path is already there (inputActions.setDraft), but two capabilities have no first-class plugin API, so the feature is only reachable through host internals / DOM hacks that would break on upgrades. This is a request for stable public surfaces.Gap 1 — Composer keymap registration (context-scoped)
dsh-client-ui-conversationowns a Lexical editor whose keymap "registers the fixed send, newline, complementary-delivery, command-menu, and reference-menu rows … and leaves every other key to the editor." There's no documented way for a third-party plugin to register a composer-focused key binding (e.g. bareArrowUponly when the draft is empty / caret at the first line).ctx.shortcutsis for global, app-wide chords (and rejects modifier-only / is unsuitable for a bareArrowUp), so the only route today is a capture-phasekeydownlistener fighting the Lexical editor (IME, multiline, caret-edge detection) — fragile.Ask: a public, composer-scoped keymap hook — e.g. a registerable row in the composer's existing key arbitration, or an
observeComposerKey-style extension point that receives{ key, isEmpty, caretAtStart }and can consume the event.Gap 2 — Readable sent-message history for a session
The data clearly exists (conversation assembly,
UiConversation.userText, the session projection /inbox), but there's no public API that hands a plugin the list of user-sent message texts for the current session. Consuming the internal conversation event feed is complex and not a stable third-party surface.Ask: a read-only, session-scoped API such as
ctx.uiConversation.sentUserMessages(sessionId)(or auseSentMessageshook) returning an ordered, de-duplicatable list of the user's own submitted texts — enough to drive history navigation.Why this is worth a stable surface
History recall is a tiny feature with broad appeal, and both gaps are reusable far beyond it: Gap 1 enables any composer-level interaction plugin; Gap 2 enables "resend / edit last", templates, analytics, and more. Today both force brittle internal coupling.
Happy to help validate a design or test a preview build.
概要(中文)
我想做一个插件(
dsh-command-history),给 Web GUI 输入框加上类似终端的输入历史回溯:输入框为空时按↑回填上一条你发过的消息,↓往回翻——和 shell 里完全一样。在
0.2.1-rc.x上试做时发现:写回输入框已有现成能力(inputActions.setDraft),但有两项能力没有一等公民的插件 API,只能靠怼 host 内部 / DOM 实现,升级即可能失效。因此来申请稳定的公开接口。缺口 1 — 输入框键位注册(限定输入框聚焦场景)
dsh-client-ui-conversation的 Lexical 编辑器键位"注册了发送、换行、互补投递、命令菜单、引用菜单等固定行……其余按键一律交给编辑器"。第三方插件没有公开途径去注册输入框内的键位(例如"仅当草稿为空 / 光标在首行时的裸↑")。ctx.shortcuts面向全局 app 级快捷键(且拒绝纯修饰键、不适合裸↑),所以今天唯一的办法是在编辑器上挂 capture 阶段keydown硬抢,和 Lexical 较劲(输入法、多行、光标边界判定)——很脆。诉求: 一个限定输入框作用域的公开键位钩子——比如可注册进 composer 既有键位仲裁的一行,或
observeComposerKey式扩展点,回调带{ key, isEmpty, caretAtStart }且可消费事件。缺口 2 — 可读取的会话"已发消息"历史
数据显然存在(conversation 装配、
UiConversation.userText、会话投影 /inbox),但没有公开 API 把当前会话里用户发过的消息文本列表交给插件。消费内部事件流复杂且不是稳定的第三方接口。诉求: 一个只读、会话作用域的 API,例如
ctx.uiConversation.sentUserMessages(sessionId)(或useSentMessageshook),返回有序、可去重的用户自己提交文本列表,足以驱动历史导航即可。为什么值得做成稳定接口
历史回溯本身小,但很通用;两个缺口的复用价值远超它:缺口 1 能支撑任何输入框级交互插件;缺口 2 能支撑"重发 / 编辑上一条"、模板、用量统计等。目前两者都迫使插件和内部实现脆性耦合。
乐意协助敲定设计或测试预览版。
All reactions