Chat UI (Redesign)

Status: ✅ Shipped — the three-panel chat (How drawer · chat · Who drawer) is the live chat. Phase 4's route swap is done: /chat/:conversationId renders NewChatPage from clientConsole/src/pages/chat-v2/ (clientConsole/src/App.tsx:539), and the old tabbed chat page is gone (no /chat/legacy route remains). The swap predates the repo's shallow history (2026-07-20), so no commit is cited; verified against the tree 2026-09-29. Some details below were built differently or not at all (e.g. package themes, which this doc already marks as future) — treat the sections as design history, and the code as the reference.

Status: Planned — built in parallel alongside the existing chat. Not a rewrite; the current chat stays functional until this one reaches feature parity.


Problem

The current chat page does too much. Nine tabs stacked into one view — chat, persona, model, mode, summary, memories, knowledge, settings, debug — means every feature competes for the same narrow space. New users don't know where to start. Experienced users spend time tab-switching to check context or swap settings mid-conversation.

The core issue: the chat, the operational controls, and the world/character context are all fighting for one screen. These are three fundamentally different concerns:

  1. The conversation — what you're reading and writing
  2. The engine — what's powering the AI (context budget, memory, model, mode)
  3. The stage — who you're talking to and what world you're in (character, lorebooks, persona)

Cramming all three into tabs creates a flat hierarchy where "Chat" sits next to "Debug" as if they're equally important. They're not.


Design

Three-panel layout with collapsible drawers. The chat dominates. Everything else is one gesture away but never in the way.

Desktop Layout (900px+)

┌──────────────────────────────────────────────────────────────────────────────┐
│ ☰  Echo of Dreams          Conversation Title              [?] [⚙] [👤]    │
├────────┬───────────────────────────────────────────────┬────────────────────┤
│        │                                               │                    │
│  HOW   │                                               │       WHO /       │
│        │                                               │       WHAT        │
│ Context│              C H A T                          │                    │
│ Memory │                                               │   Character       │
│ Summary│         Theme-styled messages                 │   Portrait        │
│ Model  │         with full background                  │   Description     │
│ Mode   │         and visual treatment                  │   Lorebooks       │
│        │                                               │   Persona         │
│        │                                               │                    │
│  ◂ ▸   │                                               │       ◂ ▸         │
│        │  ┌──────────────────────────────────────────┐ │                    │
│        │  │  [Type a message...]              [Send] │ │                    │
│        │  └──────────────────────────────────────────┘ │                    │
├────────┴───────────────────────────────────────────────┴────────────────────┤
│  ☰ Nav (collapsed)                                                          │
└──────────────────────────────────────────────────────────────────────────────┘

Both drawers are collapsed by default. The chat takes 100% width on first load. Users open drawers as needed — the layout remembers their preference per device.

Mobile Layout (under 768px)

┌──────────────────────────────────┐
│ ☰   Conversation Title    [▼]   │
├──────────────────────────────────┤
│                                  │
│         C H A T                  │
│                                  │
│    Full-width messages           │
│    Theme-styled                  │
│                                  │
│  ┌────────────────────────────┐  │
│  │  [Type...]          [Send] │  │
│  └────────────────────────────┘  │
├──────────────────────────────────┤
│  [HOW ▲]              [WHO ▲]   │
└──────────────────────────────────┘

Mobile uses bottom-sheet drawers that slide up. Two small toggle buttons at the bottom give access to HOW and WHO panels as half-screen sheets. No tabs, no navigation fighting with the keyboard.

Tablet (768–900px)

Same as desktop but only one drawer can be open at a time. Opening the left closes the right and vice versa.


Collapsed by default. The hamburger menu (☰) opens a slim rail with icon-only navigation. The chat page should feel like a full-screen experience, not an app with a sidebar.

On mobile, navigation is accessible from the header hamburger — a slide-out overlay that covers the chat when open, dismisses on tap outside.

The navigation never competes with drawers. It's a separate layer.


The Three Panels

Left Drawer — HOW (The Engine Room)

Everything about how the AI is thinking and what resources it's using. This is the operational panel — context budget, active memory, model selection.

┌─ HOW ──────────────────────────┐
│                                │
│  Context Budget                │
│  ┌────────────────────────────┐│
│  │ ████████████░░░░  68%      ││
│  │ 27,200 / 40,000 tokens     ││
│  ├────────────────────────────┤│
│  │ Character      4,200  ████ ││
│  │ Conv. rules    1,800  ██   ││
│  │ World lore     8,400  ████ ││
│  │ Story so far   6,200  ███  ││
│  │ Recalled       3,100  ██   ││
│  │ Messages       3,500  ██   ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Model ────────────────────┐│
│  │ Claude 3.5 Sonnet          ││
│  │ via Anthropic       [Edit] ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Mode ─────────────────────┐│
│  │ Campaign Mode         🔒   ││
│  │ 6 provider keys    [View]  ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Summaries ────────────────┐│
│  │ 3 active · 12 memories     ││
│  │                    [View]  ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Package ──────────────────┐│
│  │ D&D 5e Campaign  v2.1     ││
│  │ 3 locked · 1 unlocked     ││
│  │              [Workbench]   ││
│  └────────────────────────────┘│
│                                │
└────────────────────────────────┘

