Commit c6a68c0
feat: add Export Chat (Markdown / PDF) to session kebab menu (#625)
## Summary
- Adds "Export chat" submenu to the session kebab menu (both
`kebab-only` and `full` render modes) with two options: **As Markdown**
and **As PDF**
- New `utils/export-chat.ts` processes AG-UI events client-side into
structured markdown with metadata header, User/Assistant sections, and
collapsible `<details>` blocks for tool calls
- PDF export renders styled HTML in a new window and triggers
`window.print()` (browser native "Save as PDF")
- Deduplicates the blob-download pattern: extracts shared
`triggerDownload()` utility, now used by both new export and existing
JSON export in `session-details-modal.tsx`
- Fixes XSS vector in PDF path (HTML-escapes message content before
rendering) and double-print bug (guard flag)
## Files changed
| File | Change |
|------|--------|
| `components/frontend/src/utils/export-chat.ts` | **New** —
`convertEventsToMarkdown`, `downloadAsMarkdown`, `exportAsPdf`,
`triggerDownload` |
|
`components/frontend/src/app/projects/[name]/sessions/[sessionName]/session-header.tsx`
| Add Export chat `DropdownMenuSub` with loading states |
| `components/frontend/src/components/session-details-modal.tsx` |
Replace inline `downloadFile` with shared `triggerDownload` import |
## Test plan
- [ ] Open a session with chat history, click kebab menu → verify
"Export chat" submenu appears between Clone and Delete
- [ ] Click "As Markdown" → verify `.md` file downloads with readable
conversation (metadata table, User/Assistant headings, tool calls as
`<details>`)
- [ ] Click "As PDF" → verify print dialog opens with styled
conversation in a new tab
- [ ] Verify existing "Export Chat" (JSON) button in View Details modal
still works after `triggerDownload` refactor
- [ ] Verify `npm run build` passes with 0 errors, 0 warnings
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Ambient Code Bot <bot@ambient-code.local>1 parent 253af3f commit c6a68c0
File tree
9 files changed
+667
-34
lines changed- components/frontend
- src
- app
- api/projects/[name]/agentic-sessions/[sessionName]/mcp/invoke
- projects/[name]/sessions/[sessionName]
- components
- ui
- services
- api
- queries
- utils
9 files changed
+667
-34
lines changedcomponents/frontend/src/app/api/projects/[name]/agentic-sessions/[sessionName]/mcp/invoke/route.ts
Lines changed: 60 additions & 0 deletions
| 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 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
Lines changed: 129 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
| 18 | + | |
| 19 | + | |
13 | 20 | | |
14 | 21 | | |
15 | 22 | | |
| |||
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
37 | | - | |
| 44 | + | |
| 45 | + | |
38 | 46 | | |
39 | | - | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | | - | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
45 | 63 | | |
46 | 64 | | |
47 | 65 | | |
| |||
62 | 80 | | |
63 | 81 | | |
64 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
65 | 181 | | |
66 | 182 | | |
67 | 183 | | |
| |||
116 | 232 | | |
117 | 233 | | |
118 | 234 | | |
| 235 | + | |
119 | 236 | | |
120 | 237 | | |
121 | 238 | | |
| |||
131 | 248 | | |
132 | 249 | | |
133 | 250 | | |
134 | | - | |
| 251 | + | |
135 | 252 | | |
136 | 253 | | |
137 | 254 | | |
138 | 255 | | |
139 | 256 | | |
140 | 257 | | |
141 | | - | |
| 258 | + | |
142 | 259 | | |
143 | 260 | | |
144 | 261 | | |
| |||
224 | 341 | | |
225 | 342 | | |
226 | 343 | | |
227 | | - | |
| 344 | + | |
228 | 345 | | |
229 | 346 | | |
230 | 347 | | |
| |||
252 | 369 | | |
253 | 370 | | |
254 | 371 | | |
| 372 | + | |
255 | 373 | | |
256 | 374 | | |
257 | 375 | | |
| |||
276 | 394 | | |
277 | 395 | | |
278 | 396 | | |
279 | | - | |
| 397 | + | |
280 | 398 | | |
281 | 399 | | |
282 | 400 | | |
| |||
Lines changed: 8 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 39 | + | |
49 | 40 | | |
50 | 41 | | |
51 | 42 | | |
52 | | - | |
| 43 | + | |
53 | 44 | | |
54 | 45 | | |
55 | 46 | | |
56 | 47 | | |
57 | | - | |
| 48 | + | |
58 | 49 | | |
59 | | - | |
| 50 | + | |
60 | 51 | | |
61 | 52 | | |
62 | 53 | | |
63 | | - | |
| 54 | + | |
64 | 55 | | |
65 | 56 | | |
66 | 57 | | |
67 | 58 | | |
68 | | - | |
| 59 | + | |
69 | 60 | | |
70 | 61 | | |
71 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
0 commit comments