Skip to content

feat(desktop): improve the composer / and @ menus - #5093

Open
chengluyu wants to merge 6 commits into
mainfrom
branch/slash-at-interaction-table-59a701
Open

chengluyu wants to merge 6 commits into
mainfrom
branch/slash-at-interaction-table-59a701

Conversation

@chengluyu

Copy link
Copy Markdown
Collaborator

Requirement or Bug

The desktop and web composer has two typeahead menus, / for commands and skills and @ for references, and they disagreed with each other. Tab ran a command in one and completed a name in the other, Esc did not stick in either, stale file results stayed on screen but could not be selected, and nothing told a new user that either menu exists. This PR makes the two menus behave the same way and adds the missing guidance.

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

Core idea. Each menu's state lives in one composable, and the composer only forwards keys to it. The change adds the same three verbs to both composables, so the composer can treat them identically: complete (Tab), dismiss (Esc, sticky) and close (blur, outside click, session switch; not sticky).

 handleKeydown
   slash menu open
-    Escape        -> slashOpen = false          (reopens on the next keystroke)
-    Enter | Tab   -> select                     (Tab runs /new, /clear, ...)
+    Escape        -> dismiss                    (stays closed until "/" is retyped)
+    Enter         -> select
+    Tab           -> complete                   (fills in the name, menu stays open)
   mention menu open
-    Escape        -> close                      (reopens on the next keystroke)
+    Escape        -> dismiss                    (stays closed until "@" is retyped)
     Enter         -> select
     Tab           -> complete
+document pointerdown (capture, desktop layout, while a menu is open)
+  outside editor and both menus -> close

Sticky dismissal. Esc records what was dismissed: for / a flag, for @ the offset of the trigger character. update() returns early while the caret's token is still that one. A synchronous watcher on the text clears the record as soon as the trigger character is gone, so deleting and retyping reopens the menu, and so does a programmatic clear such as submit. A plain close() also clears it, which keeps a dismissal from leaking into another session's draft.

Triggers.

  • / menu: the token test is now ^[/、]\S*$. Chinese IMEs type 、 for the slash key. Selecting or completing rewrites the whole token, so the text is normalized to /. A 、 token opens the menu only when at least one command matches, so a message that really starts with 、 is left alone.

  • @ menu: a token still has to start a word, but an @ whose preceding character is CJK now counts too. The check uses Unicode property escapes:

    const CJK_TEXT_END = /[\p{scx=Han}\p{scx=Hiragana}\p{scx=Katakana}\p{scx=Hangul}＀-￯]$/u;

    scx (Script_Extensions) is used instead of Script because it also covers CJK punctuation such as 。 and 、. Full-width forms such as , belong to no CJK script property and JavaScript has no \p{Block=…}, hence the one literal range.

Stale file rows. The fileStale flag is gone. When the query changes, the old file results are dropped immediately, and the view renders a non-selectable "Searching for “x”…" row under a Files heading until the new results land. Skills, attachments and browser references are local and stay visible throughout.

Views.

 <SlashMenu>
+  "Commands" heading
   command rows
   "Skills" heading
-  skill rows
+  skill rows (with the skill icon)
+  <ComposerMenuHints />        popup layout only
 <MentionMenu>
   grouped rows
-  faded stale file rows + corner spinner
+  "Files" heading + searching row while loading
+  <ComposerMenuHints />        popup layout only

Both menu roots now prevent the default on mousedown in the popup layout, so clicking a heading or padding no longer blurs the editor and closes the menu. The viewport clamp counts the footer height.

Reading guide. Start with useSlashMenu.ts and useMentionMenu.ts for the behaviour, then handleKeydown and the pointerdown watcher in Composer.vue. The two menu views and ComposerMenuHints.vue are presentational. The rest is strings and tests.

No screenshots are attached yet.

Behavior Changes and Affected Users

The renderer is shared, so every row applies to the desktop app and to the web UI once the web bundle is synced, unless the row says otherwise. Side chat is unaffected: both menus are disabled there.

