Skip to content

Session Chat: inline skill mentions, several per prompt #797

Closed

Description

@ivanfenenko

In Session Chat on a v2 server, a skill is an inline /name pill that can sit anywhere in the prompt, several skills can go in one message, and the prompt keeps its wording and its @ mentions when it is sent.

Why

Today a skill only works as one leading /name token: the suggestion overlay opens only when the whole draft is /xxx, picking a suggestion replaces the draft, and on send the token is cut off and any @agent / @file mentions in that prompt are dropped. The v2 prompt API never required that. POST /api/session/{id}/prompt takes skills: [{ id, mention?: { start, end, text } }]; the server resolves every entry, prepends each skill's content ahead of the user text, and ignores where the mention sits. The official composer treats skills as atomic @ pills that stay in the text, sends several at once, and skips duplicates (TUI) or allows them (web).

Scope

Trigger and pills

  • / opens skill and command suggestions at the cursor when it starts the draft or follows whitespace, like the existing @ trigger (ComposerMentionRouting.atSuggestionQuery). The whole-text ^/(\S*)$ match goes away.
  • Picking a skill inserts a /name span at the cursor plus a trailing space, replacing the typed /query, and leaves the rest of the draft alone. Add a skill kind to the shared MentionSpan reconcile so the span shifts with edits and deletes as one unit, same as agent and file mentions.
  • Picking a skill from the Commands sheet Skills tile (OPE-218: v2 Commands sheet Skills tile #628) inserts the span at the cursor instead of replacing the draft.
  • A skill already in the draft is not offered again (TUI behaviour). No cap on count.
  • Style the span with the same syntaxType colour as @ mentions; a pill background is a follow-up if the Design System adds one.

Send

  • ComposerSubmitIntent gains a prompt variant that carries [skill span] next to agent and file mentions. The skill text stays in text; nothing is stripped. trimForSend re-bases skill offsets like the others.
  • Wire: each skill goes out as { id, mention: { start, end, text: "/name" } } on POST /api/session/{id}/prompt. Agents and files keep their mention parts in the same request.
  • A draft that is a server command (/cmd args with cmd in GET /api/command) still routes to POST /api/session/{id}/command; skills in that draft ride along in that route's skills array.
  • v1 is unchanged: GET /command still inlines skills as commands, a single leading /skill still goes to POST command, and the v1 prompt route carries no skills. Do not remove or skip any v1 path.

History and display

  • Read skills back from the v2 user message DTO so a reloaded session can highlight them.
  • Optimistic row and timeline bubble highlight every skill span, not only a leading [/name] token (CommandInvocationCollapser, attributedCommandDisplayText / commandTokenHighlightRange). Server-command rows keep the current leading-token collapse.

Out of scope

  • Listing skills under the @ trigger (official web does that; our product keeps /).
  • A pill background component in the Design System.
  • Skill autoinvoke metadata, opencode/slash frontmatter.

Acceptance criteria

  • Typing / after whitespace mid-draft opens the suggestion overlay filtered to skills and commands on both platforms; typing / inside a word does not
  • Two or more skills can be placed anywhere in one draft; each is an atomic span that deletes as a unit and survives edits around it
  • Sending fix @reviewer /tdd the login flow /security-check sends text verbatim, skills with two entries carrying correct mention offsets, and the agents mention intact
  • Skills sheet tile and / suggestion both insert at the cursor, never replace the draft
  • Duplicate skill is not offered while already in the draft
  • A server command draft still goes to the command route, with any skill spans in its skills array
  • v1 profiles behave exactly as before, covered by the existing v1 routing tests
  • Reloaded v2 history highlights skill spans in user messages
  • Unit coverage on iOS and Android: trigger, insert, reconcile, submit routing, PromptJSONBodyWriter / PromptJsonBodyWriter skills with mention, user DTO round-trip
  • Scenario harness check on v2 with two skills in one prompt shows both skill content blocks reaching the model

Plan

iOS: Domain/Command/ComposerSubmitRouting.swift, Domain/Agent/ComposerMentionRouting.swift (+ AgentModels.swift for a SkillMention), UI/SessionChat/Region/SessionChatComposer.swift (selectSlashSuggestion, sendPrompt), Domain/Message/MessageModels.swift (PromptSendOptions), Domain/Message/Remote/MessageDomainAdapter.swift (v2PromptRequest, projectV2User), Data/Remote/MessageDTOs.swift, Data/Remote/V2MessageDTOs.swift, Data/Remote/PromptJSONBodyWriter.swift, Domain/Command/CommandInvocationCollapser.swift, Components/Chat/OpenCodeOutgoingMessage.swift, Components/Input/OpenCodeMentionTextView.swift.

Android: domain/command/ComposerSubmitRouting.kt, domain/agent/ComposerMentionRouting.kt (+ AgentModels.kt), ui/sessionchat/region/SessionChatComposer.kt, domain/message/MessageModels.kt, domain/message/remote/MessageDomainAdapter.kt, data/remote/dto/MessageDtos.kt, network/PromptJsonBodyWriter.kt, domain/command/CommandInvocationCollapser.kt, domain/command/CommandTokenHighlight.kt, ui/components/chat/OpenCodeOutgoingMessage.kt, ui/components/input/OpenCodeSessionComposer.kt (MentionVisualTransformation).

Server reference: packages/schema/src/prompt-input.ts (SkillAttachment), packages/core/src/session/prompt.ts, packages/core/src/session/runner/to-llm-message.ts, packages/app/src/composer/request.ts and editor/actions.ts for the official insert and submit shape.

Related: #628 (Skills tile), #569 (agent mentions, span infrastructure), #413 (file mentions), #567 (server slash commands).

Remaining:

  • iOS: cursor-aware / trigger, skill span kind, insert at cursor, duplicate skip
  • iOS: submit keeps text and mentions, sends skills[].mention, command route carries skills
  • iOS: user DTO reads skills; multi-span highlight in optimistic row and timeline
  • Android: cursor-aware / trigger, skill span kind, insert at cursor, duplicate skip
  • Android: submit keeps text and mentions, sends skills[].mention, command route carries skills
  • Android: user DTO reads skills; multi-span highlight in optimistic row and timeline
  • Tests on both platforms per acceptance criteria; v1 routing tests still green
  • Scenario harness evidence on v2 with two inline skills

Activity

  1. added
    enhancement
    ios
    android
    shared
    todo
    priority: medium
    in-progress
    and removed
    todo
    on Oct 23, 2026
  2. added 2 commits that reference this issue on Oct 23, 2026
  3. ivanfenenko commented on Oct 25, 2026

    @ivanfenenko
    CollaboratorAuthor

    Scenario-harness evidence: two inline skills on v2 (iOS + Android)

    Apps built from main @ 742bf87, run against the scenario harness with real opencode v2 dev (4d5965762e) and the scripted model. The throwaway project has two skills, tdd-check and security-check. Each SKILL.md carries a unique marker so its content can be found in the model request.

    Check iOS Android
    / after whitespace mid-draft opens skill suggestions; picking one inserts a highlighted span at the caret ✅ ✅
    Two skills in one draft, rest of the text kept ✅ ✅
    POST /api/session/{id}/prompt stores text verbatim with two skills[].mention entries whose offsets slice to /tdd-check and /security-check ✅ ✅
    Both skill content blocks reach the model (markers ALPHA and BRAVO both in the model request's user content) ✅ ✅
    Sent bubble shows [/tdd-check] and [/security-check] highlighted ❌ plain /tdd-check, /security-check ✅
    Reloaded v2 history highlights both spans ❌ plain text after relaunch ✅ (also for the iOS-sent message)

    Model request check (full request bodies logged at the fake model):

    session ses_e8bc976a8ffe3r6YsML0kWoqXP: model=scripted user messages=1 ALPHA(tdd-check)=True BRAVO(security-check)=True
    session ses_e8bc69672ffej96ZHFIu1JUtHk: model=scripted user messages=1 ALPHA(tdd-check)=True BRAVO(security-check)=True
    
    iOS composeriOS sent / reloadedAndroid composerAndroid sentAndroid, iOS-sent session from history

    (The Android draft reads "he login flow" because the emulator dropped one keystroke. It doesn't affect the check.)

    iOS gap: the server returns skills with correct mentions (Android renders the same message correctly), but the iOS user bubble shows the raw text both live and after reload. Likely cause, not yet confirmed: DisplayFrame.build attaches the message's root markdown to the sole text block (attachSoleTextMarkdown). A user bubble with renderedMarkdown then renders the original text and skips the [/name] collapse from collapseSkillMentions. The iOS highlight items stay open until this is fixed.

  4. added 2 commits that reference this issue on Oct 25, 2026
  5. ivanfenenko commented on Oct 25, 2026

    @ivanfenenko
    CollaboratorAuthor

    iOS skill highlight fixed in #826 and #829

    The iOS gap from the earlier harness run had two causes:

    • Live: the v2 session.inbox.enqueued projection dropped the prompt's skills.
    • Reload: the message store rebuilt the REST copy without promptSkills.

    #826 (merged) fixes the reload path. #829 fixes the live path; it was pushed after #826 had already been squash-merged. Together they add 7 tests, and the full iOS suite passes on the combined tree (2691 tests).

    Rechecked on the scenario harness (v2 dev, two inline skills, iPhone 16 Pro Max, build with both fixes): both the sent bubble and the reloaded history show highlighted [/tdd-check] and [/security-check]. The draft reads "Can" instead of "fix" because of simulator autocorrect.

    Live, after sendReloaded

    All acceptance items are now checked on both platforms. Closing. The live-send part ships when #829 merges.

  6. removed
    in-progress
    on Oct 25, 2026
  7. added a commit that references this issue on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidenhancementiospriority: mediumshared

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions