Commit 82c4026
fix(backend): remove initialPrompt skip that blocked display name fallback (#1562)
## Summary
- **Removed** the 5-line `initialPrompt` skip guard in
`agui_proxy.go:1005-1009` that prevented the AG-UI proxy from acting as
a fallback when CreateSession's async display name generation failed
- **Updated** the comment in `sessions.go` to document the new fallback
relationship between the two generation paths
- **Added** 4 regression tests for
`triggerDisplayNameGenerationIfNeeded` covering the key code paths
## Problem
Sessions intermittently showed raw session IDs (`session-<UUID>`)
instead of friendly display names. The display name system has two
generation paths:
- **Path A** (CreateSession handler): fires `GenerateDisplayNameAsync`
in a goroutine with 10s timeout
- **Path B** (AG-UI proxy): generates on first `/agui/run` POST
Path B intentionally skipped messages matching `initialPrompt` to
prevent double-generation. But this also blocked Path B from acting as a
fallback when Path A failed (API timeout, Vertex errors, missing
credentials). The only recovery was the user sending a second message.
## Fix
The `initialPrompt` skip was **redundant** — two existing guards already
prevent double-generation:
1. `ShouldGenerateDisplayName(spec)` returns `false` if `displayName` is
already set
2. `updateSessionDisplayNameInternal` has a first-write-wins race guard
at `display_name.go:302-307`
Removing the skip lets Path B naturally retry when Path A fails, with no
risk of overwrites. Worst case in a race: one redundant Haiku API call
(~$0.001).
## Test plan
- [x] All 26 websocket package tests pass (including 4 new regression
tests)
- [x] `gofmt` and `go vet` clean
- [ ] Verify in staging: create sessions with `initialPrompt`, confirm
display name appears even when Vertex API is slow/unavailable
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved display name generation to be more consistent and reliable
when creating sessions with initial prompts.
* **Tests**
* Added comprehensive test coverage for display name generation
scenarios, including edge cases.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>1 parent 654c880 commit 82c4026
4 files changed
Lines changed: 135 additions & 10 deletions
File tree
- components/backend
- handlers
- websocket
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1203 | 1203 | | |
1204 | 1204 | | |
1205 | 1205 | | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
| 1206 | + | |
| 1207 | + | |
1209 | 1208 | | |
1210 | 1209 | | |
1211 | 1210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1002 | 1002 | | |
1003 | 1003 | | |
1004 | 1004 | | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | 1005 | | |
1012 | 1006 | | |
1013 | 1007 | | |
| |||
Lines changed: 132 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
| |||
204 | 210 | | |
205 | 211 | | |
206 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 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 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
0 commit comments