Behavior Before After Who relies on the old behavior Escape hatch
Tab in the / menu Selects the row: runs commands such as /new and /clear, inserts the skill tag Fills in the name and keeps the menu open; Enter selects Desktop and web users with a hardware keyboard who run commands with Tab Press Enter. Named in the changeset
Tab in the / menu on a skill whose name contains whitespace Inserts the skill tag Unchanged: still inserts the tag, because the name cannot stay one token — —
Esc on either menu Closes it; the next keystroke reopens it Stays closed while the same token is edited; reopens after the / or @ is deleted and typed again, or after blur Users who press Esc and keep typing to get the menu back Retype the trigger character
Pointer down outside the editor and menu (desktop layout) Menu closed only if the editor lost focus, so toolbar buttons and drag regions left it open Always closes Users who clicked a toolbar control and expected the menu to remain None; reopens on the next keystroke
Pointer down on a menu heading or padding (popup layout) Blurred the editor and closed the menu Menu stays open — —
Message starting with 、 Plain text Opens the / menu when a command matches; Enter or Tab replaces the token with the command Users whose message starts with 、 followed by text that happens to match a command name or description Esc, or keep typing until nothing matches
@ directly after CJK text, e.g. 你好@ No menu Opens the @ menu; selecting replaces only the @token Users typing a handle or address right after CJK text Esc
@ after Latin text, e.g. abc@, user@example.com No menu Unchanged, pinned by a test — —
File rows while a new @ search is pending Old rows stay, faded, and ignore Enter, Tab and clicks Old rows are removed; a searching row is shown Nobody could act on the old rows —
Loading indicator in the @ menu when other rows exist Corner spinner Searching row at the end of the list — —
/ menu headings "Skills" only "Commands" and "Skills"; skill rows carry an icon — —
Key hint footer None Shown in both menus in the popup layout when there are rows; not in mobile sheets — —
Empty composer placeholder (desktop layout, main chat) "Type a message…" "Type @ to reference files, or start with / for commands and skills" Tests or scripts that match the placeholder text Mobile layout and side chat keep the old text

Modules. packages/app-client (the two composables), packages/app-components (composer and menu views), packages/app-i18n (en and zh strings).

Coverage. Each row with a behaviour change has a unit or component test: slash-menu.test.ts (、 trigger and normalization, Tab completion, dismissal), useMentionMenu.test.ts (CJK trigger matrix including the unchanged Latin cases, dismissal, dropped stale rows) and slashMenuPointer.test.ts (headings, skill icon, footer, searching row). The / menu, Tab, Esc, outside click, 、, 你好@ and abc@ were also checked by hand in a local web build.

Not verified by hand: the @ menu with real file results and skill rows in the / menu, because the scratch instance had no project or skills. The pointerdown listener and the Tab and Esc key paths in Composer.vue have no automated test; they were only exercised by hand.

Test run details
  • The four UI packages (app-components, app-client, app-i18n, app-core) pass: 312 files, 4446 tests. The run used Node 26 with NODE_OPTIONS=--no-experimental-webstorage; without that flag 60 tests in 9 files that this PR does not touch fail on Node 26's built-in localStorage. Not run on Node 24.15.
  • Five tests that pinned the faded stale rows were rewritten or removed, since those rows no longer exist.
  • vue-tsc for the renderer and oxlint pass. The ratchet check reports scripts/release.test.mjs, which this PR does not touch.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Make the two composer menus behave the same way and explain themselves:

- Tab completes the highlighted name in the / menu instead of running the
  command, matching the @ menu; Enter still selects.
- Esc keeps a menu closed until its / or @ is deleted and typed again, and
  a click outside the editor and menu closes it.
- A message starting with 、 opens the / menu, and @ typed directly after
  CJK text opens the @ menu; @ after Latin text stays closed.
- The / menu gets a Commands heading and skill icons, both menus get a key
  hint footer, and outdated file rows are replaced by a searching row.
- The empty composer placeholder says how to use @ and /.
@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 750ea97

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

This PR includes changesets to release 1 package
Name Type
kimi-code-app Patch

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T14:09:14.468733Z 750ea97 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 19, 2026 •

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

commit: 750ea97

@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: edbca58fb7

ℹ️ 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".

…action-table-59a701

# Conflicts:
#	packages/app-components/src/composer/Composer.vue

@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: a09d64e404

ℹ️ 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".

…action-table-59a701

# Conflicts:
#	packages/app-client/src/composables/useMentionMenu.ts
#	packages/app-client/test/useMentionMenu.test.ts
#	packages/app-components/src/composer/Composer.vue
#	packages/app-components/src/composer/MentionMenu.vue
#	packages/app-composer/src/shared/icons.ts
- Enter no longer sends an unfinished @token while file results are pending
- Tab completion keeps the chosen variant when two skills share a name
- returning to a dismissed @token closes a menu opened for a later token
- the menu height is re-clamped when the key hints appear

This branch has not been deployed

No deployments
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