Sections

Section Content Expandable
Context Budget Token usage bar per provider key. Visual breakdown of what's eating the context window. Always visible (compact bar), expand for per-key breakdown
Model Current LLM model and provider. Quick-change dropdown. Inline
Mode Active prompt mode with provider key summary. Locked indicator if from package. Expand to see key list
Summaries Active summary count + memory count. Links to full summary browser. Expand for summary cards
Memories Recalled memory count for this turn. Shows what historical context was pulled in. Expand for memory list
Package If conversation was started from a package: package name, version, lock summary, link to workbench. Hidden if no package. Inline
Debug Admin-only. Full system prompt, raw messages sent to LLM, model used. Expand for full dump

Context Budget is the hero. It's the first thing in the drawer because it answers the most common question: "why did the AI forget X?" The answer is almost always "not enough context budget." Making this visible turns a mysterious problem into an understandable one.

Use human-friendly labels. The breakdown shows "Character description," "Conversation rules," "World knowledge," "Story so far," "Recalled memories," "Recent messages" — not pipeline key names like character, mode, lorebook. The ContextBudget.breakdown[].label field is mapped from pipeline keys to user-facing names at the API boundary. Users should never see internal terminology.

Key behaviors

Center Panel — Chat

The conversation. This is where users spend 95% of their time. It should feel immersive, not like a form.

Theme Integration

The current chat applies theme colors to message bubbles and backgrounds. The redesigned chat goes further — the theme becomes the atmosphere:

The goal: when a creator ships a package with a dark fantasy theme, the chat feels dark fantasy. When it's a bright slice-of-life theme, the chat feels light and open.

Contextual Hints

When the AI produces a response and the context budget is above 90% full, a subtle inline hint appears below the message:

Context is nearly full — the AI may lose earlier details. [View context budget →]

This connects the symptom (AI forgetting things) to the cause (full context) at the exact point of frustration, instead of requiring the user to open the HOW drawer and notice the budget bar themselves. The hint links directly to the context budget section in the left drawer.

Hints only appear once per session (not on every message) and can be dismissed permanently.

Message Design

┌──────────────────────────────────────────────────────────┐
│                                                          │
│         ┌──────────────────────────────────────┐         │
│         │ You                          2:34 PM │         │
│         │                                      │         │
│         │ I search the room for traps.         │         │
│         └──────────────────────────────────────┘         │
│                                                          │
│  ┌──────────────────────────────────────┐                │
│  │ ⚔️ D&D 5e Rules               2:34 PM │                │
│  │                                      │                │
│  │ *You carefully examine the stone      │                │
│  │ chamber. Make a Perception check      │                │
│  │ (DC 14).*                             │                │
│  │                                      │                │
│  │ The walls are lined with faded        │                │
│  │ tapestries depicting...               │                │
│  │                                      │                │
│  │         ◂ 2/3 ▸     ✎  ↻  📋  ⋯     │                │
│  └──────────────────────────────────────┘                │
│                                                          │
│  ┌──────────────────────────────────────────────────┐    │
│  │  [Type a message...]                      [Send] │    │
│  └──────────────────────────────────────────────────┘    │
│                                                          │
└──────────────────────────────────────────────────────────┘

Changes from current design:

Input Area

Right Drawer — WHO / WHAT (The Stage)

Everything about who you're talking to and what world you're in. This is the character/narrative panel — the context that makes the conversation meaningful.

┌─ WHO / WHAT ───────────────────┐
│                                │
│  ┌────────────────────────────┐│
│  │                            ││
│  │     Character Portrait     ││
│  │     (large, prominent)     ││
│  │                            ││
│  │     D&D 5e Rules           ││
│  │     system · by DM_Chris   ││
│  │                    🔒      ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Description ──────────────┐│
│  │ "Enforces D&D 5e combat,   ││
│  │ spells, and skill checks   ││
│  │ with authentic..."          ││
│  │                   [More ▼] ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Greeting ─────────────────┐│
│  │ "The Tavern"               ││
│  │ "You push open the heavy   ││
│  │ oak door..."               ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Your Persona ────────────┐│
│  │ Aldric the Bold            ││
│  │ Human fighter, level 5     ││
│  │              [Change]      ││
│  └────────────────────────────┘│
│                                │
│  ┌─ World Knowledge ─────────┐│
│  │ 📖 Forgotten Realms Lore   ││
│  │    1,247 entries           ││
│  │ 📖 D&D 5e Monsters         ││
│  │    892 entries             ││
│  │                            ││
│  │ Matched this turn: 3       ││
│  └────────────────────────────┘│
│                                │
│  ┌─ Custom Instructions ─────┐│
│  │ "Always describe combat    ││
│  │ in vivid detail..."        ││
│  │              [Edit]        ││
│  └────────────────────────────┘│
│                                │
└────────────────────────────────┘

