Skip to content

feat: collapse expanded skill blocks in user messages - #354

Open
wuxiangru915 wants to merge 1 commit into
agegr:mainfrom
wuxiangru915:feat/collapse-skill-blocks-in-messages
Open

feat: collapse expanded skill blocks in user messages#354
wuxiangru915 wants to merge 1 commit into
agegr:mainfrom
wuxiangru915:feat/collapse-skill-blocks-in-messages

Conversation

@wuxiangru915

Copy link
Copy Markdown

Summary

pi's agent core expands /skill:name commands by inlining the entire SKILL.md into the user message (<skill name="..." location="...">...full content...</skill>). In the web UI that floods the conversation with verbose skill instructions every time a skill is invoked.

This PR renders each expanded <skill> block in user messages as a collapsible header that defaults to collapsed — showing just skill: <name>, the SKILL.md location, and the line count — with the full content available on click.

Behavior

  • Collapsed by default: one compact header line per skill block (▸ skill: name /path/to/SKILL.md 177 行 · 展开).
  • Click to expand: reveals the full skill content, rendered as before (markdown body).
  • Text around skill blocks is preserved and rendered in order; messages without skill blocks are untouched.
  • Copy action still copies the full original message text.

Implementation

  • lib/skill-block.ts (new): splitSkillBlocks(text) splits a message into <skill> blocks and plain text segments (name/location parsed from attributes, order-independent). Unit-tested in lib/skill-block.test.mjs.
  • components/MessageView.tsx: UserMessageView renders skill segments via a new SkillBlock collapsible component; non-skill segments keep the existing MarkdownBody rendering.
  • i18n: adds chat.lines (en/zh) and reuses existing i18n.expand/i18n.collapse.

Verification

  • Unit tests: lib/skill-block.test.mjs (7) + components/MessageView.test.mjs (3 new SSR render tests) + i18n registry — all passing.
  • tsc --noEmit, eslint, production next build all clean.
  • End-to-end in a real browser: a real session containing an expanded skill block renders the collapsed header (no skill body visible), and clicking it reveals the full content.

Sending /skill:name expands the whole SKILL.md into the user message via
the pi agent core, which floods the chat with verbose instructions.
Render each <skill>...</skill> block as a collapsible header (name,
location, line count) that defaults to collapsed, with the full content
available on click. Non-skill text around the blocks is preserved.
@wuxiangru915
wuxiangru915 force-pushed the feat/collapse-skill-blocks-in-messages branch from ceecb98 to 907db9e Compare August 2, 2026 10:22
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