Repository navigation
feat(desktop): improve the composer / and @ menus - #5093
Conversation
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 detectedLatest commit: 76cbb79 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
There was a problem hiding this comment.
💡 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
There was a problem hiding this comment.
💡 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
…action-table-59a701
Centre each placeholder key cap on the line box and centre its label's cap height inside it, so the caps line up with Chinese and English text in any UI font and size. The placeholder, the workspace pill and the key caps now share one line-height variable.
…tyles The / and @ menus now use one scroll composable, one section label component and one global scroll thumb rule. The composer placeholder gives its key caps the Kbd key class, so both share one set of styles. The menu thumb reuses the overlay scrollbar geometry and drag helpers.
…5274) #5093 drops the leading slash from / menu names and turns the empty composer placeholder into @ and / hints. #5247 stages quick model menu choices until an outside click or Cmd/Ctrl+Enter, and Escape discards them. Three journeys still expected the old names, the old placeholder and a menu that applies on click, so they failed on main. Locate / menu options by their visible names, expect the new default placeholder, and commit each quick model menu choice before checking the model pill: once with an outside click and otherwise with Cmd/Ctrl+Enter.
Port upstream 5bc1f3e. Tab completes the highlighted / command instead of running it; Esc keeps the / and @ menus closed until their trigger is deleted and typed again; a message starting with 、 opens the / menu and @ typed directly after CJK text opens the @ menu; a click outside the editor and menus closes both. Both menus gain a Commands heading, skill icons, key-hint footers, a searching row in place of stale file results, plugin source labels, and a placeholder that names the two triggers. Fork adaptations: useMentionMenu keeps its session-free API (no session state to reset) and only takes the CJK trigger, dismissedStart, query and fileStale-removal hunks; MentionMenu is the session-free template with no submenu header, so searchingNeedsHeader is the no-submenu form and the sessions-submenu test is omitted; Composer.vue keeps its side-chat and model-menu layout while taking the dispatch, keydown, outside-pointer and .ph hunks; icons.ts keeps the fork's session icon alongside the new skill icon; en/zh composer and mention locales insert only the new keys, preserving fork-only keys. Verified: app-client 115 pass (useMentionMenu, slash-menu, mention-menu); app-core 68 (placeholderHtml, slashCommands); app-composer 11 (composer-placeholder); app-i18n 6; app-components slashMenuPointer 11 and composerRunningSendMode 7/7 in isolated processes. The app-components runs used a temporary worktree package snapshot because node_modules junctions to the main checkout, and a temporary vi.resetModules / accessor-spy shim because Bun 1.4.4's vi lacks them; the file cannot run as one process without module resets. Worktree-only vue-tsc over app-components (Composer.vue, MentionMenu.vue, SlashMenu.vue, menuScroll and transitively every worktree package) is clean. check:no-comments, check:locale-keys and check:locale-placeholders pass; oxlint reports 0 errors over 6605 files. Pre-existing and untouched here: apps/desktop tsc fails on browser-aot TsdownHandle; typecheck:renderer fails on SessionInfoPanel i18n keys; scripts/checks/ratchet.mjs fails because .oxlintrc.json and .oxlintrc.ratchet.json ignorePatterns differ.
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) andclose(blur, outside click, session switch; not sticky).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 plainclose()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:scx(Script_Extensions) is used instead ofScriptbecause 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
fileStaleflag 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.
Both menu roots now prevent the default on
mousedownin 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.tsanduseMentionMenu.tsfor the behaviour, thenhandleKeydownand the pointerdown watcher inComposer.vue. The two menu views andComposerMenuHints.vueare 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.
/menu/newand/clear, inserts the skill tag/menu on a skill whose name contains whitespace/or@is deleted and typed again, or after blur、/menu when a command matches; Enter or Tab replaces the token with the command、followed by text that happens to match a command name or description@directly after CJK text, e.g.你好@@menu; selecting replaces only the@token@after Latin text, e.g.abc@,[email protected]@search is pending@menu when other rows exist/menu headingsModules.
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) andslashMenuPointer.test.ts(headings, skill icon, footer, searching row). The/menu, Tab, Esc, outside click,、,你好@andabc@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 inComposer.vuehave no automated test; they were only exercised by hand.Test run details
app-components,app-client,app-i18n,app-core) pass: 312 files, 4446 tests. The run used Node 26 withNODE_OPTIONS=--no-experimental-webstorage; without that flag 60 tests in 9 files that this PR does not touch fail on Node 26's built-inlocalStorage. Not run on Node 24.15.vue-tscfor the renderer andoxlintpass. The ratchet check reportsscripts/release.test.mjs, which this PR does not touch.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.