Sections

Section Content Actions
Character Portrait (full-width, prominent), name, type badge, creator name, lock status Change (if unlocked), view full profile
Description Character description, truncated with expand. Shows first paragraph by default Expand/collapse
Greeting Active greeting name + preview. Only shown if conversation started with one —
Your Persona Active persona name, description preview, token count Change, edit, create new
World Knowledge Linked lorebooks with entry counts. Shows "matched this turn: N" after each AI response — how many lorebook entries were injected Add/remove (if unlocked)
Custom Instructions Pre-filled from package or user-set. Editable textarea Edit inline

The character portrait is the hero. It's the first and largest element because it anchors the conversation emotionally. This is who you're talking to. The current chat buries this in a resizable panel that most users probably never notice.

Compact mode (simple setups)

Not every conversation needs a full drawer. A casual chat with a single character, no lorebooks, and no persona has very little WHO/WHAT content — the drawer would be mostly empty space. For these simple setups, the character portrait and name are inlined into the chat header instead:

┌──────────────────────────────────────────────────────────────┐
│ ☰  [🖼 D&D 5e Rules]  The Tavern Campaign     [?] [⚙] [👤] │
└──────────────────────────────────────────────────────────────┘

Trigger: Compact mode activates when the conversation has a character and nothing else noteworthy (no lorebooks, no persona, no custom instructions, no package). When any of those are added, the header avatar becomes a toggle that opens the full drawer. Clicking the inline avatar in compact mode shows a popover with the character description — not the full drawer.

The ] keyboard shortcut still works — it opens the full drawer regardless of mode. Compact mode is a default, not a restriction.

Key behaviors


Where Current Tabs Map To

Every feature from the current 9-tab chat page has a home in the new layout:

Current Tab New Location Notes
Chat Center panel Core experience, expanded
Persona Right drawer → Your Persona Condensed picker, not a full page
Chat Settings Conversation header menu (⚙) Rename, delete, detach from package — rare actions go in a menu
Model Left drawer → Model Inline dropdown, not a tab
Prompt Mode Left drawer → Mode Inline selector with provider key summary
Summary Left drawer → Summaries Expandable section with summary cards
Memories Left drawer → Summaries (sub-section) Memories grouped under the summary/memory section
Knowledge Right drawer → World Knowledge Lorebook list with match feedback
Debug Left drawer → Debug (admin only) Collapsible at the bottom

Nothing is lost. Everything is relocated to a more logical grouping.


Package Integration

When a conversation is linked to a package, the chat reflects this throughout:

Package Awareness

Lock Enforcement

Version Awareness


Theme as Atmosphere

The current theme system generates ~150 CSS variables from 7 seed colors. The redesigned chat uses these variables aggressively to make the theme feel like a physical space, not just a color scheme.

What Changes Per Theme

Element How It's Themed
Chat background --color-bg-primary base + custom background image if set
Message bubbles (AI) --color-bg-glass with backdrop blur
Message bubbles (User) --color-primary-* derivation with subtle gradient
Input area Glass effect with theme border color, subtle accent glow on focus
Drawer backgrounds --color-bg-secondary with slight transparency
Scroll shadows Theme-derived gradient (not generic black)
Timestamps/metadata --color-text-muted
Character name --color-primary or --color-accent
Lock icons --color-text-secondary

Package Themes (Future)

Packages can optionally include a theme. When a user starts a conversation from a package with a theme, the chat applies that theme for the duration of the conversation. The user's global theme is restored when they leave.

This is the bridge between the theme system and packages: a creator ships a dark dungeon theme with their D&D package, and the chat feels like a dungeon. The theme doesn't just color the UI — it sets the mood.


State Management

New Store: chatViewStore

interface ChatViewStore {
  // Drawer state
  leftDrawerOpen: boolean
  rightDrawerOpen: boolean
  toggleLeftDrawer: () => void
  toggleRightDrawer: () => void

  // Drawer section collapse state (persisted)
  collapsedSections: Record<string, boolean>
  toggleSection: (sectionId: string) => void

  // Context budget (updated after each AI response)
  contextBudget: ContextBudget | null

  // Lorebook match feedback (updated after each AI response)
  lorebookMatches: LorebookMatch[]

  // Memory recall feedback (updated after each AI response)
  recalledMemories: RecalledMemory[]
}

