Skip to content

feat(tui): render structured mentions inline #41197

Description

@kitlangton

Problem

Structured references are styled while composing a prompt, but projected user messages render the original text as plain text and show attachments separately below it.

For example, a selected skill currently becomes:

Compare the workspace provider options. /api-design

[ skill | API design ]

The same underlying inconsistency exists for file and agent mentions: composer extmarks communicate structure inline, but timeline rendering loses that styling and relies on separate badges or previews.

Proposed direction

Introduce one shared user-message mention renderer that segments message text using the structured attachment mention ranges and styles each recognized reference inline:

  • @file references
  • @agent references
  • /skill references

Render a separate badge or preview only when the attachment has no valid inline mention or needs richer presentation, such as an image preview.

renderMentions(message.text, {
  files: message.files,
  agents: message.agents,
  skills: message.skills,
})

The renderer should validate that each stored range still matches its mention text and fall back safely when ranges are stale or overlap.

Scope

This is a follow-up to #41188. That PR keeps the existing timeline convention and adds structured skill attachments; it should not special-case skill rendering before files and agents share the same treatment.

Acceptance criteria

  • Structured file, agent, and skill mentions retain recognizable inline styling after submission.
  • Inline mentions and separate badges are not duplicated unnecessarily.
  • Attachments without valid mention ranges still render through the existing badge/preview UI.
  • Multiple mentions, Unicode text, stale ranges, and overlapping ranges have focused tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions