Commit 1a968f2
committed
fix(chat): every reveal of the chat view handles its own rejection
Follow-up to #76, which fixed the two instances in the code it introduced and left the
older ones alone to keep that review diff readable.
`executeCommand` returns a Thenable, so a bare call in a void context turns any rejection
into an unhandled promise rejection in the extension host — attributed to nothing, which
is the part that makes it useless.
SIX SITES, NOT SEVEN. The brief for this change listed the `levelcode.ai.focus`
registration as needing a `return`. It does not: `() => vscode.commands.executeCommand(…)`
is a concise arrow body, so it already returns the thenable and VS Code already reports its
failures. Left alone.
The other six are all BACKGROUND reveals — addSelection, addContext, resumeSession, the
editor panel's onDidDispose, the sessions view's newSession, and handleLaunch. In each the
accompanying work has already succeeded by the time the reveal runs, so failing that work
because the panel would not come forward would be worse than the panel not coming forward.
They route through one `focusChatView(why)` helper that logs and never rejects.
Logged, not swallowed: the complaint was "attributed to nothing", so `.catch(() => {})`
would answer the letter of it and none of the substance. `why` names the caller in the log.
ONE GUARD FOR THE WHOLE CLASS. Rather than six assertions naming six functions, the test
scans every occurrence of the call and accepts only returned / awaited / concise-arrow /
helper-wrapped / inline-handled forms. That covers the seventh site and the eighth nobody
has written yet — which matters, because this pattern reached six copies precisely because
nothing was watching for it.
Verified non-vacuous against develop: the same scan reports exactly the six bare sites
there (lines 423, 468, 1055, 2298, 2435, 2531) and zero here.
Bypasses, each reverted and confirmed to fail:
- a single site returned to a bare call; the switch-case site returned to a bare call
- the focus command wrapped in a block body so it stops returning (proves the guard
protects the site that was already correct)
- the helper swallowing silently; the log dropping its caller attribution
One assertion deliberately relaxed after bypassing it: pinning `.then(undefined, …)` over
`.catch(…)` failed a refactor with no behavioural difference. It now accepts either and
still fails when the handler stops logging.
23 tests in chatSurface, 32 suites green.1 parent b7b4472 commit 1a968f2
2 files changed
Lines changed: 73 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
419 | 441 | | |
420 | 442 | | |
421 | 443 | | |
422 | 444 | | |
423 | | - | |
| 445 | + | |
424 | 446 | | |
425 | 447 | | |
426 | 448 | | |
| |||
465 | 487 | | |
466 | 488 | | |
467 | 489 | | |
468 | | - | |
| 490 | + | |
469 | 491 | | |
470 | 492 | | |
471 | 493 | | |
| |||
1052 | 1074 | | |
1053 | 1075 | | |
1054 | 1076 | | |
1055 | | - | |
| 1077 | + | |
1056 | 1078 | | |
1057 | 1079 | | |
1058 | 1080 | | |
| |||
2295 | 2317 | | |
2296 | 2318 | | |
2297 | 2319 | | |
2298 | | - | |
| 2320 | + | |
2299 | 2321 | | |
2300 | 2322 | | |
2301 | 2323 | | |
| |||
2432 | 2454 | | |
2433 | 2455 | | |
2434 | 2456 | | |
2435 | | - | |
| 2457 | + | |
2436 | 2458 | | |
2437 | 2459 | | |
2438 | 2460 | | |
| |||
2528 | 2550 | | |
2529 | 2551 | | |
2530 | 2552 | | |
2531 | | - | |
| 2553 | + | |
2532 | 2554 | | |
2533 | 2555 | | |
2534 | 2556 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
148 | 150 | | |
149 | 151 | | |
150 | 152 | | |
| |||
310 | 312 | | |
311 | 313 | | |
312 | 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 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
313 | 357 | | |
0 commit comments