Skip to content

feat(composer): show the skills a person types most above the input - #74

Merged
zereight merged 1 commit into
mainfrom
feat/frequent-skill-chips
Dec 1, 2026
Merged

zereight merged 1 commit into
mainfrom
feat/frequent-skill-chips

Conversation

@zereight

@zereight zereight commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

What changed

A chip row above the composer lists the skills the person calls most with /name in this bot's threads, up to five, most used first. A chip puts /name into the draft and returns focus to the input. Nothing is sent.

GET /api/bots/:id/frequent-skills?threadId=
  threads  = bot.threadId + every task thread, filtered by what this viewer may see
  lines    = person-typed user lines containing "/" (typedSlashLines)
             excluded: steered, automated, relayed, aside, via, peerAsk, fromApp, and lines without a sendId
  lines    = only the asker's own lines where a place is shared (sharedMembership)
  used     = skillMentions(line.text) counted per name, ordered by count, then newest use
  no lines -> { skills: [] } without reading the skills folder
  else     -> used ∩ enabled skills of this bot, first 5, with their descriptions

chip click -> withSkillCall(draft, name)
  already called (skillMentions)      -> draft unchanged, caret to the end
  draft starts with /learn /setup /burst /goal -> "/learn /name rest"
  otherwise                            -> "/name rest"
  • The count comes from the stored conversation, not from a counter in the browser. It is the same on every device, it is there on the first launch, and a line that never ran a skill (a steer while the bot is busy: server/index.ts does not call expandSkillCommand for it) is not counted.
  • useFrequentSkills fetches when the bot or thread changes and when the newest / line of the thread changes. The existing / menu hook (useSlashSkills) is untouched, so that menu keeps refreshing each time it opens.
  • Rows: one line, .ui-pill, horizontal scroll, each chip at most 14rem with an ellipsis. No history, or every used skill disabled: no row is drawn. Same place in Simple and Advanced mode and on the phone layout. Rooms and the locked composer show nothing.
  • server/routes/bot-skills.ts: GET /skills and the new route share one botSkills list builder and one askedThread check (the thread names a folder on disk, so only a thread of this bot may pick it). The /skills response has the same keys as before.
  • typedSlashLines is in server/message-db-typed-lines.ts, next to message-db-attention.ts, because server/message-db.ts is exactly 1,000 lines and the size ratchet does not let it grow.
  • composer.frequentSkills.aria is added in English and Korean. The other languages fall back to English, which i18n:check allows.
  • server/routes/bot-skills.test.ts only gets the two new route deps in its three constructor calls so it compiles.

Why

Typing / and scrolling a menu of every skill is slow for the two or three a person uses all the time. The person asked for their frequently used skills at the top of the input.

How it was verified

Isolated fixture (scripts/control-omb.ts launch, fake engine), Vite on top of it, the built-in browser. Pepper has seven skills installed (fable-deslop disabled) and a history of typed /skill lines.

Before (origin/main 1abb463, same fixture, same conversation): no row above the composer.

before

After (this branch): five chips, most used first, the long name cut with an ellipsis, one line.

after, Simple mode
after, Advanced mode
after, 390 px and 760 px wide
after, a click put the call in the draft

GET /api/bots/$B/frequent-skills            (no typed skill line yet)       -> {"skills":[]}
sent: /plantuml-skill x3, /socratic-tutor x2, /mobpool x1, /fable-deslop x2 (disabled),
      "please use plantuml-skill without a slash"
GET /api/bots/$B/frequent-skills            -> plantuml-skill, socratic-tutor, mobpool
sent from the composer: /mobpool x2          -> chips reordered without a reload: mobpool, plantuml-skill, socratic-tutor
                                                (3 = 3, the newer use goes first)
PATCH /skills/plantuml-skill {enabled:false} -> chips: mobpool, socratic-tutor ; enabled again -> plantuml-skill is back
7 skills used, 6 enabled                      -> 5 chips, the oldest single use is dropped
GET /api/bots/nope/frequent-skills          -> {"error":"no such bot"} [404]
GET /api/bots/$B/skills                      -> keys ["skills","staged"], as before

typedSlashLines against a scratch database, one thread, ten lines (OMB_DATA_DIR set to a temp folder):

person-typed "/plantuml-skill ..."                                counted
steered / automated / relayed / aside / peerAsk / via / fromApp   not counted
user line without a sendId                                        not counted
line without a "/"                                                not counted
line of another sender (shared place)                             counted, and filtered by sender in the route

Draft handling in the browser, same fixture:

Draft before the click After clicking /mobpool Caret
(empty) /mobpool end
/socratic-tutor (click /socratic-tutor again) unchanged end, input focused
/learn make a skill from this /learn /mobpool make a skill from this after /mobpool

A room (group chat) with the same bots has no chip row (0 [data-frequent-skills] nodes). The row is one line of 28 px at 390 and 760 px wide, with scrollWidth 748 and overflow-x: auto.

Checks:

  • pnpm typecheck passes. oxlint --deny-warnings server src passes. pnpm i18n:check: locale catalogs valid.
  • vitest over 35 files: bot-skills, composer-commands, Composer.*, message-db, src/locales/ (including the vocabulary guard) and the static job's ratchets (file-size, index-route, store-read, tighten-ratchets, comment-history, lazy-server-modules, copy-text and Select guards): 178 passed, 3 todo.
  • Cost of the query on the owner's real database (read-only copy, json_each join on the messages_thread index): 19 ms median for the biggest bot (581 threads, 23,369 rows), under 10 ms for the others. The route reads the skills folder only when there is a count to match.

Not verified:

  • A skill typed without a slash (use plantuml-skill) is not counted. That is on purpose: only a /name call is a signal that the person ran it.
  • On a real install, typed /skill calls are rare (about one a day across all bots on the owner's machine), so most bots show zero to two chips at first.
  • Disabling a skill in settings while staying in the same thread keeps its chip until the next thread switch or the next / line. The chip then calls a skill that is off.
  • Whether goal mode expands /name is unknown, so a chip clicked in a goal draft may not run the skill.
  • The phone native clients, Electron and Safari were not run. The narrow check is a 390 px frame in Chrome.
  • No new test files. CONTRIBUTING asks for tests on new server behavior; the checks above were run by hand against the fixture.

Found while verifying, not changed here: the / menu and the chips also offer a skill while the bot is working, but a message sent then is a steer and a steer does not expand skills.

Merge danger

Door: two-way. It adds a read-only route and a row in the composer, and writes nothing. Revert the PR, or drop the FrequentSkillChips line in Composer.tsx.

Blast radius: every one-to-one composer. The new GET reads person-typed lines of the bot's own threads, only those the viewer may see, and on a shared place only the viewer's own lines. A failed request leaves the row empty.

A chip row above the composer lists up to five skills the person called with /name in this bot's threads, most used first. A chip puts the call at the start of the draft, or right after a built-in command such as /learn.
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