Commit 520686b
committed
feat(session-ui): comprehensive chat session UI overhaul
## Context
The session UI had severe UX regressions from a prior incomplete overhaul
(PR #4). Thinking blocks rendered as red JSON error cards, HITL approval
buttons were non-functional, the transcript used a flat layout with no
visual distinction between roles, and the sidebar lacked temporal grouping.
This commit addresses all outstanding issues and applies benchmark patterns
from open-webui and agent-chat-ui reference codebases.
## Changes
### Transcript (`transcript.tsx`)
- **Message layout redesign**: User messages now right-aligned with `rounded-2xl`
pill background; assistant messages left-aligned with compact indigo avatar;
system messages compact and muted with smaller amber avatar
- **Streaming indicator**: Staggered pulse dots `ThinkingDots` component with
150ms delays replacing single ping animation; indigo blinking cursor bar
for active streaming content
- **Entry animations**: `animate-in fade-in slide-in-from-bottom-2` on all
message types for smooth appearance
- **Empty states**: Centered Cpu icon with descriptive text; loading state
uses staggered dots animation
- **sessionKey prop**: Threaded through to EventRenderer and HitlApprovalCard
to enable approval mutation wiring
- Removed unused `User` icon import
### HITL Approval Card (`hitl-approval-card.tsx`)
- **Functional Approve/Reject buttons**: Wired to `sessions.resolveApproval`
tRPC mutation with Loader2 spinner during pending state
- **Optimistic local state**: `localResolution` prevents stale UI after action
- **Error display**: Inline mutation error message
- **Animated pending indicator**: Ping dot with "Pending" label replacing
static "Waiting for user" text
- Added `useMutation`, `useQueryClient`, `useTRPC` imports; component now
accepts optional `sessionKey` prop
### Content Normalizer (`normalize-content.ts`)
- **Object-format thinking recognition**: Added handler for
`{type: "thinking", thinking: "..."}` and `{type: "reasoning", ...}`
payloads that were previously falling through to the unknown event type
- These now render as purple "Agent Reasoning" cards with token estimates
instead of raw JSON in an unknown payload card
### Gateway Client (`client.ts`)
- **`execApprovalsResolve()`**: New method calling `exec.approvals.resolve`
RPC with `sessionKey` and `resolution` parameters
### tRPC Sessions Router (`sessions.ts`)
- **`resolveApproval` mutation**: New procedure with Zod-validated input
(`sessionKey: string`, `resolution: "approved" | "rejected"`)
proxying to `gateway.execApprovalsResolve()`
### Session Workspace (`session-workspace.tsx`)
- **Header metadata**: Agent Cpu icon, model/thinking/token count badges,
`formatTokens()` helper for compact display (e.g., "12.2k")
- **Connection status**: Live indicator with Streaming (indigo ping dot) /
Live (Wifi icon, emerald) / Polling (WifiOff, muted) states
- **Context panel persistence**: Toggle state saved to
`localStorage("claw-dash:context-panel")` with SSR-safe initializer
- **sessionKey threading**: Passed to Transcript component
### Session Sidebar (`session-sidebar.tsx`)
- **Time grouping**: Sessions grouped into Today/Yesterday/This Week/Older
with `getTimeGroup()` helper using start-of-day calculations
- **Fallback titles**: `generateFallbackTitle()` extracts agent name and
formats timestamp from colon-delimited session keys
- **Active state**: Indigo left border (`border-l-2 border-l-indigo-500`)
with `ring-1 ring-zinc-700/50` highlight
### Deep Thought Block (`deep-thought-block.tsx`)
- CSS grid `0fr → 1fr` expand animation replacing display toggle
- Token count estimate (`Math.ceil(rawText.length / 4)`)
- Purple theming with Brain icon; rotating chevron indicator
- `max-h-96 overflow-y-auto` on expanded content
### Tool Execution Card (`tool-execution-card.tsx`)
- **`TruncatedOutput` component**: 8-line truncation with gradient fade
overlay and "Show N more lines" / "Show less" toggle
- **Pending state**: `Loader2 animate-spin` with amber "running" label
when `isPending = !isResult && !payload.result`
- CSS grid expand animation; status icons (CheckCircle2/XCircle/Loader2)
### Unknown Payload Card (`unknown-payload-card.tsx`)
- Changed from alarming red error styling (bg-red-950, AlertTriangle) to
neutral zinc collapsible card with FileJson2 icon
- CSS grid animation; CodeBlock for syntax-highlighted JSON
### Composer (`composer.tsx`)
- **Inline errors**: `fileError` and `mutationError` state with auto-dismiss
amber/red banners replacing browser `alert()` calls
- **Drag-drop zone**: `isDragOver` state with indigo ring visual feedback
- **Auto-resize textarea**: `useCallback` + `useEffect` pattern
- **Compact action bar**: Model selector dropdown, thinking level pill
buttons, Send/Stop with icon + spinner states
### Pre-Session Page (`page.tsx`)
- **Configuration grid**: 2x2 grid for Agent/Model/Workflow/Skills selects
with shared `selectClass` for consistent styling
- **File handling**: `addFiles()` with 20MB limit and 5-file cap validation,
inline amber error banner, drag-drop zone
- **Auto-resize textarea**: Matching composer pattern
- **Action bar**: Attachment button, thinking level pills, Start Session
button with Loader2 spinner
## New Files
- **`docs/session_frontend_prompt.md`**: Originating spec prompt for the
session UI overhaul, documenting the role definition, known issues,
execution workflow phases, and benchmark research requirements
## Testing/Verification
- `npm run lint` — zero errors, zero warnings
- `npm run build` — compiled successfully, all routes generated
- Live browser audit via Chrome extension at localhost:3939/sessions:
verified message layout, thinking block rendering, collapsible cards,
context panel toggle, sidebar grouping, and composer functionality
## Related
- Follows PR #4 (001-session-ui-overhaul) which left several items incomplete
- Resolves: broken HITL buttons, red unknown payload cards, flat transcript
layout, missing thinking block recognition for object payloads1 parent ea8e1ea commit 520686b
File tree
13 files changed
+912
-379
lines changed- docs
- src
- app/sessions
- components/sessions
- orchestration
- lib
- gateway
- server/routers
13 files changed
+912
-379
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Lines changed: 18 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | 5 | | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
25 | 23 | | |
26 | | - | |
27 | | - | |
| 24 | + | |
| 25 | + | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
Lines changed: 72 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | | - | |
| 4 | + | |
3 | 5 | | |
| 6 | + | |
| 7 | + | |
4 | 8 | | |
5 | 9 | | |
6 | 10 | | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | | - | |
10 | | - | |
11 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
12 | 36 | | |
13 | 37 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
24 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
25 | 47 | | |
26 | 48 | | |
27 | 49 | | |
28 | 50 | | |
29 | | - | |
| 51 | + | |
30 | 52 | | |
31 | 53 | | |
32 | 54 | | |
33 | | - | |
| 55 | + | |
34 | 56 | | |
35 | 57 | | |
36 | 58 | | |
37 | 59 | | |
38 | | - | |
39 | | - | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
40 | 66 | | |
41 | 67 | | |
42 | 68 | | |
43 | 69 | | |
44 | 70 | | |
45 | | - | |
| 71 | + | |
46 | 72 | | |
47 | 73 | | |
48 | 74 | | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
53 | 96 | | |
54 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
55 | 103 | | |
56 | 104 | | |
57 | 105 | | |
| |||
0 commit comments