Skip to content

feat: numbered menu selection for /model and /effort + external menus.json#2

Open
baochipham942-eng wants to merge 1 commit intoeLeanwang:mainfrom
baochipham942-eng:feat/numbered-menu
Open

feat: numbered menu selection for /model and /effort + external menus.json#2
baochipham942-eng wants to merge 1 commit intoeLeanwang:mainfrom
baochipham942-eng:feat/numbered-menu

Conversation

@baochipham942-eng
Copy link
Copy Markdown

Problem

On mobile devices (WeChat, AUN, Feishu text fallback), users need to type exact model names like /model sonnet or /effort high. This is painful on small keyboards. Additionally, model lists are hardcoded in each runner file, requiring code changes whenever models are added or renamed.

Solution

1. External menus.json config file

Model lists and effort levels are now loaded from data/menus.json:

{
  "models": {
    "claude": ["opus", "sonnet", "haiku"],
    "codex": ["gpt-5.3-codex", "gpt-5.2-codex", ...],
    "gemini": ["gemini-2.5-pro", "gemini-2.5-flash", ...]
  },
  "efforts": ["low", "medium", "high", "max"]
}
  • Loaded once via loadMenus() in config.ts with caching
  • Falls back to hardcoded defaults if file is missing or invalid
  • Update models without code changes — just edit the JSON

2. Numbered menu for text fallback path

When the channel doesn't support interactive cards (AUN, WeChat) or card sending fails, /model and /effort now show numbered menus:

当前模型: sonnet

可用模型:
1. opus
2. sonnet ✓
3. haiku

回复数字切换模型(60秒内有效)

User replies 2 → switches to sonnet. No typing required.

Implementation details:

  • PendingSelection state keyed by channel:channelId:userId with 60s expiry
  • isCommand() extended to recognize digit inputs when pending selections exist
  • Non-digit messages clear pending state and process normally
  • Out-of-range digits show clear error with valid range

What's NOT changed

  • Feishu interactive card path — untouched, buttons still work for desktop/native clients
  • Command syntax/model sonnet and /effort high still work as before

Changes

File Change
data/menus.json New: external model/effort config
src/config.ts MenusConfig interface + loadMenus() with cache
src/agents/claude-runner.ts listModels() reads from menus config
src/agents/codex-runner.ts Same
src/agents/gemini-runner.ts Same
src/core/command-handler.ts Numbered menu + pending selection + digit interception

Extract hardcoded model lists into data/menus.json with loadMenus() fallback,
and replace plain text lists in the text-only path with numbered menus that
accept digit replies (60s expiry). Feishu interactive card path unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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