interface ContextBudget {
  totalTokens: number
  maxTokens: number
  breakdown: {
    key: string        // Pipeline context key (character, mode, lorebook, etc.)
    label: string      // Display name
    tokens: number
  }[]
}

interface LorebookMatch {
  lorebookId: number
  lorebookName: string
  entryId: number
  entryTitle: string
}

interface RecalledMemory {
  summaryId: number
  preview: string
  level: number
}

This store is separate from the existing conversation/message state. It only manages the view layer — drawer positions, section collapse, and per-turn feedback data. The actual conversation data (messages, settings, streaming) stays in its current location.

Backend Support Needed

The current chat SSE response returns content, done, stopped, error. The redesigned chat needs additional metadata on the done event:

// Extended SSE 'done' event payload
interface ChatDoneEvent {
  messageId: number
  versionGroupId: string
  versionNumber: number
  versionCount: number

  // New fields for the HOW drawer
  contextBudget?: ContextBudget
  lorebookMatches?: LorebookMatch[]
  recalledMemoryIds?: number[]
}

This is opt-in — the backend only includes these fields if the client requests them (via a query param or header). The existing chat page doesn't need to change.

As built (2026-10-27): lorebookMatches and recalledMemoryIds were never added to the done event. The done frame's key set is pinned unchanged. A reply's lore and memory recall are persisted per message and read through the message-info endpoint (lorebookActivations, memoryRecall).


Responsive Behavior

Breakpoint Layout Drawer Behavior
Desktop (900px+) Three-panel Both drawers can be open simultaneously. Collapsed by default.
Tablet (768–900px) Chat + one drawer Only one drawer at a time. Opening one closes the other.
Mobile (under 768px) Chat only Drawers are bottom-sheets that slide up to ~60% height. Two toggle buttons at the bottom.

Transitions

Keyboard Shortcuts

Shortcut Action
[ Toggle left drawer (HOW)
] Toggle right drawer (WHO/WHAT)
Esc Close any open drawer / cancel edit
/ Focus input (if not already focused)
j / k Navigate between messages (when input is not focused)
Ctrl+Shift+R Regenerate last AI response
Ctrl+Shift+C Copy last AI response to clipboard
Ctrl+/ Show keyboard shortcut cheat sheet overlay

All shortcuts are disabled when the input textarea is focused (except Esc and Ctrl+ combos). This prevents accidental navigation while typing.


Accessibility

Drawers

Themed Elements

Glass effects and backdrop blur look good but can reduce contrast. All themed elements must:

Messages

Screen Readers


Migration Strategy

This is a parallel build, not a rewrite. The existing chat page stays exactly as-is while the new one is built alongside it.

Phases

Phase 1 — Shell and Chat

Phase 2 — WHO/WHAT Drawer

Phase 3 — HOW Drawer

Phase 4 — Polish and Cutover

What's Reused

Most of the work is rearranging, not rebuilding:

Existing Component Reuse Strategy
SSE streaming logic Direct reuse — same API, same event handling
Message rendering (MarkdownContent) Direct reuse
ResizablePanel Not needed — drawers are fixed width
ChatPersonaCard, ChatModeCard, ChatLorebookCard Adapt to drawer layout (narrower, vertical)
themeStore Direct reuse — drives all CSS variables
SummaryView / MemoriesView Extract summary card components, embed in drawer section
ModelSettings Extract model picker dropdown, embed inline
Message actions (edit, copy, regenerate, delete, branch) Direct reuse
Version navigation Direct reuse

Open Questions (Resolved)

These were the original open questions. Both Grok and Opus provided input, and the decisions below reflect their consensus.

  1. Drawer persistence — Global default with per-conversation override. Most users develop a preference (drawers open or closed) that applies everywhere. Default is "remember globally." A toggle in the conversation ⚙ menu lets users override for specific conversations: "Always show drawers for this conversation." RPG users will want drawers open for complex sessions, casual chatters won't.

  2. Context budget data — Worth the backend effort for v1. This is the single most impactful transparency feature. Frontend-estimated counts (based on character description length etc.) will be wrong enough to erode trust — if the UI shows a number, it needs to be real. Pipeline instrumentation to report per-key token usage on the done SSE event is the right approach. If it slips, ship the section with a placeholder rather than inaccurate estimates.

  3. Lorebook match feedback — Worth doing, can slip to v1.1 if needed. The drawer section can launch with static lorebook info (name, entry count) and add per-turn match data + message annotations (📖 tooltips) when the pipeline supports it. The inline annotation on messages is higher value than the drawer count.

  4. Conversation settings — Split: frequent actions in drawers, rare actions in ⚙ menu. "Change character" and "change mode" are not rare — they happen when a conversation isn't working. These stay in their respective drawer sections (Character in WHO drawer, Mode in HOW drawer) where they already live. Only truly rare actions (rename, delete, detach from package) go in the header ⚙ dropdown.