Skip to content

feat(ui): system prompt collapsable bubble with Markdown rendering#31

Merged
Killea merged 3 commits intoKillea:mainfrom
bertheto:feat/system-prompt-ux
Mar 3, 2026
Merged

feat(ui): system prompt collapsable bubble with Markdown rendering#31
Killea merged 3 commits intoKillea:mainfrom
bertheto:feat/system-prompt-ux

Conversation

@bertheto
Copy link
Contributor

@bertheto bertheto commented Mar 2, 2026

Summary

The system prompt (injected at seq=0) was rendered as a plain-text centered pill, making it unreadable for long or structured prompts.

This PR adds a collapsable bubble with Markdown rendering, keeping visual consistency with the existing system event style (amber palette).

Changes

src/static/index.html

  • appendBubble(): new rendering path for seq=0 system messages
  • Creates a collapsable div.msg-sys-prompt with:
    • Header button (msg-sys-prompt-header) with aria-expanded + .is-expanded class
    • Body div (msg-sys-prompt-body bubble-v2) rendered via renderMessageContent() for Markdown
    • Click toggle: updates aria-expanded, .is-expanded, .collapsed, chevron direction, and label text
    • Collapsed label: Thread Instructions (system) — click to expand
    • Expanded by default
  • Non-zero seq system events continue rendering as centered pills (unchanged)

src/static/css/main.css

  • New classes: .msg-sys-prompt, .msg-sys-prompt-header, .msg-sys-prompt-chevron, .msg-sys-prompt-body, .msg-sys-prompt-body.collapsed
  • Amber palette inherited from .msg-sys-event (rgba(245,158,11,...), #fbbf24)
  • max-height: 320px + overflow-y: auto on body with thin amber custom scrollbar
  • border-radius on header/body (not wrapper) to avoid overflow:hidden clipping bug
  • .is-expanded toggles border-radius: 20px 20px 0 0 on header
  • Light theme variants included
  • Overrides to keep bubble-v2 headings/strong in amber color

frontend/src/__tests__/system-prompt-bubble.test.js (new file)

  • 7 Vitest tests covering:
    • Renders as collapsable bubble (not pill)
    • Markdown rendered in body (h2, strong)
    • Expanded by default (aria-expanded=true, .is-expanded)
    • Collapse on click: aria-expanded=false, .is-expanded removed, .collapsed added, label updated
    • Expand on second click: state restored
    • Non-zero seq still renders as pill (regression guard)
    • Deduplication: duplicate seq=0 ignored

Test plan

  • 58 tests passing (npx vitest run)
  • Open a thread with a long system prompt: bubble visible, expanded, scrollable
  • Click header: collapses with "Thread Instructions (system) — click to expand"
  • Click again: expands, label restored
  • Check light theme (?theme=light): amber palette maintained
  • Old threads without system prompt: no regression on agent messages display

bertheto added 2 commits March 3, 2026 00:06
…I-06)

Fix: system prompt (seq=0) was rendered via textContent, bypassing the
Markdown renderer entirely. All ## headings, **bold**, lists etc. were
displayed as raw text.

Changes:
- index.html: appendBubble() separates seq=0 (system prompt) from other
  system events. seq=0 renders a collapsable accordion using
  renderMessageContent() for proper Markdown support. Header label shows
  "click to expand" hint when collapsed. Other system events (seq>0)
  keep the existing centered pill unchanged.
- main.css: new .msg-sys-prompt family inheriting the exact amber palette
  of .msg-sys-event (bg rgba(245,158,11,.07), border .18, color #fbbf24,
  italic, border-radius 20px). Body has max-height 320px + overflow-y
  auto. Custom thin amber scrollbar (4px, webkit + scrollbar-width:thin).
  Expanded by default; click header to collapse/expand with aria-expanded.
  Light theme variant included.
- frontend/__tests__/system-prompt-bubble.test.js: 7 Vitest tests
  covering render type, Markdown output, default state, toggle collapse
  with label update, toggle expand with label restore, regression for
  non-zero seq events, and deduplication.

All 58 tests pass.
… from wrapper

The overflow:hidden + border-radius combo on the wrapper div was clipping
the collapsable bubble, making it appear as a thin amber line instead of
a proper header. Fix by:
- Moving border-radius to header/body elements directly
- Removing overflow:hidden from the wrapper
- Adding is-expanded class for rounded-top corners on expanded state
- Increasing header background opacity and min-height for visibility
- Adding border-radius 0 0 20px 20px to body for rounded-bottom corners

Tests: all 58 passing
@bertheto bertheto force-pushed the feat/system-prompt-ux branch from c6c0228 to bf6972f Compare March 2, 2026 23:07
- Integrated system prompt collapsable bubble (seq=0) with admin_switch_confirmation_required feature
- Added CSS styles for .msg-sys-prompt family
- Resolved merge conflict between PR Killea#31 and main branch's new admin switch card feature
@Killea Killea merged commit 520fc0a into Killea:main Mar 3, 2026
1 check passed
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.

2 participants